示例#1
0
        /// <summary>
        /// Creates the specified DeviceManagementIntent using POST.
        /// </summary>
        /// <param name="deviceManagementIntentToCreate">The DeviceManagementIntent to create.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
        /// <returns>The created DeviceManagementIntent.</returns>
        public async System.Threading.Tasks.Task <DeviceManagementIntent> CreateAsync(DeviceManagementIntent deviceManagementIntentToCreate, CancellationToken cancellationToken)
        {
            this.ContentType = "application/json";
            this.Method      = "POST";
            var newEntity = await this.SendAsync <DeviceManagementIntent>(deviceManagementIntentToCreate, cancellationToken).ConfigureAwait(false);

            this.InitializeCollectionProperties(newEntity);
            return(newEntity);
        }
示例#2
0
 /// <summary>
 /// Creates the specified DeviceManagementIntent using POST.
 /// </summary>
 /// <param name="deviceManagementIntentToCreate">The DeviceManagementIntent to create.</param>
 /// <returns>The created DeviceManagementIntent.</returns>
 public System.Threading.Tasks.Task <DeviceManagementIntent> CreateAsync(DeviceManagementIntent deviceManagementIntentToCreate)
 {
     return(this.CreateAsync(deviceManagementIntentToCreate, CancellationToken.None));
 }
示例#3
0
        /// <summary>
        /// Initializes any collection properties after deserialization, like next requests for paging.
        /// </summary>
        /// <param name="deviceManagementIntentToInitialize">The <see cref="DeviceManagementIntent"/> with the collection properties to initialize.</param>
        private void InitializeCollectionProperties(DeviceManagementIntent deviceManagementIntentToInitialize)
        {
            if (deviceManagementIntentToInitialize != null && deviceManagementIntentToInitialize.AdditionalData != null)
            {
                if (deviceManagementIntentToInitialize.Assignments != null && deviceManagementIntentToInitialize.Assignments.CurrentPage != null)
                {
                    deviceManagementIntentToInitialize.Assignments.AdditionalData = deviceManagementIntentToInitialize.AdditionalData;

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        deviceManagementIntentToInitialize.Assignments.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }

                if (deviceManagementIntentToInitialize.Categories != null && deviceManagementIntentToInitialize.Categories.CurrentPage != null)
                {
                    deviceManagementIntentToInitialize.Categories.AdditionalData = deviceManagementIntentToInitialize.AdditionalData;

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        deviceManagementIntentToInitialize.Categories.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }

                if (deviceManagementIntentToInitialize.DeviceSettingStateSummaries != null && deviceManagementIntentToInitialize.DeviceSettingStateSummaries.CurrentPage != null)
                {
                    deviceManagementIntentToInitialize.DeviceSettingStateSummaries.AdditionalData = deviceManagementIntentToInitialize.AdditionalData;

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        deviceManagementIntentToInitialize.DeviceSettingStateSummaries.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }

                if (deviceManagementIntentToInitialize.DeviceStates != null && deviceManagementIntentToInitialize.DeviceStates.CurrentPage != null)
                {
                    deviceManagementIntentToInitialize.DeviceStates.AdditionalData = deviceManagementIntentToInitialize.AdditionalData;

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        deviceManagementIntentToInitialize.DeviceStates.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }

                if (deviceManagementIntentToInitialize.Settings != null && deviceManagementIntentToInitialize.Settings.CurrentPage != null)
                {
                    deviceManagementIntentToInitialize.Settings.AdditionalData = deviceManagementIntentToInitialize.AdditionalData;

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        deviceManagementIntentToInitialize.Settings.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }

                if (deviceManagementIntentToInitialize.UserStates != null && deviceManagementIntentToInitialize.UserStates.CurrentPage != null)
                {
                    deviceManagementIntentToInitialize.UserStates.AdditionalData = deviceManagementIntentToInitialize.AdditionalData;

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

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

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