Exemplo n.º 1
0
        public async Task GetDiagnosticSettingsCategoryTest()
        {
            var ExpectDiagnosticSettingsCategoryResource = new DiagnosticSettingsCategoryResource("ID1", "Name1", "type1", CategoryType.Logs);
            var content      = @"
{

    'id': 'ID1',
    'name': 'Name1',
    'type': 'type1',
    'properties':
                {
                    'categoryType': 'Logs'
                }

}
".Replace("'", "\"");
            var mockResponse = new MockResponse((int)HttpStatusCode.OK);

            mockResponse.SetContent(content);
            var mockTransport  = new MockTransport(mockResponse);
            var insightsClient = GetInsightsManagementClient(mockTransport);
            var result         = (await insightsClient.DiagnosticSettingsCategory.GetAsync("resourceUri", "name1")).Value;

            AreEqual(ExpectDiagnosticSettingsCategoryResource, result);
        }
        public PSDiagnosticSettingCategory(DiagnosticSettingsCategoryResource category)
        {
            this.Id   = category?.Id;
            this.Name = category?.Name;
            this.Type = category?.Type;
            if (category != null)
            {
                switch (category.CategoryType)
                {
                case Microsoft.Azure.Management.Monitor.Models.CategoryType.Metrics:
                    this.CategoryType = PSDiagnosticSettingCategoryType.Metrics;
                    break;

                case Microsoft.Azure.Management.Monitor.Models.CategoryType.Logs:
                    this.CategoryType = PSDiagnosticSettingCategoryType.Logs;
                    break;

                default:
                    this.CategoryType = null;
                    break;
                }
            }
        }
        public async Task <Response <DiagnosticSettingsCategoryResource> > GetAsync(string resourceUri, string name, CancellationToken cancellationToken = default)
        {
            if (resourceUri == null)
            {
                throw new ArgumentNullException(nameof(resourceUri));
            }
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }

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

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

                value = DiagnosticSettingsCategoryResource.DeserializeDiagnosticSettingsCategoryResource(document.RootElement);
                return(Response.FromValue(value, message.Response));
            }
Exemplo n.º 4
0
 private void AreEqual(DiagnosticSettingsCategoryResource exp, DiagnosticSettingsCategoryResource act)
 {
     Assert.AreEqual(exp.Id, act.Id);
     Assert.AreEqual(exp.Name, act.Name);
     Assert.AreEqual(exp.CategoryType.Value, act.CategoryType.Value);
 }