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

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

            return(newEntity);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Initializes any collection properties after deserialization, like next requests for paging.
        /// </summary>
        /// <param name="connectorGroupToInitialize">The <see cref="ConnectorGroup"/> with the collection properties to initialize.</param>
        private void InitializeCollectionProperties(ConnectorGroup connectorGroupToInitialize)
        {
            if (connectorGroupToInitialize != null && connectorGroupToInitialize.AdditionalData != null)
            {
                if (connectorGroupToInitialize.Applications != null && connectorGroupToInitialize.Applications.CurrentPage != null)
                {
                    connectorGroupToInitialize.Applications.AdditionalData = connectorGroupToInitialize.AdditionalData;

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        connectorGroupToInitialize.Applications.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }

                if (connectorGroupToInitialize.Members != null && connectorGroupToInitialize.Members.CurrentPage != null)
                {
                    connectorGroupToInitialize.Members.AdditionalData = connectorGroupToInitialize.AdditionalData;

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        connectorGroupToInitialize.Members.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// Adds the specified ConnectorGroup to the collection via POST.
 /// </summary>
 /// <param name="connectorGroup">The ConnectorGroup to add.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
 /// <returns>The created ConnectorGroup.</returns>
 public System.Threading.Tasks.Task <ConnectorGroup> AddAsync(ConnectorGroup connectorGroup, CancellationToken cancellationToken)
 {
     this.ContentType = "application/json";
     this.Method      = "POST";
     return(this.SendAsync <ConnectorGroup>(connectorGroup, cancellationToken));
 }
Exemplo n.º 5
0
 /// <summary>
 /// Adds the specified ConnectorGroup to the collection via POST.
 /// </summary>
 /// <param name="connectorGroup">The ConnectorGroup to add.</param>
 /// <returns>The created ConnectorGroup.</returns>
 public System.Threading.Tasks.Task <ConnectorGroup> AddAsync(ConnectorGroup connectorGroup)
 {
     return(this.AddAsync(connectorGroup, CancellationToken.None));
 }
Exemplo n.º 6
0
 /// <summary>
 /// Creates the specified ConnectorGroup using POST.
 /// </summary>
 /// <param name="connectorGroupToCreate">The ConnectorGroup to create.</param>
 /// <returns>The created ConnectorGroup.</returns>
 public System.Threading.Tasks.Task <ConnectorGroup> CreateAsync(ConnectorGroup connectorGroupToCreate)
 {
     return(this.CreateAsync(connectorGroupToCreate, CancellationToken.None));
 }