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