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

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

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

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

                value = InboundEndpointData.DeserializeInboundEndpointData(document.RootElement);
                return(Response.FromValue(value, message.Response));
            }
示例#3
0
 internal InboundEndpointResource(ArmClient client, InboundEndpointData data) : this(client, data.Id)
 {
     HasData = true;
     _data   = data;
 }
示例#4
0
        public virtual async Task <ArmOperation <InboundEndpointResource> > CreateOrUpdateAsync(WaitUntil waitUntil, string inboundEndpointName, InboundEndpointData data, string ifMatch = null, string ifNoneMatch = null, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(inboundEndpointName, nameof(inboundEndpointName));
            Argument.AssertNotNull(data, nameof(data));

            using var scope = _inboundEndpointClientDiagnostics.CreateScope("InboundEndpointCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _inboundEndpointRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, inboundEndpointName, data, ifMatch, ifNoneMatch, cancellationToken).ConfigureAwait(false);

                var operation = new DnsResolverArmOperation <InboundEndpointResource>(new InboundEndpointOperationSource(Client), _inboundEndpointClientDiagnostics, Pipeline, _inboundEndpointRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, inboundEndpointName, data, ifMatch, ifNoneMatch).Request, response, OperationFinalStateVia.Location);
                if (waitUntil == WaitUntil.Completed)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
示例#5
0
        public async Task <Response> CreateOrUpdateAsync(string subscriptionId, string resourceGroupName, string dnsResolverName, string inboundEndpointName, InboundEndpointData data, string ifMatch = null, string ifNoneMatch = null, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId));
            Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName));
            Argument.AssertNotNullOrEmpty(dnsResolverName, nameof(dnsResolverName));
            Argument.AssertNotNullOrEmpty(inboundEndpointName, nameof(inboundEndpointName));
            Argument.AssertNotNull(data, nameof(data));

            using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, dnsResolverName, inboundEndpointName, data, ifMatch, ifNoneMatch);
            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);

            switch (message.Response.Status)
            {
            case 200:
            case 201:
            case 202:
                return(message.Response);

            default:
                throw new RequestFailedException(message.Response);
            }
        }
示例#6
0
        internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string dnsResolverName, string inboundEndpointName, InboundEndpointData data, string ifMatch, string ifNoneMatch)
        {
            var message = _pipeline.CreateMessage();
            var request = message.Request;

            request.Method = RequestMethod.Put;
            var uri = new RawRequestUriBuilder();

            uri.Reset(_endpoint);
            uri.AppendPath("/subscriptions/", false);
            uri.AppendPath(subscriptionId, true);
            uri.AppendPath("/resourceGroups/", false);
            uri.AppendPath(resourceGroupName, true);
            uri.AppendPath("/providers/Microsoft.Network/dnsResolvers/", false);
            uri.AppendPath(dnsResolverName, true);
            uri.AppendPath("/inboundEndpoints/", false);
            uri.AppendPath(inboundEndpointName, true);
            uri.AppendQuery("api-version", _apiVersion, true);
            request.Uri = uri;
            if (ifMatch != null)
            {
                request.Headers.Add("If-Match", ifMatch);
            }
            if (ifNoneMatch != null)
            {
                request.Headers.Add("If-None-Match", ifNoneMatch);
            }
            request.Headers.Add("Accept", "application/json");
            request.Headers.Add("Content-Type", "application/json");
            var content = new Utf8JsonRequestContent();

            content.JsonWriter.WriteObjectValue(data);
            request.Content = content;
            _userAgent.Apply(message);
            return(message);
        }