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

            this.InitializeCollectionProperties(updatedEntity);
            return(updatedEntity);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates the specified PrivilegedAccess using POST.
        /// </summary>
        /// <param name="privilegedAccessToCreate">The PrivilegedAccess to create.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
        /// <returns>The created PrivilegedAccess.</returns>
        public async System.Threading.Tasks.Task <PrivilegedAccess> CreateAsync(PrivilegedAccess privilegedAccessToCreate, CancellationToken cancellationToken)
        {
            this.ContentType = "application/json";
            this.Method      = "POST";
            var newEntity = await this.SendAsync <PrivilegedAccess>(privilegedAccessToCreate, cancellationToken).ConfigureAwait(false);

            this.InitializeCollectionProperties(newEntity);
            return(newEntity);
        }
 /// <summary>
 /// Adds the specified PrivilegedAccess to the collection via POST.
 /// </summary>
 /// <param name="privilegedAccess">The PrivilegedAccess to add.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
 /// <returns>The created PrivilegedAccess.</returns>
 public System.Threading.Tasks.Task <PrivilegedAccess> AddAsync(PrivilegedAccess privilegedAccess, CancellationToken cancellationToken)
 {
     this.ContentType = "application/json";
     this.Method      = "POST";
     return(this.SendAsync <PrivilegedAccess>(privilegedAccess, cancellationToken));
 }
 /// <summary>
 /// Adds the specified PrivilegedAccess to the collection via POST.
 /// </summary>
 /// <param name="privilegedAccess">The PrivilegedAccess to add.</param>
 /// <returns>The created PrivilegedAccess.</returns>
 public System.Threading.Tasks.Task <PrivilegedAccess> AddAsync(PrivilegedAccess privilegedAccess)
 {
     return(this.AddAsync(privilegedAccess, CancellationToken.None));
 }
Exemplo n.º 5
0
 /// <summary>
 /// Creates the specified PrivilegedAccess using POST.
 /// </summary>
 /// <param name="privilegedAccessToCreate">The PrivilegedAccess to create.</param>
 /// <returns>The created PrivilegedAccess.</returns>
 public System.Threading.Tasks.Task <PrivilegedAccess> CreateAsync(PrivilegedAccess privilegedAccessToCreate)
 {
     return(this.CreateAsync(privilegedAccessToCreate, CancellationToken.None));
 }
Exemplo n.º 6
0
        /// <summary>
        /// Initializes any collection properties after deserialization, like next requests for paging.
        /// </summary>
        /// <param name="privilegedAccessToInitialize">The <see cref="PrivilegedAccess"/> with the collection properties to initialize.</param>
        private void InitializeCollectionProperties(PrivilegedAccess privilegedAccessToInitialize)
        {
            if (privilegedAccessToInitialize != null && privilegedAccessToInitialize.AdditionalData != null)
            {
                if (privilegedAccessToInitialize.Resources != null && privilegedAccessToInitialize.Resources.CurrentPage != null)
                {
                    privilegedAccessToInitialize.Resources.AdditionalData = privilegedAccessToInitialize.AdditionalData;

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        privilegedAccessToInitialize.Resources.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }

                if (privilegedAccessToInitialize.RoleAssignmentRequests != null && privilegedAccessToInitialize.RoleAssignmentRequests.CurrentPage != null)
                {
                    privilegedAccessToInitialize.RoleAssignmentRequests.AdditionalData = privilegedAccessToInitialize.AdditionalData;

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        privilegedAccessToInitialize.RoleAssignmentRequests.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }

                if (privilegedAccessToInitialize.RoleAssignments != null && privilegedAccessToInitialize.RoleAssignments.CurrentPage != null)
                {
                    privilegedAccessToInitialize.RoleAssignments.AdditionalData = privilegedAccessToInitialize.AdditionalData;

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        privilegedAccessToInitialize.RoleAssignments.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }

                if (privilegedAccessToInitialize.RoleDefinitions != null && privilegedAccessToInitialize.RoleDefinitions.CurrentPage != null)
                {
                    privilegedAccessToInitialize.RoleDefinitions.AdditionalData = privilegedAccessToInitialize.AdditionalData;

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        privilegedAccessToInitialize.RoleDefinitions.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }

                if (privilegedAccessToInitialize.RoleSettings != null && privilegedAccessToInitialize.RoleSettings.CurrentPage != null)
                {
                    privilegedAccessToInitialize.RoleSettings.AdditionalData = privilegedAccessToInitialize.AdditionalData;

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        privilegedAccessToInitialize.RoleSettings.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }
            }
        }