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