|
4 | 4 | from snowddl.blueprint import ( |
5 | 5 | AccountGrant, |
6 | 6 | AccountObjectIdent, |
| 7 | + ApplicationRoleIdent, |
7 | 8 | DatabaseBlueprint, |
8 | 9 | DatabaseRoleIdent, |
9 | 10 | FutureGrant, |
@@ -256,7 +257,7 @@ def drop_object(self, row: dict): |
256 | 257 | return ResolveResult.DROP |
257 | 258 |
|
258 | 259 | def create_grant(self, role_name, grant: Grant): |
259 | | - if grant.privilege == "USAGE" and grant.on in (ObjectType.ROLE, ObjectType.DATABASE_ROLE): |
| 260 | + if grant.privilege == "USAGE" and grant.on in (ObjectType.ROLE, ObjectType.APPLICATION_ROLE, ObjectType.DATABASE_ROLE): |
260 | 261 | self.engine.execute_safe_ddl( |
261 | 262 | "GRANT {on:r} {name:i} TO ROLE {role_name:i}", |
262 | 263 | { |
@@ -295,7 +296,7 @@ def drop_grant(self, role_name, grant: Grant): |
295 | 296 | "current_role": self.engine.context.current_role, |
296 | 297 | }, |
297 | 298 | ) |
298 | | - elif grant.privilege == "USAGE" and grant.on in (ObjectType.ROLE, ObjectType.DATABASE_ROLE): |
| 299 | + elif grant.privilege == "USAGE" and grant.on in (ObjectType.ROLE, ObjectType.APPLICATION_ROLE, ObjectType.DATABASE_ROLE): |
299 | 300 | self.engine.execute_safe_ddl( |
300 | 301 | "REVOKE {on:r} {name:i} FROM ROLE {role_name:i}", |
301 | 302 | { |
@@ -445,6 +446,13 @@ def build_share_read_grant(self, share_name: Union[Ident, DatabaseRoleIdent]) -> |
445 | 446 | name=build_role_ident(self.config.env_prefix, share_name, self.config.SHARE_ACCESS_ROLE_SUFFIX), |
446 | 447 | ) |
447 | 448 |
|
| 449 | + def build_application_role_grant(self, application_role_name: ApplicationRoleIdent) -> Grant: |
| 450 | + return Grant( |
| 451 | + privilege="USAGE", |
| 452 | + on=ObjectType.APPLICATION_ROLE, |
| 453 | + name=application_role_name, |
| 454 | + ) |
| 455 | + |
448 | 456 | def build_technical_role_grant(self, technical_role_name: AccountObjectIdent) -> Grant: |
449 | 457 | return Grant( |
450 | 458 | privilege="USAGE", |
|
0 commit comments