示例#1
0
        GatewayResource IOperationSource <GatewayResource> .CreateResult(Response response, CancellationToken cancellationToken)
        {
            using var document = JsonDocument.Parse(response.ContentStream);
            var data = GatewayResourceData.DeserializeGatewayResourceData(document.RootElement);

            return(new GatewayResource(_client, data));
        }
示例#2
0
        public async Task <Response <GatewayResourceData> > GetAsync(string subscriptionId, string resourceGroupName, string serviceName, string gatewayName, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId));
            Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName));
            Argument.AssertNotNullOrEmpty(serviceName, nameof(serviceName));
            Argument.AssertNotNullOrEmpty(gatewayName, nameof(gatewayName));

            using var message = CreateGetRequest(subscriptionId, resourceGroupName, serviceName, gatewayName);
            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);

            switch (message.Response.Status)
            {
            case 200:
            {
                GatewayResourceData value = default;
                using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false);

                value = GatewayResourceData.DeserializeGatewayResourceData(document.RootElement);
                return(Response.FromValue(value, message.Response));
            }
示例#3
0
        public virtual ArmOperation <GatewayResource> Update(WaitUntil waitUntil, GatewayResourceData data, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNull(data, nameof(data));

            using var scope = _gatewayResourceGatewaysClientDiagnostics.CreateScope("GatewayResource.Update");
            scope.Start();
            try
            {
                var response  = _gatewayResourceGatewaysRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken);
                var operation = new AppPlatformArmOperation <GatewayResource>(new GatewayResourceOperationSource(Client), _gatewayResourceGatewaysClientDiagnostics, Pipeline, _gatewayResourceGatewaysRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data).Request, response, OperationFinalStateVia.AzureAsyncOperation);
                if (waitUntil == WaitUntil.Completed)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
示例#4
0
        public virtual async Task <ArmOperation <GatewayResource> > CreateOrUpdateAsync(WaitUntil waitUntil, string gatewayName, GatewayResourceData data, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(gatewayName, nameof(gatewayName));
            Argument.AssertNotNull(data, nameof(data));

            using var scope = _gatewayResourceGatewaysClientDiagnostics.CreateScope("GatewayResourceCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _gatewayResourceGatewaysRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, gatewayName, data, cancellationToken).ConfigureAwait(false);

                var operation = new AppPlatformArmOperation <GatewayResource>(new GatewayResourceOperationSource(Client), _gatewayResourceGatewaysClientDiagnostics, Pipeline, _gatewayResourceGatewaysRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, gatewayName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation);
                if (waitUntil == WaitUntil.Completed)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
示例#5
0
 internal GatewayResource(ArmClient client, GatewayResourceData data) : this(client, data.Id)
 {
     HasData = true;
     _data   = data;
 }