/// <summary> /// Updates the specified DataSourceContainer using PATCH. /// </summary> /// <param name="dataSourceContainerToUpdate">The DataSourceContainer to update.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param> /// <exception cref="Microsoft.Graph.ClientException">Thrown when an object returned in a response is used for updating an object in Microsoft Graph.</exception> /// <returns>The updated DataSourceContainer.</returns> public async System.Threading.Tasks.Task <DataSourceContainer> UpdateAsync(DataSourceContainer dataSourceContainerToUpdate, CancellationToken cancellationToken) { if (dataSourceContainerToUpdate.AdditionalData != null) { if (dataSourceContainerToUpdate.AdditionalData.ContainsKey(Microsoft.Graph.Constants.HttpPropertyNames.ResponseHeaders) || dataSourceContainerToUpdate.AdditionalData.ContainsKey(Microsoft.Graph.Constants.HttpPropertyNames.StatusCode)) { throw new Microsoft.Graph.ClientException( new Microsoft.Graph.Error { Code = Microsoft.Graph.GeneratedErrorConstants.Codes.NotAllowed, Message = String.Format(Microsoft.Graph.GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, dataSourceContainerToUpdate.GetType().Name) }); } } if (dataSourceContainerToUpdate.AdditionalData != null) { if (dataSourceContainerToUpdate.AdditionalData.ContainsKey(Microsoft.Graph.Constants.HttpPropertyNames.ResponseHeaders) || dataSourceContainerToUpdate.AdditionalData.ContainsKey(Microsoft.Graph.Constants.HttpPropertyNames.StatusCode)) { throw new Microsoft.Graph.ClientException( new Microsoft.Graph.Error { Code = Microsoft.Graph.GeneratedErrorConstants.Codes.NotAllowed, Message = String.Format(Microsoft.Graph.GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, dataSourceContainerToUpdate.GetType().Name) }); } } this.ContentType = "application/json"; this.Method = "PATCH"; var updatedEntity = await this.SendAsync <DataSourceContainer>(dataSourceContainerToUpdate, cancellationToken).ConfigureAwait(false); this.InitializeCollectionProperties(updatedEntity); return(updatedEntity); }
/// <summary> /// Creates the specified DataSourceContainer using POST. /// </summary> /// <param name="dataSourceContainerToCreate">The DataSourceContainer to create.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param> /// <returns>The created DataSourceContainer.</returns> public async System.Threading.Tasks.Task <DataSourceContainer> CreateAsync(DataSourceContainer dataSourceContainerToCreate, CancellationToken cancellationToken) { this.ContentType = "application/json"; this.Method = "POST"; var newEntity = await this.SendAsync <DataSourceContainer>(dataSourceContainerToCreate, cancellationToken).ConfigureAwait(false); this.InitializeCollectionProperties(newEntity); return(newEntity); }
/// <summary> /// Creates the specified DataSourceContainer using POST. /// </summary> /// <param name="dataSourceContainerToCreate">The DataSourceContainer to create.</param> /// <returns>The created DataSourceContainer.</returns> public System.Threading.Tasks.Task <DataSourceContainer> CreateAsync(DataSourceContainer dataSourceContainerToCreate) { return(this.CreateAsync(dataSourceContainerToCreate, CancellationToken.None)); }
/// <summary> /// Initializes any collection properties after deserialization, like next requests for paging. /// </summary> /// <param name="dataSourceContainerToInitialize">The <see cref="DataSourceContainer"/> with the collection properties to initialize.</param> private void InitializeCollectionProperties(DataSourceContainer dataSourceContainerToInitialize) { }