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