/// <summary> /// Validate that the service objective properties match the expected values /// </summary> /// <param name="so">The service objective object</param> /// <param name="name">The expected name for the service objective</param> /// <param name="description">The expected description for the service objective</param> /// <param name="dimSettingsCount">The expected number of dimension settings</param> /// <param name="desc">A list of the expected descriptions for each dimension setting</param> private static void ValidateServiceObjectiveProperties(ServiceObjective so, string name, string description, int dimSettingsCount, params string[] desc) { Assert.AreEqual(name, so.Name); Assert.AreEqual(description, so.Description); Assert.IsNotNull(so.DimensionSettings, "Expecting some Dimension Setting objects."); Assert.AreEqual(dimSettingsCount, so.DimensionSettings.Count(), "Expecting 1 Dimension Setting."); for (int i = 0; i < dimSettingsCount; i++) { Assert.AreEqual(desc[i], so.DimensionSettings[i].Description); } }
/// <summary> /// Returns information about a certain Service Objective with a /// specific Id. /// </summary> /// <param name='serverName'> /// Required. The name of the Azure SQL Database Server to be queried. /// </param> /// <param name='serviceObjectiveId'> /// Required. The Id of the Service Objective to be obtained. /// </param> /// <param name='cancellationToken'> /// Cancellation token. /// </param> /// <returns> /// Response containing the service objective for a given Azure SQL /// Database Server with matching service objective Id. /// </returns> public async System.Threading.Tasks.Task <Microsoft.WindowsAzure.Management.Sql.Models.ServiceObjectiveGetResponse> GetAsync(string serverName, string serviceObjectiveId, CancellationToken cancellationToken) { // Validate if (serverName == null) { throw new ArgumentNullException("serverName"); } if (serviceObjectiveId == null) { throw new ArgumentNullException("serviceObjectiveId"); } // Tracing bool shouldTrace = CloudContext.Configuration.Tracing.IsEnabled; string invocationId = null; if (shouldTrace) { invocationId = Tracing.NextInvocationId.ToString(); Dictionary <string, object> tracingParameters = new Dictionary <string, object>(); tracingParameters.Add("serverName", serverName); tracingParameters.Add("serviceObjectiveId", serviceObjectiveId); Tracing.Enter(invocationId, this, "GetAsync", tracingParameters); } // Construct URL string url = (this.Client.Credentials.SubscriptionId != null ? this.Client.Credentials.SubscriptionId.Trim() : "") + "/services/sqlservers/servers/" + serverName.Trim() + "/serviceobjectives/" + serviceObjectiveId.Trim(); 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("x-ms-version", "2012-03-01"); // Set Credentials cancellationToken.ThrowIfCancellationRequested(); await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); // Send Request HttpResponseMessage httpResponse = null; try { if (shouldTrace) { Tracing.SendRequest(invocationId, httpRequest); } cancellationToken.ThrowIfCancellationRequested(); httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); if (shouldTrace) { Tracing.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) { Tracing.Error(invocationId, ex); } throw ex; } // Create Result ServiceObjectiveGetResponse result = null; // Deserialize Response cancellationToken.ThrowIfCancellationRequested(); string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); result = new ServiceObjectiveGetResponse(); XDocument responseDoc = XDocument.Parse(responseContent); XElement serviceResourceElement = responseDoc.Element(XName.Get("ServiceResource", "http://schemas.microsoft.com/windowsazure")); if (serviceResourceElement != null) { ServiceObjective serviceResourceInstance = new ServiceObjective(); result.ServiceObjective = serviceResourceInstance; XElement idElement = serviceResourceElement.Element(XName.Get("Id", "http://schemas.microsoft.com/windowsazure")); if (idElement != null) { string idInstance = idElement.Value; serviceResourceInstance.Id = idInstance; } XElement isDefaultElement = serviceResourceElement.Element(XName.Get("IsDefault", "http://schemas.microsoft.com/windowsazure")); if (isDefaultElement != null) { bool isDefaultInstance = bool.Parse(isDefaultElement.Value); serviceResourceInstance.IsDefault = isDefaultInstance; } XElement isSystemElement = serviceResourceElement.Element(XName.Get("IsSystem", "http://schemas.microsoft.com/windowsazure")); if (isSystemElement != null) { bool isSystemInstance = bool.Parse(isSystemElement.Value); serviceResourceInstance.IsSystem = isSystemInstance; } XElement descriptionElement = serviceResourceElement.Element(XName.Get("Description", "http://schemas.microsoft.com/windowsazure")); if (descriptionElement != null) { string descriptionInstance = descriptionElement.Value; serviceResourceInstance.Description = descriptionInstance; } XElement enabledElement = serviceResourceElement.Element(XName.Get("Enabled", "http://schemas.microsoft.com/windowsazure")); if (enabledElement != null) { bool enabledInstance = bool.Parse(enabledElement.Value); serviceResourceInstance.Enabled = enabledInstance; } XElement dimensionSettingsSequenceElement = serviceResourceElement.Element(XName.Get("DimensionSettings", "http://schemas.microsoft.com/windowsazure")); if (dimensionSettingsSequenceElement != null) { serviceResourceInstance.DimensionSettings = new List <ServiceObjective.DimensionSettingResponse>(); foreach (XElement dimensionSettingsElement in dimensionSettingsSequenceElement.Elements(XName.Get("ServiceResource", "http://schemas.microsoft.com/windowsazure"))) { ServiceObjective.DimensionSettingResponse serviceResourceInstance2 = new ServiceObjective.DimensionSettingResponse(); serviceResourceInstance.DimensionSettings.Add(serviceResourceInstance2); XElement idElement2 = dimensionSettingsElement.Element(XName.Get("Id", "http://schemas.microsoft.com/windowsazure")); if (idElement2 != null) { string idInstance2 = idElement2.Value; serviceResourceInstance2.Id = idInstance2; } XElement descriptionElement2 = dimensionSettingsElement.Element(XName.Get("Description", "http://schemas.microsoft.com/windowsazure")); if (descriptionElement2 != null) { string descriptionInstance2 = descriptionElement2.Value; serviceResourceInstance2.Description = descriptionInstance2; } XElement ordinalElement = dimensionSettingsElement.Element(XName.Get("Ordinal", "http://schemas.microsoft.com/windowsazure")); if (ordinalElement != null) { byte ordinalInstance = byte.Parse(ordinalElement.Value, CultureInfo.InvariantCulture); serviceResourceInstance2.Ordinal = ordinalInstance; } XElement isDefaultElement2 = dimensionSettingsElement.Element(XName.Get("IsDefault", "http://schemas.microsoft.com/windowsazure")); if (isDefaultElement2 != null) { bool isDefaultInstance2 = bool.Parse(isDefaultElement2.Value); serviceResourceInstance2.IsDefault = isDefaultInstance2; } XElement nameElement = dimensionSettingsElement.Element(XName.Get("Name", "http://schemas.microsoft.com/windowsazure")); if (nameElement != null) { string nameInstance = nameElement.Value; serviceResourceInstance2.Name = nameInstance; } XElement typeElement = dimensionSettingsElement.Element(XName.Get("Type", "http://schemas.microsoft.com/windowsazure")); if (typeElement != null) { string typeInstance = typeElement.Value; serviceResourceInstance2.Type = typeInstance; } XElement stateElement = dimensionSettingsElement.Element(XName.Get("State", "http://schemas.microsoft.com/windowsazure")); if (stateElement != null) { string stateInstance = stateElement.Value; serviceResourceInstance2.State = stateInstance; } } } XElement nameElement2 = serviceResourceElement.Element(XName.Get("Name", "http://schemas.microsoft.com/windowsazure")); if (nameElement2 != null) { string nameInstance2 = nameElement2.Value; serviceResourceInstance.Name = nameInstance2; } XElement typeElement2 = serviceResourceElement.Element(XName.Get("Type", "http://schemas.microsoft.com/windowsazure")); if (typeElement2 != null) { string typeInstance2 = typeElement2.Value; serviceResourceInstance.Type = typeInstance2; } XElement stateElement2 = serviceResourceElement.Element(XName.Get("State", "http://schemas.microsoft.com/windowsazure")); if (stateElement2 != null) { string stateInstance2 = stateElement2.Value; serviceResourceInstance.State = stateInstance2; } } result.StatusCode = statusCode; if (httpResponse.Headers.Contains("x-ms-request-id")) { result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); } if (shouldTrace) { Tracing.Exit(invocationId, result); } return(result); } finally { if (httpResponse != null) { httpResponse.Dispose(); } } } finally { if (httpRequest != null) { httpRequest.Dispose(); } } }
public void AddToServiceObjectives(ServiceObjective serviceObjective) { base.AddObject("ServiceObjectives", serviceObjective); }
public static ServiceObjective CreateServiceObjective(global::System.Guid ID, bool isDefault, bool isSystem, bool enabled) { ServiceObjective serviceObjective = new ServiceObjective(); serviceObjective.Id = ID; serviceObjective.IsDefault = isDefault; serviceObjective.IsSystem = isSystem; serviceObjective.Enabled = enabled; return serviceObjective; }
/// <summary> /// Retrieve information on latest service objective with service objective /// </summary> /// <param name="serviceObjectiveToRefresh">The service objective to refresh.</param> /// <returns> /// An object containing the information about the specific service objective. /// </returns> public ServiceObjective GetServiceObjective(ServiceObjective serviceObjectiveToRefresh) { var serviceObjective = Objectives.Where(s => s.Id == serviceObjectiveToRefresh.Id).FirstOrDefault(); if (serviceObjective == null) { throw new InvalidOperationException( string.Format( CultureInfo.InvariantCulture, Resources.ServiceObjectiveNotFound, this.ServerName, serviceObjectiveToRefresh.Id)); } return serviceObjective; }
public override int GetHashCode() { return(Edition.GetHashCode() ^ ServiceObjective.GetHashCode()); }
/// <summary> /// Creates a new sql database. /// </summary> /// <param name="databaseName">The name for the new database</param> /// <param name="databaseMaxSizeInGB">The maximum size of the new database</param> /// <param name="databaseCollation">The collation for the new database</param> /// <param name="databaseEdition">The edition for the new database</param> /// <returns>The newly created Sql Database</returns> public Database CreateNewDatabase( string databaseName, int? databaseMaxSizeInGB, long? databaseMaxSizeInBytes, string databaseCollation, DatabaseEdition databaseEdition, ServiceObjective serviceObjective) { this.clientRequestId = SqlDatabaseCmdletBase.GenerateClientTracingId(); // Get the SQL management client SqlManagementClient sqlManagementClient = AzureSession.ClientFactory.CreateClient<SqlManagementClient>(this.profile, subscription, AzureEnvironment.Endpoint.ServiceManagement); this.AddTracingHeaders(sqlManagementClient); DatabaseCreateParameters parameters = new DatabaseCreateParameters() { Name = databaseName, Edition = databaseEdition != DatabaseEdition.None ? databaseEdition.ToString() : null, CollationName = databaseCollation ?? string.Empty, MaximumDatabaseSizeInGB = databaseMaxSizeInGB, MaximumDatabaseSizeInBytes = databaseMaxSizeInBytes, ServiceObjectiveId = serviceObjective != null ? serviceObjective.Id.ToString() : null, }; // Create the database DatabaseCreateResponse response = sqlManagementClient.Databases.Create( this.serverName, parameters); // Construct the resulting Database object Database database = CreateDatabaseFromResponse(response); return database; }
/// <summary> /// Update a database on the server. /// </summary> /// <param name="databaseName">The name of the database to modify.</param> /// <param name="newDatabaseName">The new name of the database.</param> /// <param name="databaseMaxSizeInGB">The new maximum size of the database.</param> /// <param name="databaseEdition">The new edition of the database.</param> /// <param name="serviceObjective">The new service objective of the database.</param> /// <returns>The updated database.</returns> public Database UpdateDatabase( string databaseName, string newDatabaseName, int? databaseMaxSizeInGB, long? databaseMaxSizeInBytes, DatabaseEdition? databaseEdition, ServiceObjective serviceObjective) { this.clientRequestId = SqlDatabaseCmdletBase.GenerateClientTracingId(); // Get the SQL management client SqlManagementClient sqlManagementClient = AzureSession.ClientFactory.CreateClient<SqlManagementClient>(this.profile, subscription, AzureEnvironment.Endpoint.ServiceManagement); this.AddTracingHeaders(sqlManagementClient); // Retrieve the specified database DatabaseGetResponse database = sqlManagementClient.Databases.Get( this.serverName, databaseName); DatabaseUpdateParameters parameters = new DatabaseUpdateParameters() { Name = !string.IsNullOrEmpty(newDatabaseName) ? newDatabaseName : database.Database.Name, MaximumDatabaseSizeInGB = databaseMaxSizeInGB, MaximumDatabaseSizeInBytes = databaseMaxSizeInBytes, }; parameters.Edition = (database.Database.Edition ?? string.Empty); if (databaseEdition.HasValue) { if (databaseEdition != DatabaseEdition.None) { parameters.Edition = databaseEdition.ToString(); } } parameters.ServiceObjectiveId = database.Database.ServiceObjectiveId; if (serviceObjective != null) { parameters.ServiceObjectiveId = serviceObjective.Id.ToString(); } // Update the database with the new properties DatabaseUpdateResponse response = sqlManagementClient.Databases.Update( this.serverName, databaseName, parameters ); // Construct the resulting Database object Database updatedDatabase = CreateDatabaseFromResponse(response); return updatedDatabase; }
/// <summary> /// Retrieve information on latest service objective with service objective /// </summary> /// <param name="serviceObjectiveToRefresh">The service objective to refresh.</param> /// <returns> /// An object containing the information about the specific service objective. /// </returns> public ServiceObjective GetServiceObjective(ServiceObjective serviceObjectiveToRefresh) { this.clientRequestId = SqlDatabaseCmdletBase.GenerateClientTracingId(); // Get the SQL management client SqlManagementClient sqlManagementClient = AzureSession.ClientFactory.CreateClient<SqlManagementClient>(subscription, AzureEnvironment.Endpoint.ServiceManagement); this.AddTracingHeaders(sqlManagementClient); // Retrieve the specified database ServiceObjectiveGetResponse response = sqlManagementClient.ServiceObjectives.Get( this.serverName, serviceObjectiveToRefresh.Id.ToString()); // Construct the resulting Database object ServiceObjective serviceObjective = CreateServiceObjectiveFromResponse(response.ServiceObjective); return serviceObjective; }
/// <summary> /// Update a database on the server. /// </summary> /// <param name="databaseName">The name of the database to modify.</param> /// <param name="newDatabaseName">The new name of the database.</param> /// <param name="databaseMaxSizeInGB">The new maximum size of the database.</param> /// <param name="databaseEdition">The new edition of the database.</param> /// <param name="serviceObjective">The new service objective of the database.</param> /// <returns>The updated database.</returns> public Database UpdateDatabase( string databaseName, string newDatabaseName, int? databaseMaxSizeInGB, DatabaseEdition? databaseEdition, ServiceObjective serviceObjective) { this.clientRequestId = SqlDatabaseCmdletBase.GenerateClientTracingId(); // Get the SQL management client SqlManagementClient sqlManagementClient = this.subscription.CreateClient<SqlManagementClient>(); this.AddTracingHeaders(sqlManagementClient); // Retrieve the specified database DatabaseGetResponse database = sqlManagementClient.Databases.Get( this.serverName, databaseName); // Update the database with the new properties DatabaseUpdateResponse response = sqlManagementClient.Databases.Update( this.serverName, databaseName, new DatabaseUpdateParameters() { Id = database.Id, Name = !string.IsNullOrEmpty(newDatabaseName) ? newDatabaseName : database.Name, Edition = databaseEdition.HasValue && (databaseEdition != DatabaseEdition.None) ? databaseEdition.ToString() : (database.Edition ?? string.Empty), CollationName = database.CollationName ?? string.Empty, MaximumDatabaseSizeInGB = databaseMaxSizeInGB.HasValue ? databaseMaxSizeInGB.Value : database.MaximumDatabaseSizeInGB, ServiceObjectiveId = serviceObjective != null ? serviceObjective.Id.ToString() : null, }); // Construct the resulting Database object Database updatedDatabase = CreateDatabaseFromResponse(response); return updatedDatabase; }
/// <summary> /// Creates a new sql database. /// </summary> /// <param name="databaseName">The name for the new database</param> /// <param name="databaseMaxSizeInGB">The maximum size of the new database</param> /// <param name="databaseCollation">The collation for the new database</param> /// <param name="databaseEdition">The edition for the new database</param> /// <returns>The newly created Sql Database</returns> public Database CreateNewDatabase( string databaseName, int? databaseMaxSizeInGB, string databaseCollation, DatabaseEdition databaseEdition, ServiceObjective serviceObjective) { this.clientRequestId = SqlDatabaseCmdletBase.GenerateClientTracingId(); // Get the SQL management client SqlManagementClient sqlManagementClient = this.subscription.CreateClient<SqlManagementClient>(); this.AddTracingHeaders(sqlManagementClient); // Create the database DatabaseCreateResponse response = sqlManagementClient.Databases.Create( this.serverName, new DatabaseCreateParameters() { Name = databaseName, Edition = databaseEdition != DatabaseEdition.None ? databaseEdition.ToString() : DatabaseEdition.Web.ToString(), CollationName = databaseCollation ?? string.Empty, MaximumDatabaseSizeInGB = databaseMaxSizeInGB ?? (databaseEdition == DatabaseEdition.Business || databaseEdition == DatabaseEdition.Premium ? 10 : 1), ServiceObjectiveId = serviceObjective != null ? serviceObjective.Id.ToString() : null, }); // Construct the resulting Database object Database database = CreateDatabaseFromResponse(response); return database; }
/// <summary> /// Returns information about an Azure SQL Database Server Service /// Objectives. /// </summary> /// <param name='resourceGroupName'> /// Required. The name of the Resource Group to which the server /// belongs. /// </param> /// <param name='serverName'> /// Required. The name of the Server. /// </param> /// <param name='serviceObjectiveName'> /// Required. The name of the service objective to retrieve. /// </param> /// <param name='cancellationToken'> /// Cancellation token. /// </param> /// <returns> /// Represents the response to a Get Azure Sql Database Service /// Objective request. /// </returns> public async Task <ServiceObjectiveGetResponse> GetAsync(string resourceGroupName, string serverName, string serviceObjectiveName, CancellationToken cancellationToken) { // Validate if (resourceGroupName == null) { throw new ArgumentNullException("resourceGroupName"); } if (serverName == null) { throw new ArgumentNullException("serverName"); } if (serviceObjectiveName == null) { throw new ArgumentNullException("serviceObjectiveName"); } // Tracing bool shouldTrace = TracingAdapter.IsEnabled; string invocationId = null; if (shouldTrace) { invocationId = TracingAdapter.NextInvocationId.ToString(); Dictionary <string, object> tracingParameters = new Dictionary <string, object>(); tracingParameters.Add("resourceGroupName", resourceGroupName); tracingParameters.Add("serverName", serverName); tracingParameters.Add("serviceObjectiveName", serviceObjectiveName); TracingAdapter.Enter(invocationId, this, "GetAsync", tracingParameters); } // Construct URL string url = ""; url = url + "/subscriptions/"; if (this.Client.Credentials.SubscriptionId != null) { url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId); } url = url + "/resourceGroups/"; url = url + Uri.EscapeDataString(resourceGroupName); url = url + "/providers/"; url = url + "Microsoft.Sql"; url = url + "/servers/"; url = url + Uri.EscapeDataString(serverName); url = url + "/serviceObjectives/"; url = url + Uri.EscapeDataString(serviceObjectiveName); List <string> queryParameters = new List <string>(); queryParameters.Add("api-version=2014-04-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 // 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 ServiceObjectiveGetResponse result = null; // Deserialize Response if (statusCode == HttpStatusCode.OK) { cancellationToken.ThrowIfCancellationRequested(); string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); result = new ServiceObjectiveGetResponse(); JToken responseDoc = null; if (string.IsNullOrEmpty(responseContent) == false) { responseDoc = JToken.Parse(responseContent); } if (responseDoc != null && responseDoc.Type != JTokenType.Null) { ServiceObjective serviceObjectiveInstance = new ServiceObjective(); result.ServiceObjective = serviceObjectiveInstance; JToken propertiesValue = responseDoc["properties"]; if (propertiesValue != null && propertiesValue.Type != JTokenType.Null) { ServiceObjectiveProperties propertiesInstance = new ServiceObjectiveProperties(); serviceObjectiveInstance.Properties = propertiesInstance; JToken serviceObjectiveNameValue = propertiesValue["serviceObjectiveName"]; if (serviceObjectiveNameValue != null && serviceObjectiveNameValue.Type != JTokenType.Null) { string serviceObjectiveNameInstance = ((string)serviceObjectiveNameValue); propertiesInstance.ServiceObjectiveName = serviceObjectiveNameInstance; } JToken isDefaultValue = propertiesValue["isDefault"]; if (isDefaultValue != null && isDefaultValue.Type != JTokenType.Null) { bool isDefaultInstance = ((bool)isDefaultValue); propertiesInstance.IsDefault = isDefaultInstance; } JToken isSystemValue = propertiesValue["isSystem"]; if (isSystemValue != null && isSystemValue.Type != JTokenType.Null) { bool isSystemInstance = ((bool)isSystemValue); propertiesInstance.IsSystem = isSystemInstance; } JToken descriptionValue = propertiesValue["description"]; if (descriptionValue != null && descriptionValue.Type != JTokenType.Null) { string descriptionInstance = ((string)descriptionValue); propertiesInstance.Description = descriptionInstance; } JToken enabledValue = propertiesValue["enabled"]; if (enabledValue != null && enabledValue.Type != JTokenType.Null) { bool enabledInstance = ((bool)enabledValue); propertiesInstance.Enabled = enabledInstance; } } JToken idValue = responseDoc["id"]; if (idValue != null && idValue.Type != JTokenType.Null) { string idInstance = ((string)idValue); serviceObjectiveInstance.Id = idInstance; } JToken nameValue = responseDoc["name"]; if (nameValue != null && nameValue.Type != JTokenType.Null) { string nameInstance = ((string)nameValue); serviceObjectiveInstance.Name = nameInstance; } JToken typeValue = responseDoc["type"]; if (typeValue != null && typeValue.Type != JTokenType.Null) { string typeInstance = ((string)typeValue); serviceObjectiveInstance.Type = typeInstance; } JToken locationValue = responseDoc["location"]; if (locationValue != null && locationValue.Type != JTokenType.Null) { string locationInstance = ((string)locationValue); serviceObjectiveInstance.Location = locationInstance; } JToken tagsSequenceElement = ((JToken)responseDoc["tags"]); if (tagsSequenceElement != null && tagsSequenceElement.Type != JTokenType.Null) { foreach (JProperty property in tagsSequenceElement) { string tagsKey = ((string)property.Name); string tagsValue = ((string)property.Value); serviceObjectiveInstance.Tags.Add(tagsKey, tagsValue); } } } } 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(); } } }
public void CreateServiceObjective() { var newServiceObjective = new ServiceObjective(CreateServiceViewModel.ObjectiveName, CreateServiceViewModel.ObjectiveDescription); CreateServiceViewModel.ObjectiveCatalog.Add(newServiceObjective); }