Esempio n. 1
0
        AzureTrafficCollectorResource IOperationSource <AzureTrafficCollectorResource> .CreateResult(Response response, CancellationToken cancellationToken)
        {
            using var document = JsonDocument.Parse(response.ContentStream);
            var data = AzureTrafficCollectorData.DeserializeAzureTrafficCollectorData(document.RootElement);

            return(new AzureTrafficCollectorResource(_client, data));
        }
Esempio n. 2
0
        public async Task <Response <AzureTrafficCollectorData> > GetAsync(string subscriptionId, string resourceGroupName, string azureTrafficCollectorName, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId));
            Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName));
            Argument.AssertNotNullOrEmpty(azureTrafficCollectorName, nameof(azureTrafficCollectorName));

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

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

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

            using var scope = _azureTrafficCollectorClientDiagnostics.CreateScope("AzureTrafficCollectorCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _azureTrafficCollectorRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, azureTrafficCollectorName, data, cancellationToken).ConfigureAwait(false);

                var operation = new NetworkFunctionArmOperation <AzureTrafficCollectorResource>(new AzureTrafficCollectorOperationSource(Client), _azureTrafficCollectorClientDiagnostics, Pipeline, _azureTrafficCollectorRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, azureTrafficCollectorName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation);
                if (waitUntil == WaitUntil.Completed)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }