Skip to content

Commit

Permalink
add more documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
rcohngru committed Dec 31, 2024
1 parent 1303c08 commit 75350c5
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 2 deletions.
40 changes: 38 additions & 2 deletions titan/resources/grant.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,14 @@ class Grant(Resource):
Yaml:
```yaml
- Grant:
priv: "SELECT"
grants:
- priv: "SELECT"
on_table: "some_table"
to: "some_role"
grant_option: true
- priv: "USAGE"
on_schema: somedb.someschema
to: somedb.somedbrole
```
"""

Expand Down Expand Up @@ -769,7 +772,40 @@ def __post_init__(self):


class DatabaseRoleGrant(Resource):
"""
Description:
Represents a grant of a database role to another role or database role in Snowflake.
Snowflake Docs:
https://docs.snowflake.com/en/sql-reference/sql/grant-database-role
Fields:
database_role (string or Role, required): The database role to be granted.
to_role (string or Role): The role to which the database role is granted.
to_database_role (string or User): The database role to which the database role is granted.
Python:
```python
# Grant to Database Role:
role_grant = DatabaseRoleGrant(database_role="somedb.somerole", to_database_role="somedb.someotherrole")
role_grant = DatabaseRoleGrant(database_role="somedb.somerole", to=DatabaseRole(database="somedb", name="someotherrole"))
# Grant to Role:
role_grant = DatabaseRoleGrant(database_role="somedb.somerole", to_role="somerole")
role_grant = DatabaseRoleGrant(database_role="somedb.somerole", to=Role(name="somerole"))
```
Yaml:
```yaml
database_role_grants:
- database_role: somedb.somerole
to_database_role: somedb.someotherrole
- database_role: somedb.somerole
to_role: somerole
```
"""
resource_type = ResourceType.DATABASE_ROLE_GRANT
props = Props(
database_role=IdentifierProp("database role", eq=False),
Expand Down
16 changes: 16 additions & 0 deletions titan/resources/network_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,15 @@ class NetworkRule(NamedResource, Resource):
mode="INGRESS",
comment="Example network rule"
)
network_rule = NetworkRule(
name="some_network_rule",
database="somedb",
schema="someschema",
type="IPV4",
value_list=["192.168.1.1", "192.168.1.2"],
mode="INGRESS",
comment="Example network rule with fully qualified name"
)
```
Yaml:
Expand All @@ -83,6 +92,13 @@ class NetworkRule(NamedResource, Resource):
value_list: ["192.168.1.1", "192.168.1.2"]
mode: INGRESS
comment: "Example network rule"
- name: some_network_rule
database: somedb
schema: someschema
type: IPV4
value_list: ["192.168.1.1", "192.168.1.2"]
mode: INGRESS
comment: "Example network rule with fully qualified name"
```
"""

Expand Down

0 comments on commit 75350c5

Please sign in to comment.