Exemplo n.º 1
0
        TagRuleResource IOperationSource <TagRuleResource> .CreateResult(Response response, CancellationToken cancellationToken)
        {
            using var document = JsonDocument.Parse(response.ContentStream);
            var data = TagRuleData.DeserializeTagRuleData(document.RootElement);

            return(new TagRuleResource(_client, data));
        }
Exemplo n.º 2
0
        public async Task <Response <TagRuleData> > GetAsync(string subscriptionId, string resourceGroupName, string monitorName, string ruleSetName, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId));
            Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName));
            Argument.AssertNotNullOrEmpty(monitorName, nameof(monitorName));
            Argument.AssertNotNullOrEmpty(ruleSetName, nameof(ruleSetName));

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

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

                value = TagRuleData.DeserializeTagRuleData(document.RootElement);
                return(Response.FromValue(value, message.Response));
            }
Exemplo n.º 3
0
 internal TagRuleResource(ArmClient client, TagRuleData data) : this(client, data.Id)
 {
     HasData = true;
     _data   = data;
 }
Exemplo n.º 4
0
        public virtual async Task <ArmOperation <TagRuleResource> > CreateOrUpdateAsync(WaitUntil waitUntil, string ruleSetName, TagRuleData data, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(ruleSetName, nameof(ruleSetName));
            Argument.AssertNotNull(data, nameof(data));

            using var scope = _tagRuleClientDiagnostics.CreateScope("TagRuleCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _tagRuleRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, ruleSetName, data, cancellationToken).ConfigureAwait(false);

                var operation = new DynatraceArmOperation <TagRuleResource>(new TagRuleOperationSource(Client), _tagRuleClientDiagnostics, Pipeline, _tagRuleRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, ruleSetName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation);
                if (waitUntil == WaitUntil.Completed)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }