Skip to content

Commit

Permalink
Switch asset endpoints to use id instead of uri (apache#44801)
Browse files Browse the repository at this point in the history
* Switch asset endpoints to use id instead of uri

With the addition of Asset.name, we can't guarantee the uri to be unique
anymore. Using uri also presents addition issues on endpoints since it
conflicts with subroutes.

* Does not need annnotation in route format
  • Loading branch information
uranusjr authored Dec 10, 2024
1 parent ddae5a5 commit dcd41f6
Show file tree
Hide file tree
Showing 12 changed files with 211 additions and 283 deletions.
5 changes: 2 additions & 3 deletions airflow/api_fastapi/core_api/datamodels/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ class AssetEventResponse(BaseModel):

id: int
asset_id: int
uri: str
extra: dict | None = None
source_task_id: str | None = None
source_dag_id: str | None = None
Expand All @@ -127,8 +126,8 @@ class AssetEventCollectionResponse(BaseModel):
class QueuedEventResponse(BaseModel):
"""Queued Event serializer for responses.."""

uri: str
dag_id: str
asset_id: int
created_at: datetime


Expand All @@ -142,7 +141,7 @@ class QueuedEventCollectionResponse(BaseModel):
class CreateAssetEventsBody(BaseModel):
"""Create asset events request."""

uri: str
asset_id: int
extra: dict = Field(default_factory=dict)

@field_validator("extra", mode="after")
Expand Down
56 changes: 26 additions & 30 deletions airflow/api_fastapi/core_api/openapi/v1-generated.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -594,20 +594,20 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
/public/assets/queuedEvents/{uri}:
/public/assets/{asset_id}/queuedEvents:
get:
tags:
- Asset
summary: Get Asset Queued Events
description: Get queued asset events for an asset.
operationId: get_asset_queued_events
parameters:
- name: uri
- name: asset_id
in: path
required: true
schema:
type: string
title: Uri
type: integer
title: Asset Id
- name: before
in: query
required: false
Expand Down Expand Up @@ -654,12 +654,12 @@ paths:
description: Delete queued asset events for an asset.
operationId: delete_asset_queued_events
parameters:
- name: uri
- name: asset_id
in: path
required: true
schema:
type: string
title: Uri
type: integer
title: Asset Id
- name: before
in: query
required: false
Expand Down Expand Up @@ -695,20 +695,20 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
/public/assets/{uri}:
/public/assets/{asset_id}:
get:
tags:
- Asset
summary: Get Asset
description: Get an asset.
operationId: get_asset
parameters:
- name: uri
- name: asset_id
in: path
required: true
schema:
type: string
title: Uri
type: integer
title: Asset Id
responses:
'200':
description: Successful Response
Expand Down Expand Up @@ -846,7 +846,7 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
/public/dags/{dag_id}/assets/queuedEvents/{uri}:
/public/dags/{dag_id}/assets/{asset_id}/queuedEvents:
get:
tags:
- Asset
Expand All @@ -860,12 +860,12 @@ paths:
schema:
type: string
title: Dag Id
- name: uri
- name: asset_id
in: path
required: true
schema:
type: string
title: Uri
type: integer
title: Asset Id
- name: before
in: query
required: false
Expand Down Expand Up @@ -918,12 +918,12 @@ paths:
schema:
type: string
title: Dag Id
- name: uri
- name: asset_id
in: path
required: true
schema:
type: string
title: Uri
type: integer
title: Asset Id
- name: before
in: query
required: false
Expand Down Expand Up @@ -5982,9 +5982,6 @@ components:
asset_id:
type: integer
title: Asset Id
uri:
type: string
title: Uri
extra:
anyOf:
- type: object
Expand Down Expand Up @@ -6021,7 +6018,6 @@ components:
required:
- id
- asset_id
- uri
- source_map_index
- created_dagruns
- timestamp
Expand Down Expand Up @@ -6548,16 +6544,16 @@ components:
description: Connection Test serializer for responses.
CreateAssetEventsBody:
properties:
uri:
type: string
title: Uri
asset_id:
type: integer
title: Asset Id
extra:
type: object
title: Extra
additionalProperties: false
type: object
required:
- uri
- asset_id
title: CreateAssetEventsBody
description: Create asset events request.
DAGCollectionResponse:
Expand Down Expand Up @@ -8273,20 +8269,20 @@ components:
description: Queued Event Collection serializer for responses.
QueuedEventResponse:
properties:
uri:
type: string
title: Uri
dag_id:
type: string
title: Dag Id
asset_id:
type: integer
title: Asset Id
created_at:
type: string
format: date-time
title: Created At
type: object
required:
- uri
- dag_id
- asset_id
- created_at
title: QueuedEventResponse
description: Queued Event serializer for responses..
Expand Down
Loading

0 comments on commit dcd41f6

Please sign in to comment.