예제 #1
0
        public static Pageable<UpdateWorkspaceQuotas> UpdateQuotas(this SubscriptionResource subscriptionResource, string location, QuotaUpdateContent content, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(location, nameof(location));
            Argument.AssertNotNull(content, nameof(content));

            return GetExtensionClient(subscriptionResource).UpdateQuotas(location, content, cancellationToken);
        }
예제 #2
0
        internal HttpMessage CreateUpdateRequest(string subscriptionId, string location, QuotaUpdateContent content)
        {
            var message = _pipeline.CreateMessage();
            var request = message.Request;

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

            uri.Reset(_endpoint);
            uri.AppendPath("/subscriptions/", false);
            uri.AppendPath(subscriptionId, true);
            uri.AppendPath("/providers/Microsoft.MachineLearningServices/locations/", false);
            uri.AppendPath(location, true);
            uri.AppendPath("/updateQuotas", false);
            uri.AppendQuery("api-version", _apiVersion, true);
            request.Uri = uri;
            request.Headers.Add("Accept", "application/json");
            request.Headers.Add("Content-Type", "application/json");
            var content0 = new Utf8JsonRequestContent();

            content0.JsonWriter.WriteObjectValue(content);
            request.Content = content0;
            _userAgent.Apply(message);
            return(message);
        }
예제 #3
0
        public async Task <Response <UpdateWorkspaceQuotasResult> > UpdateAsync(string subscriptionId, string location, QuotaUpdateContent content, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId));
            Argument.AssertNotNullOrEmpty(location, nameof(location));
            Argument.AssertNotNull(content, nameof(content));

            using var message = CreateUpdateRequest(subscriptionId, location, content);
            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);

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

                value = UpdateWorkspaceQuotasResult.DeserializeUpdateWorkspaceQuotasResult(document.RootElement);
                return(Response.FromValue(value, message.Response));
            }
예제 #4
0
        public virtual Pageable <UpdateWorkspaceQuotas> UpdateQuotas(string location, QuotaUpdateContent content, CancellationToken cancellationToken = default)
        {
            Page <UpdateWorkspaceQuotas> FirstPageFunc(int?pageSizeHint)
            {
                using var scope = QuotasClientDiagnostics.CreateScope("SubscriptionResourceExtensionClient.UpdateQuotas");
                scope.Start();
                try
                {
                    var response = QuotasRestClient.Update(Id.SubscriptionId, location, content, cancellationToken: cancellationToken);
                    return(Page.FromValues(response.Value.Value, null, response.GetRawResponse()));
                }
                catch (Exception e)
                {
                    scope.Failed(e);
                    throw;
                }
            }

            return(PageableHelpers.CreateEnumerable(FirstPageFunc, null));
        }