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