/// <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); }
/// <summary> /// Creates the specified PolicySetItem using POST. /// </summary> /// <param name="policySetItemToCreate">The PolicySetItem to create.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param> /// <returns>The created PolicySetItem.</returns> public async System.Threading.Tasks.Task <PolicySetItem> CreateAsync(PolicySetItem policySetItemToCreate, CancellationToken cancellationToken) { this.ContentType = "application/json"; this.Method = "POST"; var newEntity = await this.SendAsync <PolicySetItem>(policySetItemToCreate, cancellationToken).ConfigureAwait(false); this.InitializeCollectionProperties(newEntity); return(newEntity); }
/// <summary> /// Adds the specified PolicySetItem to the collection via POST. /// </summary> /// <param name="policySetItem">The PolicySetItem to add.</param> /// <returns>The created PolicySetItem.</returns> public System.Threading.Tasks.Task <PolicySetItem> AddAsync(PolicySetItem policySetItem) { return(this.AddAsync(policySetItem, CancellationToken.None)); }
/// <summary> /// Creates the specified PolicySetItem using POST. /// </summary> /// <param name="policySetItemToCreate">The PolicySetItem to create.</param> /// <returns>The created PolicySetItem.</returns> public System.Threading.Tasks.Task <PolicySetItem> CreateAsync(PolicySetItem policySetItemToCreate) { return(this.CreateAsync(policySetItemToCreate, CancellationToken.None)); }
/// <summary> /// Initializes any collection properties after deserialization, like next requests for paging. /// </summary> /// <param name="policySetItemToInitialize">The <see cref="PolicySetItem"/> with the collection properties to initialize.</param> private void InitializeCollectionProperties(PolicySetItem policySetItemToInitialize) { }