public async stt::Task ListAsync() { moq::Mock <Zones.ZonesClient> mockGrpcClient = new moq::Mock <Zones.ZonesClient>(moq::MockBehavior.Strict); ListZonesRequest request = new ListZonesRequest { Project = "projectaa6ff846", }; ZoneList expectedResponse = new ZoneList { Id = "id74b70bb8", Kind = "kindf7aa39d9", Warning = new Warning(), NextPageToken = "next_page_tokendbee0940", Items = { new Zone(), }, SelfLink = "self_link7e87f12d", }; mockGrpcClient.Setup(x => x.ListAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <ZoneList>(stt::Task.FromResult(expectedResponse), null, null, null, null)); ZonesClient client = new ZonesClientImpl(mockGrpcClient.Object, null); ZoneList responseCallSettings = await client.ListAsync(request.Project, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); ZoneList responseCancellationToken = await client.ListAsync(request.Project, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public void ListRequestObject() { moq::Mock <Zones.ZonesClient> mockGrpcClient = new moq::Mock <Zones.ZonesClient>(moq::MockBehavior.Strict); ListZonesRequest request = new ListZonesRequest { PageToken = "page_tokenf09e5538", MaxResults = 2806814450U, OrderBy = "order_byb4d33ada", Project = "projectaa6ff846", Filter = "filtere47ac9b2", ReturnPartialSuccess = false, }; ZoneList expectedResponse = new ZoneList { Id = "id74b70bb8", Kind = "kindf7aa39d9", Warning = new Warning(), NextPageToken = "next_page_tokendbee0940", Items = { new Zone(), }, SelfLink = "self_link7e87f12d", }; mockGrpcClient.Setup(x => x.List(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); ZonesClient client = new ZonesClientImpl(mockGrpcClient.Object, null); ZoneList response = client.List(request); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
protected override void ProcessRecord() { base.ProcessRecord(); ListZonesRequest request; try { request = new ListZonesRequest { CompartmentId = CompartmentId, OpcRequestId = OpcRequestId, Limit = Limit, Page = Page, Name = Name, NameContains = NameContains, ZoneType = ZoneType, TimeCreatedGreaterThanOrEqualTo = TimeCreatedGreaterThanOrEqualTo, TimeCreatedLessThan = TimeCreatedLessThan, LifecycleState = LifecycleState, SortBy = SortBy, SortOrder = SortOrder }; IEnumerable <ListZonesResponse> responses = GetRequestDelegate().Invoke(request); foreach (var item in responses) { response = item; WriteOutput(response, response.Items, true); } FinishProcessing(response); } catch (Exception ex) { TerminatingErrorDuringExecution(ex); } }
public async Task <IEnumerable <BigZone> > ListZonesAsync() { var request = new ListZonesRequest { Name = ProjectId }; var response = await _client.ListZonesAsync(request); await Task.Yield(); return(response.Zones.Select(zone => new BigZone(this, zone))); }
internal void ListZones() { try { ListZonesRequest request = new ListZonesRequest(); var response = _client.ListZones(request); _logWriter(response.ToString()); } catch (System.Exception ex) { _logWriter(ex.Message); } }
/// <summary>Snippet for ListAsync</summary> public async Task ListRequestObjectAsync() { // Snippet: ListAsync(ListZonesRequest, CallSettings) // Create client ZonesClient zonesClient = await ZonesClient.CreateAsync(); // Initialize request argument(s) ListZonesRequest request = new ListZonesRequest { OrderBy = "", Project = "", Filter = "", ReturnPartialSuccess = false, }; // Make the request PagedAsyncEnumerable <ZoneList, Zone> response = zonesClient.ListAsync(request); // Iterate over all response items, lazily performing RPCs as required await response.ForEachAsync((Zone item) => { // Do something with each item Console.WriteLine(item); }); // Or iterate over pages (of server-defined size), performing one RPC per page await response.AsRawResponses().ForEachAsync((ZoneList page) => { // Do something with each page of items Console.WriteLine("A page of results:"); foreach (Zone item in page) { // Do something with each item Console.WriteLine(item); } }); // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required int pageSize = 10; Page <Zone> singlePage = await response.ReadPageAsync(pageSize); // Do something with the page of items Console.WriteLine($"A page of {pageSize} results (unless it's the final page):"); foreach (Zone item in singlePage) { // Do something with each item Console.WriteLine(item); } // Store the pageToken, for when the next page is required. string nextPageToken = singlePage.NextPageToken; // End snippet }
/// <summary> /// Creates a new enumerable which will iterate over the responses received from the ListZones operation. This enumerable /// will fetch more data from the server as needed. /// </summary> /// <param name="request">The request object containing the details to send</param> /// <param name="retryConfiguration">The configuration for retrying, may be null</param> /// <param name="cancellationToken">The cancellation token object</param> /// <returns>The enumerator, which supports a simple iteration over a collection of a specified type</returns> public IEnumerable <ListZonesResponse> ListZonesResponseEnumerator(ListZonesRequest request, Common.Retry.RetryConfiguration retryConfiguration = null, CancellationToken cancellationToken = default) { return(new Common.Utils.ResponseEnumerable <ListZonesRequest, ListZonesResponse>( response => response.OpcNextPage, input => { if (!string.IsNullOrEmpty(input)) { request.Page = input; } return request; }, request => client.ListZones(request, retryConfiguration, cancellationToken) )); }
/// <summary>Snippet for List</summary> public void ListRequestObject() { // Snippet: List(ListZonesRequest, CallSettings) // Create client ZonesClient zonesClient = ZonesClient.Create(); // Initialize request argument(s) ListZonesRequest request = new ListZonesRequest { PageToken = "", MaxResults = 0U, OrderBy = "", Project = "", Filter = "", ReturnPartialSuccess = false, }; // Make the request ZoneList response = zonesClient.List(request); // End snippet }
/// <summary> /// Gets a list of all zones in the specified compartment. The collection can be filtered by name, time created, and zone type. /// </summary> /// <param name="request"></param> /// <returns></returns> public async Task <ListZonesResponse> ListZones(ListZonesRequest request) { var uri = new Uri($"{GetEndPoint(DNSServices.Zones, this.Region)}?{request.GetOptionQuery()}"); using (var webResponse = await this.RestClientAsync.Get(uri)) using (var stream = webResponse.GetResponseStream()) using (var reader = new StreamReader(stream)) { var response = await reader.ReadToEndAsync(); return(new ListZonesResponse() { Items = this.JsonSerializer.Deserialize <List <ZoneSummary> >(response), OpcRequestId = webResponse.Headers.Get("opc-request-id"), OpcTotalItems = webResponse.Headers.Get("opc-total-items"), OpcNextPage = webResponse.Headers.Get("opc-next-page") }); } }
protected override void ProcessRecord() { base.ProcessRecord(); ListZonesRequest request; try { request = new ListZonesRequest { CompartmentId = CompartmentId, OpcRequestId = OpcRequestId, Limit = Limit, Page = Page, Name = Name, NameContains = NameContains, ZoneType = ZoneType, TimeCreatedGreaterThanOrEqualTo = TimeCreatedGreaterThanOrEqualTo, TimeCreatedLessThan = TimeCreatedLessThan, LifecycleState = LifecycleState, SortBy = SortBy, SortOrder = SortOrder, Scope = Scope, ViewId = ViewId, TsigKeyId = TsigKeyId }; IEnumerable <ListZonesResponse> 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); } }
/// <summary>Snippet for ListAsync</summary> public async Task ListRequestObjectAsync() { // Snippet: ListAsync(ListZonesRequest, CallSettings) // Additional: ListAsync(ListZonesRequest, CancellationToken) // Create client ZonesClient zonesClient = await ZonesClient.CreateAsync(); // Initialize request argument(s) ListZonesRequest request = new ListZonesRequest { PageToken = "", MaxResults = 0U, OrderBy = "", Project = "", Filter = "", ReturnPartialSuccess = false, }; // Make the request ZoneList response = await zonesClient.ListAsync(request); // End snippet }
public void List() { moq::Mock <Zones.ZonesClient> mockGrpcClient = new moq::Mock <Zones.ZonesClient>(moq::MockBehavior.Strict); ListZonesRequest request = new ListZonesRequest { Project = "projectaa6ff846", }; ZoneList expectedResponse = new ZoneList { Id = "id74b70bb8", Kind = "kindf7aa39d9", Warning = new Warning(), NextPageToken = "next_page_tokendbee0940", Items = { new Zone(), }, SelfLink = "self_link7e87f12d", }; mockGrpcClient.Setup(x => x.List(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); ZonesClient client = new ZonesClientImpl(mockGrpcClient.Object, null); ZoneList response = client.List(request.Project); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public static void DNSConsoleDisplay(ClientConfig config) { var identityClient = new IdentityClient(config) { Region = Regions.US_ASHBURN_1 }; var dnsClient = new DNSClient(config); var listCompartmentRequest = new ListCompartmentRequest() { CompartmentId = config.TenancyId, CompartmentIdInSubtree = true, AccessLevel = ListCompartmentRequest.AccessLevels.ACCESSIBLE }; var compartments = identityClient.ListCompartment(listCompartmentRequest).Items; Console.WriteLine("* DNS SteeringPolicy------------------------"); foreach (var com in compartments) { if (com.LifecycleState != "ACTIVE") { continue; } Console.WriteLine($" Compartment<{com.Name}>--------"); var listSteeringPoliciesRequest = new ListSteeringPoliciesRequest() { CompartmentId = com.Id, SortBy = ListSteeringPoliciesRequest.SortByParam.DisplayName }; var steeringPolicies = dnsClient.ListSteeringPolicies(listSteeringPoliciesRequest).Items; foreach (var sp in steeringPolicies) { var getSteeringPolicyRequest = new GetSteeringPolicyRequest() { SteeringPolicyId = sp.Id }; var steeringPolicy = dnsClient.GetSteeringPolicy(getSteeringPolicyRequest).SteeringPolicy; Console.WriteLine($"\t|- displayName: {steeringPolicy.DisplayName}"); Console.WriteLine($"\t| state: {steeringPolicy.LifecycleState}"); Console.WriteLine($"\t| timeCreated: {steeringPolicy.TimeCreated}"); Console.WriteLine($"\t| rule: {steeringPolicy.Rules.Count}"); foreach (var rule in steeringPolicy.Rules) { Console.WriteLine($"\t| | type: {rule.RuleType}"); } Console.WriteLine($"\t| Answer: {steeringPolicy.Answers.Count}"); foreach (var answer in steeringPolicy.Answers) { Console.WriteLine($"\t| | name: {answer.Name}"); Console.WriteLine($"\t| | pool: {answer.Pool}"); Console.WriteLine($"\t| | rtype: {answer.Rtype}"); Console.WriteLine($"\t| | rdata: {answer.Rdata}"); } var listSteeringPolicyAttachmentsRequest = new ListSteeringPolicyAttachmentsRequest() { SteeringPolicyId = sp.Id, CompartmentId = com.Id }; var steeringPolicyAttachments = dnsClient.ListSteeringPolicyAttachments(listSteeringPolicyAttachmentsRequest).Items; if (steeringPolicyAttachments.Count > 0) { Console.WriteLine($"\t| Attach: {steeringPolicyAttachments.Count}"); foreach (var attach in steeringPolicyAttachments) { Console.WriteLine($"\t| | state: {attach.LifecycleState}"); Console.WriteLine($"\t| | rtype: {attach.Rtypes}"); Console.WriteLine($"\t| | self: {attach.Self}"); Console.WriteLine($"\t| | timeCreated: {attach.TimeCreated}"); Console.WriteLine($"\t| | zoneId: {attach.ZoneId}"); } } } } Console.WriteLine("* DNS Zone------------------------"); foreach (var com in compartments) { if (com.LifecycleState != "ACTIVE") { continue; } Console.WriteLine($" Compartment<{com.Name}>--------"); var listZonesRequest = new ListZonesRequest() { CompartmentId = com.Id, SortBy = ListZonesRequest.SortByParam.Name }; var zones = dnsClient.ListZones(listZonesRequest).Items; foreach (var zone in zones) { var getZoneRequest = new GetZoneRequest() { CompartmentId = com.Id, ZoneNameOrId = zone.Id }; var zoneDetails = dnsClient.GetZone(getZoneRequest).Zone; Console.WriteLine($"\t|- name: {zone.Name}"); Console.WriteLine($"\t| version: {zone.Version}"); Console.WriteLine($"\t| state: {zone.LifecycleState}"); Console.WriteLine($"\t| timeCreated: {zone.TimeCreated}"); Console.WriteLine($"\t| type: {zone.ZoneType}"); Console.WriteLine($"\t| self: {zone.Self}"); Console.WriteLine($"\t| serial: {zone.Serial}"); Console.WriteLine($"\t| nameservers:"); if (zoneDetails.Nameservers != null) { zoneDetails.Nameservers.ForEach(n => { Console.WriteLine($"\t| |- {n.Hostname}"); }); } Console.WriteLine($"\t| externalMasters:"); if (zoneDetails.ExternalMasters != null) { zoneDetails.ExternalMasters.ForEach(e => { Console.Write($"\t| |- {e.Addres}"); }); } var getZoneRecordsRequest = new GetZoneRecordsRequest() { ZoneNameOrId = zone.Id, CompartmentId = com.Id }; var zrecordRes = dnsClient.GetZoneRecords(getZoneRecordsRequest); var zrecords = zrecordRes.RecordCollection.Items; Console.WriteLine($"\t| zone records"); foreach (var zr in zrecords) { Console.WriteLine($"\t| |- domain: {zr.Domain}"); Console.WriteLine($"\t| | rrsetVersion: {zr.RrsetVersion}"); Console.WriteLine($"\t| | rtype: {zr.Rtype}"); Console.WriteLine($"\t| | rdata: {zr.Rdata}"); var getDomainRecordsRequest = new GetDomainRecordsRequest() { ZoneNameOrId = zone.Id, Domain = zr.Domain, CompartmentId = com.Id }; var drecords = dnsClient.GetDomainRecords(getDomainRecordsRequest).RecordCollection.Items; Console.WriteLine($"\t| |- domain records"); foreach (var dr in drecords) { Console.WriteLine($"\t| | |- domain: {dr.Domain}"); } var getRRSetRequest = new GetRRSetRequest() { ZoneNameOrId = zone.Id, Domain = zr.Domain, Rtype = zr.Rtype, CompartmentId = com.Id }; var rrsets = dnsClient.GetRRSet(getRRSetRequest).RRSet.Items; Console.WriteLine($"\t| |- rrset"); foreach (var rrset in rrsets) { Console.WriteLine($"\t| | |- rdata: {rrset.Rdata}"); Console.WriteLine($"\t| | | ttl: {rrset.Ttl}"); Console.WriteLine($"\t| | | rrsetVersion: {rrset.RrsetVersion}"); } } } } }
internal void ListZones() { Client session = new Client(serviceUri, apiKey, secretKey); try { ListZonesRequest request = new ListZonesRequest(); ListZonesResponse response = session.ListZones(request); logWriter(response.ToString()); } catch (System.Exception ex) { logWriter(ex.Message); } }