/// <summary>Snippet for InsertAsync</summary> public async Task InsertAsync() { // Snippet: InsertAsync(string, string, VpnGateway, CallSettings) // Additional: InsertAsync(string, string, VpnGateway, CancellationToken) // Create client VpnGatewaysClient vpnGatewaysClient = await VpnGatewaysClient.CreateAsync(); // Initialize request argument(s) string project = ""; string region = ""; VpnGateway vpnGatewayResource = new VpnGateway(); // Make the request lro::Operation <Operation, Operation> response = await vpnGatewaysClient.InsertAsync(project, region, vpnGatewayResource); // Poll until the returned long-running operation is complete lro::Operation <Operation, Operation> completedResponse = await response.PollUntilCompletedAsync(); // Retrieve the operation result Operation result = completedResponse.Result; // Or get the name of the operation string operationName = response.Name; // This name can be stored, then the long-running operation retrieved later by name lro::Operation <Operation, Operation> retrievedResponse = await vpnGatewaysClient.PollOnceInsertAsync(operationName); // Check if the retrieved long-running operation has completed if (retrievedResponse.IsCompleted) { // If it has completed, then access the result Operation retrievedResult = retrievedResponse.Result; } // End snippet }
public async ValueTask <Response <VpnGateway> > GetAsync(string resourceGroupName, string gatewayName, CancellationToken cancellationToken = default) { if (resourceGroupName == null) { throw new ArgumentNullException(nameof(resourceGroupName)); } if (gatewayName == null) { throw new ArgumentNullException(nameof(gatewayName)); } using var message = CreateGetRequest(resourceGroupName, gatewayName); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 200: { VpnGateway value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); if (document.RootElement.ValueKind == JsonValueKind.Null) { value = null; } else { value = VpnGateway.DeserializeVpnGateway(document.RootElement); } return(Response.FromValue(value, message.Response)); }
/// <summary>Snippet for Get</summary> public void Get() { // Snippet: Get(string, string, string, CallSettings) // Create client VpnGatewaysClient vpnGatewaysClient = VpnGatewaysClient.Create(); // Initialize request argument(s) string project = ""; string region = ""; string vpnGateway = ""; // Make the request VpnGateway response = vpnGatewaysClient.Get(project, region, vpnGateway); // End snippet }
/// <summary>Snippet for Insert</summary> public void Insert() { // Snippet: Insert(string, string, VpnGateway, CallSettings) // Create client VpnGatewaysClient vpnGatewaysClient = VpnGatewaysClient.Create(); // Initialize request argument(s) string project = ""; string region = ""; VpnGateway vpnGatewayResource = new VpnGateway(); // Make the request Operation response = vpnGatewaysClient.Insert(project, region, vpnGatewayResource); // End snippet }
/// <summary>Snippet for GetAsync</summary> public async Task GetAsync() { // Snippet: GetAsync(string, string, string, CallSettings) // Additional: GetAsync(string, string, string, CancellationToken) // Create client VpnGatewaysClient vpnGatewaysClient = await VpnGatewaysClient.CreateAsync(); // Initialize request argument(s) string project = ""; string region = ""; string vpnGateway = ""; // Make the request VpnGateway response = await vpnGatewaysClient.GetAsync(project, region, vpnGateway); // End snippet }
/// <summary>Snippet for Get</summary> public void GetRequestObject() { // Snippet: Get(GetVpnGatewayRequest, CallSettings) // Create client VpnGatewaysClient vpnGatewaysClient = VpnGatewaysClient.Create(); // Initialize request argument(s) GetVpnGatewayRequest request = new GetVpnGatewayRequest { Region = "", Project = "", VpnGateway = "", }; // Make the request VpnGateway response = vpnGatewaysClient.Get(request); // End snippet }
/// <summary>Snippet for InsertAsync</summary> public async Task InsertAsync() { // Snippet: InsertAsync(string, string, VpnGateway, CallSettings) // Additional: InsertAsync(string, string, VpnGateway, CancellationToken) // Create client VpnGatewaysClient vpnGatewaysClient = await VpnGatewaysClient.CreateAsync(); // Initialize request argument(s) string project = ""; string region = ""; VpnGateway vpnGatewayResource = new VpnGateway(); // Make the request Operation response = await vpnGatewaysClient.InsertAsync(project, region, vpnGatewayResource); // End snippet }
public async stt::Task GetRequestObjectAsync() { moq::Mock <VpnGateways.VpnGatewaysClient> mockGrpcClient = new moq::Mock <VpnGateways.VpnGatewaysClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClientForRegionOperations()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); GetVpnGatewayRequest request = new GetVpnGatewayRequest { Region = "regionedb20d96", Project = "projectaa6ff846", VpnGateway = "vpn_gatewayaa15de14", }; VpnGateway expectedResponse = new VpnGateway { Id = 11672635353343658936UL, Kind = "kindf7aa39d9", Name = "name1c9368b0", CreationTimestamp = "creation_timestamp235e59a1", VpnInterfaces = { new VpnGatewayVpnGatewayInterface(), }, Region = "regionedb20d96", LabelFingerprint = "label_fingerprint06ccff3a", Network = "networkd22ce091", Description = "description2cf9da67", SelfLink = "self_link7e87f12d", Labels = { { "key8a0b6e3c", "value60c16320" }, }, }; mockGrpcClient.Setup(x => x.GetAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <VpnGateway>(stt::Task.FromResult(expectedResponse), null, null, null, null)); VpnGatewaysClient client = new VpnGatewaysClientImpl(mockGrpcClient.Object, null); VpnGateway responseCallSettings = await client.GetAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); VpnGateway responseCancellationToken = await client.GetAsync(request, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
/// <summary>Snippet for GetAsync</summary> public async Task GetRequestObjectAsync() { // Snippet: GetAsync(GetVpnGatewayRequest, CallSettings) // Additional: GetAsync(GetVpnGatewayRequest, CancellationToken) // Create client VpnGatewaysClient vpnGatewaysClient = await VpnGatewaysClient.CreateAsync(); // Initialize request argument(s) GetVpnGatewayRequest request = new GetVpnGatewayRequest { Region = "", Project = "", VpnGateway = "", }; // Make the request VpnGateway response = await vpnGatewaysClient.GetAsync(request); // End snippet }
public virtual VpnGatewaysCreateOrUpdateOperation StartCreateOrUpdate(string resourceGroupName, string gatewayName, VpnGateway vpnGatewayParameters, CancellationToken cancellationToken = default) { if (resourceGroupName == null) { throw new ArgumentNullException(nameof(resourceGroupName)); } if (gatewayName == null) { throw new ArgumentNullException(nameof(gatewayName)); } if (vpnGatewayParameters == null) { throw new ArgumentNullException(nameof(vpnGatewayParameters)); } using var scope = _clientDiagnostics.CreateScope("VpnGatewaysOperations.StartCreateOrUpdate"); scope.Start(); try { var originalResponse = RestClient.CreateOrUpdate(resourceGroupName, gatewayName, vpnGatewayParameters, cancellationToken); return(new VpnGatewaysCreateOrUpdateOperation(_clientDiagnostics, _pipeline, RestClient.CreateCreateOrUpdateRequest(resourceGroupName, gatewayName, vpnGatewayParameters).Request, originalResponse)); } catch (Exception e) { scope.Failed(e); throw; } }
/// <summary> /// Creates a virtual wan vpn gateway if it doesn't exist else updates the /// existing gateway. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The resource group name of the VpnGateway. /// </param> /// <param name='gatewayName'> /// The name of the gateway. /// </param> /// <param name='vpnGatewayParameters'> /// Parameters supplied to create or Update a virtual wan vpn gateway. /// </param> public static VpnGateway CreateOrUpdate(this IVpnGatewaysOperations operations, string resourceGroupName, string gatewayName, VpnGateway vpnGatewayParameters) { return(operations.CreateOrUpdateAsync(resourceGroupName, gatewayName, vpnGatewayParameters).GetAwaiter().GetResult()); }
/// <summary> /// Creates a virtual wan vpn gateway if it doesn't exist else updates the /// existing gateway. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The resource group name of the VpnGateway. /// </param> /// <param name='gatewayName'> /// The name of the gateway. /// </param> /// <param name='vpnGatewayParameters'> /// Parameters supplied to create or Update a virtual wan vpn gateway. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <VpnGateway> BeginCreateOrUpdateAsync(this IVpnGatewaysOperations operations, string resourceGroupName, string gatewayName, VpnGateway vpnGatewayParameters, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, gatewayName, vpnGatewayParameters, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }