Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add more documentation #184

Merged
merged 1 commit into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading