Beispiel #1
0
        /// <summary>
        /// Initializes any collection properties after deserialization, like next requests for paging.
        /// </summary>
        /// <param name="deviceComplianceScriptToInitialize">The <see cref="DeviceComplianceScript"/> with the collection properties to initialize.</param>
        private void InitializeCollectionProperties(DeviceComplianceScript deviceComplianceScriptToInitialize)
        {
            if (deviceComplianceScriptToInitialize != null && deviceComplianceScriptToInitialize.AdditionalData != null)
            {
                if (deviceComplianceScriptToInitialize.Assignments != null && deviceComplianceScriptToInitialize.Assignments.CurrentPage != null)
                {
                    deviceComplianceScriptToInitialize.Assignments.AdditionalData = deviceComplianceScriptToInitialize.AdditionalData;

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

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

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

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        deviceComplianceScriptToInitialize.DeviceRunStates.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Creates the specified DeviceComplianceScript using POST.
        /// </summary>
        /// <param name="deviceComplianceScriptToCreate">The DeviceComplianceScript to create.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
        /// <returns>The created DeviceComplianceScript.</returns>
        public async System.Threading.Tasks.Task <DeviceComplianceScript> CreateAsync(DeviceComplianceScript deviceComplianceScriptToCreate, CancellationToken cancellationToken)
        {
            this.ContentType = "application/json";
            this.Method      = "POST";
            var newEntity = await this.SendAsync <DeviceComplianceScript>(deviceComplianceScriptToCreate, cancellationToken).ConfigureAwait(false);

            this.InitializeCollectionProperties(newEntity);
            return(newEntity);
        }
Beispiel #3
0
 /// <summary>
 /// Creates the specified DeviceComplianceScript using POST.
 /// </summary>
 /// <param name="deviceComplianceScriptToCreate">The DeviceComplianceScript to create.</param>
 /// <returns>The created DeviceComplianceScript.</returns>
 public System.Threading.Tasks.Task <DeviceComplianceScript> CreateAsync(DeviceComplianceScript deviceComplianceScriptToCreate)
 {
     return(this.CreateAsync(deviceComplianceScriptToCreate, CancellationToken.None));
 }
Beispiel #4
0
        /// <summary>
        /// Updates the specified DeviceComplianceScript using PATCH.
        /// </summary>
        /// <param name="deviceComplianceScriptToUpdate">The DeviceComplianceScript 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 DeviceComplianceScript.</returns>
        public async System.Threading.Tasks.Task <DeviceComplianceScript> UpdateAsync(DeviceComplianceScript deviceComplianceScriptToUpdate, CancellationToken cancellationToken)
        {
            if (deviceComplianceScriptToUpdate.AdditionalData != null)
            {
                if (deviceComplianceScriptToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) ||
                    deviceComplianceScriptToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode))
                {
                    throw new ClientException(
                              new Error
                    {
                        Code    = GeneratedErrorConstants.Codes.NotAllowed,
                        Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, deviceComplianceScriptToUpdate.GetType().Name)
                    });
                }
            }
            if (deviceComplianceScriptToUpdate.AdditionalData != null)
            {
                if (deviceComplianceScriptToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) ||
                    deviceComplianceScriptToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode))
                {
                    throw new ClientException(
                              new Error
                    {
                        Code    = GeneratedErrorConstants.Codes.NotAllowed,
                        Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, deviceComplianceScriptToUpdate.GetType().Name)
                    });
                }
            }
            this.ContentType = "application/json";
            this.Method      = "PATCH";
            var updatedEntity = await this.SendAsync <DeviceComplianceScript>(deviceComplianceScriptToUpdate, cancellationToken).ConfigureAwait(false);

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