/// <summary> /// Adds the specified PolicySetItem to the collection via POST. /// </summary> /// <param name="policySetItem">The PolicySetItem to add.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param> /// <returns>The created PolicySetItem.</returns> public System.Threading.Tasks.Task <PolicySetItem> AddAsync(PolicySetItem policySetItem, CancellationToken cancellationToken) { this.ContentType = "application/json"; this.Method = "POST"; policySetItem.ODataType = string.Concat("#", StringHelper.ConvertTypeToLowerCamelCase(policySetItem.GetType().FullName)); return(this.SendAsync <PolicySetItem>(policySetItem, cancellationToken)); }
/// <summary> /// Updates the specified PolicySetItem using PATCH. /// </summary> /// <param name="policySetItemToUpdate">The PolicySetItem 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 PolicySetItem.</returns> public async System.Threading.Tasks.Task <PolicySetItem> UpdateAsync(PolicySetItem policySetItemToUpdate, CancellationToken cancellationToken) { if (policySetItemToUpdate.AdditionalData != null) { if (policySetItemToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) || policySetItemToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode)) { throw new ClientException( new Error { Code = GeneratedErrorConstants.Codes.NotAllowed, Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, policySetItemToUpdate.GetType().Name) }); } } if (policySetItemToUpdate.AdditionalData != null) { if (policySetItemToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) || policySetItemToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode)) { throw new ClientException( new Error { Code = GeneratedErrorConstants.Codes.NotAllowed, Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, policySetItemToUpdate.GetType().Name) }); } } this.ContentType = "application/json"; this.Method = "PATCH"; var updatedEntity = await this.SendAsync <PolicySetItem>(policySetItemToUpdate, cancellationToken).ConfigureAwait(false); this.InitializeCollectionProperties(updatedEntity); return(updatedEntity); }