Exemple #1
0
        /// <summary>
        /// Initializes any collection properties after deserialization, like next requests for paging.
        /// </summary>
        /// <param name="androidManagedAppProtectionToInitialize">The <see cref="AndroidManagedAppProtection"/> with the collection properties to initialize.</param>
        private void InitializeCollectionProperties(AndroidManagedAppProtection androidManagedAppProtectionToInitialize)
        {
            if (androidManagedAppProtectionToInitialize != null && androidManagedAppProtectionToInitialize.AdditionalData != null)
            {
                if (androidManagedAppProtectionToInitialize.Apps != null && androidManagedAppProtectionToInitialize.Apps.CurrentPage != null)
                {
                    androidManagedAppProtectionToInitialize.Apps.AdditionalData = androidManagedAppProtectionToInitialize.AdditionalData;

                    object nextPageLink;
                    androidManagedAppProtectionToInitialize.AdditionalData.TryGetValue("*****@*****.**", out nextPageLink);
                    var nextPageLinkString = nextPageLink as string;

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        androidManagedAppProtectionToInitialize.Apps.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Creates the specified AndroidManagedAppProtection using POST.
        /// </summary>
        /// <param name="androidManagedAppProtectionToCreate">The AndroidManagedAppProtection to create.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
        /// <returns>The created AndroidManagedAppProtection.</returns>
        public async System.Threading.Tasks.Task <AndroidManagedAppProtection> CreateAsync(AndroidManagedAppProtection androidManagedAppProtectionToCreate, CancellationToken cancellationToken)
        {
            this.ContentType = "application/json";
            this.Method      = "POST";
            var newEntity = await this.SendAsync <AndroidManagedAppProtection>(androidManagedAppProtectionToCreate, cancellationToken).ConfigureAwait(false);

            this.InitializeCollectionProperties(newEntity);
            return(newEntity);
        }
Exemple #3
0
 /// <summary>
 /// Creates the specified AndroidManagedAppProtection using POST.
 /// </summary>
 /// <param name="androidManagedAppProtectionToCreate">The AndroidManagedAppProtection to create.</param>
 /// <returns>The created AndroidManagedAppProtection.</returns>
 public System.Threading.Tasks.Task <AndroidManagedAppProtection> CreateAsync(AndroidManagedAppProtection androidManagedAppProtectionToCreate)
 {
     return(this.CreateAsync(androidManagedAppProtectionToCreate, CancellationToken.None));
 }
Exemple #4
0
        /// <summary>
        /// Updates the specified AndroidManagedAppProtection using PATCH.
        /// </summary>
        /// <param name="androidManagedAppProtectionToUpdate">The AndroidManagedAppProtection 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 AndroidManagedAppProtection.</returns>
        public async System.Threading.Tasks.Task <AndroidManagedAppProtection> UpdateAsync(AndroidManagedAppProtection androidManagedAppProtectionToUpdate, CancellationToken cancellationToken)
        {
            if (androidManagedAppProtectionToUpdate.AdditionalData != null)
            {
                if (androidManagedAppProtectionToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) ||
                    androidManagedAppProtectionToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode))
                {
                    throw new ClientException(
                              new Error
                    {
                        Code    = GeneratedErrorConstants.Codes.NotAllowed,
                        Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, androidManagedAppProtectionToUpdate.GetType().Name)
                    });
                }
            }
            if (androidManagedAppProtectionToUpdate.AdditionalData != null)
            {
                if (androidManagedAppProtectionToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) ||
                    androidManagedAppProtectionToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode))
                {
                    throw new ClientException(
                              new Error
                    {
                        Code    = GeneratedErrorConstants.Codes.NotAllowed,
                        Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, androidManagedAppProtectionToUpdate.GetType().Name)
                    });
                }
            }
            this.ContentType = "application/json";
            this.Method      = "PATCH";
            var updatedEntity = await this.SendAsync <AndroidManagedAppProtection>(androidManagedAppProtectionToUpdate, cancellationToken).ConfigureAwait(false);

            this.InitializeCollectionProperties(updatedEntity);
            return(updatedEntity);
        }
 /// <summary>
 /// Adds the specified AndroidManagedAppProtection to the collection via POST.
 /// </summary>
 /// <param name="androidManagedAppProtection">The AndroidManagedAppProtection to add.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
 /// <returns>The created AndroidManagedAppProtection.</returns>
 public System.Threading.Tasks.Task <AndroidManagedAppProtection> AddAsync(AndroidManagedAppProtection androidManagedAppProtection, CancellationToken cancellationToken)
 {
     this.ContentType = "application/json";
     this.Method      = "POST";
     return(this.SendAsync <AndroidManagedAppProtection>(androidManagedAppProtection, cancellationToken));
 }
 /// <summary>
 /// Adds the specified AndroidManagedAppProtection to the collection via POST.
 /// </summary>
 /// <param name="androidManagedAppProtection">The AndroidManagedAppProtection to add.</param>
 /// <returns>The created AndroidManagedAppProtection.</returns>
 public System.Threading.Tasks.Task <AndroidManagedAppProtection> AddAsync(AndroidManagedAppProtection androidManagedAppProtection)
 {
     return(this.AddAsync(androidManagedAppProtection, CancellationToken.None));
 }