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

Fix base_url for creating schema #1044

Merged
merged 1 commit into from
Jul 18, 2023
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
12 changes: 9 additions & 3 deletions aws-lambda/src/databricks_cdk/resources/unity_catalog/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import logging
from typing import Dict, Optional

import requests.exceptions
from pydantic import BaseModel, Field

from databricks_cdk.utils import CnfResponse, delete_request, get_request, patch_request, post_request
Expand Down Expand Up @@ -29,11 +30,16 @@ class SchemaResponse(CnfResponse):

def get_schema_url(workspace_url: str):
"""Getting url for job requests"""
return f"{workspace_url}/api/2.1/unity-catalog/schemas"
return f"{workspace_url}api/2.1/unity-catalog/schemas"


def get_schema_by_name(catalog_name: str, schema_name: str, base_url: str) -> Optional[dict]:
return get_request(f"{base_url}/{catalog_name}.{schema_name}")
try:
return get_request(f"{base_url}/{catalog_name}.{schema_name}")
except requests.exceptions.HTTPError as e:
if e.response.status_code == 404:
return None
raise


def create_or_update_schema(properties: SchemaProperties) -> SchemaResponse:
Expand All @@ -47,7 +53,7 @@ def create_or_update_schema(properties: SchemaProperties) -> SchemaResponse:
base_url=base_url,
)
body = json.loads(properties.schema_object.json())
# body["full_name"] = f"{properties.schema_object.catalog_name}.{properties.schema_object.name}"

if current is None:
post_request(
base_url,
Expand Down
Loading