/// <summary> /// Updates the specified DeviceManagementSettingInstance using PATCH. /// </summary> /// <param name="deviceManagementSettingInstanceToUpdate">The DeviceManagementSettingInstance to update.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param> /// <exception cref="ClientException">Thrown when an object returned in a response is used for updating an object in Microsoft Graph.</exception> /// <returns>The updated DeviceManagementSettingInstance.</returns> public async System.Threading.Tasks.Task <DeviceManagementSettingInstance> UpdateAsync(DeviceManagementSettingInstance deviceManagementSettingInstanceToUpdate, CancellationToken cancellationToken) { if (deviceManagementSettingInstanceToUpdate.AdditionalData != null) { if (deviceManagementSettingInstanceToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) || deviceManagementSettingInstanceToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode)) { throw new ClientException( new Error { Code = GeneratedErrorConstants.Codes.NotAllowed, Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, deviceManagementSettingInstanceToUpdate.GetType().Name) }); } } if (deviceManagementSettingInstanceToUpdate.AdditionalData != null) { if (deviceManagementSettingInstanceToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) || deviceManagementSettingInstanceToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode)) { throw new ClientException( new Error { Code = GeneratedErrorConstants.Codes.NotAllowed, Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, deviceManagementSettingInstanceToUpdate.GetType().Name) }); } } this.ContentType = "application/json"; this.Method = "PATCH"; var updatedEntity = await this.SendAsync <DeviceManagementSettingInstance>(deviceManagementSettingInstanceToUpdate, cancellationToken).ConfigureAwait(false); this.InitializeCollectionProperties(updatedEntity); return(updatedEntity); }
/// <summary> /// Adds the specified DeviceManagementSettingInstance to the collection via POST. /// </summary> /// <param name="deviceManagementSettingInstance">The DeviceManagementSettingInstance to add.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param> /// <returns>The created DeviceManagementSettingInstance.</returns> public System.Threading.Tasks.Task <DeviceManagementSettingInstance> AddAsync(DeviceManagementSettingInstance deviceManagementSettingInstance, CancellationToken cancellationToken) { this.ContentType = "application/json"; this.Method = "POST"; deviceManagementSettingInstance.ODataType = string.Concat("#", StringHelper.ConvertTypeToLowerCamelCase(deviceManagementSettingInstance.GetType().FullName)); return(this.SendAsync <DeviceManagementSettingInstance>(deviceManagementSettingInstance, cancellationToken)); }