diff --git a/cmd/influx/authorization.go b/cmd/influx/authorization.go index 5795ca4e0b..ac0b5b0d19 100644 --- a/cmd/influx/authorization.go +++ b/cmd/influx/authorization.go @@ -44,6 +44,9 @@ type AuthorizationCreateFlags struct { writeDashboardsPermission bool readDashboardsPermission bool + + writeNotificationRulePermission bool + readNotificationRulePermission bool } var authorizationCreateFlags AuthorizationCreateFlags @@ -81,6 +84,9 @@ func init() { authorizationCreateCmd.Flags().BoolVarP(&authorizationCreateFlags.writeDashboardsPermission, "write-dashboards", "", false, "Grants the permission to create dashboards") authorizationCreateCmd.Flags().BoolVarP(&authorizationCreateFlags.readDashboardsPermission, "read-dashboards", "", false, "Grants the permission to read dashboards") + authorizationCreateCmd.Flags().BoolVarP(&authorizationCreateFlags.writeNotificationRulePermission, "write-notificationRules", "", false, "Grants the permission to create notificationRules") + authorizationCreateCmd.Flags().BoolVarP(&authorizationCreateFlags.readNotificationRulePermission, "read-notificationRules", "", false, "Grants the permission to read notificationRules") + authorizationCmd.AddCommand(authorizationCreateCmd) } @@ -221,6 +227,22 @@ func authorizationCreateF(cmd *cobra.Command, args []string) error { permissions = append(permissions, *p) } + if authorizationCreateFlags.writeNotificationRulePermission { + p, err := platform.NewPermission(platform.WriteAction, platform.NotificationRuleResourceType, o.ID) + if err != nil { + return err + } + permissions = append(permissions, *p) + } + + if authorizationCreateFlags.readNotificationRulePermission { + p, err := platform.NewPermission(platform.ReadAction, platform.NotificationRuleResourceType, o.ID) + if err != nil { + return err + } + permissions = append(permissions, *p) + } + authorization := &platform.Authorization{ Permissions: permissions, OrgID: o.ID,