public async Task <Response <UsagesListResult> > ListAsync(string location, CancellationToken cancellationToken = default) { if (location == null) { throw new ArgumentNullException(nameof(location)); } using var message = CreateListRequest(location); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 200: { UsagesListResult value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); if (document.RootElement.ValueKind == JsonValueKind.Null) { value = null; } else { value = UsagesListResult.DeserializeUsagesListResult(document.RootElement); } return(Response.FromValue(value, message.Response)); }
public void TestGetUsages() { string suiteName = GetType().FullName; string testName = "TestGetUsages"; using (MockContext context = MockContext.Start(suiteName, testName)) { var handler = new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }; var client = HDInsightManagementTestUtilities.GetHDInsightManagementClient(context, handler); UsagesListResult usages = client.Locations.ListUsages(HDInsightManagementTestUtilities.DefaultLocation); Assert.NotNull(usages); Assert.NotNull(usages.Value); foreach (Usage usage in usages.Value) { Assert.NotNull(usage); Assert.NotNull(usage.CurrentValue); Assert.NotNull(usage.Limit); Assert.NotNull(usage.Name); Assert.NotNull(usage.Unit); } } }
public async Task<Response<UsagesListResult>> ListResourceUsageAsync(string subscriptionId, string resourceGroupName, string profileName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); using var message = CreateListResourceUsageRequest(subscriptionId, resourceGroupName, profileName); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 200: { UsagesListResult value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); value = UsagesListResult.DeserializeUsagesListResult(document.RootElement); return Response.FromValue(value, message.Response); }