|
20 | 20 | validate_mongo_user_definition_id, |
21 | 21 | validate_table_role_definition_body, |
22 | 22 | validate_table_role_definition_id, |
23 | | - validate_table_role_assignment_id) |
| 23 | + validate_table_role_assignment_id, |
| 24 | + validate_gremlin_role_definition_body, |
| 25 | + validate_gremlin_role_definition_id, |
| 26 | + validate_gremlin_role_assignment_id, |
| 27 | + validate_cassandra_role_definition_body, |
| 28 | + validate_cassandra_role_definition_id, |
| 29 | + validate_cassandra_role_assignment_id, |
| 30 | + validate_mongoMI_role_definition_body, |
| 31 | + validate_mongoMI_role_definition_id, |
| 32 | + validate_mongoMI_role_assignment_id) |
24 | 33 |
|
25 | 34 | from azext_cosmosdb_preview.actions import ( |
26 | 35 | CreateGremlinDatabaseRestoreResource, |
|
76 | 85 | }" |
77 | 86 | """ |
78 | 87 |
|
| 88 | +GREMLIN_ROLE_DEFINITION_EXAMPLE = """--body "{ |
| 89 | +\\"Id\\": \\"be79875a-2cc4-40d5-8958-566017875b39\\", |
| 90 | +\\"RoleName\\": \\"MyTestRole\\", |
| 91 | +\\"type\\": \\"CustomRole\\", |
| 92 | +\\"description\\": \\"Custom role to read Cosmos DB metadata\\", |
| 93 | +\\"AssignableScopes\\":[\\"/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.DocumentDB/databaseAccounts/MyDBAccountName\\"], |
| 94 | +\\"Permissions\\": [{\\"dataActions\\": [\\"Microsoft.DocumentDB/databaseAccounts/readMetadata\\"]}] |
| 95 | +}" |
| 96 | +""" |
| 97 | + |
| 98 | +GREMLIN_ROLE_ASSIGNMENT_EXAMPLE = """--body "{ |
| 99 | +\\"Id\\": \\"be79875a-2cc4-40d5-8958-566017875b39\\", |
| 100 | +\\"RoleDefinitionId\\": \\"MyTestRoleAssignment\\", |
| 101 | +\\"PrincipalId\\": \\"efc9875a-2cc4-40d5-8958-566017875b39\\", |
| 102 | +\\"Scope\\":\\"/subscriptions/cfe9875a-2cc4-40d5-8958-566017875b39/resourceGroups/MyResourceGroup/providers/Microsoft.DocumentDB/databaseAccounts/MyDBAccountName\\", |
| 103 | +}" |
| 104 | +""" |
| 105 | + |
| 106 | +CASSANDRA_ROLE_DEFINITION_EXAMPLE = """--body "{ |
| 107 | +\\"Id\\": \\"be79875a-2cc4-40d5-8958-566017875b39\\", |
| 108 | +\\"RoleName\\": \\"MyTestRole\\", |
| 109 | +\\"type\\": \\"CustomRole\\", |
| 110 | +\\"description\\": \\"Custom role to read Cosmos DB metadata\\", |
| 111 | +\\"AssignableScopes\\":[\\"/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.DocumentDB/databaseAccounts/MyDBAccountName\\"], |
| 112 | +\\"Permissions\\": [{\\"dataActions\\": [\\"Microsoft.DocumentDB/databaseAccounts/readMetadata\\"]}] |
| 113 | +}" |
| 114 | +""" |
| 115 | + |
| 116 | +CASSANDRA_ROLE_ASSIGNMENT_EXAMPLE = """--body "{ |
| 117 | +\\"Id\\": \\"be79875a-2cc4-40d5-8958-566017875b39\\", |
| 118 | +\\"RoleDefinitionId\\": \\"MyTestRoleAssignment\\", |
| 119 | +\\"PrincipalId\\": \\"efc9875a-2cc4-40d5-8958-566017875b39\\", |
| 120 | +\\"Scope\\":\\"/subscriptions/cfe9875a-2cc4-40d5-8958-566017875b39/resourceGroups/MyResourceGroup/providers/Microsoft.DocumentDB/databaseAccounts/MyDBAccountName\\", |
| 121 | +}" |
| 122 | +""" |
| 123 | + |
| 124 | +MONGOMI_ROLE_DEFINITION_EXAMPLE = """--body "{ |
| 125 | +\\"Id\\": \\"be79875a-2cc4-40d5-8958-566017875b39\\", |
| 126 | +\\"RoleName\\": \\"MyTestRole\\", |
| 127 | +\\"type\\": \\"CustomRole\\", |
| 128 | +\\"description\\": \\"Custom role to read Cosmos DB metadata\\", |
| 129 | +\\"AssignableScopes\\":[\\"/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.DocumentDB/databaseAccounts/MyDBAccountName\\"], |
| 130 | +\\"Permissions\\": [{\\"dataActions\\": [\\"Microsoft.DocumentDB/databaseAccounts/readMetadata\\"]}] |
| 131 | +}" |
| 132 | +""" |
| 133 | + |
| 134 | +MONGOMI_ROLE_ASSIGNMENT_EXAMPLE = """--body "{ |
| 135 | +\\"Id\\": \\"be79875a-2cc4-40d5-8958-566017875b39\\", |
| 136 | +\\"RoleDefinitionId\\": \\"MyTestRoleAssignment\\", |
| 137 | +\\"PrincipalId\\": \\"efc9875a-2cc4-40d5-8958-566017875b39\\", |
| 138 | +\\"Scope\\":\\"/subscriptions/cfe9875a-2cc4-40d5-8958-566017875b39/resourceGroups/MyResourceGroup/providers/Microsoft.DocumentDB/databaseAccounts/MyDBAccountName\\", |
| 139 | +}" |
| 140 | +""" |
| 141 | + |
79 | 142 | MONGO_ROLE_DEFINITION_EXAMPLE = """--body "{ |
80 | 143 | \\"Id\\": \\"be79875a-2cc4-40d5-8958-566017875b39\\", |
81 | 144 | \\"RoleName\\": \\"MyRWRole\\", |
@@ -689,3 +752,45 @@ def load_arguments(self, _): |
689 | 752 | c.argument('role_definition_name', options_list=['--role-definition-name', '-n'], help="Unique Name of the Role Definition that this Role Assignment refers to. Eg. 'Contoso Reader Role'.") |
690 | 753 | c.argument('scope', options_list=['--scope', '-s'], help="Data plane resource path at which this Role Assignment is being granted.") |
691 | 754 | c.argument('principal_id', options_list=['--principal-id', '-p'], help="AAD Object ID of the principal to which this Role Assignment is being granted.") |
| 755 | + |
| 756 | + # gremlin role definition |
| 757 | + with self.argument_context('cosmosdb gremlin role definition') as c: |
| 758 | + c.argument('account_name', account_name_type, id_part=None) |
| 759 | + c.argument('role_definition_id', options_list=['--role-definition-id', '-i'], validator=validate_gremlin_role_definition_id, help="Unique ID for the Gremlin Role Definition.") |
| 760 | + c.argument('gremlin_role_definition_body', options_list=['--body', '-b'], validator=validate_gremlin_role_definition_body, completer=FilesCompleter(), help="Role Definition body with Id (Optional for create), Type (Default is CustomRole), RoleName, Description, AssignableScopes, Permissions. You can enter it as a string or as a file, e.g., --body @gremlin-role_definition-body-file.json or " + GREMLIN_ROLE_DEFINITION_EXAMPLE) |
| 761 | + |
| 762 | + with self.argument_context('cosmosdb gremlin role assignment') as c: |
| 763 | + c.argument('account_name', account_name_type, id_part=None) |
| 764 | + c.argument('role_assignment_id', options_list=['--role-assignment-id', '-i'], validator=validate_gremlin_role_assignment_id, help="Optional for Create. Unique ID for the Role Assignment. If not provided, a new GUID will be used.") |
| 765 | + c.argument('role_definition_id', options_list=['--role-definition-id', '-d'], help="Unique ID of the Role Definition that this Role Assignment refers to.") |
| 766 | + c.argument('role_definition_name', options_list=['--role-definition-name', '-n'], help="Unique Name of the Role Definition that this Role Assignment refers to. Eg. 'Contoso Reader Role'.") |
| 767 | + c.argument('scope', options_list=['--scope', '-s'], help="Data plane resource path at which this Role Assignment is being granted.") |
| 768 | + c.argument('principal_id', options_list=['--principal-id', '-p'], help="AAD Object ID of the principal to which this Role Assignment is being granted.") |
| 769 | + |
| 770 | + # cassandra role definition |
| 771 | + with self.argument_context('cosmosdb cassandra role definition') as c: |
| 772 | + c.argument('account_name', account_name_type, id_part=None) |
| 773 | + c.argument('role_definition_id', options_list=['--role-definition-id', '-i'], validator=validate_cassandra_role_definition_id, help="Unique ID for the Cassandra Role Definition.") |
| 774 | + c.argument('cassandra_role_definition_body', options_list=['--body', '-b'], validator=validate_cassandra_role_definition_body, completer=FilesCompleter(), help="Role Definition body with Id (Optional for create), Type (Default is CustomRole), RoleName, Description, AssignableScopes, Permissions. You can enter it as a string or as a file, e.g., --body @cassandra-role_definition-body-file.json or " + GREMLIN_ROLE_DEFINITION_EXAMPLE) |
| 775 | + |
| 776 | + with self.argument_context('cosmosdb cassandra role assignment') as c: |
| 777 | + c.argument('account_name', account_name_type, id_part=None) |
| 778 | + c.argument('role_assignment_id', options_list=['--role-assignment-id', '-i'], validator=validate_cassandra_role_assignment_id, help="Optional for Create. Unique ID for the Role Assignment. If not provided, a new GUID will be used.") |
| 779 | + c.argument('role_definition_id', options_list=['--role-definition-id', '-d'], help="Unique ID of the Role Definition that this Role Assignment refers to.") |
| 780 | + c.argument('role_definition_name', options_list=['--role-definition-name', '-n'], help="Unique Name of the Role Definition that this Role Assignment refers to. Eg. 'Contoso Reader Role'.") |
| 781 | + c.argument('scope', options_list=['--scope', '-s'], help="Data plane resource path at which this Role Assignment is being granted.") |
| 782 | + c.argument('principal_id', options_list=['--principal-id', '-p'], help="AAD Object ID of the principal to which this Role Assignment is being granted.") |
| 783 | + |
| 784 | + # mongoMI role definition |
| 785 | + with self.argument_context('cosmosdb mongomi role definition') as c: |
| 786 | + c.argument('account_name', account_name_type, id_part=None) |
| 787 | + c.argument('role_definition_id', options_list=['--role-definition-id', '-i'], validator=validate_mongoMI_role_definition_id, help="Unique ID for the MongoMI Role Definition.") |
| 788 | + c.argument('mongoMI_role_definition_body', options_list=['--body', '-b'], validator=validate_mongoMI_role_definition_body, completer=FilesCompleter(), help="Role Definition body with Id (Optional for create), Type (Default is CustomRole), RoleName, Description, AssignableScopes, Permissions. You can enter it as a string or as a file, e.g., --body @mongoMI-role_definition-body-file.json or " + GREMLIN_ROLE_DEFINITION_EXAMPLE) |
| 789 | + |
| 790 | + with self.argument_context('cosmosdb mongomi role assignment') as c: |
| 791 | + c.argument('account_name', account_name_type, id_part=None) |
| 792 | + c.argument('role_assignment_id', options_list=['--role-assignment-id', '-i'], validator=validate_mongoMI_role_assignment_id, help="Optional for Create. Unique ID for the Role Assignment. If not provided, a new GUID will be used.") |
| 793 | + c.argument('role_definition_id', options_list=['--role-definition-id', '-d'], help="Unique ID of the Role Definition that this Role Assignment refers to.") |
| 794 | + c.argument('role_definition_name', options_list=['--role-definition-name', '-n'], help="Unique Name of the Role Definition that this Role Assignment refers to. Eg. 'Contoso Reader Role'.") |
| 795 | + c.argument('scope', options_list=['--scope', '-s'], help="Data plane resource path at which this Role Assignment is being granted.") |
| 796 | + c.argument('principal_id', options_list=['--principal-id', '-p'], help="AAD Object ID of the principal to which this Role Assignment is being granted.") |
0 commit comments