コード例 #1
0
        JitRequest IOperationSource <JitRequest> .CreateResult(Response response, CancellationToken cancellationToken)
        {
            using var document = JsonDocument.Parse(response.ContentStream);
            var data = JitRequestData.DeserializeJitRequestData(document.RootElement);

            return(new JitRequest(_client, data));
        }
コード例 #2
0
        public async Task <Response <JitRequestData> > GetAsync(string subscriptionId, string resourceGroupName, string jitRequestName, CancellationToken cancellationToken = default)
        {
            if (subscriptionId == null)
            {
                throw new ArgumentNullException(nameof(subscriptionId));
            }
            if (resourceGroupName == null)
            {
                throw new ArgumentNullException(nameof(resourceGroupName));
            }
            if (jitRequestName == null)
            {
                throw new ArgumentNullException(nameof(jitRequestName));
            }

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

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

                value = JitRequestData.DeserializeJitRequestData(document.RootElement);
                return(Response.FromValue(value, message.Response));
            }
コード例 #3
0
 internal JitRequestResource(ArmClient client, JitRequestData data) : this(client, data.Id)
 {
     HasData = true;
     _data   = data;
 }
コード例 #4
0
        public virtual async Task <ArmOperation <JitRequest> > CreateOrUpdateAsync(WaitUntil waitUntil, string jitRequestName, JitRequestData parameters, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(jitRequestName, nameof(jitRequestName));
            Argument.AssertNotNull(parameters, nameof(parameters));

            using var scope = _jitRequestClientDiagnostics.CreateScope("JitRequestCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _jitRequestRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, jitRequestName, parameters, cancellationToken).ConfigureAwait(false);

                var operation = new ResourcesArmOperation <JitRequest>(new JitRequestOperationSource(Client), _jitRequestClientDiagnostics, Pipeline, _jitRequestRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, jitRequestName, parameters).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
 internal JitRequest(ArmClient armClient, JitRequestData data) : this(armClient, data.Id)
 {
     HasData = true;
     _data   = data;
 }
コード例 #6
0
        public async virtual Task <JitRequestCreateOrUpdateOperation> CreateOrUpdateAsync(bool waitForCompletion, string jitRequestName, JitRequestData parameters, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(jitRequestName, nameof(jitRequestName));
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            using var scope = _jitRequestClientDiagnostics.CreateScope("JitRequestCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _jitRequestRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, jitRequestName, parameters, cancellationToken).ConfigureAwait(false);

                var operation = new JitRequestCreateOrUpdateOperation(ArmClient, _jitRequestClientDiagnostics, Pipeline, _jitRequestRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, jitRequestName, parameters).Request, response);
                if (waitForCompletion)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }