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

            this.InitializeCollectionProperties(updatedEntity);
            return(updatedEntity);
        }
Esempio n. 2
0
 /// <summary>
 /// Creates the specified AuditLogRoot using POST.
 /// </summary>
 /// <param name="auditLogRootToCreate">The AuditLogRoot to create.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
 /// <returns>The created AuditLogRoot.</returns>
 public async System.Threading.Tasks.Task<AuditLogRoot> CreateAsync(AuditLogRoot auditLogRootToCreate, CancellationToken cancellationToken)
 {
     this.ContentType = "application/json";
     this.Method = "POST";
     var newEntity = await this.SendAsync<AuditLogRoot>(auditLogRootToCreate, cancellationToken).ConfigureAwait(false);
     this.InitializeCollectionProperties(newEntity);
     return newEntity;
 }
Esempio n. 3
0
        /// <summary>
        /// Initializes any collection properties after deserialization, like next requests for paging.
        /// </summary>
        /// <param name="auditLogRootToInitialize">The <see cref="AuditLogRoot"/> with the collection properties to initialize.</param>
        private void InitializeCollectionProperties(AuditLogRoot auditLogRootToInitialize)
        {

            if (auditLogRootToInitialize != null && auditLogRootToInitialize.AdditionalData != null)
            {

                if (auditLogRootToInitialize.DirectoryAudits != null && auditLogRootToInitialize.DirectoryAudits.CurrentPage != null)
                {
                    auditLogRootToInitialize.DirectoryAudits.AdditionalData = auditLogRootToInitialize.AdditionalData;

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        auditLogRootToInitialize.DirectoryAudits.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }

                if (auditLogRootToInitialize.RestrictedSignIns != null && auditLogRootToInitialize.RestrictedSignIns.CurrentPage != null)
                {
                    auditLogRootToInitialize.RestrictedSignIns.AdditionalData = auditLogRootToInitialize.AdditionalData;

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        auditLogRootToInitialize.RestrictedSignIns.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }

                if (auditLogRootToInitialize.SignIns != null && auditLogRootToInitialize.SignIns.CurrentPage != null)
                {
                    auditLogRootToInitialize.SignIns.AdditionalData = auditLogRootToInitialize.AdditionalData;

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        auditLogRootToInitialize.SignIns.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }

            }


        }
 /// <summary>
 /// Creates the specified AuditLogRoot using POST.
 /// </summary>
 /// <param name="auditLogRootToCreate">The AuditLogRoot to create.</param>
 /// <returns>The created AuditLogRoot.</returns>
 public System.Threading.Tasks.Task <AuditLogRoot> CreateAsync(AuditLogRoot auditLogRootToCreate)
 {
     return(this.CreateAsync(auditLogRootToCreate, CancellationToken.None));
 }
Esempio n. 5
0
 /// <summary>
 /// Updates the specified AuditLogRoot using PATCH.
 /// </summary>
 /// <param name="auditLogRootToUpdate">The AuditLogRoot to update.</param>
 /// <returns>The updated AuditLogRoot.</returns>
 public System.Threading.Tasks.Task<AuditLogRoot> UpdateAsync(AuditLogRoot auditLogRootToUpdate)
 {
     return this.UpdateAsync(auditLogRootToUpdate, CancellationToken.None);
 }