Skip to content

Enhance workspace schema with metadata, UUID owner type, and consistent JSON field names#495

Open
Copilot wants to merge 3 commits intomasterfrom
copilot/enhance-workspace-schema
Open

Enhance workspace schema with metadata, UUID owner type, and consistent JSON field names#495
Copilot wants to merge 3 commits intomasterfrom
copilot/enhance-workspace-schema

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Dec 28, 2025

The workspace schema had structural differences preventing direct type aliasing with the Meshery remote provider: org_id vs organization_id JSON tags, Owner as string vs *uuid.UUID, and missing Metadata field.

Changes

Workspace Schema

  • Changed organization_id JSON tag from org_id to organization_id
  • Changed Owner field type from string to *uuid.UUID
  • Added metadata field using core.Map type
  • Added proper db: tags for all fields

Payload Schemas

  • Added metadata field to both WorkspacePayload and WorkspaceUpdatePayload

New Pagination Schemas

  • TeamsPage, EnvironmentPage, MesheryDesignPage, ViewsPage for related entity pagination

API Endpoints

  • Added comprehensive REST endpoints for workspace CRUD and resource management (designs, environments, teams, views)

Generated Type Comparison

Before:

type Workspace struct {
    OrganizationId uuid.UUID `json:"org_id" db:"org_id"`
    Owner          string    // missing metadata field
}

After:

type Workspace struct {
    OrganizationID uuid.UUID     `db:"organization_id" json:"organization_id"`
    Owner          *uuid.UUID    `db:"owner" json:"owner"`
    Metadata       core.Map      `db:"metadata" json:"metadata"`
}

Also fixed pre-existing typo in core schema: reponsesresponses.

Original prompt

@copilot, here is example use of the "workspace" model in a Meshery remote provider. See the comments. They identify where the "workspace" schema is lacking. I want you to enhance the workspace schema, making it a fully-complete and robust definition inclusive of any and all of the actions that might be taken against it and its responses.

package models

import (
	"database/sql"
	"time"

	"github.com/gobuffalo/pop/slices"
	"github.com/gofrs/uuid"

	// schemasWorkspace provides the official v1beta1 Workspace types.
	// However, there are structural differences that prevent direct type aliasing:
	// - Schema Workspace uses json:"org_id" while local uses json:"organization_id"
	// - Schema Workspace.Owner is string while local uses *uuid.UUID
	// - Schema WorkspacePage uses []Workspace while local uses []AvailableWorkspace
	// These local types are maintained for backward API compatibility.
	_ "github.com/meshery/schemas/models/v1beta1/workspace"
)

// Workspace represents a workspace entity.
// Note: The schema's Workspace type uses different JSON field names:
// - Schema uses json:"org_id" for OrganizationId, local uses json:"organization_id"
// - Schema uses string for Owner, local uses *uuid.UUID
// Migrating would change the API response format, so this local type is kept.
type Workspace struct {
	ID             uuid.UUID    `json:"id,omitempty" db:"id"`
	Name           string       `json:"name,omitempty" db:"name"`
	OrganizationID uuid.UUID    `json:"organization_id,omitempty" db:"organization_id"`
	Owner          *uuid.UUID   `json:"owner,omitempty" db:"owner"`
	Metadata       slices.Map   `json:"metadata" db:"metadata"`
	Description    string       `json:"description,omitempty" db:"description"`
	CreatedAt      time.Time    `json:"created_at,omitempty" db:"created_at"`
	UpdatedAt      time.Time    `json:"updated_at,omitempty" db:"updated_at"`
	DeletedAt      sql.NullTime `json:"deleted_at,omitempty" db:"deleted_at"`
}

// WorkspacePayload represents the request payload for creating a workspace.
// Note: The schema's WorkspacePayload uses string for OrganizationID and lacks Metadata.
// This local type includes Metadata and uses string for OrganizationID for consistency.
type WorkspacePayload struct {
	Name           string     `json:"name,omitempty"`
	Description    string     `json:"description,omitempty"`
	OrganizationID string     `json:"organization_id,omitempty"`
	Metadata       slices.Map `json:"metadata,omitempty"`
}

// WorkspacePage represents a paginated list of workspaces.
// Note: This uses AvailableWorkspace (with JOINed data) instead of Workspace.
type WorkspacePage struct {
	Page       int                  `json:"page"`
	PageSize   int                  `json:"page_size"`
	TotalCount int                  `json:"total_count"`
	Workspaces []AvailableWorkspace `json:"workspaces"`
}

// MesheryDesignPage - represents a page of meshery patterns
type MesheryDesignPage struct {
	Page       int               `json:"page"`
	PageSize   int               `json:"page_size"`
	TotalCount int               `json:"total_count"`
	Designs    []*MesheryPattern `json:"designs"`
}

func (w *Workspace) EventCategory() string {
	return "workspace"
}

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits December 28, 2025 19:27
…, and consistent JSON field names

Co-authored-by: hamza-mohd <135669921+hamza-mohd@users.noreply.github.com>
…e import

Co-authored-by: hamza-mohd <135669921+hamza-mohd@users.noreply.github.com>
Copilot AI changed the title [WIP] Enhance workspace schema for completeness and robustness Enhance workspace schema with metadata, UUID owner type, and consistent JSON field names Dec 28, 2025
Copilot AI requested a review from hamza-mohd December 28, 2025 19:35
@marblom007 marblom007 marked this pull request as ready for review December 29, 2025 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants