Skip to content
Merged
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
21 changes: 16 additions & 5 deletions docs/gen-client-docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,11 +267,22 @@ def _load_mapping(self) -> dict[str, Tag]:
pkgs = {p.name: p for p in self.packages}
spec = json.loads(self._openapi_spec())
for tag in spec['tags']:
is_account=tag.get('x-databricks-is-accounts')
# Unique identifier for the tag. Note that the service name may not be unique
key = 'a' if is_account else 'w'
parent_service = tag.get('x-databricks-parent-service')
if parent_service:
# SDK generation removes the "account" prefix from account services
clean_parent_service = parent_service.lower().removeprefix("account")
key = f"{key}.{clean_parent_service}"

key = f"{key}.{tag['x-databricks-service']}".lower()

t = Tag(name=tag['name'],
service=tag['x-databricks-service'],
is_account=tag.get('x-databricks-is-accounts', False),
package=pkgs[tag['x-databricks-package']])
mapping[tag['name']] = t
mapping[key] = t
return mapping

@staticmethod
Expand Down Expand Up @@ -360,7 +371,7 @@ def service_docs(self, client_inst, client_prefix: str) -> list[ServiceDoc]:
service_name=service_name,
class_name=class_name,
doc=class_doc,
tag=self._get_tag_name(service_inst.__class__.__name__, service_name),
tag=self._get_tag_name(service_inst.__class__.__name__, client_prefix, service_name),
methods=self.class_methods(service_inst),
property=self.class_properties(service_inst)))
return all
Expand Down Expand Up @@ -399,13 +410,13 @@ def write_dataclass_docs(self):

{all}''')

def _get_tag_name(self, class_name, service_name) -> Tag:
def _get_tag_name(self, class_name, client_prefix, service_name) -> Tag:
if class_name[-3:] == 'Ext':
# ClustersExt, DbfsExt, WorkspaceExt, but not ExternalLocations
class_name = class_name.replace('Ext', 'API')
class_name = class_name[:-3]
for tag_name, t in self.mapping.items():
if t.service.lower() == str(class_name).lower():
for key, t in self.mapping.items():
if key == f'{client_prefix}.{str(class_name).lower()}':
return t
raise KeyError(f'Cannot find {class_name} / {service_name} tag')

Expand Down
Loading