fix(tags): clean up bulk create api and schema (#31427)
This commit is contained in:
parent
cd200f07a5
commit
bf56a327f4
File diff suppressed because it is too large
Load Diff
|
|
@ -47,6 +47,7 @@ from superset.tags.schemas import (
|
||||||
openapi_spec_methods_override,
|
openapi_spec_methods_override,
|
||||||
TaggedObjectEntityResponseSchema,
|
TaggedObjectEntityResponseSchema,
|
||||||
TagGetResponseSchema,
|
TagGetResponseSchema,
|
||||||
|
TagPostBulkResponseSchema,
|
||||||
TagPostBulkSchema,
|
TagPostBulkSchema,
|
||||||
TagPostSchema,
|
TagPostSchema,
|
||||||
TagPutSchema,
|
TagPutSchema,
|
||||||
|
|
@ -132,6 +133,8 @@ class TagRestApi(BaseSupersetModelRestApi):
|
||||||
openapi_spec_component_schemas = (
|
openapi_spec_component_schemas = (
|
||||||
TagGetResponseSchema,
|
TagGetResponseSchema,
|
||||||
TaggedObjectEntityResponseSchema,
|
TaggedObjectEntityResponseSchema,
|
||||||
|
TagPostBulkResponseSchema,
|
||||||
|
TagPostBulkSchema,
|
||||||
)
|
)
|
||||||
apispec_parameter_schemas = {
|
apispec_parameter_schemas = {
|
||||||
"delete_tags_schema": delete_tags_schema,
|
"delete_tags_schema": delete_tags_schema,
|
||||||
|
|
@ -211,40 +214,21 @@ class TagRestApi(BaseSupersetModelRestApi):
|
||||||
"""Bulk create tags and tagged objects
|
"""Bulk create tags and tagged objects
|
||||||
---
|
---
|
||||||
post:
|
post:
|
||||||
summary: Get all objects associated with a tag
|
summary: Bulk create tags and tagged objects
|
||||||
parameters:
|
|
||||||
- in: path
|
|
||||||
schema:
|
|
||||||
type: integer
|
|
||||||
name: tag_id
|
|
||||||
requestBody:
|
requestBody:
|
||||||
description: Tag schema
|
description: Tag schema
|
||||||
required: true
|
required: true
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
type: object
|
$ref: '#/components/schemas/TagPostBulkSchema'
|
||||||
properties:
|
|
||||||
tags:
|
|
||||||
description: list of tag names to add to object
|
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
type: string
|
|
||||||
objects_to_tag:
|
|
||||||
description: list of object names to add to object
|
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
type: array
|
|
||||||
responses:
|
responses:
|
||||||
200:
|
200:
|
||||||
description: Tag added to favorites
|
description: Bulk created tags and tagged objects
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
type: object
|
$ref: '#/components/schemas/TagPostBulkResponseSchema'
|
||||||
properties:
|
|
||||||
result:
|
|
||||||
type: object
|
|
||||||
302:
|
302:
|
||||||
description: Redirects to the current digest
|
description: Redirects to the current digest
|
||||||
400:
|
400:
|
||||||
|
|
@ -267,6 +251,7 @@ class TagRestApi(BaseSupersetModelRestApi):
|
||||||
tagged_item: dict[str, Any] = self.add_model_schema.load(
|
tagged_item: dict[str, Any] = self.add_model_schema.load(
|
||||||
{
|
{
|
||||||
"name": tag.get("name"),
|
"name": tag.get("name"),
|
||||||
|
"description": tag.get("description"),
|
||||||
"objects_to_tag": tag.get("objects_to_tag"),
|
"objects_to_tag": tag.get("objects_to_tag"),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -53,21 +53,41 @@ class TaggedObjectEntityResponseSchema(Schema):
|
||||||
changed_on = fields.DateTime()
|
changed_on = fields.DateTime()
|
||||||
created_by = fields.Nested(UserSchema(exclude=["username"]))
|
created_by = fields.Nested(UserSchema(exclude=["username"]))
|
||||||
creator = fields.String()
|
creator = fields.String()
|
||||||
tags = fields.List(fields.Nested(TagGetResponseSchema))
|
tags = fields.List(fields.Nested(TagGetResponseSchema()))
|
||||||
owners = fields.List(fields.Nested(UserSchema))
|
owners = fields.List(fields.Nested(UserSchema()))
|
||||||
|
|
||||||
|
|
||||||
|
objects_to_tag_field = fields.List(
|
||||||
|
fields.Tuple(
|
||||||
|
(
|
||||||
|
fields.String(metadata={"description": "type of resource"}),
|
||||||
|
fields.Int(validate=Range(min=1), metadata={"description": "resource id"}),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
metadata={
|
||||||
|
"description": "Objects to tag",
|
||||||
|
},
|
||||||
|
required=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class TagObjectSchema(Schema):
|
class TagObjectSchema(Schema):
|
||||||
name = fields.String(validate=Length(min=1))
|
name = fields.String(validate=Length(min=1))
|
||||||
description = fields.String(required=False, allow_none=True)
|
description = fields.String(required=False, allow_none=True)
|
||||||
objects_to_tag = fields.List(
|
objects_to_tag = objects_to_tag_field
|
||||||
fields.Tuple((fields.String(), fields.Int(validate=Range(min=1)))),
|
|
||||||
required=False,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class TagPostBulkSchema(Schema):
|
class TagPostBulkSchema(Schema):
|
||||||
tags = fields.List(fields.Nested(TagObjectSchema))
|
tags = fields.List(fields.Nested(TagObjectSchema()))
|
||||||
|
|
||||||
|
|
||||||
|
class TagPostBulkResponseObjectSchema(Schema):
|
||||||
|
objects_tagged = objects_to_tag_field
|
||||||
|
objects_skipped = objects_to_tag_field
|
||||||
|
|
||||||
|
|
||||||
|
class TagPostBulkResponseSchema(Schema):
|
||||||
|
result = fields.Nested(TagPostBulkResponseObjectSchema())
|
||||||
|
|
||||||
|
|
||||||
class TagPostSchema(TagObjectSchema):
|
class TagPostSchema(TagObjectSchema):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue