/// <summary>
        /// Adds the specified DeviceConfiguration to the collection via POST.
        /// </summary>
        /// <param name="deviceConfiguration">The DeviceConfiguration to add.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
        /// <returns>The task to await.</returns>
        public System.Threading.Tasks.Task AddAsync(DeviceConfiguration deviceConfiguration, CancellationToken cancellationToken)
        {
            this.ContentType = "application/json";
            this.Method      = "POST";

            if (string.IsNullOrEmpty(deviceConfiguration.Id))
            {
                throw new ServiceException(new Error {
                    Code = "invalidRequest", Message = "ID is required to add a reference."
                });
            }

            var requestBody = new ReferenceRequestBody {
                ODataId = string.Format("{0}/deviceManagement/networkAccessConfigurations/{1}", this.Client.BaseUrl, deviceConfiguration.Id)
            };

            return(this.SendAsync(requestBody, cancellationToken));
        }
 /// <summary>
 /// Creates the specified DeviceConfiguration using POST.
 /// </summary>
 /// <param name="deviceConfigurationToCreate">The DeviceConfiguration to create.</param>
 /// <returns>The created DeviceConfiguration.</returns>
 public System.Threading.Tasks.Task <DeviceConfiguration> CreateAsync(DeviceConfiguration deviceConfigurationToCreate)
 {
     return(this.CreateAsync(deviceConfigurationToCreate, CancellationToken.None));
 }
        /// <summary>
        /// Initializes any collection properties after deserialization, like next requests for paging.
        /// </summary>
        /// <param name="deviceConfigurationToInitialize">The <see cref="DeviceConfiguration"/> with the collection properties to initialize.</param>
        private void InitializeCollectionProperties(DeviceConfiguration deviceConfigurationToInitialize)
        {
            if (deviceConfigurationToInitialize != null && deviceConfigurationToInitialize.AdditionalData != null)
            {
                if (deviceConfigurationToInitialize.Assignments != null && deviceConfigurationToInitialize.Assignments.CurrentPage != null)
                {
                    deviceConfigurationToInitialize.Assignments.AdditionalData = deviceConfigurationToInitialize.AdditionalData;

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

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

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

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

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

                if (deviceConfigurationToInitialize.DeviceStatuses != null && deviceConfigurationToInitialize.DeviceStatuses.CurrentPage != null)
                {
                    deviceConfigurationToInitialize.DeviceStatuses.AdditionalData = deviceConfigurationToInitialize.AdditionalData;

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        deviceConfigurationToInitialize.DeviceStatuses.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }

                if (deviceConfigurationToInitialize.UserStatuses != null && deviceConfigurationToInitialize.UserStatuses.CurrentPage != null)
                {
                    deviceConfigurationToInitialize.UserStatuses.AdditionalData = deviceConfigurationToInitialize.AdditionalData;

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        deviceConfigurationToInitialize.UserStatuses.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }
            }
        }
 /// <summary>
 /// Adds the specified DeviceConfiguration to the collection via POST.
 /// </summary>
 /// <param name="deviceConfiguration">The DeviceConfiguration to add.</param>
 /// <returns>The created DeviceConfiguration.</returns>
 public System.Threading.Tasks.Task <DeviceConfiguration> AddAsync(DeviceConfiguration deviceConfiguration)
 {
     return(this.AddAsync(deviceConfiguration, CancellationToken.None));
 }