Skip to content

Commit 1a8d899

Browse files
authored
add more documentation (#184)
1 parent 1303c08 commit 1a8d899

File tree

2 files changed

+54
-2
lines changed

2 files changed

+54
-2
lines changed

titan/resources/grant.py

+38-2
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,14 @@ class Grant(Resource):
8484
Yaml:
8585
8686
```yaml
87-
- Grant:
88-
priv: "SELECT"
87+
grants:
88+
- priv: "SELECT"
8989
on_table: "some_table"
9090
to: "some_role"
9191
grant_option: true
92+
- priv: "USAGE"
93+
on_schema: somedb.someschema
94+
to: somedb.somedbrole
9295
```
9396
"""
9497

@@ -769,7 +772,40 @@ def __post_init__(self):
769772

770773

771774
class DatabaseRoleGrant(Resource):
775+
"""
776+
Description:
777+
Represents a grant of a database role to another role or database role in Snowflake.
778+
779+
Snowflake Docs:
780+
https://docs.snowflake.com/en/sql-reference/sql/grant-database-role
781+
782+
Fields:
783+
database_role (string or Role, required): The database role to be granted.
784+
to_role (string or Role): The role to which the database role is granted.
785+
to_database_role (string or User): The database role to which the database role is granted.
786+
787+
Python:
788+
789+
```python
790+
# Grant to Database Role:
791+
role_grant = DatabaseRoleGrant(database_role="somedb.somerole", to_database_role="somedb.someotherrole")
792+
role_grant = DatabaseRoleGrant(database_role="somedb.somerole", to=DatabaseRole(database="somedb", name="someotherrole"))
772793
794+
# Grant to Role:
795+
role_grant = DatabaseRoleGrant(database_role="somedb.somerole", to_role="somerole")
796+
role_grant = DatabaseRoleGrant(database_role="somedb.somerole", to=Role(name="somerole"))
797+
```
798+
799+
Yaml:
800+
801+
```yaml
802+
database_role_grants:
803+
- database_role: somedb.somerole
804+
to_database_role: somedb.someotherrole
805+
- database_role: somedb.somerole
806+
to_role: somerole
807+
```
808+
"""
773809
resource_type = ResourceType.DATABASE_ROLE_GRANT
774810
props = Props(
775811
database_role=IdentifierProp("database role", eq=False),

titan/resources/network_rule.py

+16
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,15 @@ class NetworkRule(NamedResource, Resource):
7272
mode="INGRESS",
7373
comment="Example network rule"
7474
)
75+
network_rule = NetworkRule(
76+
name="some_network_rule",
77+
database="somedb",
78+
schema="someschema",
79+
type="IPV4",
80+
value_list=["192.168.1.1", "192.168.1.2"],
81+
mode="INGRESS",
82+
comment="Example network rule with fully qualified name"
83+
)
7584
```
7685
7786
Yaml:
@@ -83,6 +92,13 @@ class NetworkRule(NamedResource, Resource):
8392
value_list: ["192.168.1.1", "192.168.1.2"]
8493
mode: INGRESS
8594
comment: "Example network rule"
95+
- name: some_network_rule
96+
database: somedb
97+
schema: someschema
98+
type: IPV4
99+
value_list: ["192.168.1.1", "192.168.1.2"]
100+
mode: INGRESS
101+
comment: "Example network rule with fully qualified name"
86102
```
87103
"""
88104

0 commit comments

Comments
 (0)