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