Skip to content

Commit

Permalink
Merge pull request #1044 from dan1elt0m/fix-schema-creation
Browse files Browse the repository at this point in the history
Fix base_url for creating schema
  • Loading branch information
dan1elt0m authored Jul 18, 2023
2 parents f03aed8 + 0ee6cc2 commit 7ba81b9
Showing 1 changed file with 9 additions and 3 deletions.
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

0 comments on commit 7ba81b9

Please sign in to comment.