protected override ServerAuditModel GetEntity()
        {
            if (ServerObject != null)
            {
                ResourceGroupName = ServerObject.ResourceGroupName;
                ServerName        = ServerObject.ServerName;
            }

            ServerAuditModel model = new ServerAuditModel()
            {
                ResourceGroupName = ResourceGroupName,
                ServerName        = ServerName
            };

            ModelAdapter.GetAuditingSettings(ResourceGroupName, ServerName, model);
            return(model);
        }
Example #2
0
        protected override DatabaseBlobAuditingSettingsModel GetEntity()
        {
            DatabaseBlobAuditingSettingsModel model = null;

            if (ParameterSetName == DefinitionsCommon.BlobStorageParameterSetName ||
                ParameterSetName == DefinitionsCommon.StorageAccountSubscriptionIdParameterSetName ||
                ParameterSetName == DefinitionsCommon.BlobStorageByParentResourceParameterSetName ||
                ParameterSetName == DefinitionsCommon.StorageAccountSubscriptionIdByParentResourceParameterSetName)
            {
                if (BlobStorage.IsPresent == false)
                {
                    WriteWarning(DefinitionsCommon.AuditLogsDestinationWasNotSpecifiedWarning);
                }

                model = new DatabaseBlobAuditingSettingsModel();
            }
            else if (ParameterSetName == DefinitionsCommon.EventHubParameterSetName ||
                     ParameterSetName == DefinitionsCommon.EventHubByParentResourceParameterSetName)
            {
                model = new DatabsaeEventHubAuditingSettingsModel();
            }
            else if (ParameterSetName == DefinitionsCommon.LogAnalyticsParameterSetName ||
                     ParameterSetName == DefinitionsCommon.LogAnalyticsByParentResourceParameterSetName)
            {
                model = new DatabaseLogAnalyticsAuditingSettingsModel();
            }

            if (InputObject == null)
            {
                model.ResourceGroupName = ResourceGroupName;
                model.ServerName        = ServerName;
                model.DatabaseName      = DatabaseName;
            }
            else
            {
                model.ResourceGroupName = InputObject.ResourceGroupName;
                model.ServerName        = InputObject.ServerName;
                model.DatabaseName      = InputObject.DatabaseName;
            }

            ModelAdapter.GetAuditingSettings(model.ResourceGroupName, model.ServerName, model.DatabaseName, model);

            return(model);
        }
        protected override DatabaseAuditModel GetEntity()
        {
            if (DatabaseObject != null)
            {
                ResourceGroupName = DatabaseObject.ResourceGroupName;
                ServerName        = DatabaseObject.ServerName;
                DatabaseName      = DatabaseObject.DatabaseName;
            }

            DatabaseAuditModel model = new DatabaseAuditModel
            {
                ResourceGroupName = ResourceGroupName,
                ServerName        = ServerName,
                DatabaseName      = DatabaseName
            };

            ModelAdapter.GetAuditingSettings(ResourceGroupName, ServerName, DatabaseName, model);
            return(model);
        }
        protected override SqlPoolAuditModel GetEntity()
        {
            if (SqlPoolObject != null)
            {
                var resourceIdentifier = new ResourceIdentifier(this.SqlPoolObject.Id);
                this.ResourceGroupName = resourceIdentifier.ResourceGroupName;
                this.WorkspaceName     = resourceIdentifier.ParentResource;
                this.WorkspaceName     = this.WorkspaceName.Substring(this.WorkspaceName.LastIndexOf('/') + 1);
                this.SqlPoolName       = resourceIdentifier.ResourceName;
            }

            if (WorkspaceObject != null)
            {
                this.ResourceGroupName = new ResourceIdentifier(this.WorkspaceObject.Id).ResourceGroupName;
                this.WorkspaceName     = this.WorkspaceObject.Name;
            }

            if (ResourceId != null)
            {
                var resourceIdentifier = new ResourceIdentifier(this.ResourceId);
                this.ResourceGroupName = resourceIdentifier.ResourceGroupName;
                this.WorkspaceName     = resourceIdentifier.ParentResource;
                this.WorkspaceName     = this.WorkspaceName.Substring(this.WorkspaceName.LastIndexOf('/') + 1);
                this.SqlPoolName       = resourceIdentifier.ResourceName;
            }

            SqlPoolAuditModel model = new SqlPoolAuditModel
            {
                ResourceGroupName = ResourceGroupName,
                WorkspaceName     = WorkspaceName,
                SqlPoolName       = SqlPoolName
            };

            ModelAdapter.SqlPoolName = SqlPoolName;
            ModelAdapter.GetAuditingSettings(ResourceGroupName, WorkspaceName, model);

            return(model);
        }
        protected override ServerAuditModelType GetEntity()
        {
            if (WorkspaceObject != null)
            {
                ResourceGroupName = new ResourceIdentifier(this.WorkspaceObject.Id).ResourceGroupName;
                WorkspaceName     = WorkspaceObject.Name;
            }

            if (ResourceId != null)
            {
                var resourceIdentifier = new ResourceIdentifier(this.ResourceId);
                this.ResourceGroupName = resourceIdentifier.ResourceGroupName;
                this.WorkspaceName     = resourceIdentifier.ResourceName;
            }

            ServerAuditModelType model = new ServerAuditModelType()
            {
                ResourceGroupName = ResourceGroupName,
                WorkspaceName     = WorkspaceName
            };

            ModelAdapter.GetAuditingSettings(ResourceGroupName, WorkspaceName, model);
            return(model);
        }