/// <summary> /// Updates the specified ExternalGroup using PATCH. /// </summary> /// <param name="externalGroupToUpdate">The ExternalGroup 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 ExternalGroup.</returns> public async System.Threading.Tasks.Task <ExternalGroup> UpdateAsync(ExternalGroup externalGroupToUpdate, CancellationToken cancellationToken) { if (externalGroupToUpdate.AdditionalData != null) { if (externalGroupToUpdate.AdditionalData.ContainsKey(Microsoft.Graph.Constants.HttpPropertyNames.ResponseHeaders) || externalGroupToUpdate.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, externalGroupToUpdate.GetType().Name) }); } } if (externalGroupToUpdate.AdditionalData != null) { if (externalGroupToUpdate.AdditionalData.ContainsKey(Microsoft.Graph.Constants.HttpPropertyNames.ResponseHeaders) || externalGroupToUpdate.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, externalGroupToUpdate.GetType().Name) }); } } this.ContentType = "application/json"; this.Method = "PATCH"; var updatedEntity = await this.SendAsync <ExternalGroup>(externalGroupToUpdate, cancellationToken).ConfigureAwait(false); this.InitializeCollectionProperties(updatedEntity); return(updatedEntity); }
/// <summary> /// Creates the specified ExternalGroup using POST. /// </summary> /// <param name="externalGroupToCreate">The ExternalGroup to create.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param> /// <returns>The created ExternalGroup.</returns> public async System.Threading.Tasks.Task <ExternalGroup> CreateAsync(ExternalGroup externalGroupToCreate, CancellationToken cancellationToken) { this.ContentType = "application/json"; this.Method = "POST"; var newEntity = await this.SendAsync <ExternalGroup>(externalGroupToCreate, cancellationToken).ConfigureAwait(false); this.InitializeCollectionProperties(newEntity); return(newEntity); }
/// <summary> /// Initializes any collection properties after deserialization, like next requests for paging. /// </summary> /// <param name="externalGroupToInitialize">The <see cref="ExternalGroup"/> with the collection properties to initialize.</param> private void InitializeCollectionProperties(ExternalGroup externalGroupToInitialize) { if (externalGroupToInitialize != null && externalGroupToInitialize.AdditionalData != null) { if (externalGroupToInitialize.Members != null && externalGroupToInitialize.Members.CurrentPage != null) { externalGroupToInitialize.Members.AdditionalData = externalGroupToInitialize.AdditionalData; object nextPageLink; externalGroupToInitialize.AdditionalData.TryGetValue("*****@*****.**", out nextPageLink); var nextPageLinkString = nextPageLink as string; if (!string.IsNullOrEmpty(nextPageLinkString)) { externalGroupToInitialize.Members.InitializeNextPageRequest( this.Client, nextPageLinkString); } } } }
/// <summary> /// Creates the specified ExternalGroup using POST. /// </summary> /// <param name="externalGroupToCreate">The ExternalGroup to create.</param> /// <returns>The created ExternalGroup.</returns> public System.Threading.Tasks.Task <ExternalGroup> CreateAsync(ExternalGroup externalGroupToCreate) { return(this.CreateAsync(externalGroupToCreate, CancellationToken.None)); }
/// <summary> /// Adds the specified ExternalGroup to the collection via POST. /// </summary> /// <param name="externalGroup">The ExternalGroup to add.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param> /// <returns>The created ExternalGroup.</returns> public System.Threading.Tasks.Task <ExternalGroup> AddAsync(ExternalGroup externalGroup, CancellationToken cancellationToken) { this.ContentType = "application/json"; this.Method = "POST"; return(this.SendAsync <ExternalGroup>(externalGroup, cancellationToken)); }
/// <summary> /// Adds the specified ExternalGroup to the collection via POST. /// </summary> /// <param name="externalGroup">The ExternalGroup to add.</param> /// <returns>The created ExternalGroup.</returns> public System.Threading.Tasks.Task <ExternalGroup> AddAsync(ExternalGroup externalGroup) { return(this.AddAsync(externalGroup, CancellationToken.None)); }