Пример #1
0
 /// <summary>
 /// Initializes a new instance of the PSMetricSettings class.
 /// </summary>
 public PSMetricSettings(MetricSettings metricSettings)
 {
     if (metricSettings != null)
     {
         this.Category        = metricSettings.Category;
         this.Enabled         = metricSettings.Enabled;
         this.RetentionPolicy = new PSRetentionPolicy(metricSettings.RetentionPolicy);
         this.TimeGrain       = metricSettings.TimeGrain ?? default(System.TimeSpan);
     }
     this.CategoryType = PSDiagnosticSettingCategoryType.Metrics;
 }
Пример #2
0
        public ActionResult Details(MetricSettings metricSettings, Guid uniqueId = default(Guid))
        {
            metricSettings.Metric.UniqueId = uniqueId;
            if (ModelState.IsValid)
            {
                metricSettings.Metric.CompanyId = CompanyId;

                if (metricSettings.Metric.AreaId == -2)
                {
                    metricSettings.Metric.AreaId = -1;
                    // created via Wizard, look for an area called "KPIs" and assign metric to that area if it exists
                    ListHelper.InitializeAreas(CurrentUser);
                    var area = ListHelper.GetAreas().FirstOrDefault(a => a.Name == "KPIs");
                    if (area != null)
                    {
                        metricSettings.Metric.AreaId = area.Id;
                    }
                }

                if (metricSettings.Metric.AreaId == -1)
                {
                    metricSettings.Metric.AreaId = null;
                }
                else
                {
                    if (!CurrentUser.AccessibleAreaIds.Contains(metricSettings.Metric.AreaId.Value))
                    {
                        throw new HttpException(400, "Bad Request");
                    }
                }

                if (metricSettings.Metric.DataSourceId == -1)
                {
                    metricSettings.Metric.DataSourceId = null;
                }

                this.SetNotificationMessage(NotificationType.Success, "Metric successfully saved.");

                return
                    (Json(metricSettings.Metric.UniqueId == Guid.Empty
            ? new { success = _metricManager.Create(metricSettings.Metric) != null }
            : new { success = _metricManager.Update(metricSettings.Metric) != null }));
            }
            return(Json(new { success = false }));
        }
        private void SetSelectedMetricsCategories(DiagnosticSettingsResource properties)
        {
            if (!this.isEnbledParameterPresent)
            {
                throw new ArgumentException("Parameter 'Enabled' is required by 'MetricCategory' parameter.");
            }

            foreach (string category in this.MetricCategory)
            {
                MetricSettings metricSettings = properties.Metrics.FirstOrDefault(x => string.Equals(x.Category, category, StringComparison.OrdinalIgnoreCase));

                if (metricSettings == null)
                {
                    throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Metric category '{0}' is not available", category));
                }

                metricSettings.Enabled = this.Enabled;
            }
        }
        private void SetSelectedTimegrains(DiagnosticSettingsResource properties)
        {
            if (!this.isEnbledParameterPresent)
            {
                throw new ArgumentException("Parameter 'Enabled' is required by 'Timegrains' parameter.");
            }

            foreach (string timegrainString in this.Timegrains)
            {
                TimeSpan       timegrain      = XmlConvert.ToTimeSpan(timegrainString);
                MetricSettings metricSettings = properties.Metrics.FirstOrDefault(x => TimeSpan.Equals(x.TimeGrain, timegrain));

                if (metricSettings == null)
                {
                    throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Metric timegrain '{0}' is not available", timegrainString));
                }
                metricSettings.Enabled = this.Enabled;
            }
        }
Пример #5
0
        private void SetSelectedMetricsCategories(DiagnosticSettingsResource properties)
        {
            if (!(this.isEnableMetricsParameterPresent || this.isEnabledParameterPresent))
            {
                throw new ArgumentException("Parameters 'Enabled' or 'EnableMetrics' are required by 'MetricCategory' parameter.");
            }

            WriteDebugWithTimestamp("Setting metric categories, including Enabled property");
            if (properties.Metrics == null)
            {
                properties.Metrics = new List <MetricSettings>();
            }

            foreach (string category in this.MetricCategory)
            {
                MetricSettings metricSettings = properties.Metrics.FirstOrDefault(x => string.Equals(x.Category, category, StringComparison.OrdinalIgnoreCase));

                if (metricSettings == null)
                {
                    // If not there add it
                    metricSettings = new MetricSettings
                    {
                        Category        = category,
                        Enabled         = this.EnableMetrics,
                        RetentionPolicy = new RetentionPolicy
                        {
                            Days    = 0,
                            Enabled = false
                        },
                        TimeGrain = null
                    };

                    properties.Metrics.Add(metricSettings);
                }
                else
                {
                    // else update it
                    metricSettings.Enabled = this.EnableMetrics;
                }
            }
        }
        protected override void ProcessRecordInternal()
        {
            var putParameters = new ServiceDiagnosticSettingsPutParameters();

            ServiceDiagnosticSettingsGetResponse getResponse = this.InsightsManagementClient.ServiceDiagnosticSettingsOperations.GetAsync(this.ResourceId, CancellationToken.None).Result;

            ServiceDiagnosticSettings properties = getResponse.Properties;

            if (this.Enabled && string.IsNullOrWhiteSpace(this.StorageAccountId))
            {
                throw new ArgumentException("StorageAccountId can't be null when enabling");
            }

            if (!string.IsNullOrWhiteSpace(this.StorageAccountId))
            {
                properties.StorageAccountId = this.StorageAccountId;
            }

            if (this.Categories == null && this.Timegrains == null)
            {
                foreach (var log in properties.Logs)
                {
                    log.Enabled = this.Enabled;
                }

                foreach (var metric in properties.Metrics)
                {
                    metric.Enabled = this.Enabled;
                }
            }
            else
            {
                if (this.Categories != null)
                {
                    foreach (string category in this.Categories)
                    {
                        LogSettings logSettings = properties.Logs.FirstOrDefault(x => string.Equals(x.Category, category, StringComparison.OrdinalIgnoreCase));

                        if (logSettings == null)
                        {
                            throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Log category '{0}' is not available for '{1}'", category, this.StorageAccountId));
                        }

                        logSettings.Enabled = this.Enabled;
                    }
                }

                if (this.Timegrains != null)
                {
                    foreach (string timegrainString in this.Timegrains)
                    {
                        TimeSpan       timegrain      = XmlConvert.ToTimeSpan(timegrainString);
                        MetricSettings metricSettings = properties.Metrics.FirstOrDefault(x => TimeSpan.Equals(x.TimeGrain, timegrain));

                        if (metricSettings == null)
                        {
                            throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Metric timegrain '{0}' is not available for '{1}'", timegrainString, this.StorageAccountId));
                        }
                        metricSettings.Enabled = this.Enabled;
                    }
                }
            }

            putParameters.Properties = properties;

            this.InsightsManagementClient.ServiceDiagnosticSettingsOperations.PutAsync(this.ResourceId, putParameters, CancellationToken.None).Wait();
            PSServiceDiagnosticSettings psResult = new PSServiceDiagnosticSettings(putParameters.Properties);

            WriteObject(psResult);
        }
 /// <summary>
 /// Initializes a new instance of the PSMetricSettings class.
 /// </summary>
 public PSMetricSettings(MetricSettings metricSettings)
 {
     this.Enabled         = metricSettings.Enabled;
     this.TimeGrain       = metricSettings.TimeGrain;
     this.RetentionPolicy = metricSettings.RetentionPolicy;
 }
Пример #8
0
        internal static DiagnosticSettingsData DeserializeDiagnosticSettingsData(JsonElement element)
        {
            ResourceIdentifier id                          = default;
            string             name                        = default;
            ResourceType       type                        = default;
            SystemData         systemData                  = default;
            Optional <string>  storageAccountId            = default;
            Optional <string>  serviceBusRuleId            = default;
            Optional <string>  eventHubAuthorizationRuleId = default;
            Optional <string>  eventHubName                = default;
            Optional <IList <MetricSettings> > metrics     = default;
            Optional <IList <LogSettings> >    logs        = default;
            Optional <string> workspaceId                  = default;
            Optional <string> logAnalyticsDestinationType  = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("id"))
                {
                    id = new ResourceIdentifier(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("type"))
                {
                    type = new ResourceType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("systemData"))
                {
                    systemData = JsonSerializer.Deserialize <SystemData>(property.Value.ToString());
                    continue;
                }
                if (property.NameEquals("properties"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        if (property0.NameEquals("storageAccountId"))
                        {
                            storageAccountId = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("serviceBusRuleId"))
                        {
                            serviceBusRuleId = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("eventHubAuthorizationRuleId"))
                        {
                            eventHubAuthorizationRuleId = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("eventHubName"))
                        {
                            eventHubName = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("metrics"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <MetricSettings> array = new List <MetricSettings>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(MetricSettings.DeserializeMetricSettings(item));
                            }
                            metrics = array;
                            continue;
                        }
                        if (property0.NameEquals("logs"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <LogSettings> array = new List <LogSettings>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(LogSettings.DeserializeLogSettings(item));
                            }
                            logs = array;
                            continue;
                        }
                        if (property0.NameEquals("workspaceId"))
                        {
                            workspaceId = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("logAnalyticsDestinationType"))
                        {
                            logAnalyticsDestinationType = property0.Value.GetString();
                            continue;
                        }
                    }
                    continue;
                }
            }
            return(new DiagnosticSettingsData(id, name, type, systemData, storageAccountId.Value, serviceBusRuleId.Value, eventHubAuthorizationRuleId.Value, eventHubName.Value, Optional.ToList(metrics), Optional.ToList(logs), workspaceId.Value, logAnalyticsDestinationType.Value));
        }
Пример #9
0
        protected override void ProcessRecordInternal()
        {
            var putParameters = new ServiceDiagnosticSettingsResource(location: string.Empty);

            ServiceDiagnosticSettingsResource getResponse = this.InsightsManagementClient.ServiceDiagnosticSettings.GetAsync(resourceUri: this.ResourceId, cancellationToken: CancellationToken.None).Result;

            ServiceDiagnosticSettingsResource properties = getResponse;

            if (!string.IsNullOrWhiteSpace(this.StorageAccountId))
            {
                properties.StorageAccountId = this.StorageAccountId;
            }

            if (!string.IsNullOrWhiteSpace(this.ServiceBusRuleId))
            {
                properties.ServiceBusRuleId = this.ServiceBusRuleId;
            }

            if (!string.IsNullOrWhiteSpace(this.WorkspaceId))
            {
                properties.WorkspaceId = this.WorkspaceId;
            }

            if (this.Categories == null && this.Timegrains == null)
            {
                foreach (var log in properties.Logs)
                {
                    log.Enabled = this.Enabled;
                }

                foreach (var metric in properties.Metrics)
                {
                    metric.Enabled = this.Enabled;
                }
            }
            else
            {
                if (this.Categories != null)
                {
                    foreach (string category in this.Categories)
                    {
                        LogSettings logSettings = properties.Logs.FirstOrDefault(x => string.Equals(x.Category, category, StringComparison.OrdinalIgnoreCase));

                        if (logSettings == null)
                        {
                            throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Log category '{0}' is not available", category));
                        }

                        logSettings.Enabled = this.Enabled;
                    }
                }

                if (this.Timegrains != null)
                {
                    foreach (string timegrainString in this.Timegrains)
                    {
                        TimeSpan       timegrain      = XmlConvert.ToTimeSpan(timegrainString);
                        MetricSettings metricSettings = properties.Metrics.FirstOrDefault(x => TimeSpan.Equals(x.TimeGrain, timegrain));

                        if (metricSettings == null)
                        {
                            throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Metric timegrain '{0}' is not available", timegrainString));
                        }
                        metricSettings.Enabled = this.Enabled;
                    }
                }
            }

            if (this.RetentionEnabled.HasValue)
            {
                var retentionPolicy = new RetentionPolicy
                {
                    Enabled = this.RetentionEnabled.Value,
                    Days    = this.RetentionInDays.Value
                };

                if (properties.Logs != null)
                {
                    foreach (LogSettings logSettings in properties.Logs)
                    {
                        logSettings.RetentionPolicy = retentionPolicy;
                    }
                }

                if (properties.Metrics != null)
                {
                    foreach (MetricSettings metricSettings in properties.Metrics)
                    {
                        metricSettings.RetentionPolicy = retentionPolicy;
                    }
                }
            }

            putParameters.Logs             = properties.Logs;
            putParameters.Metrics          = properties.Metrics;
            putParameters.ServiceBusRuleId = properties.ServiceBusRuleId;
            putParameters.StorageAccountId = properties.StorageAccountId;
            putParameters.WorkspaceId      = properties.WorkspaceId;

            ServiceDiagnosticSettingsResource result = this.InsightsManagementClient.ServiceDiagnosticSettings.CreateOrUpdateAsync(resourceUri: this.ResourceId, parameters: putParameters, cancellationToken: CancellationToken.None).Result;

            WriteObject(result);
        }
Пример #10
0
 /// <summary>
 /// Initializes a new instance of the PSMetricSettings class.
 /// </summary>
 public PSMetricSettings(MetricSettings metricSettings) : base(metricSettings)
 {
 }
Пример #11
0
 /// <summary>
 /// Initializes a new instance of the PSMetricSettings class.
 /// </summary>
 public PSMetricSettings(MetricSettings metricSettings)
 {
     this.Enabled         = metricSettings.Enabled;
     this.Timegrain       = XmlConvert.ToString(metricSettings.TimeGrain);
     this.RetentionPolicy = new PSRetentionPolicy(metricSettings.RetentionPolicy);
 }
Пример #12
0
 /// <summary>
 /// Initializes a new instance of the PSMetricSettings class.
 /// </summary>
 public PSMetricSettings(MetricSettings metricSettings)
 {
     this.Enabled   = metricSettings.Enabled;
     this.Timegrain = XmlConvert.ToString(metricSettings.TimeGrain);
 }
Пример #13
0
        /// <summary>
        /// Gets the active diagnostic settings. To get the diagnostic settings
        /// being applied, use GetStatus.
        /// </summary>
        /// <param name='resourceUri'>
        /// Required. The resource identifier of the configuration.
        /// </param>
        /// <param name='cancellationToken'>
        /// Cancellation token.
        /// </param>
        /// <returns>
        /// A standard service response including an HTTP status code and
        /// request ID.
        /// </returns>
        public async Task <ServiceDiagnosticSettingsGetResponse> GetAsync(string resourceUri, CancellationToken cancellationToken)
        {
            // Validate
            if (resourceUri == null)
            {
                throw new ArgumentNullException("resourceUri");
            }

            // Tracing
            bool   shouldTrace  = TracingAdapter.IsEnabled;
            string invocationId = null;

            if (shouldTrace)
            {
                invocationId = TracingAdapter.NextInvocationId.ToString();
                Dictionary <string, object> tracingParameters = new Dictionary <string, object>();
                tracingParameters.Add("resourceUri", resourceUri);
                TracingAdapter.Enter(invocationId, this, "GetAsync", tracingParameters);
            }

            // Construct URL
            string url = "";

            url = url + "/";
            url = url + Uri.EscapeDataString(resourceUri);
            url = url + "/providers/microsoft.insights/diagnosticSettings/service";
            List <string> queryParameters = new List <string>();

            queryParameters.Add("api-version=2015-07-01");
            if (queryParameters.Count > 0)
            {
                url = url + "?" + string.Join("&", queryParameters);
            }
            string baseUrl = this.Client.BaseUri.AbsoluteUri;

            // Trim '/' character from the end of baseUrl and beginning of url.
            if (baseUrl[baseUrl.Length - 1] == '/')
            {
                baseUrl = baseUrl.Substring(0, baseUrl.Length - 1);
            }
            if (url[0] == '/')
            {
                url = url.Substring(1);
            }
            url = baseUrl + "/" + url;
            url = url.Replace(" ", "%20");

            // Create HTTP transport objects
            HttpRequestMessage httpRequest = null;

            try
            {
                httpRequest            = new HttpRequestMessage();
                httpRequest.Method     = HttpMethod.Get;
                httpRequest.RequestUri = new Uri(url);

                // Set Headers
                httpRequest.Headers.Add("Accept", "application/json");

                // Set Credentials
                cancellationToken.ThrowIfCancellationRequested();
                await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false);

                // Send Request
                HttpResponseMessage httpResponse = null;
                try
                {
                    if (shouldTrace)
                    {
                        TracingAdapter.SendRequest(invocationId, httpRequest);
                    }
                    cancellationToken.ThrowIfCancellationRequested();
                    httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false);

                    if (shouldTrace)
                    {
                        TracingAdapter.ReceiveResponse(invocationId, httpResponse);
                    }
                    HttpStatusCode statusCode = httpResponse.StatusCode;
                    if (statusCode != HttpStatusCode.OK)
                    {
                        cancellationToken.ThrowIfCancellationRequested();
                        CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false));
                        if (shouldTrace)
                        {
                            TracingAdapter.Error(invocationId, ex);
                        }
                        throw ex;
                    }

                    // Create Result
                    ServiceDiagnosticSettingsGetResponse result = null;
                    // Deserialize Response
                    if (statusCode == HttpStatusCode.OK)
                    {
                        cancellationToken.ThrowIfCancellationRequested();
                        string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);

                        result = new ServiceDiagnosticSettingsGetResponse();
                        JToken responseDoc = null;
                        if (string.IsNullOrEmpty(responseContent) == false)
                        {
                            responseDoc = JToken.Parse(responseContent);
                        }

                        if (responseDoc != null && responseDoc.Type != JTokenType.Null)
                        {
                            JToken nameValue = responseDoc["name"];
                            if (nameValue != null && nameValue.Type != JTokenType.Null)
                            {
                                string nameInstance = ((string)nameValue);
                                result.Name = nameInstance;
                            }

                            JToken locationValue = responseDoc["location"];
                            if (locationValue != null && locationValue.Type != JTokenType.Null)
                            {
                                string locationInstance = ((string)locationValue);
                                result.Location = locationInstance;
                            }

                            JToken propertiesValue = responseDoc["properties"];
                            if (propertiesValue != null && propertiesValue.Type != JTokenType.Null)
                            {
                                ServiceDiagnosticSettings propertiesInstance = new ServiceDiagnosticSettings();
                                result.Properties = propertiesInstance;

                                JToken storageAccountIdValue = propertiesValue["storageAccountId"];
                                if (storageAccountIdValue != null && storageAccountIdValue.Type != JTokenType.Null)
                                {
                                    string storageAccountIdInstance = ((string)storageAccountIdValue);
                                    propertiesInstance.StorageAccountId = storageAccountIdInstance;
                                }

                                JToken serviceBusRuleIdValue = propertiesValue["serviceBusRuleId"];
                                if (serviceBusRuleIdValue != null && serviceBusRuleIdValue.Type != JTokenType.Null)
                                {
                                    string serviceBusRuleIdInstance = ((string)serviceBusRuleIdValue);
                                    propertiesInstance.ServiceBusRuleId = serviceBusRuleIdInstance;
                                }

                                JToken storageAccountNameValue = propertiesValue["storageAccountName"];
                                if (storageAccountNameValue != null && storageAccountNameValue.Type != JTokenType.Null)
                                {
                                    string storageAccountNameInstance = ((string)storageAccountNameValue);
                                    propertiesInstance.StorageAccountName = storageAccountNameInstance;
                                }

                                JToken metricsArray = propertiesValue["metrics"];
                                if (metricsArray != null && metricsArray.Type != JTokenType.Null)
                                {
                                    foreach (JToken metricsValue in ((JArray)metricsArray))
                                    {
                                        MetricSettings metricSettingsInstance = new MetricSettings();
                                        propertiesInstance.Metrics.Add(metricSettingsInstance);

                                        JToken timeGrainValue = metricsValue["timeGrain"];
                                        if (timeGrainValue != null && timeGrainValue.Type != JTokenType.Null)
                                        {
                                            TimeSpan timeGrainInstance = XmlConvert.ToTimeSpan(((string)timeGrainValue));
                                            metricSettingsInstance.TimeGrain = timeGrainInstance;
                                        }

                                        JToken enabledValue = metricsValue["enabled"];
                                        if (enabledValue != null && enabledValue.Type != JTokenType.Null)
                                        {
                                            bool enabledInstance = ((bool)enabledValue);
                                            metricSettingsInstance.Enabled = enabledInstance;
                                        }

                                        JToken retentionPolicyValue = metricsValue["retentionPolicy"];
                                        if (retentionPolicyValue != null && retentionPolicyValue.Type != JTokenType.Null)
                                        {
                                            RetentionPolicy retentionPolicyInstance = new RetentionPolicy();
                                            metricSettingsInstance.RetentionPolicy = retentionPolicyInstance;

                                            JToken enabledValue2 = retentionPolicyValue["enabled"];
                                            if (enabledValue2 != null && enabledValue2.Type != JTokenType.Null)
                                            {
                                                bool enabledInstance2 = ((bool)enabledValue2);
                                                retentionPolicyInstance.Enabled = enabledInstance2;
                                            }

                                            JToken daysValue = retentionPolicyValue["days"];
                                            if (daysValue != null && daysValue.Type != JTokenType.Null)
                                            {
                                                int daysInstance = ((int)daysValue);
                                                retentionPolicyInstance.Days = daysInstance;
                                            }
                                        }
                                    }
                                }

                                JToken logsArray = propertiesValue["logs"];
                                if (logsArray != null && logsArray.Type != JTokenType.Null)
                                {
                                    foreach (JToken logsValue in ((JArray)logsArray))
                                    {
                                        LogSettings logSettingsInstance = new LogSettings();
                                        propertiesInstance.Logs.Add(logSettingsInstance);

                                        JToken categoryValue = logsValue["category"];
                                        if (categoryValue != null && categoryValue.Type != JTokenType.Null)
                                        {
                                            string categoryInstance = ((string)categoryValue);
                                            logSettingsInstance.Category = categoryInstance;
                                        }

                                        JToken enabledValue3 = logsValue["enabled"];
                                        if (enabledValue3 != null && enabledValue3.Type != JTokenType.Null)
                                        {
                                            bool enabledInstance3 = ((bool)enabledValue3);
                                            logSettingsInstance.Enabled = enabledInstance3;
                                        }

                                        JToken retentionPolicyValue2 = logsValue["retentionPolicy"];
                                        if (retentionPolicyValue2 != null && retentionPolicyValue2.Type != JTokenType.Null)
                                        {
                                            RetentionPolicy retentionPolicyInstance2 = new RetentionPolicy();
                                            logSettingsInstance.RetentionPolicy = retentionPolicyInstance2;

                                            JToken enabledValue4 = retentionPolicyValue2["enabled"];
                                            if (enabledValue4 != null && enabledValue4.Type != JTokenType.Null)
                                            {
                                                bool enabledInstance4 = ((bool)enabledValue4);
                                                retentionPolicyInstance2.Enabled = enabledInstance4;
                                            }

                                            JToken daysValue2 = retentionPolicyValue2["days"];
                                            if (daysValue2 != null && daysValue2.Type != JTokenType.Null)
                                            {
                                                int daysInstance2 = ((int)daysValue2);
                                                retentionPolicyInstance2.Days = daysInstance2;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    result.StatusCode = statusCode;
                    if (httpResponse.Headers.Contains("x-ms-request-id"))
                    {
                        result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
                    }

                    if (shouldTrace)
                    {
                        TracingAdapter.Exit(invocationId, result);
                    }
                    return(result);
                }
                finally
                {
                    if (httpResponse != null)
                    {
                        httpResponse.Dispose();
                    }
                }
            }
            finally
            {
                if (httpRequest != null)
                {
                    httpRequest.Dispose();
                }
            }
        }