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