Skip to content

Commit

Permalink
Merge pull request #2 from chaos-genius/dev
Browse files Browse the repository at this point in the history
merged dev
  • Loading branch information
manassolanki committed Jul 2, 2024
2 parents 9c115c2 + f933141 commit 3d55145
Show file tree
Hide file tree
Showing 448 changed files with 13,632 additions and 3,553 deletions.
Binary file added .DS_Store
Binary file not shown.
5 changes: 3 additions & 2 deletions .codegen.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
},
"batch": {
".codegen/__init__.py.tmpl": "databricks/sdk/__init__.py",
".codegen/error_mapping.py.tmpl": "databricks/sdk/errors/platform.py"
".codegen/error_mapping.py.tmpl": "databricks/sdk/errors/platform.py",
".codegen/error_overrides.py.tmpl": "databricks/sdk/errors/overrides.py"
},
"samples": {
".codegen/example.py.tmpl": "examples/{{.Service.SnakeName}}/{{.Method.SnakeName}}_{{.SnakeName}}.py"
".codegen/example.py.tmpl": "examples/{{if .IsAccount}}account{{else}}workspace{{end}}/{{.Service.SnakeName}}/{{.Method.SnakeName}}_{{.SnakeName}}.py"
},
"version": {
"databricks/sdk/version.py": "__version__ = '$VERSION'"
Expand Down
22 changes: 13 additions & 9 deletions .codegen/__init__.py.tmpl
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import databricks.sdk.core as client
import databricks.sdk.dbutils as dbutils
from databricks.sdk.credentials_provider import CredentialsProvider
from databricks.sdk.credentials_provider import CredentialsStrategy

from databricks.sdk.mixins.files import DbfsExt
from databricks.sdk.mixins.compute import ClustersExt
from databricks.sdk.mixins.workspace import WorkspaceExt
{{- range .Services}}
from databricks.sdk.service.{{.Package.Name}} import {{.PascalName}}API{{end}}
{{- range .Services}} {{if not .IsDataPlane}}
from databricks.sdk.service.{{.Package.Name}} import {{.PascalName}}API{{end}}{{end}}
from databricks.sdk.service.provisioning import Workspace
from databricks.sdk import azure

Expand Down Expand Up @@ -46,10 +46,12 @@ class WorkspaceClient:
debug_headers: bool = None,
product="unknown",
product_version="0.0.0",
credentials_provider: CredentialsProvider = None,
credentials_strategy: CredentialsStrategy = None,
credentials_provider: CredentialsStrategy = None,
config: client.Config = None):
if not config:
config = client.Config({{range $args}}{{.}}={{.}}, {{end}}
credentials_strategy=credentials_strategy,
credentials_provider=credentials_provider,
debug_truncate_bytes=debug_truncate_bytes,
debug_headers=debug_headers,
Expand All @@ -59,7 +61,7 @@ class WorkspaceClient:
self._dbutils = _make_dbutils(self._config)
self._api_client = client.ApiClient(self._config)

{{- range .Services}}{{if and (not .IsAccounts) (not .HasParent)}}
{{- range .Services}}{{if and (not .IsAccounts) (not .HasParent) (not .IsDataPlane)}}
self._{{.SnakeName}} = {{template "api" .}}(self._api_client){{end -}}{{end}}

@property
Expand All @@ -74,7 +76,7 @@ class WorkspaceClient:
def dbutils(self) -> dbutils.RemoteDbUtils:
return self._dbutils

{{- range .Services}}{{if and (not .IsAccounts) (not .HasParent)}}
{{- range .Services}}{{if and (not .IsAccounts) (not .HasParent) (not .IsDataPlane)}}
@property
def {{.SnakeName}}(self) -> {{template "api" .}}:
{{if .Description}}"""{{.Summary}}"""{{end}}
Expand All @@ -101,10 +103,12 @@ class AccountClient:
debug_headers: bool = None,
product="unknown",
product_version="0.0.0",
credentials_provider: CredentialsProvider = None,
credentials_strategy: CredentialsStrategy = None,
credentials_provider: CredentialsStrategy = None,
config: client.Config = None):
if not config:
config = client.Config({{range $args}}{{.}}={{.}}, {{end}}
credentials_strategy=credentials_strategy,
credentials_provider=credentials_provider,
debug_truncate_bytes=debug_truncate_bytes,
debug_headers=debug_headers,
Expand All @@ -113,7 +117,7 @@ class AccountClient:
self._config = config.copy()
self._api_client = client.ApiClient(self._config)

{{- range .Services}}{{if and .IsAccounts (not .HasParent)}}
{{- range .Services}}{{if and .IsAccounts (not .HasParent) (not .IsDataPlane)}}
self._{{(.TrimPrefix "account").SnakeName}} = {{template "api" .}}(self._api_client){{end -}}{{end}}

@property
Expand All @@ -124,7 +128,7 @@ class AccountClient:
def api_client(self) -> client.ApiClient:
return self._api_client

{{- range .Services}}{{if and .IsAccounts (not .HasParent)}}
{{- range .Services}}{{if and .IsAccounts (not .HasParent) (not .IsDataPlane)}}
@property
def {{(.TrimPrefix "account").SnakeName}}(self) -> {{template "api" .}}:{{if .Description}}
"""{{.Summary}}"""{{end}}
Expand Down
2 changes: 1 addition & 1 deletion .codegen/_openapi_sha
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1026b998b14fba1b8317528f47778240dc4e9a5d
37b925eba37dfb3d7e05b6ba2d458454ce62d3a0
2 changes: 1 addition & 1 deletion .codegen/changelog.md.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Dependency updates:
{{- end -}}

{{- define "service" -}}
[{{if .IsAccounts}}a{{else}}w{{end}}.{{.SnakeName}}](https://databricks-sdk-py.readthedocs.io/en/latest/{{if .IsAccounts}}account{{else}}workspace{{end}}/{{.SnakeName}}.html) {{if .IsAccounts}}account{{else}}workspace{{end}}-level service
[{{if .IsAccounts}}a{{else}}w{{end}}.{{.SnakeName}}](https://databricks-sdk-py.readthedocs.io/en/latest/{{if .IsAccounts}}account{{else}}workspace{{end}}{{with .ParentService}}/{{.SnakeName}}{{end}}/{{.SnakeName}}.html) {{if .IsAccounts}}account{{else}}workspace{{end}}-level service
{{- end -}}

{{- define "entity" -}}
Expand Down
20 changes: 20 additions & 0 deletions .codegen/error_overrides.py.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT.

from .base import _ErrorOverride
from .platform import *
import re


_ALL_OVERRIDES = [
{{ range .ErrorOverrides -}}
_ErrorOverride(
debug_name="{{.Name}}",
path_regex=re.compile(r'{{.PathRegex}}'),
verb="{{.Verb}}",
status_code_matcher=re.compile(r'{{.StatusCodeMatcher}}'),
error_code_matcher=re.compile(r'{{.ErrorCodeMatcher}}'),
message_matcher=re.compile(r'{{.MessageMatcher}}'),
custom_error={{.OverrideErrorCode.PascalName}},
),
{{- end }}
]
34 changes: 29 additions & 5 deletions .codegen/service.py.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import time
import random
import logging
from ..errors import OperationTimeout, OperationFailed
from ._internal import _enum, _from_dict, _repeated_dict, _repeated_enum, Wait
from ._internal import _enum, _from_dict, _repeated_dict, _repeated_enum, Wait, _escape_multi_segment_path_parameter

_LOG = logging.getLogger('databricks.sdk')

Expand Down Expand Up @@ -100,7 +100,7 @@ class {{.PascalName}}{{if eq "List" .PascalName}}Request{{end}}:{{if .Descriptio
{{- end -}}
{{- end -}}

{{range .Services}}
{{range .Services}} {{if not .IsDataPlane}}
class {{.PascalName}}API:{{if .Description}}
"""{{.Comment " " 110}}"""
{{end}}
Expand Down Expand Up @@ -195,6 +195,7 @@ class {{.PascalName}}API:{{if .Description}}
return self.{{template "safe-snake-name" .}}({{range $i, $x := .Request.Fields}}{{if $i}}, {{end}}{{template "safe-snake-name" .}}={{template "safe-snake-name" .}}{{end}}).result(timeout=timeout)
{{end}}
{{end -}}
{{end}}
{{- end}}

{{define "method-parameters" -}}
Expand Down Expand Up @@ -325,9 +326,7 @@ class {{.PascalName}}API:{{if .Description}}

{{define "method-do" -}}
self._api.do('{{.Verb}}',
{{if .PathParts -}}
f'{{range .PathParts}}{{.Prefix}}{{if .Field}}{{"{"}}{{template "safe-snake-name" .Field}}{{with .Field.Entity.Enum}}.value{{end}}{{"}"}}{{else if .IsAccountId}}{{"{self._api.account_id}"}}{{end}}{{ end }}'
{{- else}}'{{.Path}}'{{end}}
{{ template "path" . }}
{{if .Request}}
{{- if .Request.HasQueryField}}, query=query{{end}}
{{- if .Request.MapValue}}, body=contents
Expand All @@ -341,6 +340,31 @@ self._api.do('{{.Verb}}',
{{- if .IsResponseByteStream }}, raw=True{{ end }})
{{- end}}

{{- define "path" -}}
{{- if .PathParts -}}
f'{{range .PathParts -}}
{{- .Prefix -}}
{{- if .Field -}}
{{- "{" -}}
{{- if .Field.IsPathMultiSegment -}}_escape_multi_segment_path_parameter({{ template "path-parameter" . }})
{{- else -}}{{ template "path-parameter" . }}
{{- end -}}
{{- "}" -}}
{{- else if .IsAccountId}}
{{- "{" -}}
self._api.account_id
{{- "}" -}}
{{- end -}}
{{- end }}'
{{- else -}}
'{{.Path}}'
{{- end -}}
{{- end -}}

{{- define "path-parameter" -}}
{{template "safe-snake-name" .Field}}{{with .Field.Entity.Enum}}.value{{end}}
{{- end -}}

{{define "method-return-type" -}}
{{if and .Wait (and (not .IsCrudRead) (not (eq .SnakeName "get_run"))) }} -> Wait[{{.Wait.Poll.Response.PascalName}}]
{{- else if not .Response.IsEmpty }} -> {{if .Response.ArrayValue -}}
Expand Down
Loading

0 comments on commit 3d55145

Please sign in to comment.