From 5d4ec82930a5fe981ef3762d8dbf8e2f16fb5738 Mon Sep 17 00:00:00 2001 From: Yash Sharma Date: Tue, 30 Jul 2024 18:49:19 +0530 Subject: [PATCH 1/4] Add workspace schema Signed-off-by: Yash Sharma --- schemas/constructs/openapi/common/core.yml | 26 +- schemas/constructs/openapi/environment.yml | 4 +- schemas/constructs/openapi/workspace.yml | 579 +++++++++++++++++++++ 3 files changed, 606 insertions(+), 3 deletions(-) create mode 100644 schemas/constructs/openapi/workspace.yml diff --git a/schemas/constructs/openapi/common/core.yml b/schemas/constructs/openapi/common/core.yml index 38fe3cb3ad..9c4fee00a7 100644 --- a/schemas/constructs/openapi/common/core.yml +++ b/schemas/constructs/openapi/common/core.yml @@ -177,7 +177,7 @@ components: x-go-type-name: OrganizationId x-go-type-skip-optional-pointer: true - environment_id: + general_id: type: string format: uuid x-go-type: uuid.UUID @@ -186,9 +186,33 @@ components: x-oapi-codegen-extra-tags: db: id json: id + x-go-type-name: GeneralId + x-go-type-skip-optional-pointer: true + + environment_id: + type: string + format: uuid + x-go-type: uuid.UUID + x-go-type-import: + path: github.com/gofrs/uuid + x-oapi-codegen-extra-tags: + db: environment_id + json: environment_id x-go-type-name: EnvironmentId x-go-type-skip-optional-pointer: true + workspace_id: + type: string + format: uuid + x-go-type: uuid.UUID + x-go-type-import: + path: github.com/gofrs/uuid + x-oapi-codegen-extra-tags: + db: workspace_id + json: workspace_id + x-go-type-name: WorkspaceId + x-go-type-skip-optional-pointer: true + credential_uuid: type: string format: uuid diff --git a/schemas/constructs/openapi/environment.yml b/schemas/constructs/openapi/environment.yml index f70af08cfe..51bcfa1732 100644 --- a/schemas/constructs/openapi/environment.yml +++ b/schemas/constructs/openapi/environment.yml @@ -27,7 +27,7 @@ components: environment: properties: ID: - $ref: ./common/core.yml#/components/schemas/environment_id + $ref: ./common/core.yml#/components/schemas/general_id name: $ref: ./common/core.yml#/components/schemas/text description: @@ -45,7 +45,7 @@ components: environmentConnectionMapping: properties: ID: - $ref: ./common/core.yml#/components/schemas/environment_id + $ref: ./common/core.yml#/components/schemas/general_id environment_id: type: string format: uuid diff --git a/schemas/constructs/openapi/workspace.yml b/schemas/constructs/openapi/workspace.yml new file mode 100644 index 0000000000..ba553c41c7 --- /dev/null +++ b/schemas/constructs/openapi/workspace.yml @@ -0,0 +1,579 @@ +openapi: 3.0.0 +info: + title: Meshery Cloud + description: Documentation for meshery Cloud REST APIs + contact: + email: support@layer5.io + version: v0.6.394 +servers: + - url: https://meshery.layer5.io + description: Meshery Cloud production server URL + - url: https://staging-meshery.layer5.io + description: Meshery Cloud staging server URL + - url: http://localhost:9876 + description: Meshery Cloud development server URL (controlled via PORT environment variable) +security: + - jwt: [] +tags: + - name: workspaces + description: Workspaces bring teams, environments, and designs together +components: + securitySchemes: + jwt: + type: http + scheme: Bearer + bearerFormat: JWT + schemas: + workspace: + properties: + ID: + $ref: ./common/core.yml#/components/schemas/general_id + name: + $ref: './common/core.yml#/components/schemas/text' + description: + $ref: './common/core.yml#/components/schemas/text' + organization_id: + $ref: ./common/core.yml#/components/schemas/organization_id + owner: + $ref: './common/core.yml#/components/schemas/text' + created_at: + $ref: './common/core.yml#/components/schemas/time' + updated_at: + $ref: './common/core.yml#/components/schemas/time' + deleted_at: + $ref: './common/core.yml#/components/schemas/nullTime' + workspacesTeamsMapping: + properties: + id: + $ref: ./common/core.yml#/components/schemas/general_id + team_id: + $ref: './common/core.yml#/components/schemas/id' + workspace_id: + $ref: './common/core.yml#/components/schemas/id' + created_at: + $ref: './common/core.yml#/components/schemas/time' + updated_at: + $ref: './common/core.yml#/components/schemas/time' + deleted_at: + $ref: './common/core.yml#/components/schemas/time' + workspacesEnvironmentsMapping: + properties: + id: + $ref: ./common/core.yml#/components/schemas/general_id + environment_id: + $ref: './common/core.yml#/components/schemas/id' + workspace_id: + $ref: './common/core.yml#/components/schemas/id' + created_at: + $ref: './common/core.yml#/components/schemas/time' + updated_at: + $ref: './common/core.yml#/components/schemas/time' + deleted_at: + $ref: './common/core.yml#/components/schemas/time' + workspacesViewsMapping: + properties: + id: + $ref: ./common/core.yml#/components/schemas/general_id + view_id: + $ref: './common/core.yml#/components/schemas/id' + workspace_id: + $ref: './common/core.yml#/components/schemas/id' + created_at: + $ref: './common/core.yml#/components/schemas/time' + updated_at: + $ref: './common/core.yml#/components/schemas/time' + deleted_at: + $ref: './common/core.yml#/components/schemas/time' + workspacesDesignsMapping: + properties: + id: + $ref: ./common/core.yml#/components/schemas/general_id + design_id: + $ref: './common/core.yml#/components/schemas/id' + workspace_id: + $ref: './common/core.yml#/components/schemas/id' + created_at: + $ref: './common/core.yml#/components/schemas/time' + updated_at: + $ref: './common/core.yml#/components/schemas/time' + deleted_at: + $ref: './common/core.yml#/components/schemas/time' + workspaceUpdatePayload: + properties: + name: + $ref: './common/core.yml#/components/schemas/text' + description: Name of workspace + description: + $ref: './common/core.yml#/components/schemas/text' + description: Environment description + organization_id: + type: string + description: Organization ID + x-go-type-skip-optional-pointer: true + x-go-name: OrgId + x-oapi-codegen-extra-tags: + json: organization_id + required: + - organization_id + workspacePayload: + properties: + name: + $ref: './common/core.yml#/components/schemas/text' + description: Name + description: + $ref: './common/core.yml#/components/schemas/text' + description: Environment description + organization_id: + type: string + description: Organization ID + x-go-type-skip-optional-pointer: true + x-go-name: OrgId + x-oapi-codegen-extra-tags: + json: organization_id + required: + - name + - organization_ + workspacePage: + properties: + page: + type: ./common/core.yml#/components/schemas/number + page_size: + type: ./common/core.yml#/components/schemas/number + total_count: + type: ./common/core.yml#/components/schemas/number + environments: + type: array + items: + $ref: '#/components/schemas/workspace' + requestBodies: + workspacePayload: + description: Body for creating workspace + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/workspacePayload' + workspaceUpdatePayload: + description: Body for updating workspace + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/workspaceUpdatePayload' + +# paths: +# #designs + # /api/workspaces: + # post: + # tags: + # - workspaces + # operationId: CreateWorkspace + # summary: Create an workspace + # description: Creates a new workspace + # parameters: + # - $ref: '#/components/parameters/orgID' + # requestBody: + # $ref: '#/components/requestBodies/workspacePayload' + # responses: + # '201': + # description: Created workspace + # content: + # application/json: + # schema: + # $ref: '#/components/schemas/workspace' + # '400': + # $ref: '#/components/responses/400' + # '500': + # $ref: '#/components/responses/500' + # get: + # tags: + # - workspaces + # operationId: GetWorkspaces + # summary: Get all workspaces + # description: Gets all workspaces + # parameters: + # - $ref: '#/components/parameters/search' + # - $ref: '#/components/parameters/order' + # - $ref: '#/components/parameters/page' + # - $ref: '#/components/parameters/pagesize' + # - $ref: '#/components/parameters/filter' + # - $ref: '#/components/parameters/orgIDQuery' + # responses: + # '200': + # description: Workspaces + # content: + # application/json: + # schema: + # $ref: '#/components/schemas/workspacePage' + # '401': + # $ref: '#/components/responses/401' + # '500': + # $ref: '#/components/responses/500' + # /api/workspaces/{workspaceId}: + # get: + # tags: + # - workspaces + # operationId: GetWorkspaceByID + # summary: Get an workspace by ID + # description: Gets an workspace by its ID + # parameters: + # - $ref: '#/components/parameters/workspaceId' + # - $ref: '#/components/parameters/orgIDQuery' + # responses: + # '200': + # description: Workspace + # content: + # application/json: + # schema: + # $ref: '#/components/schemas/workspace' + # '400': + # $ref: '#/components/responses/400' + # '401': + # $ref: '#/components/responses/401' + # '404': + # $ref: '#/components/responses/404' + # '500': + # $ref: '#/components/responses/500' + # delete: + # tags: + # - workspaces + # operationId: DeleteWorkspace + # summary: Delete an workspace + # description: Deletes an workspace by its ID + # parameters: + # - $ref: '#/components/parameters/workspaceId' + # responses: + # '204': + # description: Workspace deleted successfully + # '400': + # $ref: '#/components/responses/400' + # '401': + # $ref: '#/components/responses/401' + # '404': + # $ref: '#/components/responses/404' + # '500': + # $ref: '#/components/responses/500' + # put: + # tags: + # - workspaces + # operationId: UpdateWorkspace + # summary: Update an workspace + # description: Updates the workspace + # parameters: + # - $ref: '#/components/parameters/workspaceId' + # requestBody: + # $ref: '#/components/requestBodies/workspaceUpdatePayload' + # responses: + # '200': + # $ref: '#/components/responses/200' + # '400': + # $ref: '#/components/responses/400' + # '401': + # $ref: '#/components/responses/401' + # '500': + # $ref: '#/components/responses/500' + # /api/workspaces/{workspaceId}/teams: + # get: + # tags: + # - workspaces + # operationId: GetTeamsOfWorkspace + # summary: Get all teams assigned to a workspace (by default returns assigned) + # description: Gets an Teams of a given workspace by its ID + # parameters: + # - $ref: '#/components/parameters/workspaceId' + # - $ref: '#/components/parameters/search' + # - $ref: '#/components/parameters/order' + # - $ref: '#/components/parameters/page' + # - $ref: '#/components/parameters/pagesize' + # - $ref: '#/components/parameters/workspaceFilter' + # responses: + # '200': + # description: Teams + # content: + # application/json: + # schema: + # $ref: '#/components/schemas/teamsPage' + # '400': + # $ref: '#/components/responses/400' + # '401': + # $ref: '#/components/responses/401' + # '404': + # $ref: '#/components/responses/404' + # '500': + # $ref: '#/components/responses/500' + # /api/workspaces/{workspaceId}/teams/{teamId}: + # delete: + # tags: + # - workspaces + # operationId: UnassignTeamFromWorkspace + # summary: Unassign a team from a workspace + # description: Unassigns a team from a workspace + # parameters: + # - $ref: '#/components/parameters/workspaceId' + # - $ref: '#/components/parameters/teamId' + # responses: + # '200': + # description: Workspaces teams mappings + # content: + # application/json: + # schema: + # $ref: '#/components/schemas/workspacesTeamsMapping' + # '400': + # $ref: '#/components/responses/400' + # '401': + # $ref: '#/components/responses/401' + # '404': + # $ref: '#/components/responses/404' + # '500': + # $ref: '#/components/responses/500' + # post: + # tags: + # - workspaces + # operationId: AssignTeamToWorkspace + # summary: Assign a team to a workspace + # description: Assigns a team to a workspace + # parameters: + # - $ref: '#/components/parameters/workspaceId' + # - $ref: '#/components/parameters/teamId' + # responses: + # '200': + # description: Workspaces teams mappings + # content: + # application/json: + # schema: + # $ref: '#/components/schemas/workspacesTeamsMapping' + # '400': + # $ref: '#/components/responses/400' + # '401': + # $ref: '#/components/responses/401' + # '500': + # $ref: '#/components/responses/500' + # /api/workspaces/{workspaceId}/environments: + # get: + # tags: + # - workspaces + # operationId: GetEnvironmentsOfWorkspace + # summary: Get all environments assigned to a workspace (by default returns assigned) + # description: Gets an environments of a given workspace by its ID + # parameters: + # - $ref: '#/components/parameters/workspaceId' + # - $ref: '#/components/parameters/search' + # - $ref: '#/components/parameters/order' + # - $ref: '#/components/parameters/page' + # - $ref: '#/components/parameters/pagesize' + # - $ref: '#/components/parameters/workspaceFilter' + # responses: + # '200': + # description: Environment + # content: + # application/json: + # schema: + # $ref: '#/components/schemas/environmentPage' + # '400': + # $ref: '#/components/responses/400' + # '401': + # $ref: '#/components/responses/401' + # '404': + # $ref: '#/components/responses/404' + # '500': + # $ref: '#/components/responses/500' + # /api/workspaces/{workspaceId}/environments/{environmentId}: + # delete: + # tags: + # - workspaces + # operationId: UnassignEnvironmentFromWorkspace + # summary: Unassign a environment from a workspace + # description: Unassigns a environment from a workspace + # parameters: + # - $ref: '#/components/parameters/workspaceId' + # - $ref: '#/components/parameters/environmentId' + # responses: + # '200': + # description: Workspaces environments mappings + # content: + # application/json: + # schema: + # $ref: '#/components/schemas/workspacesEnvironmentsMapping' + # '400': + # $ref: '#/components/responses/400' + # '401': + # $ref: '#/components/responses/401' + # '404': + # $ref: '#/components/responses/404' + # '500': + # $ref: '#/components/responses/500' + # post: + # tags: + # - workspaces + # operationId: AssignEnvironmentToWorkspace + # summary: Assign a environment to a workspace + # description: Assigns a environment to a workspace + # parameters: + # - $ref: '#/components/parameters/workspaceId' + # - $ref: '#/components/parameters/environmentId' + # responses: + # '200': + # description: Workspaces environments mappings + # content: + # application/json: + # schema: + # $ref: '#/components/schemas/workspacesEnvironmentsMapping' + # '400': + # $ref: '#/components/responses/400' + # '401': + # $ref: '#/components/responses/401' + # '500': + # $ref: '#/components/responses/500' + # /api/workspaces/{workspaceId}/designs/{designId}: + # delete: + # tags: + # - workspaces + # operationId: UnassignDesignFromWorkspace + # summary: Unassign a design from a workspace + # description: Unassign a design from a workspace + # parameters: + # - $ref: '#/components/parameters/workspaceId' + # - $ref: '#/components/parameters/designId' + # responses: + # '200': + # description: Workspaces designs mappings + # content: + # application/json: + # schema: + # $ref: '#/components/schemas/workspacesDesignsMapping' + # '400': + # $ref: '#/components/responses/400' + # '401': + # $ref: '#/components/responses/401' + # '404': + # $ref: '#/components/responses/404' + # '500': + # $ref: '#/components/responses/500' + # post: + # tags: + # - workspaces + # operationId: AssignDesignToWorkspace + # summary: Assign a design to a workspace + # description: Assigns a design to a workspace + # parameters: + # - $ref: '#/components/parameters/workspaceId' + # - $ref: '#/components/parameters/designId' + # responses: + # '200': + # description: Workspaces designs mappings + # content: + # application/json: + # schema: + # $ref: '#/components/schemas/workspacesDesignsMapping' + # '400': + # $ref: '#/components/responses/400' + # '401': + # $ref: '#/components/responses/401' + # '500': + # $ref: '#/components/responses/500' + # /api/workspaces/{workspaceId}/designs: + # get: + # tags: + # - workspaces + # operationId: GetDesignsOfWorkspace + # summary: Get all designs assigned to a workspace (by default returns assigned) + # description: Gets an designs of a given workspace by its ID + # parameters: + # - $ref: '#/components/parameters/search' + # - $ref: '#/components/parameters/order' + # - $ref: '#/components/parameters/page' + # - $ref: '#/components/parameters/pagesize' + # - $ref: '#/components/parameters/workspaceFilter' + # - $ref: '#/components/parameters/workspaceId' + # responses: + # '200': + # description: Design + # content: + # application/json: + # schema: + # $ref: '#/components/schemas/mesheryDesignPage' + # '400': + # $ref: '#/components/responses/400' + # '401': + # $ref: '#/components/responses/401' + # '404': + # $ref: '#/components/responses/404' + # '500': + # $ref: '#/components/responses/500' + # /api/workspaces/{workspaceId}/views/{viewId}: + # delete: + # tags: + # - workspaces + # operationId: UnassignViewFromWorkspace + # summary: Unassign a view from a workspace + # description: Unassign a view from a workspace + # parameters: + # - $ref: '#/components/parameters/workspaceId' + # - $ref: '#/components/parameters/viewId' + # responses: + # '200': + # description: Workspaces views mappings + # content: + # application/json: + # schema: + # $ref: '#/components/schemas/workspacesViewsMapping' + # '400': + # $ref: '#/components/responses/400' + # '401': + # $ref: '#/components/responses/401' + # '404': + # $ref: '#/components/responses/404' + # '500': + # $ref: '#/components/responses/500' + # post: + # tags: + # - workspaces + # operationId: AssignViewToWorkspace + # summary: Assign a view to a workspace + # description: Assigns a view to a workspace + # parameters: + # - $ref: '#/components/parameters/workspaceId' + # - $ref: '#/components/parameters/viewId' + # responses: + # '200': + # description: Workspaces views mappings + # content: + # application/json: + # schema: + # $ref: '#/components/schemas/workspacesViewsMapping' + # '400': + # $ref: '#/components/responses/400' + # '401': + # $ref: '#/components/responses/401' + # '500': + # $ref: '#/components/responses/500' + # /api/workspaces/{workspaceId}/views: + # get: + # tags: + # - workspaces + # operationId: GetViewsOfWorkspace + # summary: Get all views assigned to a workspace (by default returns assigned) + # description: Gets views of a given workspace by its ID + # parameters: + # - $ref: '#/components/parameters/search' + # - $ref: '#/components/parameters/order' + # - $ref: '#/components/parameters/page' + # - $ref: '#/components/parameters/pagesize' + # - $ref: '#/components/parameters/workspaceFilter' + # - $ref: '#/components/parameters/workspaceId' + # responses: + # '200': + # description: View + # content: + # application/json: + # schema: + # $ref: '#/components/schemas/mesheryViewPage' + # '400': + # $ref: '#/components/responses/400' + # '401': + # $ref: '#/components/responses/401' + # '404': + # $ref: '#/components/responses/404' + # '500': + # $ref: '#/components/responses/500' + # /api/workspaces/{workspaceId}/events: \ No newline at end of file From 238be2a33b2456cca1dc4a0fb9ca570828d05338 Mon Sep 17 00:00:00 2001 From: Yash Sharma Date: Tue, 30 Jul 2024 19:17:33 +0530 Subject: [PATCH 2/4] Generate structs Signed-off-by: Yash Sharma --- models/core/core.go | 15 ++++ models/v1beta1/workspace.go | 88 ++++++++++++++++++++++ schemas/constructs/openapi/common/core.yml | 36 +++++++++ schemas/constructs/openapi/workspace.yml | 25 +++--- 4 files changed, 152 insertions(+), 12 deletions(-) create mode 100644 models/v1beta1/workspace.go diff --git a/models/core/core.go b/models/core/core.go index 03f397934f..7a0d047896 100644 --- a/models/core/core.go +++ b/models/core/core.go @@ -29,6 +29,9 @@ type CredentialID = uuid.UUID // DeletedAt Timestamp when the resource was deleted. type DeletedAt = time.Time +// DesignId defines model for design_id. +type DesignId = uuid.UUID + // Email email type Email = openapi_types.Email @@ -50,6 +53,9 @@ type Endpoint = Text // EnvironmentId defines model for environment_id. type EnvironmentId = uuid.UUID +// GeneralId defines model for general_id. +type GeneralId = uuid.UUID + // ID defines model for id. type ID = uuid.UUID @@ -105,6 +111,9 @@ type Status = string // SystemID defines model for system_id. type SystemID = uuid.UUID +// TeamId defines model for team_id. +type TeamId = uuid.UUID + // Text defines model for text. type Text = string @@ -125,3 +134,9 @@ type UserID = uuid.UUID // Username defines model for username. type Username = string + +// ViewId defines model for view_id. +type ViewId = uuid.UUID + +// WorkspaceId defines model for workspace_id. +type WorkspaceId = uuid.UUID diff --git a/models/v1beta1/workspace.go b/models/v1beta1/workspace.go new file mode 100644 index 0000000000..06242ce7d5 --- /dev/null +++ b/models/v1beta1/workspace.go @@ -0,0 +1,88 @@ +// Package v1beta1 provides primitives to interact with the openapi HTTP API. +// +// Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.3.0 DO NOT EDIT. +package v1beta1 + +import ( + externalRef2 "github.com/meshery/schemas/models/core" +) + +// Workspace defines model for workspace. +type Workspace struct { + ID externalRef2.GeneralId `db:"id" json:"id"` + CreatedAt externalRef2.Time `json:"created_at,omitempty"` + + // DeletedAt SQL null Timestamp to handle null values of time. + DeletedAt externalRef2.NullTime `json:"deleted_at,omitempty"` + Description externalRef2.Text `json:"description,omitempty"` + Name externalRef2.Text `json:"name,omitempty"` + OrganizationId externalRef2.OrganizationId `db:"org_id" json:"org_id"` + Owner externalRef2.Text `json:"owner,omitempty"` + UpdatedAt externalRef2.Time `json:"updated_at,omitempty"` +} + +// WorkspacePage defines model for workspacePage. +type WorkspacePage struct { + Page externalRef2.Number `json:"page,omitempty"` + PageSize externalRef2.Number `json:"page_size,omitempty"` + TotalCount externalRef2.Number `json:"total_count,omitempty"` + Workspaces []Workspace `json:"workspaces,omitempty"` +} + +// WorkspacePayload defines model for workspacePayload. +type WorkspacePayload struct { + Description externalRef2.Text `json:"description,omitempty"` + Name externalRef2.Text `json:"name"` + + // OrgId Organization ID + OrgId string `json:"organization_id"` +} + +// WorkspaceUpdatePayload defines model for workspaceUpdatePayload. +type WorkspaceUpdatePayload struct { + Description externalRef2.Text `json:"description,omitempty"` + Name externalRef2.Text `json:"name,omitempty"` + + // OrgId Organization ID + OrgId string `json:"organization_id"` +} + +// WorkspacesDesignsMapping defines model for workspacesDesignsMapping. +type WorkspacesDesignsMapping struct { + CreatedAt externalRef2.Time `json:"created_at,omitempty"` + DeletedAt externalRef2.Time `json:"deleted_at,omitempty"` + DesignId externalRef2.DesignId `db:"design_id" json:"design_id"` + Id externalRef2.GeneralId `db:"id" json:"id"` + UpdatedAt externalRef2.Time `json:"updated_at,omitempty"` + WorkspaceId externalRef2.WorkspaceId `db:"workspace_id" json:"workspace_id"` +} + +// WorkspacesEnvironmentsMapping defines model for workspacesEnvironmentsMapping. +type WorkspacesEnvironmentsMapping struct { + CreatedAt externalRef2.Time `json:"created_at,omitempty"` + DeletedAt externalRef2.Time `json:"deleted_at,omitempty"` + EnvironmentId externalRef2.EnvironmentId `db:"environment_id" json:"environment_id"` + Id externalRef2.GeneralId `db:"id" json:"id"` + UpdatedAt externalRef2.Time `json:"updated_at,omitempty"` + WorkspaceId externalRef2.WorkspaceId `db:"workspace_id" json:"workspace_id"` +} + +// WorkspacesTeamsMapping defines model for workspacesTeamsMapping. +type WorkspacesTeamsMapping struct { + CreatedAt externalRef2.Time `json:"created_at,omitempty"` + DeletedAt externalRef2.Time `json:"deleted_at,omitempty"` + Id externalRef2.GeneralId `db:"id" json:"id"` + TeamId externalRef2.TeamId `db:"team_id" json:"team_id"` + UpdatedAt externalRef2.Time `json:"updated_at,omitempty"` + WorkspaceId externalRef2.WorkspaceId `db:"workspace_id" json:"workspace_id"` +} + +// WorkspacesViewsMapping defines model for workspacesViewsMapping. +type WorkspacesViewsMapping struct { + CreatedAt externalRef2.Time `json:"created_at,omitempty"` + DeletedAt externalRef2.Time `json:"deleted_at,omitempty"` + Id externalRef2.GeneralId `db:"id" json:"id"` + UpdatedAt externalRef2.Time `json:"updated_at,omitempty"` + ViewId externalRef2.ViewId `db:"view_id" json:"view_id"` + WorkspaceId externalRef2.WorkspaceId `db:"workspace_id" json:"workspace_id"` +} diff --git a/schemas/constructs/openapi/common/core.yml b/schemas/constructs/openapi/common/core.yml index 9c4fee00a7..705f3d66dc 100644 --- a/schemas/constructs/openapi/common/core.yml +++ b/schemas/constructs/openapi/common/core.yml @@ -213,6 +213,42 @@ components: x-go-type-name: WorkspaceId x-go-type-skip-optional-pointer: true + view_id: + type: string + format: uuid + x-go-type: uuid.UUID + x-go-type-import: + path: github.com/gofrs/uuid + x-oapi-codegen-extra-tags: + db: view_id + json: view_id + x-go-type-name: ViewId + x-go-type-skip-optional-pointer: true + + team_id: + type: string + format: uuid + x-go-type: uuid.UUID + x-go-type-import: + path: github.com/gofrs/uuid + x-oapi-codegen-extra-tags: + db: team_id + json: team_id + x-go-type-name: TeamId + x-go-type-skip-optional-pointer: true + + design_id: + type: string + format: uuid + x-go-type: uuid.UUID + x-go-type-import: + path: github.com/gofrs/uuid + x-oapi-codegen-extra-tags: + db: design_id + json: design_id + x-go-type-name: DesignId + x-go-type-skip-optional-pointer: true + credential_uuid: type: string format: uuid diff --git a/schemas/constructs/openapi/workspace.yml b/schemas/constructs/openapi/workspace.yml index ba553c41c7..a3273af5d3 100644 --- a/schemas/constructs/openapi/workspace.yml +++ b/schemas/constructs/openapi/workspace.yml @@ -47,9 +47,9 @@ components: id: $ref: ./common/core.yml#/components/schemas/general_id team_id: - $ref: './common/core.yml#/components/schemas/id' + $ref: './common/core.yml#/components/schemas/team_id' workspace_id: - $ref: './common/core.yml#/components/schemas/id' + $ref: './common/core.yml#/components/schemas/workspace_id' created_at: $ref: './common/core.yml#/components/schemas/time' updated_at: @@ -61,9 +61,9 @@ components: id: $ref: ./common/core.yml#/components/schemas/general_id environment_id: - $ref: './common/core.yml#/components/schemas/id' + $ref: './common/core.yml#/components/schemas/environment_id' workspace_id: - $ref: './common/core.yml#/components/schemas/id' + $ref: './common/core.yml#/components/schemas/workspace_id' created_at: $ref: './common/core.yml#/components/schemas/time' updated_at: @@ -75,9 +75,9 @@ components: id: $ref: ./common/core.yml#/components/schemas/general_id view_id: - $ref: './common/core.yml#/components/schemas/id' + $ref: './common/core.yml#/components/schemas/view_id' workspace_id: - $ref: './common/core.yml#/components/schemas/id' + $ref: './common/core.yml#/components/schemas/workspace_id' created_at: $ref: './common/core.yml#/components/schemas/time' updated_at: @@ -89,9 +89,9 @@ components: id: $ref: ./common/core.yml#/components/schemas/general_id design_id: - $ref: './common/core.yml#/components/schemas/id' + $ref: './common/core.yml#/components/schemas/design_id' workspace_id: - $ref: './common/core.yml#/components/schemas/id' + $ref: './common/core.yml#/components/schemas/workspace_id' created_at: $ref: './common/core.yml#/components/schemas/time' updated_at: @@ -136,13 +136,14 @@ components: workspacePage: properties: page: - type: ./common/core.yml#/components/schemas/number + $ref: ./common/core.yml#/components/schemas/number page_size: - type: ./common/core.yml#/components/schemas/number + $ref: ./common/core.yml#/components/schemas/number total_count: - type: ./common/core.yml#/components/schemas/number - environments: + $ref: ./common/core.yml#/components/schemas/number + workspaces: type: array + x-go-type-skip-optional-pointer: true items: $ref: '#/components/schemas/workspace' requestBodies: From d33608dc3d5ff845f892f8954938d1fdaf944522 Mon Sep 17 00:00:00 2001 From: Yash Sharma Date: Tue, 30 Jul 2024 19:23:46 +0530 Subject: [PATCH 3/4] Fix struct Signed-off-by: Yash Sharma --- models/v1beta1/workspace.go | 16 ++++++++-------- schemas/constructs/openapi/workspace.yml | 12 ++++++------ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/models/v1beta1/workspace.go b/models/v1beta1/workspace.go index 06242ce7d5..392e9cfc36 100644 --- a/models/v1beta1/workspace.go +++ b/models/v1beta1/workspace.go @@ -34,8 +34,8 @@ type WorkspacePayload struct { Description externalRef2.Text `json:"description,omitempty"` Name externalRef2.Text `json:"name"` - // OrgId Organization ID - OrgId string `json:"organization_id"` + // OrganizationID Organization ID + OrganizationID string `json:"organization_id"` } // WorkspaceUpdatePayload defines model for workspaceUpdatePayload. @@ -43,35 +43,35 @@ type WorkspaceUpdatePayload struct { Description externalRef2.Text `json:"description,omitempty"` Name externalRef2.Text `json:"name,omitempty"` - // OrgId Organization ID - OrgId string `json:"organization_id"` + // OrganizationID Organization ID + OrganizationID string `json:"organization_id"` } // WorkspacesDesignsMapping defines model for workspacesDesignsMapping. type WorkspacesDesignsMapping struct { + ID externalRef2.GeneralId `db:"id" json:"id"` CreatedAt externalRef2.Time `json:"created_at,omitempty"` DeletedAt externalRef2.Time `json:"deleted_at,omitempty"` DesignId externalRef2.DesignId `db:"design_id" json:"design_id"` - Id externalRef2.GeneralId `db:"id" json:"id"` UpdatedAt externalRef2.Time `json:"updated_at,omitempty"` WorkspaceId externalRef2.WorkspaceId `db:"workspace_id" json:"workspace_id"` } // WorkspacesEnvironmentsMapping defines model for workspacesEnvironmentsMapping. type WorkspacesEnvironmentsMapping struct { + ID externalRef2.GeneralId `db:"id" json:"id"` CreatedAt externalRef2.Time `json:"created_at,omitempty"` DeletedAt externalRef2.Time `json:"deleted_at,omitempty"` EnvironmentId externalRef2.EnvironmentId `db:"environment_id" json:"environment_id"` - Id externalRef2.GeneralId `db:"id" json:"id"` UpdatedAt externalRef2.Time `json:"updated_at,omitempty"` WorkspaceId externalRef2.WorkspaceId `db:"workspace_id" json:"workspace_id"` } // WorkspacesTeamsMapping defines model for workspacesTeamsMapping. type WorkspacesTeamsMapping struct { + ID externalRef2.GeneralId `db:"id" json:"id"` CreatedAt externalRef2.Time `json:"created_at,omitempty"` DeletedAt externalRef2.Time `json:"deleted_at,omitempty"` - Id externalRef2.GeneralId `db:"id" json:"id"` TeamId externalRef2.TeamId `db:"team_id" json:"team_id"` UpdatedAt externalRef2.Time `json:"updated_at,omitempty"` WorkspaceId externalRef2.WorkspaceId `db:"workspace_id" json:"workspace_id"` @@ -79,9 +79,9 @@ type WorkspacesTeamsMapping struct { // WorkspacesViewsMapping defines model for workspacesViewsMapping. type WorkspacesViewsMapping struct { + ID externalRef2.GeneralId `db:"id" json:"id"` CreatedAt externalRef2.Time `json:"created_at,omitempty"` DeletedAt externalRef2.Time `json:"deleted_at,omitempty"` - Id externalRef2.GeneralId `db:"id" json:"id"` UpdatedAt externalRef2.Time `json:"updated_at,omitempty"` ViewId externalRef2.ViewId `db:"view_id" json:"view_id"` WorkspaceId externalRef2.WorkspaceId `db:"workspace_id" json:"workspace_id"` diff --git a/schemas/constructs/openapi/workspace.yml b/schemas/constructs/openapi/workspace.yml index a3273af5d3..01aef7535f 100644 --- a/schemas/constructs/openapi/workspace.yml +++ b/schemas/constructs/openapi/workspace.yml @@ -44,7 +44,7 @@ components: $ref: './common/core.yml#/components/schemas/nullTime' workspacesTeamsMapping: properties: - id: + ID: $ref: ./common/core.yml#/components/schemas/general_id team_id: $ref: './common/core.yml#/components/schemas/team_id' @@ -58,7 +58,7 @@ components: $ref: './common/core.yml#/components/schemas/time' workspacesEnvironmentsMapping: properties: - id: + ID: $ref: ./common/core.yml#/components/schemas/general_id environment_id: $ref: './common/core.yml#/components/schemas/environment_id' @@ -72,7 +72,7 @@ components: $ref: './common/core.yml#/components/schemas/time' workspacesViewsMapping: properties: - id: + ID: $ref: ./common/core.yml#/components/schemas/general_id view_id: $ref: './common/core.yml#/components/schemas/view_id' @@ -86,7 +86,7 @@ components: $ref: './common/core.yml#/components/schemas/time' workspacesDesignsMapping: properties: - id: + ID: $ref: ./common/core.yml#/components/schemas/general_id design_id: $ref: './common/core.yml#/components/schemas/design_id' @@ -110,7 +110,7 @@ components: type: string description: Organization ID x-go-type-skip-optional-pointer: true - x-go-name: OrgId + x-go-name: OrganizationID x-oapi-codegen-extra-tags: json: organization_id required: @@ -127,7 +127,7 @@ components: type: string description: Organization ID x-go-type-skip-optional-pointer: true - x-go-name: OrgId + x-go-name: OrganizationID x-oapi-codegen-extra-tags: json: organization_id required: From 2a443685dae2ce70d7d6093f38478ac4b62749f4 Mon Sep 17 00:00:00 2001 From: Yash Sharma Date: Wed, 31 Jul 2024 08:10:52 +0530 Subject: [PATCH 4/4] Fix nullTime for deleted_At property Signed-off-by: Yash Sharma --- models/v1beta1/workspace.go | 8 ++++---- schemas/constructs/openapi/workspace.yml | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/models/v1beta1/workspace.go b/models/v1beta1/workspace.go index 392e9cfc36..abb4a646bd 100644 --- a/models/v1beta1/workspace.go +++ b/models/v1beta1/workspace.go @@ -51,7 +51,7 @@ type WorkspaceUpdatePayload struct { type WorkspacesDesignsMapping struct { ID externalRef2.GeneralId `db:"id" json:"id"` CreatedAt externalRef2.Time `json:"created_at,omitempty"` - DeletedAt externalRef2.Time `json:"deleted_at,omitempty"` + DeletedAt externalRef2.NullTime `json:"deleted_at,omitempty"` DesignId externalRef2.DesignId `db:"design_id" json:"design_id"` UpdatedAt externalRef2.Time `json:"updated_at,omitempty"` WorkspaceId externalRef2.WorkspaceId `db:"workspace_id" json:"workspace_id"` @@ -61,7 +61,7 @@ type WorkspacesDesignsMapping struct { type WorkspacesEnvironmentsMapping struct { ID externalRef2.GeneralId `db:"id" json:"id"` CreatedAt externalRef2.Time `json:"created_at,omitempty"` - DeletedAt externalRef2.Time `json:"deleted_at,omitempty"` + DeletedAt externalRef2.NullTime `json:"deleted_at,omitempty"` EnvironmentId externalRef2.EnvironmentId `db:"environment_id" json:"environment_id"` UpdatedAt externalRef2.Time `json:"updated_at,omitempty"` WorkspaceId externalRef2.WorkspaceId `db:"workspace_id" json:"workspace_id"` @@ -71,7 +71,7 @@ type WorkspacesEnvironmentsMapping struct { type WorkspacesTeamsMapping struct { ID externalRef2.GeneralId `db:"id" json:"id"` CreatedAt externalRef2.Time `json:"created_at,omitempty"` - DeletedAt externalRef2.Time `json:"deleted_at,omitempty"` + DeletedAt externalRef2.NullTime `json:"deleted_at,omitempty"` TeamId externalRef2.TeamId `db:"team_id" json:"team_id"` UpdatedAt externalRef2.Time `json:"updated_at,omitempty"` WorkspaceId externalRef2.WorkspaceId `db:"workspace_id" json:"workspace_id"` @@ -81,7 +81,7 @@ type WorkspacesTeamsMapping struct { type WorkspacesViewsMapping struct { ID externalRef2.GeneralId `db:"id" json:"id"` CreatedAt externalRef2.Time `json:"created_at,omitempty"` - DeletedAt externalRef2.Time `json:"deleted_at,omitempty"` + DeletedAt externalRef2.NullTime `json:"deleted_at,omitempty"` UpdatedAt externalRef2.Time `json:"updated_at,omitempty"` ViewId externalRef2.ViewId `db:"view_id" json:"view_id"` WorkspaceId externalRef2.WorkspaceId `db:"workspace_id" json:"workspace_id"` diff --git a/schemas/constructs/openapi/workspace.yml b/schemas/constructs/openapi/workspace.yml index 01aef7535f..2c7ede245e 100644 --- a/schemas/constructs/openapi/workspace.yml +++ b/schemas/constructs/openapi/workspace.yml @@ -55,7 +55,7 @@ components: updated_at: $ref: './common/core.yml#/components/schemas/time' deleted_at: - $ref: './common/core.yml#/components/schemas/time' + $ref: './common/core.yml#/components/schemas/nullTime' workspacesEnvironmentsMapping: properties: ID: @@ -69,7 +69,7 @@ components: updated_at: $ref: './common/core.yml#/components/schemas/time' deleted_at: - $ref: './common/core.yml#/components/schemas/time' + $ref: './common/core.yml#/components/schemas/nullTime' workspacesViewsMapping: properties: ID: @@ -83,7 +83,7 @@ components: updated_at: $ref: './common/core.yml#/components/schemas/time' deleted_at: - $ref: './common/core.yml#/components/schemas/time' + $ref: './common/core.yml#/components/schemas/nullTime' workspacesDesignsMapping: properties: ID: @@ -97,7 +97,7 @@ components: updated_at: $ref: './common/core.yml#/components/schemas/time' deleted_at: - $ref: './common/core.yml#/components/schemas/time' + $ref: './common/core.yml#/components/schemas/nullTime' workspaceUpdatePayload: properties: name: