コード例 #1
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            ListDrgsRequest request;

            try
            {
                request = new ListDrgsRequest
                {
                    CompartmentId = CompartmentId,
                    Limit         = Limit,
                    Page          = Page
                };
                IEnumerable <ListDrgsResponse> responses = GetRequestDelegate().Invoke(request);
                foreach (var item in responses)
                {
                    response = item;
                    WriteOutput(response, response.Items, true);
                }
                FinishProcessing(response);
            }
            catch (Exception ex)
            {
                TerminatingErrorDuringExecution(ex);
            }
        }
コード例 #2
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            ListDrgsRequest request;

            try
            {
                request = new ListDrgsRequest
                {
                    CompartmentId = CompartmentId,
                    Limit         = Limit,
                    Page          = Page
                };
                IEnumerable <ListDrgsResponse> responses = GetRequestDelegate().Invoke(request);
                foreach (var item in responses)
                {
                    response = item;
                    WriteOutput(response, response.Items, true);
                }
                if (!ParameterSetName.Equals(AllPageSet) && !ParameterSetName.Equals(LimitSet) && response.OpcNextPage != null)
                {
                    WriteWarning("This operation supports pagination and not all resources were returned. Re-run using the -All option to auto paginate and list all resources.");
                }
                FinishProcessing(response);
            }
            catch (Exception ex)
            {
                TerminatingErrorDuringExecution(ex);
            }
        }
コード例 #3
0
        private static void VirtualNetworkConsoleDisplay(ClientConfig config)
        {
            // create client
            VirtualNetworkClient client = new VirtualNetworkClient(config)
            {
                Region = Regions.US_ASHBURN_1
            };

            Console.WriteLine("* List VCN------------------------");
            var listVcnRequest = new ListVcnRequest()
            {
                // target compartment is root compartment(tenancy)
                CompartmentId = config.TenancyId,
                Limit         = 50,
                SortOrder     = SortOrder.ASC
            };
            // get vcns
            var listVcn = client.ListVcn(listVcnRequest);

            listVcn.Items.ForEach(vcn =>
            {
                Console.WriteLine(" |-" + vcn.DisplayName);
                Console.WriteLine(" | " + vcn.Id);

                // get dhcps in vcn
                var listDhcpRequest = new ListDhcpOptionsRequest()
                {
                    // target is same compartment and VCN
                    CompartmentId = vcn.CompartmentId,
                    VcnId         = vcn.Id,
                    Limit         = 50,
                    SortOrder     = SortOrder.ASC
                };
                var listDhcp = client.ListDhcpOptions(listDhcpRequest);
                listDhcp.Items.ForEach(dhcp =>
                {
                    Console.WriteLine(" |\t|- * DHCP");
                    Console.WriteLine(" |\t|\t" + dhcp.DisplayName);
                    Console.WriteLine(" |\t|\t" + dhcp.Id);
                });

                // get RouteTable in vcn
                var listRouteTableRequest = new ListRouteTableRequest()
                {
                    // target is same compartment and VCN
                    CompartmentId = vcn.CompartmentId,
                    VcnId         = vcn.Id,
                    Limit         = 50,
                    SortOrder     = SortOrder.ASC
                };
                var listRouteTable = client.ListRouteTableOptions(listRouteTableRequest);
                listRouteTable.Items.ForEach(rt =>
                {
                    Console.WriteLine(" |\t|- * RouteTable");
                    Console.WriteLine(" |\t|\t" + rt.DisplayName);
                    Console.WriteLine(" |\t|\t" + rt.Id);

                    // RouteRules
                    rt.RouteRules.ForEach(rr =>
                    {
                        if (!string.IsNullOrEmpty(rr.DestinationType))
                        {
                            Console.WriteLine(" |\t|\t|- DestinationType:" + rr.DestinationType);
                        }
                        if (!string.IsNullOrEmpty(rr.CidrBlock))
                        {
                            Console.WriteLine(" |\t|\t|\tCidrBlock:" + rr.CidrBlock);
                        }
                        if (!string.IsNullOrEmpty(rr.Destination))
                        {
                            Console.WriteLine(" |\t|\t|\tDestination:" + rr.Destination);
                        }
                        if (!string.IsNullOrEmpty(rr.NetworkEntityId))
                        {
                            Console.WriteLine(" |\t|\t|\tNetworkEntityId:" + rr.NetworkEntityId);
                        }
                    });
                });

                // get RouteTable in vcn
                var listSecurityListRequest = new ListSecurityListsRequest()
                {
                    // target is same compartment and VCN
                    CompartmentId = vcn.CompartmentId,
                    VcnId         = vcn.Id,
                    Limit         = 50,
                    SortOrder     = SortOrder.ASC
                };
                var listSecurityList = client.ListSecurityLists(listSecurityListRequest);
                listSecurityList.Items.ForEach(sl =>
                {
                    Console.WriteLine(" |\t|- * SecurityList");
                    Console.WriteLine(" |\t|\t" + sl.DisplayName);
                    Console.WriteLine(" |\t|\t" + sl.Id);
                    Console.WriteLine(" |\t|\t" + sl.LifecycleState);
                });

                // get Subnet in vcn
                var listSubnetRequest = new ListSubnetsRequest()
                {
                    // target is same compartment and VCN
                    CompartmentId = vcn.CompartmentId,
                    VcnId         = vcn.Id,
                    Limit         = 50,
                    SortOrder     = SortOrder.ASC
                };
                var listSubnet = client.ListSubnets(listSubnetRequest);
                listSubnet.Items.ForEach(sl =>
                {
                    Console.WriteLine(" |\t|- * Subnet");
                    Console.WriteLine(" |\t|\t" + sl.DisplayName);
                    Console.WriteLine(" |\t|\t" + sl.Id);
                    Console.WriteLine(" |\t|\t" + sl.LifecycleState);
                });

                // get InternetGateway in vcn
                var listIGRequest = new ListInternetGatewaysRequest()
                {
                    // target is same compartment and VCN
                    CompartmentId = vcn.CompartmentId,
                    VcnId         = vcn.Id,
                    Limit         = 50,
                    SortOrder     = SortOrder.ASC
                };
                var listIG = client.ListInternetGateways(listIGRequest);
                listDhcp.Items.ForEach(ig =>
                {
                    Console.WriteLine(" |\t|- * InternetGateway");
                    Console.WriteLine(" |\t|\t" + ig.DisplayName);
                    Console.WriteLine(" |\t|\t" + ig.Id);
                });
            });

            Console.WriteLine("* List DRG------------------------");

            var identityClient = new IdentityClient(config)
            {
                Region = Regions.US_ASHBURN_1
            };

            var listCompartmentRequest = new ListCompartmentRequest()
            {
                CompartmentId          = config.TenancyId,
                CompartmentIdInSubtree = true,
                AccessLevel            = ListCompartmentRequest.AccessLevels.ACCESSIBLE
            };
            var compartments = identityClient.ListCompartment(listCompartmentRequest).Items;

            foreach (var com in compartments)
            {
                var listDrgsRequest = new ListDrgsRequest()
                {
                    CompartmentId = com.Id
                };
                var drgs = client.ListDrgs(listDrgsRequest).Items;
                foreach (var drg in drgs)
                {
                    Console.WriteLine($" |-name: {drg.DisplayName}");
                    Console.WriteLine($" | state: {drg.LifecycleState}");
                    Console.WriteLine($" | timeCreate: {drg.TimeCreated}");
                    Console.WriteLine($" | compartment: {com.Name}");
                }
            }
        }