/// <summary>
 /// Adds the specified DeviceManagementScript to the collection via POST.
 /// </summary>
 /// <param name="deviceManagementScript">The DeviceManagementScript to add.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
 /// <returns>The created DeviceManagementScript.</returns>
 public System.Threading.Tasks.Task <DeviceManagementScript> AddAsync(DeviceManagementScript deviceManagementScript, CancellationToken cancellationToken)
 {
     this.ContentType = "application/json";
     this.Method      = "POST";
     return(this.SendAsync <DeviceManagementScript>(deviceManagementScript, cancellationToken));
 }
 /// <summary>
 /// Adds the specified DeviceManagementScript to the collection via POST.
 /// </summary>
 /// <param name="deviceManagementScript">The DeviceManagementScript to add.</param>
 /// <returns>The created DeviceManagementScript.</returns>
 public System.Threading.Tasks.Task <DeviceManagementScript> AddAsync(DeviceManagementScript deviceManagementScript)
 {
     return(this.AddAsync(deviceManagementScript, CancellationToken.None));
 }
Esempio n. 3
0
        /// <summary>
        /// Creates the specified DeviceManagementScript using POST.
        /// </summary>
        /// <param name="deviceManagementScriptToCreate">The DeviceManagementScript to create.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
        /// <returns>The created DeviceManagementScript.</returns>
        public async System.Threading.Tasks.Task <DeviceManagementScript> CreateAsync(DeviceManagementScript deviceManagementScriptToCreate, CancellationToken cancellationToken)
        {
            this.ContentType = "application/json";
            this.Method      = "POST";
            var newEntity = await this.SendAsync <DeviceManagementScript>(deviceManagementScriptToCreate, cancellationToken).ConfigureAwait(false);

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

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

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

                if (deviceManagementScriptToInitialize.DeviceRunStates != null && deviceManagementScriptToInitialize.DeviceRunStates.CurrentPage != null)
                {
                    deviceManagementScriptToInitialize.DeviceRunStates.AdditionalData = deviceManagementScriptToInitialize.AdditionalData;

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        deviceManagementScriptToInitialize.DeviceRunStates.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }

                if (deviceManagementScriptToInitialize.GroupAssignments != null && deviceManagementScriptToInitialize.GroupAssignments.CurrentPage != null)
                {
                    deviceManagementScriptToInitialize.GroupAssignments.AdditionalData = deviceManagementScriptToInitialize.AdditionalData;

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        deviceManagementScriptToInitialize.GroupAssignments.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }

                if (deviceManagementScriptToInitialize.UserRunStates != null && deviceManagementScriptToInitialize.UserRunStates.CurrentPage != null)
                {
                    deviceManagementScriptToInitialize.UserRunStates.AdditionalData = deviceManagementScriptToInitialize.AdditionalData;

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

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

            this.InitializeCollectionProperties(updatedEntity);
            return(updatedEntity);
        }