Ejemplo n.º 1
0
        public async Task <Response <LogProfileData> > GetAsync(string subscriptionId, string logProfileName, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId));
            Argument.AssertNotNullOrEmpty(logProfileName, nameof(logProfileName));

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

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

                value = LogProfileData.DeserializeLogProfileData(document.RootElement);
                return(Response.FromValue(value, message.Response));
            }
Ejemplo n.º 2
0
        public virtual async Task <ArmOperation <LogProfileResource> > CreateOrUpdateAsync(WaitUntil waitUntil, string logProfileName, LogProfileData data, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(logProfileName, nameof(logProfileName));
            Argument.AssertNotNull(data, nameof(data));

            using var scope = _logProfileClientDiagnostics.CreateScope("LogProfileCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _logProfileRestClient.CreateOrUpdateAsync(Id.SubscriptionId, logProfileName, data, cancellationToken).ConfigureAwait(false);

                var operation = new MonitorArmOperation <LogProfileResource>(Response.FromValue(new LogProfileResource(Client, response), response.GetRawResponse()));
                if (waitUntil == WaitUntil.Completed)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Ejemplo n.º 3
0
 internal LogProfileResource(ArmClient client, LogProfileData data) : this(client, data.Id)
 {
     HasData = true;
     _data   = data;
 }