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