/// <summary>
        /// Updates the given model element with the cmdlet specific operation
        /// </summary>
        /// <param name="model">A model object</param>
        protected override ServerBlobAuditingSettingsModel ApplyUserInputToModel(ServerBlobAuditingSettingsModel model)
        {
            base.ApplyUserInputToModel(model);
            model.AuditState = State == SecurityConstants.Enabled ? AuditStateType.Enabled : AuditStateType.Disabled;
            if (RetentionInDays != null)
            {
                model.RetentionInDays = RetentionInDays;
            }

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

            if (MyInvocation.BoundParameters.ContainsKey(SecurityConstants.StorageKeyType)) // the user enter a key type - we use it (and running over the previously defined key type)
            {
                model.StorageKeyType = (StorageKeyType == SecurityConstants.Primary) ? StorageKeyKind.Primary : StorageKeyKind.Secondary;
            }

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

            if (!StorageAccountSubscriptionId.Equals(Guid.Empty))
            {
                model.StorageAccountSubscriptionId = StorageAccountSubscriptionId;
            }
            else if (StorageAccountName != null)
            {
                model.StorageAccountSubscriptionId = Guid.Parse(DefaultProfile.DefaultContext.Subscription.Id);
            }

            return(model);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Updates the given model element with the cmdlet specific operation
        /// </summary>
        /// <param name="model">A model object</param>
        protected override DatabaseBlobAuditingSettingsModel ApplyUserInputToModel(DatabaseBlobAuditingSettingsModel model)
        {
            base.ApplyUserInputToModel(model);

            model.AuditState = State == SecurityConstants.Enabled ? AuditStateType.Enabled : AuditStateType.Disabled;

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

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

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

            if (ParameterSetName == DefinitionsCommon.BlobStorageParameterSetName ||
                ParameterSetName == DefinitionsCommon.StorageAccountSubscriptionIdParameterSetName ||
                ParameterSetName == DefinitionsCommon.BlobStorageByParentResourceParameterSetName ||
                ParameterSetName == DefinitionsCommon.StorageAccountSubscriptionIdByParentResourceParameterSetName)
            {
                if (RetentionInDays != null)
                {
                    model.RetentionInDays = RetentionInDays;
                }

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

                if (MyInvocation.BoundParameters.ContainsKey(SecurityConstants.StorageKeyType))
                {
                    // the user enter a key type - we use it (and override the previously defined key type)
                    model.StorageKeyType = (StorageKeyType == SecurityConstants.Primary)
                        ? StorageKeyKind.Primary
                        : StorageKeyKind.Secondary;
                }

                if (!StorageAccountSubscriptionId.Equals(Guid.Empty))
                {
                    model.StorageAccountSubscriptionId = StorageAccountSubscriptionId;
                }
                else if (StorageAccountName != null)
                {
                    model.StorageAccountSubscriptionId = Guid.Parse(DefaultProfile.DefaultContext.Subscription.Id);
                }
            }
            else if (ParameterSetName == DefinitionsCommon.EventHubParameterSetName ||
                     ParameterSetName == DefinitionsCommon.EventHubByParentResourceParameterSetName)
            {
                DatabsaeEventHubAuditingSettingsModel eventHubModel = model as DatabsaeEventHubAuditingSettingsModel;
                if (EventHubName != null)
                {
                    eventHubModel.EventHubName = EventHubName;
                }

                if (EventHubAuthorizationRuleResourceId != null)
                {
                    eventHubModel.EventHubAuthorizationRuleResourceId = EventHubAuthorizationRuleResourceId;
                }
            }
            else if (ParameterSetName == DefinitionsCommon.LogAnalyticsParameterSetName ||
                     ParameterSetName == DefinitionsCommon.LogAnalyticsByParentResourceParameterSetName)

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

            return(model);
        }