Skip to content

Commit

Permalink
feat: tag repository, service and CRUD endpoints (#14971)
Browse files Browse the repository at this point in the history
  • Loading branch information
josephkmh committed Jan 15, 2025
1 parent 153436d commit 4986dcb
Show file tree
Hide file tree
Showing 17 changed files with 915 additions and 4 deletions.
82 changes: 82 additions & 0 deletions airbyte-api/problems-api/src/main/openapi/api-problems.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -879,6 +879,88 @@ components:
default: Not enough actors are eligible for the progressive rollout.
data:
$ref: "#/components/schemas/ProblemMessageData"
TagAlreadyExistsProblemResponse:
x-implements: io.airbyte.api.problems.ProblemResponse
type: object
allOf:
- $ref: "#/components/schemas/BaseProblemFields"
- type: object
properties:
status:
type: integer
default: 409
type:
type: string
default: error:tag-already-exists
title:
type: string
default: Tag already exists
detail:
type: string
default: A tag with this name already exists in this workspace.
data:
$ref: "#/components/schemas/ProblemMessageData"
TagInvalidHexColorProblemResponse:
x-implements: io.airbyte.api.problems.ProblemResponse
type: object
allOf:
- $ref: "#/components/schemas/BaseProblemFields"
- type: object
properties:
status:
type: integer
default: 400
type:
type: string
default: error:tag-invalid-hex-color
title:
type: string
default: Invalid hex color
detail:
type: string
default: The hex color provided is invalid.
data:
$ref: "#/components/schemas/ProblemMessageData"
TagNameTooLongProblemResponse:
x-implements: io.airbyte.api.problems.ProblemResponse
type: object
allOf:
- $ref: "#/components/schemas/BaseProblemFields"
- type: object
properties:
status:
type: integer
default: 400
type:
type: string
default: error:tag-name-too-long
title:
type: string
default: Tag name too long
detail:
type: string
default: The tag name can be maximuim 30 characters.
data:
$ref: "#/components/schemas/ProblemMessageData"
TagLimitForWorkspaceReachedProblemResponse:
x-implements: io.airbyte.api.problems.ProblemResponse
type: object
allOf:
- $ref: "#/components/schemas/BaseProblemFields"
- type: object
properties:
status:
type: integer
default: 400
type:
type: string
default: error:tag-limit-for-workspace-reached
title:
type: string
default: Tag limit for workspace reached
detail:
type: string
default: The workspace has reached the maximum number of tags.
ProblemCronData:
type: object
properties:
Expand Down
131 changes: 129 additions & 2 deletions airbyte-api/server-api/src/main/openapi/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5664,6 +5664,82 @@ paths:
schema:
$ref: "#/components/schemas/UserInvitationRead"

# Tags
/v1/tags/list:
post:
summary: List tags in a workspace
tags:
- tag
operationId: listTags
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/TagListRequestBody"
responses:
"200":
description: Successfully retrieved list of tags.
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/Tag"
/v1/tags/update:
post:
summary: Update a tag
tags:
- tag
operationId: updateTag
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/TagUpdateRequestBody"
responses:
"200":
description: Successfully updated tag.
content:
application/json:
schema:
$ref: "#/components/schemas/Tag"
/v1/tags/delete:
post:
summary: Delete a tag
tags:
- tag
operationId: deleteTag
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/TagDeleteRequestBody"
responses:
"200":
description: Successfully deleted tag.
content:
application/json:
schema:
$ref: "#/components/schemas/Tag"
/v1/tags/create:
post:
summary: Create a tag
tags:
- tag
operationId: createTag
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/TagCreateRequestBody"
responses:
"200":
description: Successfully created tag.
content:
application/json:
schema:
$ref: "#/components/schemas/Tag"

/v1/diagnostic_tool/generate_report:
post:
summary: Generate a diagnostic report
Expand Down Expand Up @@ -11097,13 +11173,16 @@ components:
description: A tag that can be associated with a connection. Useful for grouping and organizing connections in a workspace.
type: object
required:
- id
- tagId
- workspaceId
- name
- color
properties:
id:
tagId:
type: string
format: uuid
workspaceId:
$ref: "#/components/schemas/WorkspaceId"
name:
type: string
color:
Expand Down Expand Up @@ -14655,6 +14734,54 @@ components:
type: string
version:
type: string
TagListRequestBody:
type: object
required:
- workspaceId
properties:
workspaceId:
$ref: "#/components/schemas/WorkspaceId"
TagUpdateRequestBody:
type: object
required:
- tagId
- workspaceId
- name
- color
properties:
tagId:
type: string
format: uuid
workspaceId:
$ref: "#/components/schemas/WorkspaceId"
name:
type: string
color:
type: string
TagDeleteRequestBody:
type: object
required:
- tagId
- workspaceId
properties:
tagId:
type: string
format: uuid
workspaceId:
$ref: "#/components/schemas/WorkspaceId"
TagCreateRequestBody:
type: object
required:
- workspaceId
- name
- color
properties:
workspaceId:
$ref: "#/components/schemas/WorkspaceId"
name:
type: string
color:
type: string

NotFoundKnownExceptionInfo:
type: object
Expand Down
9 changes: 9 additions & 0 deletions airbyte-commons-auth/src/main/resources/intents.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
intents:
CreateOrEditConnection:
name: Create or edit connection
description: Create a connection between a source and a destination
roles:
- ORGANIZATION_EDITOR
- ORGANIZATION_ADMIN
- WORKSPACE_EDITOR
- WORKSPACE_ADMIN
- ADMIN
CreateOrEditConnector:
name: Create or edit connector
description: Create a source or destination connector, or change the settings of an existing connector
Expand Down
2 changes: 1 addition & 1 deletion airbyte-config/config-models/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This module uses `jsonschema2pojo` to generate Java config objects from [json sc
```
- Run the following command under the project root:
```sh
./gradlew airbyte-config:config-models:generateJsonSchema2Pojo
./gradlew :oss:airbyte-config:config-models:generateJsonSchema2Pojo
```
The generated file is under:
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ public enum ConfigSchema implements AirbyteConfig {

SCOPED_CONFIGURATION("ScopedConfiguration.yaml", ScopedConfiguration.class),
CONNECTOR_ROLLOUT("ConnectorRollout.yaml", ConnectorRollout.class),
USER_INVITATION("UserInvitation.yaml", UserInvitation.class);
USER_INVITATION("UserInvitation.yaml", UserInvitation.class),
TAG("Tag.yaml", Tag.class);

static final Path KNOWN_SCHEMAS_ROOT = JsonSchemas.prepareSchemas("types", ConfigSchema.class);

Expand Down
23 changes: 23 additions & 0 deletions airbyte-config/config-models/src/main/resources/types/Tag.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
"$schema": http://json-schema.org/draft-07/schema#
"$id": https://github.com/airbytehq/airbyte/blob/master/airbyte-config/models/src/main/resources/types/Tag.yaml
title: Tag
description: Tag for organizing and grouping resources
type: object
required:
- tagId
- workspaceId
- name
- color
additionalProperties: false
properties:
tagId:
type: string
format: uuid
workspaceId:
type: string
format: uuid
name:
type: string
color:
type: string
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package io.airbyte.data.repositories

import io.airbyte.data.repositories.entities.Tag
import io.micronaut.data.jdbc.annotation.JdbcRepository
import io.micronaut.data.model.query.builder.sql.Dialect
import io.micronaut.data.repository.PageableRepository
import java.util.UUID

@JdbcRepository(dialect = Dialect.POSTGRES, dataSource = "config")
interface TagRepository : PageableRepository<Tag, UUID> {
fun findByWorkspaceId(workspaceId: UUID): List<Tag>

fun countByWorkspaceId(workspaceId: UUID): Int

fun findByIdForUpdate(id: UUID): Tag

fun findByIdAndWorkspaceId(
id: UUID,
workspaceId: UUID,
): Tag
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package io.airbyte.data.repositories.entities

import io.micronaut.data.annotation.AutoPopulated
import io.micronaut.data.annotation.DateCreated
import io.micronaut.data.annotation.DateUpdated
import io.micronaut.data.annotation.Id
import io.micronaut.data.annotation.MappedEntity
import java.util.UUID

@MappedEntity("tag")
data class Tag(
@field:Id
@AutoPopulated
var id: UUID? = null,
var workspaceId: UUID,
var name: String,
var color: String,
@DateCreated
var createdAt: java.time.OffsetDateTime? = null,
@DateUpdated
var updatedAt: java.time.OffsetDateTime? = null,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package io.airbyte.data.services

import io.airbyte.config.Tag
import java.util.UUID

/**
* A service that manages tags
*/
interface TagService {
fun getTag(
tagId: UUID,
workspaceId: UUID,
): Tag

fun getTagsByWorkspaceId(workspaceId: UUID): List<Tag>

fun updateTag(tag: Tag): Tag

fun deleteTag(tagId: UUID)

fun createTag(tag: Tag): Tag
}
Loading

0 comments on commit 4986dcb

Please sign in to comment.