/// <summary> /// Creates the specified DeviceManagementIntentDeviceState using POST. /// </summary> /// <param name="deviceManagementIntentDeviceStateToCreate">The DeviceManagementIntentDeviceState to create.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param> /// <returns>The created DeviceManagementIntentDeviceState.</returns> public async System.Threading.Tasks.Task <DeviceManagementIntentDeviceState> CreateAsync(DeviceManagementIntentDeviceState deviceManagementIntentDeviceStateToCreate, CancellationToken cancellationToken) { this.ContentType = "application/json"; this.Method = "POST"; var newEntity = await this.SendAsync <DeviceManagementIntentDeviceState>(deviceManagementIntentDeviceStateToCreate, cancellationToken).ConfigureAwait(false); this.InitializeCollectionProperties(newEntity); return(newEntity); }
/// <summary> /// Creates the specified DeviceManagementIntentDeviceState using POST. /// </summary> /// <param name="deviceManagementIntentDeviceStateToCreate">The DeviceManagementIntentDeviceState to create.</param> /// <returns>The created DeviceManagementIntentDeviceState.</returns> public System.Threading.Tasks.Task <DeviceManagementIntentDeviceState> CreateAsync(DeviceManagementIntentDeviceState deviceManagementIntentDeviceStateToCreate) { return(this.CreateAsync(deviceManagementIntentDeviceStateToCreate, CancellationToken.None)); }
/// <summary> /// Updates the specified DeviceManagementIntentDeviceState using PATCH. /// </summary> /// <param name="deviceManagementIntentDeviceStateToUpdate">The DeviceManagementIntentDeviceState 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 DeviceManagementIntentDeviceState.</returns> public async System.Threading.Tasks.Task <DeviceManagementIntentDeviceState> UpdateAsync(DeviceManagementIntentDeviceState deviceManagementIntentDeviceStateToUpdate, CancellationToken cancellationToken) { if (deviceManagementIntentDeviceStateToUpdate.AdditionalData != null) { if (deviceManagementIntentDeviceStateToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) || deviceManagementIntentDeviceStateToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode)) { throw new ClientException( new Error { Code = GeneratedErrorConstants.Codes.NotAllowed, Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, deviceManagementIntentDeviceStateToUpdate.GetType().Name) }); } } if (deviceManagementIntentDeviceStateToUpdate.AdditionalData != null) { if (deviceManagementIntentDeviceStateToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) || deviceManagementIntentDeviceStateToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode)) { throw new ClientException( new Error { Code = GeneratedErrorConstants.Codes.NotAllowed, Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, deviceManagementIntentDeviceStateToUpdate.GetType().Name) }); } } this.ContentType = "application/json"; this.Method = "PATCH"; var updatedEntity = await this.SendAsync <DeviceManagementIntentDeviceState>(deviceManagementIntentDeviceStateToUpdate, cancellationToken).ConfigureAwait(false); this.InitializeCollectionProperties(updatedEntity); return(updatedEntity); }
/// <summary> /// Initializes any collection properties after deserialization, like next requests for paging. /// </summary> /// <param name="deviceManagementIntentDeviceStateToInitialize">The <see cref="DeviceManagementIntentDeviceState"/> with the collection properties to initialize.</param> private void InitializeCollectionProperties(DeviceManagementIntentDeviceState deviceManagementIntentDeviceStateToInitialize) { }
/// <summary> /// Adds the specified DeviceManagementIntentDeviceState to the collection via POST. /// </summary> /// <param name="deviceManagementIntentDeviceState">The DeviceManagementIntentDeviceState to add.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param> /// <returns>The created DeviceManagementIntentDeviceState.</returns> public System.Threading.Tasks.Task <DeviceManagementIntentDeviceState> AddAsync(DeviceManagementIntentDeviceState deviceManagementIntentDeviceState, CancellationToken cancellationToken) { this.ContentType = "application/json"; this.Method = "POST"; return(this.SendAsync <DeviceManagementIntentDeviceState>(deviceManagementIntentDeviceState, cancellationToken)); }