public void GetRequestObject() { moq::Mock <Zones.ZonesClient> mockGrpcClient = new moq::Mock <Zones.ZonesClient>(moq::MockBehavior.Strict); GetZoneRequest request = new GetZoneRequest { Zone = "zone255f4ea8", Project = "projectaa6ff846", }; Zone expectedResponse = new Zone { Id = 11672635353343658936UL, Kind = "kindf7aa39d9", Name = "name1c9368b0", CreationTimestamp = "creation_timestamp235e59a1", SupportsPzs = false, Region = "regionedb20d96", AvailableCpuPlatforms = { "available_cpu_platforms1e56dc3a", }, Status = Zone.Types.Status.Up, Description = "description2cf9da67", SelfLink = "self_link7e87f12d", Deprecated = new DeprecationStatus(), }; mockGrpcClient.Setup(x => x.Get(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); ZonesClient client = new ZonesClientImpl(mockGrpcClient.Object, null); Zone response = client.Get(request); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
protected override void ProcessRecord() { base.ProcessRecord(); GetZoneRequest request; try { request = new GetZoneRequest { ZoneNameOrId = ZoneNameOrId, IfNoneMatch = IfNoneMatch, IfModifiedSince = IfModifiedSince, OpcRequestId = OpcRequestId, Scope = Scope, ViewId = ViewId, CompartmentId = CompartmentId }; HandleOutput(request); FinishProcessing(response); } catch (Exception ex) { TerminatingErrorDuringExecution(ex); } }
/// <summary> /// Gets information about the specified zone, including its creation date, zone type, and serial. /// </summary> /// <param name="request"></param> /// <returns></returns> public async Task <GetZoneResponse> GetZone(GetZoneRequest request) { var uriStr = $"{GetEndPoint(DNSServices.Zones, this.Region)}/{request.ZoneNameOrId}"; if (!string.IsNullOrEmpty(request.CompartmentId)) { uriStr = $"{uriStr}?compartmentId={request.CompartmentId}"; } var uri = new Uri(uriStr); var httpRequestHeaderParam = new HttpRequestHeaderParam() { IfNoneMatch = request.IfNoneMatch, IfModifiedSince = request.IfModifiedSince }; var webResponse = await this.RestClientAsync.Get(uri, httpRequestHeaderParam); using (var stream = webResponse.GetResponseStream()) using (var reader = new StreamReader(stream)) { var response = reader.ReadToEnd(); return(new GetZoneResponse() { Zone = this.JsonSerializer.Deserialize <ZoneDetails>(response), OpcRequestId = webResponse.Headers.Get("opc-request-id"), ETag = webResponse.Headers.Get("ETag") }); } }
public async stt::Task GetRequestObjectAsync() { moq::Mock <Zones.ZonesClient> mockGrpcClient = new moq::Mock <Zones.ZonesClient>(moq::MockBehavior.Strict); GetZoneRequest request = new GetZoneRequest { Zone = "zone255f4ea8", Project = "projectaa6ff846", }; Zone expectedResponse = new Zone { Id = "id74b70bb8", Kind = "kindf7aa39d9", Name = "name1c9368b0", CreationTimestamp = "creation_timestamp235e59a1", Region = "regionedb20d96", AvailableCpuPlatforms = { "available_cpu_platforms1e56dc3a", }, Status = Zone.Types.Status.Up, Description = "description2cf9da67", SelfLink = "self_link7e87f12d", Deprecated = new DeprecationStatus(), }; mockGrpcClient.Setup(x => x.GetAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Zone>(stt::Task.FromResult(expectedResponse), null, null, null, null)); ZonesClient client = new ZonesClientImpl(mockGrpcClient.Object, null); Zone responseCallSettings = await client.GetAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); Zone responseCancellationToken = await client.GetAsync(request, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
/// <summary> /// Creates a waiter using the provided configuration. /// </summary> /// <param name="request">Request to send.</param> /// <param name="config">Wait Configuration</param> /// <param name="targetStates">Desired resource states. If multiple states are provided then the waiter will return once the resource reaches any of the provided states</param> /// <returns>a new Oci.common.Waiter instance</returns> public Waiter <GetZoneRequest, GetZoneResponse> ForZone(GetZoneRequest request, WaiterConfiguration config, params Zone.LifecycleStateEnum[] targetStates) { var agent = new WaiterAgent <GetZoneRequest, GetZoneResponse>( request, request => client.GetZone(request), response => targetStates.Contains(response.Zone.LifecycleState.Value), targetStates.Contains(Zone.LifecycleStateEnum.Deleted) ); return(new Waiter <GetZoneRequest, GetZoneResponse>(config, agent)); }
/// <summary>Snippet for Get</summary> public void GetRequestObject() { // Snippet: Get(GetZoneRequest, CallSettings) // Create client ZonesClient zonesClient = ZonesClient.Create(); // Initialize request argument(s) GetZoneRequest request = new GetZoneRequest { Zone = "", Project = "", }; // Make the request Zone response = zonesClient.Get(request); // End snippet }
/// <summary>Snippet for GetAsync</summary> public async Task GetRequestObjectAsync() { // Snippet: GetAsync(GetZoneRequest, CallSettings) // Additional: GetAsync(GetZoneRequest, CancellationToken) // Create client ZonesClient zonesClient = await ZonesClient.CreateAsync(); // Initialize request argument(s) GetZoneRequest request = new GetZoneRequest { Zone = "", Project = "", }; // Make the request Zone response = await zonesClient.GetAsync(request); // End snippet }
private void HandleOutput(GetZoneRequest request) { var waiterConfig = new WaiterConfiguration { MaxAttempts = MaxWaitAttempts, GetNextDelayInSeconds = (_) => WaitIntervalSeconds }; switch (ParameterSetName) { case LifecycleStateParamSet: response = client.Waiters.ForZone(request, waiterConfig, WaitForLifecycleState).Execute(); break; case Default: response = client.GetZone(request).GetAwaiter().GetResult(); break; } WriteOutput(response, response.Zone); }
/// <summary> /// Returns the specified Zone resource. Gets a list of available zones by making a list() request. /// </summary> /// <param name="request">The request object containing all of the parameters for the API call.</param> /// <param name="callSettings">If not null, applies overrides to this RPC call.</param> /// <returns>A Task containing the RPC response.</returns> public override stt::Task <Zone> GetAsync(GetZoneRequest request, gaxgrpc::CallSettings callSettings = null) { Modify_GetZoneRequest(ref request, ref callSettings); return(_callGet.Async(request, callSettings)); }
/// <summary> /// Returns the specified Zone resource. Gets a list of available zones by making a list() request. /// </summary> /// <param name="request">The request object containing all of the parameters for the API call.</param> /// <param name="callSettings">If not null, applies overrides to this RPC call.</param> /// <returns>The RPC response.</returns> public override Zone Get(GetZoneRequest request, gaxgrpc::CallSettings callSettings = null) { Modify_GetZoneRequest(ref request, ref callSettings); return(_callGet.Sync(request, callSettings)); }
partial void Modify_GetZoneRequest(ref GetZoneRequest request, ref gaxgrpc::CallSettings settings);
/// <summary> /// Returns the specified Zone resource. Gets a list of available zones by making a list() request. /// </summary> /// <param name="request">The request object containing all of the parameters for the API call.</param> /// <param name="cancellationToken">A <see cref="st::CancellationToken"/> to use for this RPC.</param> /// <returns>A Task containing the RPC response.</returns> public virtual stt::Task <Zone> GetAsync(GetZoneRequest request, st::CancellationToken cancellationToken) => GetAsync(request, gaxgrpc::CallSettings.FromCancellationToken(cancellationToken));
/// <summary> /// Returns the specified Zone resource. Gets a list of available zones by making a list() request. /// </summary> /// <param name="request">The request object containing all of the parameters for the API call.</param> /// <param name="callSettings">If not null, applies overrides to this RPC call.</param> /// <returns>A Task containing the RPC response.</returns> public virtual stt::Task <Zone> GetAsync(GetZoneRequest request, gaxgrpc::CallSettings callSettings = null) => throw new sys::NotImplementedException();
/// <summary> /// Returns the specified Zone resource. Gets a list of available zones by making a list() request. /// </summary> /// <param name="request">The request object containing all of the parameters for the API call.</param> /// <param name="callSettings">If not null, applies overrides to this RPC call.</param> /// <returns>The RPC response.</returns> public virtual Zone Get(GetZoneRequest request, gaxgrpc::CallSettings callSettings = null) => throw new sys::NotImplementedException();
/// <summary> /// Creates a waiter using default wait configuration. /// </summary> /// <param name="request">Request to send.</param> /// <param name="targetStates">Desired resource states. If multiple states are provided then the waiter will return once the resource reaches any of the provided states</param> /// <returns>a new Oci.common.Waiter instance</returns> public Waiter <GetZoneRequest, GetZoneResponse> ForZone(GetZoneRequest request, params Zone.LifecycleStateEnum[] targetStates) { return(this.ForZone(request, WaiterConfiguration.DefaultWaiterConfiguration, targetStates)); }
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}"); } } } } }