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