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