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

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

            this.InitializeCollectionProperties(newEntity);
            return(newEntity);
        }
コード例 #3
0
        /// <summary>
        /// Initializes any collection properties after deserialization, like next requests for paging.
        /// </summary>
        /// <param name="legalholdToInitialize">The <see cref="Legalhold"/> with the collection properties to initialize.</param>
        private void InitializeCollectionProperties(Legalhold legalholdToInitialize)
        {
            if (legalholdToInitialize != null && legalholdToInitialize.AdditionalData != null)
            {
                if (legalholdToInitialize.SiteSources != null && legalholdToInitialize.SiteSources.CurrentPage != null)
                {
                    legalholdToInitialize.SiteSources.AdditionalData = legalholdToInitialize.AdditionalData;

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        legalholdToInitialize.SiteSources.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }

                if (legalholdToInitialize.UnifiedGroupSources != null && legalholdToInitialize.UnifiedGroupSources.CurrentPage != null)
                {
                    legalholdToInitialize.UnifiedGroupSources.AdditionalData = legalholdToInitialize.AdditionalData;

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        legalholdToInitialize.UnifiedGroupSources.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }

                if (legalholdToInitialize.UserSources != null && legalholdToInitialize.UserSources.CurrentPage != null)
                {
                    legalholdToInitialize.UserSources.AdditionalData = legalholdToInitialize.AdditionalData;

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        legalholdToInitialize.UserSources.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }
            }
        }
コード例 #4
0
 /// <summary>
 /// Creates the specified Legalhold using POST.
 /// </summary>
 /// <param name="legalholdToCreate">The Legalhold to create.</param>
 /// <returns>The created Legalhold.</returns>
 public System.Threading.Tasks.Task <Legalhold> CreateAsync(Legalhold legalholdToCreate)
 {
     return(this.CreateAsync(legalholdToCreate, CancellationToken.None));
 }
 /// <summary>
 /// Adds the specified Legalhold to the collection via POST.
 /// </summary>
 /// <param name="legalhold">The Legalhold to add.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
 /// <returns>The created Legalhold.</returns>
 public System.Threading.Tasks.Task <Legalhold> AddAsync(Legalhold legalhold, CancellationToken cancellationToken)
 {
     this.ContentType = "application/json";
     this.Method      = "POST";
     return(this.SendAsync <Legalhold>(legalhold, cancellationToken));
 }
 /// <summary>
 /// Adds the specified Legalhold to the collection via POST.
 /// </summary>
 /// <param name="legalhold">The Legalhold to add.</param>
 /// <returns>The created Legalhold.</returns>
 public System.Threading.Tasks.Task <Legalhold> AddAsync(Legalhold legalhold)
 {
     return(this.AddAsync(legalhold, CancellationToken.None));
 }