Example #1
0
        GatewayRouteConfigResource IOperationSource <GatewayRouteConfigResource> .CreateResult(Response response, CancellationToken cancellationToken)
        {
            using var document = JsonDocument.Parse(response.ContentStream);
            var data = GatewayRouteConfigResourceData.DeserializeGatewayRouteConfigResourceData(document.RootElement);

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

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

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

                value = GatewayRouteConfigResourceData.DeserializeGatewayRouteConfigResourceData(document.RootElement);
                return(Response.FromValue(value, message.Response));
            }
Example #3
0
        public virtual async Task <ArmOperation <GatewayRouteConfigResource> > CreateOrUpdateAsync(WaitUntil waitUntil, string routeConfigName, GatewayRouteConfigResourceData data, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(routeConfigName, nameof(routeConfigName));
            Argument.AssertNotNull(data, nameof(data));

            using var scope = _gatewayRouteConfigResourceGatewayRouteConfigsClientDiagnostics.CreateScope("GatewayRouteConfigResourceCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _gatewayRouteConfigResourceGatewayRouteConfigsRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, routeConfigName, data, cancellationToken).ConfigureAwait(false);

                var operation = new AppPlatformArmOperation <GatewayRouteConfigResource>(new GatewayRouteConfigResourceOperationSource(Client), _gatewayRouteConfigResourceGatewayRouteConfigsClientDiagnostics, Pipeline, _gatewayRouteConfigResourceGatewayRouteConfigsRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, routeConfigName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation);
                if (waitUntil == WaitUntil.Completed)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Example #4
0
 internal GatewayRouteConfigResource(ArmClient client, GatewayRouteConfigResourceData data) : this(client, data.Id)
 {
     HasData = true;
     _data   = data;
 }