예제 #1
0
        CertificateResource IOperationSource <CertificateResource> .CreateResult(Response response, CancellationToken cancellationToken)
        {
            using var document = JsonDocument.Parse(response.ContentStream);
            var data = CertificateResourceData.DeserializeCertificateResourceData(document.RootElement);

            return(new CertificateResource(_client, data));
        }
예제 #2
0
        public async Task <Response <CertificateResourceData> > GetAsync(string subscriptionId, string resourceGroupName, string serviceName, string certificateName, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId));
            Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName));
            Argument.AssertNotNullOrEmpty(serviceName, nameof(serviceName));
            Argument.AssertNotNullOrEmpty(certificateName, nameof(certificateName));

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

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

                value = CertificateResourceData.DeserializeCertificateResourceData(document.RootElement);
                return(Response.FromValue(value, message.Response));
            }
예제 #3
0
        public virtual async Task <ArmOperation <CertificateResource> > CreateOrUpdateAsync(WaitUntil waitUntil, string certificateName, CertificateResourceData data, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(certificateName, nameof(certificateName));
            Argument.AssertNotNull(data, nameof(data));

            using var scope = _certificateResourceCertificatesClientDiagnostics.CreateScope("CertificateResourceCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _certificateResourceCertificatesRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, certificateName, data, cancellationToken).ConfigureAwait(false);

                var operation = new AppPlatformArmOperation <CertificateResource>(new CertificateResourceOperationSource(Client), _certificateResourceCertificatesClientDiagnostics, Pipeline, _certificateResourceCertificatesRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, certificateName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation);
                if (waitUntil == WaitUntil.Completed)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
예제 #4
0
 internal CertificateResource(ArmClient client, CertificateResourceData data) : this(client, data.Id)
 {
     HasData = true;
     _data   = data;
 }