From 75350c5e2edae8e1aba1bf76b896604d477a03cb Mon Sep 17 00:00:00 2001 From: Rafi Cohn-Gruenwald Date: Tue, 31 Dec 2024 15:35:44 -0800 Subject: [PATCH] add more documentation --- titan/resources/grant.py | 40 +++++++++++++++++++++++++++++++-- titan/resources/network_rule.py | 16 +++++++++++++ 2 files changed, 54 insertions(+), 2 deletions(-) diff --git a/titan/resources/grant.py b/titan/resources/grant.py index 0406299e..599c8175 100644 --- a/titan/resources/grant.py +++ b/titan/resources/grant.py @@ -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 ``` """ @@ -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), diff --git a/titan/resources/network_rule.py b/titan/resources/network_rule.py index 82a6568a..62e96a9d 100644 --- a/titan/resources/network_rule.py +++ b/titan/resources/network_rule.py @@ -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: @@ -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" ``` """