Skip to content

Commit 7e07911

Browse files
committed
Add codegen
1 parent b906545 commit 7e07911

File tree

4 files changed

+147
-0
lines changed

4 files changed

+147
-0
lines changed

experimental/python/codegen/codegen/packages.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,15 @@
88
"resources.JobPermissionLevel": "jobs",
99
"resources.PipelinePermission": "pipelines",
1010
"resources.PipelinePermissionLevel": "pipelines",
11+
"resources.Schema": "catalog",
12+
"resources.Grant": "catalog",
1113
}
1214

1315
# All supported resource types
1416
RESOURCE_TYPES = [
1517
"resources.Job",
1618
"resources.Pipeline",
19+
"resources.Schema",
1720
]
1821

1922
# Namespaces to load from OpenAPI spec.
@@ -24,6 +27,7 @@
2427
"jobs",
2528
"pipelines",
2629
"resources",
30+
"catalog",
2731
]
2832

2933
RENAMES = {
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
__all__ = [
2+
"Grant",
3+
"GrantDict",
4+
"GrantParam",
5+
"Schema",
6+
"SchemaDict",
7+
"SchemaParam",
8+
]
9+
10+
11+
from databricks.bundles.catalog._models.grant import Grant, GrantDict, GrantParam
12+
from databricks.bundles.catalog._models.schema import Schema, SchemaDict, SchemaParam
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
from dataclasses import dataclass, field
2+
from typing import TYPE_CHECKING, TypedDict
3+
4+
from databricks.bundles.core._transform import _transform
5+
from databricks.bundles.core._transform_to_json import _transform_to_json_value
6+
from databricks.bundles.core._variable import VariableOr, VariableOrList
7+
8+
if TYPE_CHECKING:
9+
from typing_extensions import Self
10+
11+
12+
@dataclass(kw_only=True)
13+
class Grant:
14+
""""""
15+
16+
principal: VariableOr[str]
17+
"""
18+
The name of the principal that will be granted privileges
19+
"""
20+
21+
privileges: VariableOrList[str] = field(default_factory=list)
22+
"""
23+
The privileges to grant to the specified entity
24+
"""
25+
26+
@classmethod
27+
def from_dict(cls, value: "GrantDict") -> "Self":
28+
return _transform(cls, value)
29+
30+
def as_dict(self) -> "GrantDict":
31+
return _transform_to_json_value(self) # type:ignore
32+
33+
34+
class GrantDict(TypedDict, total=False):
35+
""""""
36+
37+
principal: VariableOr[str]
38+
"""
39+
The name of the principal that will be granted privileges
40+
"""
41+
42+
privileges: VariableOrList[str]
43+
"""
44+
The privileges to grant to the specified entity
45+
"""
46+
47+
48+
GrantParam = GrantDict | Grant
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
from dataclasses import dataclass, field
2+
from typing import TYPE_CHECKING, TypedDict
3+
4+
from databricks.bundles.catalog._models.grant import Grant, GrantParam
5+
from databricks.bundles.core._resource import Resource
6+
from databricks.bundles.core._transform import _transform
7+
from databricks.bundles.core._transform_to_json import _transform_to_json_value
8+
from databricks.bundles.core._variable import (
9+
VariableOr,
10+
VariableOrDict,
11+
VariableOrList,
12+
VariableOrOptional,
13+
)
14+
15+
if TYPE_CHECKING:
16+
from typing_extensions import Self
17+
18+
19+
@dataclass(kw_only=True)
20+
class Schema(Resource):
21+
""""""
22+
23+
catalog_name: VariableOr[str]
24+
"""
25+
Name of parent catalog.
26+
"""
27+
28+
name: VariableOr[str]
29+
"""
30+
Name of schema, relative to parent catalog.
31+
"""
32+
33+
comment: VariableOrOptional[str] = None
34+
"""
35+
User-provided free-form text description.
36+
"""
37+
38+
grants: VariableOrList[Grant] = field(default_factory=list)
39+
40+
properties: VariableOrDict[str] = field(default_factory=dict)
41+
42+
storage_root: VariableOrOptional[str] = None
43+
"""
44+
Storage root URL for managed tables within schema.
45+
"""
46+
47+
@classmethod
48+
def from_dict(cls, value: "SchemaDict") -> "Self":
49+
return _transform(cls, value)
50+
51+
def as_dict(self) -> "SchemaDict":
52+
return _transform_to_json_value(self) # type:ignore
53+
54+
55+
class SchemaDict(TypedDict, total=False):
56+
""""""
57+
58+
catalog_name: VariableOr[str]
59+
"""
60+
Name of parent catalog.
61+
"""
62+
63+
name: VariableOr[str]
64+
"""
65+
Name of schema, relative to parent catalog.
66+
"""
67+
68+
comment: VariableOrOptional[str]
69+
"""
70+
User-provided free-form text description.
71+
"""
72+
73+
grants: VariableOrList[GrantParam]
74+
75+
properties: VariableOrDict[str]
76+
77+
storage_root: VariableOrOptional[str]
78+
"""
79+
Storage root URL for managed tables within schema.
80+
"""
81+
82+
83+
SchemaParam = SchemaDict | Schema

0 commit comments

Comments
 (0)