Esempio n. 1
0
 protected override SqlPoolAuditModel PersistChanges(SqlPoolAuditModel entity)
 {
     ModelAdapter.RemoveAuditingSettings(entity);
     return(null);
 }
        protected override SqlPoolAuditModel ApplyUserInputToModel(SqlPoolAuditModel model)
        {
            base.ApplyUserInputToModel(model);

            if (AuditAction != null)
            {
                model.AuditAction = AuditAction;
            }

            if (AuditActionGroup != null)
            {
                model.AuditActionGroup = AuditActionGroup;
            }

            if (PredicateExpression != null)
            {
                model.PredicateExpression = PredicateExpression;
            }

            if (BlobStorageTargetState != null)
            {
                model.BlobStorageTargetState = BlobStorageTargetState == SynapseConstants.Security.Enabled ?
                                               AuditStateType.Enabled : AuditStateType.Disabled;
            }

            if (StorageAccountResourceId != null)
            {
                model.StorageAccountResourceId = StorageAccountResourceId;
            }

            if (this.IsParameterBound(c => c.StorageKeyType))
            {
                model.StorageKeyType = (StorageKeyType == SynapseConstants.Security.Primary) ? StorageKeyKind.Primary : StorageKeyKind.Secondary;
            }

            if (RetentionInDays != null)
            {
                model.RetentionInDays = RetentionInDays;
            }

            if (EventHubTargetState != null)
            {
                model.EventHubTargetState = EventHubTargetState == SynapseConstants.Security.Enabled ?
                                            AuditStateType.Enabled : AuditStateType.Disabled;
            }

            if (EventHubName != null)
            {
                model.EventHubName = EventHubName;
            }

            if (EventHubAuthorizationRuleResourceId != null)
            {
                model.EventHubAuthorizationRuleResourceId = EventHubAuthorizationRuleResourceId;
            }

            if (LogAnalyticsTargetState != null)
            {
                model.LogAnalyticsTargetState = LogAnalyticsTargetState == SynapseConstants.Security.Enabled ?
                                                AuditStateType.Enabled : AuditStateType.Disabled;
            }

            if (WorkspaceResourceId != null)
            {
                model.WorkspaceResourceId = WorkspaceResourceId;
            }

            return(model);
        }
 protected override SqlPoolAuditModel PersistChanges(SqlPoolAuditModel entity)
 {
     ModelAdapter.PersistAuditChanges(entity);
     return(null);
 }
Esempio n. 4
0
        public override void ExecuteCmdlet()
        {
            if (this.IsParameterBound(c => c.WorkspaceObject))
            {
                this.ResourceGroupName = new ResourceIdentifier(this.WorkspaceObject.Id).ResourceGroupName;
                this.WorkspaceName     = this.WorkspaceObject.Name;
            }

            if (this.IsParameterBound(c => c.InputObject))
            {
                var resourceIdentifier = new ResourceIdentifier(this.InputObject.Id);
                this.ResourceGroupName = resourceIdentifier.ResourceGroupName;
                this.WorkspaceName     = resourceIdentifier.ParentResource;
                this.WorkspaceName     = this.WorkspaceName.Substring(this.WorkspaceName.LastIndexOf('/') + 1);
                this.Name = resourceIdentifier.ResourceName;
            }

            if (this.IsParameterBound(c => c.ResourceId))
            {
                var resourceIdentifier = new ResourceIdentifier(this.ResourceId);
                this.ResourceGroupName = resourceIdentifier.ResourceGroupName;
                this.WorkspaceName     = resourceIdentifier.ParentResource;
                this.WorkspaceName     = this.WorkspaceName.Substring(this.WorkspaceName.LastIndexOf('/') + 1);
                this.Name = resourceIdentifier.ResourceName;
            }

            if (this.ShouldProcess(this.Name, string.Format(Resources.SettingSqlPoolAudit, this.Name, this.WorkspaceName)))
            {
                SqlPoolAuditModel model = SynapseAnalyticsClient.GetSqlPoolAudit(this.ResourceGroupName, this.WorkspaceName, this.Name);

                if (this.IsParameterBound(c => c.AuditAction))
                {
                    model.AuditAction = this.AuditAction;
                }

                if (this.IsParameterBound(c => c.AuditActionGroup))
                {
                    model.AuditActionGroup = this.AuditActionGroup;
                }

                if (this.IsParameterBound(c => c.PredicateExpression))
                {
                    model.PredicateExpression = this.PredicateExpression;
                }

                if (this.IsParameterBound(c => c.BlobStorageTargetState))
                {
                    model.BlobStorageTargetState = this.BlobStorageTargetState == SynapseConstants.Security.Enabled ?
                                                   AuditStateType.Enabled : AuditStateType.Disabled;
                }

                if (this.IsParameterBound(c => c.StorageAccountResourceId))
                {
                    model.StorageAccountResourceId = this.StorageAccountResourceId;
                }

                if (this.IsParameterBound(c => c.StorageKeyType))
                {
                    model.StorageKeyType = (this.StorageKeyType == SynapseConstants.Security.Primary) ? StorageKeyKind.Primary : StorageKeyKind.Secondary;
                }

                if (this.IsParameterBound(c => c.RetentionInDays))
                {
                    model.RetentionInDays = this.RetentionInDays;
                }

                // check parameters
                if (this.BlobStorageTargetState == SynapseConstants.Security.Enabled &&
                    string.IsNullOrEmpty(this.StorageAccountResourceId))
                {
                    throw new PSArgumentException(Resources.StorageAccountNameParameterException, "StorageAccountName");
                }

                SynapseAnalyticsClient.CreateOrUpdateSqlPoolAudit(model);
                if (PassThru)
                {
                    WriteObject(model);
                }
            }
        }