/// <summary> /// Updates the specified PrintConnector using PATCH. /// </summary> /// <param name="printConnectorToUpdate">The PrintConnector 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 PrintConnector.</returns> public async System.Threading.Tasks.Task <PrintConnector> UpdateAsync(PrintConnector printConnectorToUpdate, CancellationToken cancellationToken) { if (printConnectorToUpdate.AdditionalData != null) { if (printConnectorToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) || printConnectorToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode)) { throw new ClientException( new Error { Code = GeneratedErrorConstants.Codes.NotAllowed, Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, printConnectorToUpdate.GetType().Name) }); } } if (printConnectorToUpdate.AdditionalData != null) { if (printConnectorToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) || printConnectorToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode)) { throw new ClientException( new Error { Code = GeneratedErrorConstants.Codes.NotAllowed, Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, printConnectorToUpdate.GetType().Name) }); } } this.ContentType = "application/json"; this.Method = "PATCH"; var updatedEntity = await this.SendAsync <PrintConnector>(printConnectorToUpdate, cancellationToken).ConfigureAwait(false); return(updatedEntity); }
/// <summary> /// Creates the specified PrintConnector using POST. /// </summary> /// <param name="printConnectorToCreate">The PrintConnector to create.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param> /// <returns>The created PrintConnector.</returns> public async System.Threading.Tasks.Task <PrintConnector> CreateAsync(PrintConnector printConnectorToCreate, CancellationToken cancellationToken) { this.ContentType = "application/json"; this.Method = "POST"; var newEntity = await this.SendAsync <PrintConnector>(printConnectorToCreate, cancellationToken).ConfigureAwait(false); return(newEntity); }
/// <summary> /// Adds the specified PrintConnector to the collection via POST. /// </summary> /// <param name="printConnector">The PrintConnector to add.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param> /// <returns>The task to await.</returns> public System.Threading.Tasks.Task AddAsync(PrintConnector printConnector, CancellationToken cancellationToken) { this.ContentType = "application/json"; this.Method = "POST"; if (string.IsNullOrEmpty(printConnector.Id)) { throw new ServiceException(new Error { Code = "invalidRequest", Message = "ID is required to add a reference." }); } var requestBody = new ReferenceRequestBody { ODataId = string.Format("{0}/print/connectors/{1}", this.Client.BaseUrl, printConnector.Id) }; return(this.SendAsync(requestBody, cancellationToken)); }
/// <summary> /// Adds the specified PrintConnector to the collection via POST. /// </summary> /// <param name="printConnector">The PrintConnector to add.</param> /// <returns>The task to await.</returns> public System.Threading.Tasks.Task AddAsync(PrintConnector printConnector) { return(this.AddAsync(printConnector, CancellationToken.None)); }
/// <summary> /// Updates the specified PrintConnector using PATCH. /// </summary> /// <param name="printConnectorToUpdate">The PrintConnector to update.</param> /// <returns>The updated PrintConnector.</returns> public System.Threading.Tasks.Task <PrintConnector> UpdateAsync(PrintConnector printConnectorToUpdate) { return(this.UpdateAsync(printConnectorToUpdate, CancellationToken.None)); }
/// <summary> /// Adds the specified PrintConnector to the collection via POST. /// </summary> /// <param name="printConnector">The PrintConnector to add.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param> /// <returns>The created PrintConnector.</returns> public System.Threading.Tasks.Task <PrintConnector> AddAsync(PrintConnector printConnector, CancellationToken cancellationToken) { this.ContentType = "application/json"; this.Method = "POST"; return(this.SendAsync <PrintConnector>(printConnector, cancellationToken)); }
/// <summary> /// Initializes any collection properties after deserialization, like next requests for paging. /// </summary> /// <param name="printConnectorToInitialize">The <see cref="PrintConnector"/> with the collection properties to initialize.</param> private void InitializeCollectionProperties(PrintConnector printConnectorToInitialize) { }