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

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        unifiedRoleManagementPolicyToInitialize.EffectiveRules.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }

                if (unifiedRoleManagementPolicyToInitialize.Rules != null && unifiedRoleManagementPolicyToInitialize.Rules.CurrentPage != null)
                {
                    unifiedRoleManagementPolicyToInitialize.Rules.AdditionalData = unifiedRoleManagementPolicyToInitialize.AdditionalData;

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        unifiedRoleManagementPolicyToInitialize.Rules.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }
            }
        }
Example #2
0
 /// <summary>
 /// Updates the specified UnifiedRoleManagementPolicy using PATCH.
 /// </summary>
 /// <param name="unifiedRoleManagementPolicyToUpdate">The UnifiedRoleManagementPolicy to update.</param>
 /// <returns>The updated UnifiedRoleManagementPolicy.</returns>
 public System.Threading.Tasks.Task <UnifiedRoleManagementPolicy> UpdateAsync(UnifiedRoleManagementPolicy unifiedRoleManagementPolicyToUpdate)
 {
     return(this.UpdateAsync(unifiedRoleManagementPolicyToUpdate, CancellationToken.None));
 }
Example #3
0
        /// <summary>
        /// Creates the specified UnifiedRoleManagementPolicy using POST.
        /// </summary>
        /// <param name="unifiedRoleManagementPolicyToCreate">The UnifiedRoleManagementPolicy to create.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
        /// <returns>The created UnifiedRoleManagementPolicy.</returns>
        public async System.Threading.Tasks.Task <UnifiedRoleManagementPolicy> CreateAsync(UnifiedRoleManagementPolicy unifiedRoleManagementPolicyToCreate, CancellationToken cancellationToken)
        {
            this.ContentType = "application/json";
            this.Method      = "POST";
            var newEntity = await this.SendAsync <UnifiedRoleManagementPolicy>(unifiedRoleManagementPolicyToCreate, cancellationToken).ConfigureAwait(false);

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

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