public async stt::Task CreateAutoscalingPolicyRequestObjectAsync() { moq::Mock <AutoscalingPolicyService.AutoscalingPolicyServiceClient> mockGrpcClient = new moq::Mock <AutoscalingPolicyService.AutoscalingPolicyServiceClient>(moq::MockBehavior.Strict); CreateAutoscalingPolicyRequest request = new CreateAutoscalingPolicyRequest { ParentAsLocationName = gagr::LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"), Policy = new AutoscalingPolicy(), }; AutoscalingPolicy expectedResponse = new AutoscalingPolicy { Id = "id74b70bb8", AutoscalingPolicyName = AutoscalingPolicyName.FromProjectLocationAutoscalingPolicy("[PROJECT]", "[LOCATION]", "[AUTOSCALING_POLICY]"), BasicAlgorithm = new BasicAutoscalingAlgorithm(), WorkerConfig = new InstanceGroupAutoscalingPolicyConfig(), SecondaryWorkerConfig = new InstanceGroupAutoscalingPolicyConfig(), Labels = { { "key8a0b6e3c", "value60c16320" }, }, }; mockGrpcClient.Setup(x => x.CreateAutoscalingPolicyAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <AutoscalingPolicy>(stt::Task.FromResult(expectedResponse), null, null, null, null)); AutoscalingPolicyServiceClient client = new AutoscalingPolicyServiceClientImpl(mockGrpcClient.Object, null); AutoscalingPolicy responseCallSettings = await client.CreateAutoscalingPolicyAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); AutoscalingPolicy responseCancellationToken = await client.CreateAutoscalingPolicyAsync(request, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public void CreateAutoscalingPolicyResourceNames2() { moq::Mock <AutoscalingPolicyService.AutoscalingPolicyServiceClient> mockGrpcClient = new moq::Mock <AutoscalingPolicyService.AutoscalingPolicyServiceClient>(moq::MockBehavior.Strict); CreateAutoscalingPolicyRequest request = new CreateAutoscalingPolicyRequest { ParentAsLocationName = gagr::LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"), Policy = new AutoscalingPolicy(), }; AutoscalingPolicy expectedResponse = new AutoscalingPolicy { Id = "id74b70bb8", AutoscalingPolicyName = AutoscalingPolicyName.FromProjectLocationAutoscalingPolicy("[PROJECT]", "[LOCATION]", "[AUTOSCALING_POLICY]"), BasicAlgorithm = new BasicAutoscalingAlgorithm(), WorkerConfig = new InstanceGroupAutoscalingPolicyConfig(), SecondaryWorkerConfig = new InstanceGroupAutoscalingPolicyConfig(), Labels = { { "key8a0b6e3c", "value60c16320" }, }, }; mockGrpcClient.Setup(x => x.CreateAutoscalingPolicy(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); AutoscalingPolicyServiceClient client = new AutoscalingPolicyServiceClientImpl(mockGrpcClient.Object, null); AutoscalingPolicy response = client.CreateAutoscalingPolicy(request.ParentAsRegionName, request.Policy); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
/// <summary>Snippet for CreateAutoscalingPolicy</summary> public void CreateAutoscalingPolicyRequestObject() { // Snippet: CreateAutoscalingPolicy(CreateAutoscalingPolicyRequest, CallSettings) // Create client AutoscalingPolicyServiceClient autoscalingPolicyServiceClient = AutoscalingPolicyServiceClient.Create(); // Initialize request argument(s) CreateAutoscalingPolicyRequest request = new CreateAutoscalingPolicyRequest { ParentAsLocationName = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"), Policy = new AutoscalingPolicy(), }; // Make the request AutoscalingPolicy response = autoscalingPolicyServiceClient.CreateAutoscalingPolicy(request); // End snippet }
/// <summary>Snippet for CreateAutoscalingPolicy</summary> public void CreateAutoscalingPolicy_RequestObject() { // Snippet: CreateAutoscalingPolicy(CreateAutoscalingPolicyRequest,CallSettings) // Create client AutoscalingPolicyServiceClient autoscalingPolicyServiceClient = AutoscalingPolicyServiceClient.Create(); // Initialize request argument(s) CreateAutoscalingPolicyRequest request = new CreateAutoscalingPolicyRequest { Parent = new RegionName("[PROJECT]", "[REGION]").ToString(), Policy = new AutoscalingPolicy(), }; // Make the request AutoscalingPolicy response = autoscalingPolicyServiceClient.CreateAutoscalingPolicy(request); // End snippet }
/// <summary>Snippet for CreateAutoscalingPolicyAsync</summary> public async Task CreateAutoscalingPolicyRequestObjectAsync() { // Snippet: CreateAutoscalingPolicyAsync(CreateAutoscalingPolicyRequest, CallSettings) // Additional: CreateAutoscalingPolicyAsync(CreateAutoscalingPolicyRequest, CancellationToken) // Create client AutoscalingPolicyServiceClient autoscalingPolicyServiceClient = await AutoscalingPolicyServiceClient.CreateAsync(); // Initialize request argument(s) CreateAutoscalingPolicyRequest request = new CreateAutoscalingPolicyRequest { ParentAsLocationName = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"), Policy = new AutoscalingPolicy(), }; // Make the request AutoscalingPolicy response = await autoscalingPolicyServiceClient.CreateAutoscalingPolicyAsync(request); // End snippet }
public void CreateAutoscalingPolicy2() { Mock <AutoscalingPolicyService.AutoscalingPolicyServiceClient> mockGrpcClient = new Mock <AutoscalingPolicyService.AutoscalingPolicyServiceClient>(MockBehavior.Strict); CreateAutoscalingPolicyRequest request = new CreateAutoscalingPolicyRequest { Parent = new RegionName("[PROJECT]", "[REGION]").ToString(), Policy = new AutoscalingPolicy(), }; AutoscalingPolicy expectedResponse = new AutoscalingPolicy { Id = "id3355", Name = "name3373707", }; mockGrpcClient.Setup(x => x.CreateAutoscalingPolicy(request, It.IsAny <CallOptions>())) .Returns(expectedResponse); AutoscalingPolicyServiceClient client = new AutoscalingPolicyServiceClientImpl(mockGrpcClient.Object, null); AutoscalingPolicy response = client.CreateAutoscalingPolicy(request); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async Task CreateAutoscalingPolicyAsync() { Mock <AutoscalingPolicyService.AutoscalingPolicyServiceClient> mockGrpcClient = new Mock <AutoscalingPolicyService.AutoscalingPolicyServiceClient>(MockBehavior.Strict); CreateAutoscalingPolicyRequest expectedRequest = new CreateAutoscalingPolicyRequest { Parent = new RegionName("[PROJECT]", "[REGION]").ToString(), Policy = new AutoscalingPolicy(), }; AutoscalingPolicy expectedResponse = new AutoscalingPolicy { Id = "id3355", Name = "name3373707", }; mockGrpcClient.Setup(x => x.CreateAutoscalingPolicyAsync(expectedRequest, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <AutoscalingPolicy>(Task.FromResult(expectedResponse), null, null, null, null)); AutoscalingPolicyServiceClient client = new AutoscalingPolicyServiceClientImpl(mockGrpcClient.Object, null); string formattedParent = new RegionName("[PROJECT]", "[REGION]").ToString(); AutoscalingPolicy policy = new AutoscalingPolicy(); AutoscalingPolicy response = await client.CreateAutoscalingPolicyAsync(formattedParent, policy); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
/// <summary> /// Creates new autoscaling policy. /// </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 <AutoscalingPolicy> CreateAutoscalingPolicyAsync(CreateAutoscalingPolicyRequest request, gaxgrpc::CallSettings callSettings = null) { Modify_CreateAutoscalingPolicyRequest(ref request, ref callSettings); return(_callCreateAutoscalingPolicy.Async(request, callSettings)); }
/// <summary> /// Creates new autoscaling policy. /// </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 AutoscalingPolicy CreateAutoscalingPolicy(CreateAutoscalingPolicyRequest request, gaxgrpc::CallSettings callSettings = null) { Modify_CreateAutoscalingPolicyRequest(ref request, ref callSettings); return(_callCreateAutoscalingPolicy.Sync(request, callSettings)); }
partial void Modify_CreateAutoscalingPolicyRequest(ref CreateAutoscalingPolicyRequest request, ref gaxgrpc::CallSettings settings);
/// <summary> /// Creates new autoscaling policy. /// </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 <AutoscalingPolicy> CreateAutoscalingPolicyAsync(CreateAutoscalingPolicyRequest request, st::CancellationToken cancellationToken) => CreateAutoscalingPolicyAsync(request, gaxgrpc::CallSettings.FromCancellationToken(cancellationToken));
/// <summary> /// Creates new autoscaling policy. /// </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 <AutoscalingPolicy> CreateAutoscalingPolicyAsync(CreateAutoscalingPolicyRequest request, gaxgrpc::CallSettings callSettings = null) => throw new sys::NotImplementedException();
/// <summary> /// Creates new autoscaling policy. /// </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 AutoscalingPolicy CreateAutoscalingPolicy(CreateAutoscalingPolicyRequest request, gaxgrpc::CallSettings callSettings = null) => throw new sys::NotImplementedException();