From 8cb9c8cfee1b1e0cef5efeb4a1afdbed45a38951 Mon Sep 17 00:00:00 2001 From: Shubham Upadhyay Date: Fri, 30 Aug 2024 15:37:17 +0530 Subject: [PATCH] Update structs for connection Signed-off-by: Shubham Upadhyay --- models/core/core.go | 10 + .../v1beta1/connection/connection_helper.go | 21 +- models/v1beta1/connection/connections.go | 211 ++++-- models/v1beta1/environment.go | 41 +- schemas/constructs/openapi/common/core.yml | 28 +- .../constructs/openapi/common/parameters.yml | 8 + schemas/constructs/openapi/connection.yml | 654 ++++++++++++------ schemas/constructs/openapi/environment.yml | 11 +- 8 files changed, 690 insertions(+), 294 deletions(-) diff --git a/models/core/core.go b/models/core/core.go index b09b00cf8e..919a780cd6 100644 --- a/models/core/core.go +++ b/models/core/core.go @@ -7,6 +7,7 @@ import ( "database/sql" "time" + "github.com/gobuffalo/pop/slices" "github.com/gofrs/uuid" openapi_types "github.com/oapi-codegen/runtime/types" ) @@ -20,6 +21,9 @@ type AvatarUrl = string // Bio defines model for bio. type Bio = string +// CommonId defines model for common_id. +type CommonId = uuid.UUID + // CreatedAt Timestamp when the resource was created. type CreatedAt = time.Time @@ -74,6 +78,9 @@ type NullTime = sql.NullTime // Number defines model for number. type Number = int +// NumberNullable defines model for number_nullable. +type NumberNullable = int + // OperationID defines model for operation_id. type OperationID = uuid.UUID @@ -105,6 +112,9 @@ type ResultsPage struct { // RoleNames defines model for roleNames. type RoleNames = []string +// SliceObject defines model for slice_object. +type SliceObject = slices.Map + // Status defines model for status. type Status = string diff --git a/models/v1beta1/connection/connection_helper.go b/models/v1beta1/connection/connection_helper.go index 0f413c827b..9de0eceea0 100644 --- a/models/v1beta1/connection/connection_helper.go +++ b/models/v1beta1/connection/connection_helper.go @@ -41,14 +41,29 @@ func (h *Connection) Create(db *database.Handler) (uuid.UUID, error) { // if not exists then create a new host and return the id if err == gorm.ErrRecordNotFound { - h.Id = hID + h.ID = hID err = db.Create(&h).Error if err != nil { return uuid.UUID{}, err } - return h.Id, nil + return h.ID, nil } // else return the id of the existing connection - return connection.Id, nil + return connection.ID, nil +} + +func (h *Connection) EventCategory() string { + return "connection" +} + +func (h *MesheryInstance) EventCategory() string { + return "connection" +} + +var ValidConnectionsKinds = map[ConnectionKind]bool{ + Meshery: true, + Kubernetes: true, + Prometheus: true, + Grafana: true, } diff --git a/models/v1beta1/connection/connections.go b/models/v1beta1/connection/connections.go index 70ffbaf543..03e9ecb69e 100644 --- a/models/v1beta1/connection/connections.go +++ b/models/v1beta1/connection/connections.go @@ -4,94 +4,155 @@ package connection import ( + "database/sql" "time" + "github.com/gobuffalo/pop/slices" "github.com/gofrs/uuid" - externalRef2 "github.com/meshery/schemas/models/core" + externalRef1 "github.com/meshery/schemas/models/core" + externalRef2 "github.com/meshery/schemas/models/v1beta1" +) + +// Defines values for ConnectionAction. +const ( + ConnectionActionDeleted ConnectionAction = "deleted" + ConnectionActionRegistered ConnectionAction = "registered" + ConnectionActionUpdated ConnectionAction = "updated" +) + +// Defines values for ConnectionKind. +const ( + Aws ConnectionKind = "aws" + Azure ConnectionKind = "azure" + Github ConnectionKind = "github" + Gke ConnectionKind = "gke" + Grafana ConnectionKind = "grafana" + Kubernetes ConnectionKind = "kubernetes" + Meshery ConnectionKind = "meshery" + Prometheus ConnectionKind = "prometheus" + Slack ConnectionKind = "slack" +) + +// Defines values for ConnectionRegistrationProcess. +const ( + PostRegistration ConnectionRegistrationProcess = "post_registration" + PreRegistration ConnectionRegistrationProcess = "pre_registration" + Registration ConnectionRegistrationProcess = "registration" ) // Defines values for ConnectionStatus. const ( - Connected ConnectionStatus = "connected" - Deleted ConnectionStatus = "deleted" - Disconnected ConnectionStatus = "disconnected" - Discovered ConnectionStatus = "discovered" - Ignored ConnectionStatus = "ignored" - Maintenance ConnectionStatus = "maintenance" - NotFound ConnectionStatus = "not found" - Registered ConnectionStatus = "registered" + ConnectionStatusConnected ConnectionStatus = "connected" + ConnectionStatusDeleted ConnectionStatus = "deleted" + ConnectionStatusDisconnected ConnectionStatus = "disconnected" + ConnectionStatusDiscovered ConnectionStatus = "discovered" + ConnectionStatusIgnored ConnectionStatus = "ignored" + ConnectionStatusMaintenance ConnectionStatus = "maintenance" + ConnectionStatusNotFound ConnectionStatus = "not_found" + ConnectionStatusRegistered ConnectionStatus = "registered" ) -// Connection Meshery Connections are managed and unmanaged resources that either through discovery or manual entry are tracked by Meshery. Learn more at https://docs.meshery.io/concepts/logical/connections -type Connection struct { - CreatedAt time.Time `json:"created_at" yaml:"created_at"` +// Defines values for ConnectionSubType. +const ( + Chat ConnectionSubType = "chat" + Cloud ConnectionSubType = "cloud" + Git ConnectionSubType = "git" + Identity ConnectionSubType = "identity" + Metrics ConnectionSubType = "metrics" + Orchestration ConnectionSubType = "orchestration" +) + +// Defines values for ConnectionType. +const ( + Collaboration ConnectionType = "collaboration" + Platform ConnectionType = "platform" + Telemetry ConnectionType = "telemetry" +) + +// ConnectionAction defines model for ConnectionAction. +type ConnectionAction string + +// ConnectionKind defines model for ConnectionKind. +type ConnectionKind string - // CredentialId Credential ID - CredentialId uuid.UUID `json:"credential_id" yaml:"credential_id"` - DeletedAt time.Time `json:"deleted_at" yaml:"deleted_at"` +// ConnectionRegistrationProcess defines model for ConnectionRegistrationProcess. +type ConnectionRegistrationProcess string - // Id ID - Id uuid.UUID `json:"id" yaml:"id"` +// ConnectionStatus Connection Status +type ConnectionStatus string + +// ConnectionSubType defines model for ConnectionSubType. +type ConnectionSubType string + +// ConnectionType defines model for ConnectionType. +type ConnectionType string + +// Connection defines model for connection. +type Connection struct { + ID externalRef1.GeneralId `db:"id" json:"id"` + CreatedAt time.Time `db:"created_at" json:"created_at,omitempty" yaml:"created_at"` + CredentialID *uuid.UUID `db:"credential_id" json:"credential_id"` + + // DeletedAt SQL null Timestamp to handle null values of time. + DeletedAt sql.NullTime `db:"deleted_at" json:"deleted_at"` + Environments []externalRef2.Environment `db:"-" json:"environments"` // Kind Connection Kind - Kind string `json:"kind" yaml:"kind"` - Metadata map[string]interface{} `json:"metadata,omitempty" yaml:"metadata,omitempty" gorm:"type:bytes;serializer:json"` + Kind string `db:"kind" json:"kind"` + Metadata slices.Map `db:"metadata" json:"metadata"` // Name Connection Name - Name string `json:"name" yaml:"name"` + Name string `db:"name" json:"name"` // Status Connection Status - Status ConnectionStatus `json:"status" yaml:"status"` + Status ConnectionStatus `db:"status" json:"status"` // SubType Connection Subtype - SubType string `json:"sub_type" yaml:"sub_type"` + SubType string `db:"sub_type" json:"sub_type"` // Type Connection Type - Type string `json:"type" yaml:"type"` - UpdatedAt time.Time `json:"updated_at" yaml:"updated_at"` - - // UserID A Universally Unique Identifier used to uniquely identify entites in Meshery. The UUID core defintion is used across different schemas. - UserID uuid.UUID `json:"user_id" yaml:"user_id"` + Type string `db:"type" json:"type"` + UpdatedAt time.Time `db:"updated_at" json:"updated_at,omitempty" yaml:"updated_at"` + UserID *uuid.UUID `db:"user_id" json:"user_id"` } -// ConnectionStatus Connection Status -type ConnectionStatus string - // ConnectionPage defines model for connectionPage. type ConnectionPage struct { - Connections []Connection `json:"connections,omitempty"` - Page int `json:"page,omitempty"` - PageSize int `json:"page_size,omitempty"` - ResultType string `json:"resultType,omitempty"` - TotalCount int `json:"total_count,omitempty"` + Connections []Connection `json:"connections"` + Page externalRef1.NumberNullable `json:"page"` + PageSize externalRef1.NumberNullable `json:"page_size"` + TotalCount externalRef1.NumberNullable `json:"total_count"` } // ConnectionStatusInfo defines model for connectionStatusInfo. type ConnectionStatusInfo struct { // Count Number of connections having the status Count int `json:"count,omitempty"` - Status externalRef2.Text `json:"status,omitempty"` + Status externalRef1.Text `json:"status,omitempty"` } // ConnectionsStatusPage defines model for connectionsStatusPage. type ConnectionsStatusPage struct { ConnectionsStatus []ConnectionStatusInfo `json:"connections_status,omitempty"` + Page externalRef1.Number `json:"page,omitempty"` + PageSize externalRef1.Number `json:"page_size,omitempty"` + TotalCount externalRef1.Number `json:"total_count,omitempty"` } // K8sContext defines model for k8sContext. type K8sContext struct { - Auth externalRef2.MapObject `json:"auth,omitempty"` - Cluster externalRef2.MapObject `json:"cluster,omitempty"` - CreatedAt externalRef2.Time `json:"created_at,omitempty"` - CreatedBy externalRef2.Id `json:"created_by,omitempty"` - DeploymentType *string `json:"deployment_type,omitempty"` - Id externalRef2.Id `json:"id,omitempty"` - KubernetesServerId externalRef2.Id `json:"kubernetes_server_id,omitempty"` - MesheryInstanceId externalRef2.Id `json:"meshery_instance_id,omitempty"` - Name externalRef2.Text `json:"name,omitempty"` - Owner externalRef2.Id `json:"owner,omitempty"` - Server *string `json:"server,omitempty"` - UpdatedAt externalRef2.Time `json:"updated_at,omitempty"` + Auth externalRef1.SliceObject `json:"auth,omitempty"` + Cluster externalRef1.SliceObject `json:"cluster,omitempty"` + CreatedAt externalRef1.Time `json:"created_at,omitempty"` + CreatedBy externalRef1.Id `json:"created_by,omitempty"` + DeploymentType *string `json:"deployment_type,omitempty"` + Id externalRef1.GeneralId `db:"id" json:"id"` + KubernetesServerId externalRef1.Id `json:"kubernetes_server_id,omitempty"` + MesheryInstanceId externalRef1.Id `json:"meshery_instance_id,omitempty"` + Name externalRef1.Text `json:"name,omitempty"` + Owner externalRef1.Id `json:"owner,omitempty"` + Server *string `json:"server,omitempty"` + UpdatedAt externalRef1.Time `json:"updated_at,omitempty"` } // K8sContextPersistResponse defines model for k8sContextPersistResponse. @@ -102,32 +163,46 @@ type K8sContextPersistResponse struct { // MesheryInstance defines model for mesheryInstance. type MesheryInstance struct { - CreatedAt externalRef2.Time `json:"created_at,omitempty"` - DeletedAt externalRef2.Time `json:"deleted_at,omitempty"` - Id externalRef2.Id `json:"id,omitempty"` - Name externalRef2.Text `json:"name,omitempty"` - ServerBuildSha externalRef2.Text `json:"server_build_sha,omitempty"` - ServerId externalRef2.Text `json:"server_id,omitempty"` - ServerLocation externalRef2.Endpoint `json:"server_location,omitempty"` - ServerVersion externalRef2.Text `json:"server_version,omitempty"` - Status externalRef2.Text `json:"status,omitempty"` - UpdatedAt externalRef2.Time `json:"updated_at,omitempty"` + CreatedAt externalRef1.Time `json:"created_at,omitempty"` + + // DeletedAt SQL null Timestamp to handle null values of time. + DeletedAt externalRef1.NullTime `json:"deleted_at,omitempty"` + + // ID Connection id + ID string `json:"id,omitempty"` + Name externalRef1.Text `json:"name,omitempty"` + ServerBuildSha externalRef1.Text `json:"server_build_sha,omitempty"` + + // ServerID Connected server id + ServerID string `json:"server_id,omitempty"` + ServerLocation externalRef1.Endpoint `json:"server_location,omitempty"` + ServerVersion externalRef1.Text `json:"server_version,omitempty"` + UpdatedAt externalRef1.Time `json:"updated_at,omitempty"` } -// ConnectionId defines model for connectionId. -type ConnectionId = externalRef2.Id +// MesheryInstancePage defines model for mesheryInstancePage. +type MesheryInstancePage struct { + MesheryInstances []MesheryInstance `json:"mesheryInstances,omitempty"` + Page externalRef1.Number `json:"page,omitempty"` + PageSize externalRef1.Number `json:"page_size,omitempty"` + TotalCount externalRef1.Number `json:"total_count,omitempty"` +} -// ConnectionKind defines model for connectionKind. -type ConnectionKind = externalRef2.Text +// ConnectionId defines model for connectionId. +type ConnectionId = externalRef1.Id // ServerId defines model for serverId. -type ServerId = externalRef2.Id +type ServerId = externalRef1.Id // ConnectionPayload defines model for connectionPayload. type ConnectionPayload struct { - CredentialSecret externalRef2.MapObject `json:"credential_secret,omitempty"` - Kind externalRef2.Text `json:"kind,omitempty"` - Metadata externalRef2.MapObject `json:"metadata,omitempty"` - SubType externalRef2.Text `json:"sub_type,omitempty"` - Type externalRef2.Text `json:"type,omitempty"` + ConnectionID uuid.UUID `json:"id"` + CredentialID *uuid.UUID `json:"credential_id,omitempty"` + CredentialSecret externalRef1.SliceObject `json:"credential_secret,omitempty"` + Kind externalRef1.Text `json:"kind,omitempty"` + Metadata externalRef1.SliceObject `json:"metadata,omitempty"` + Name externalRef1.Text `json:"name,omitempty"` + Status externalRef1.Text `json:"status,omitempty"` + SubType externalRef1.Text `json:"sub_type,omitempty"` + Type externalRef1.Text `json:"type,omitempty"` } diff --git a/models/v1beta1/environment.go b/models/v1beta1/environment.go index 3eebd1227c..51e8dc7e7f 100644 --- a/models/v1beta1/environment.go +++ b/models/v1beta1/environment.go @@ -1,51 +1,52 @@ -// Package v1beta1 provides primitives to interact with the openapi HTTP API. +// Package environment 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 ( "github.com/gofrs/uuid" - externalRef2 "github.com/meshery/schemas/models/core" + externalRef1 "github.com/meshery/schemas/models/core" ) // Environment defines model for environment. type Environment struct { - ID externalRef2.EnvironmentId `db:"id" json:"id"` - CreatedAt externalRef2.Time `json:"created_at,omitempty"` + ID externalRef1.GeneralId `db:"id" json:"id"` + CreatedAt externalRef1.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"` + DeletedAt externalRef1.NullTime `json:"deleted_at,omitempty"` + Description externalRef1.Text `json:"description,omitempty"` + Metadata externalRef1.MapObject `json:"metadata,omitempty"` + Name externalRef1.Text `json:"name,omitempty"` + OrganizationId externalRef1.OrganizationId `db:"organization_id" json:"organization_id"` + Owner *uuid.UUID `db:"owner" json:"owner"` + UpdatedAt externalRef1.Time `json:"updated_at,omitempty"` } // EnvironmentConnectionMapping defines model for environmentConnectionMapping. type EnvironmentConnectionMapping struct { - ID externalRef2.EnvironmentId `db:"id" json:"id"` - ConnectionId uuid.UUID `db:"connection_id" json:"connection_id"` - CreatedAt externalRef2.Time `json:"created_at,omitempty"` + ID externalRef1.GeneralId `db:"id" json:"id"` + ConnectionId uuid.UUID `db:"connection_id" json:"connection_id"` + CreatedAt externalRef1.Time `json:"created_at,omitempty"` // DeletedAt SQL null Timestamp to handle null values of time. - DeletedAt externalRef2.NullTime `json:"deleted_at,omitempty"` + DeletedAt externalRef1.NullTime `json:"deleted_at,omitempty"` EnvironmentId uuid.UUID `db:"environment_id" json:"environment_id"` - UpdatedAt externalRef2.Time `json:"updated_at,omitempty"` + UpdatedAt externalRef1.Time `json:"updated_at,omitempty"` } // EnvironmentPage defines model for environmentPage. type EnvironmentPage struct { Environments []Environment `json:"environments,omitempty"` - Page externalRef2.Number `json:"page,omitempty"` - PageSize externalRef2.Number `json:"page_size,omitempty"` - TotalCount externalRef2.Number `json:"total_count,omitempty"` + Page externalRef1.Number `json:"page,omitempty"` + PageSize externalRef1.Number `json:"page_size,omitempty"` + TotalCount externalRef1.Number `json:"total_count,omitempty"` } // EnvironmentPayload defines model for environmentPayload. type EnvironmentPayload struct { // OrgId Organization ID OrgId string `json:"organization_id"` - Description externalRef2.Text `json:"description,omitempty"` - Name externalRef2.Text `json:"name"` + Description externalRef1.Text `json:"description,omitempty"` + Name externalRef1.Text `json:"name"` } diff --git a/schemas/constructs/openapi/common/core.yml b/schemas/constructs/openapi/common/core.yml index 2d076604c2..32a2d68664 100644 --- a/schemas/constructs/openapi/common/core.yml +++ b/schemas/constructs/openapi/common/core.yml @@ -35,6 +35,11 @@ components: number: type: integer x-go-type-skip-optional-pointer: true + + number_nullable: + type: integer + nullable: true + x-go-type-skip-optional-pointer: true avatar_url: type: string @@ -46,6 +51,16 @@ components: additionalProperties: type: string x-go-type-skip-optional-pointer: true + + slice_object: + type: object + additionalProperties: + type: string + x-go-type-skip-optional-pointer: true + format: slices.Map + x-go-type: slices.Map + x-go-type-import: + path: github.com/gobuffalo/pop/slices status: type: string #oneOf: ["active", "pending", "inactive"]? @@ -168,8 +183,8 @@ components: x-go-type-import: path: github.com/gofrs/uuid x-oapi-codegen-extra-tags: - db: org_id - json: org_id + db: organization_id + json: organization_id x-go-type-name: OrganizationId x-go-type-skip-optional-pointer: true @@ -185,6 +200,14 @@ components: x-go-type-name: GeneralId x-go-type-skip-optional-pointer: true + common_id: + type: string + format: uuid + x-go-type: uuid.UUID + x-go-type-import: + path: github.com/gofrs/uuid + x-go-type-name: CommonId + environment_id: type: string format: uuid @@ -317,7 +340,6 @@ components: x-oapi-codegen-extra-tags: db: created_at yaml: created_at - x-go-type-skip-optional-pointer: true updated_at: diff --git a/schemas/constructs/openapi/common/parameters.yml b/schemas/constructs/openapi/common/parameters.yml index cd38e08093..a58024dcbf 100644 --- a/schemas/constructs/openapi/common/parameters.yml +++ b/schemas/constructs/openapi/common/parameters.yml @@ -234,5 +234,13 @@ components: name: status in: query description: Get models based on status, e.g 'ignored', 'registered' + schema: + type: string + + connectionKind: + name: connectionKind + in: path + description: "Connection kind (eg: Meshery)" + required: true schema: type: string \ No newline at end of file diff --git a/schemas/constructs/openapi/connection.yml b/schemas/constructs/openapi/connection.yml index d45acdf340..84942bbc47 100644 --- a/schemas/constructs/openapi/connection.yml +++ b/schemas/constructs/openapi/connection.yml @@ -16,23 +16,187 @@ security: - jwt: [] tags: - name: integrations - description: APIs for integrations + description: APIs for integrations components: schemas: + ConnectionRegistrationProcess: + type: string + enum: + - pre_registration + - post_registration + - registration + + ConnectionType: + type: string + enum: + - platform + - telemetry + - collaboration + + ConnectionKind: + type: string + enum: + - meshery + - grafana + - prometheus + - gke + - aws + - azure + - slack + - github + - kubernetes + + ConnectionAction: + type: string + enum: + - registered + - deleted + - updated + + ConnectionSubType: + type: string + enum: + - cloud + - identity + - metrics + - chat + - git + - orchestration + + ConnectionStatus: + type: string + description: Connection Status + x-go-type-skip-optional-pointer: true + x-oapi-codegen-extra-tags: + db: status + json: status + enum: + - discovered + - registered + - connected + - ignored + - maintenance + - disconnected + - deleted + - not_found + connection: - $ref: ../v1beta1/connection.json + properties: + ID: + $ref: './common/core.yml#/components/schemas/general_id' + description: ID + name: + type: string + x-oapi-codegen-extra-tags: + db: name + json: name + description: Connection Name + x-go-type-skip-optional-pointer: true + credential_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: credential_id + json: credential_id + x-go-name: CredentialID + type: + type: string + x-oapi-codegen-extra-tags: + db: type + json: type + description: Connection Type + x-go-type-skip-optional-pointer: true + sub_type: + type: string + x-oapi-codegen-extra-tags: + db: sub_type + json: sub_type + description: Connection Subtype + x-go-type-skip-optional-pointer: true + kind: + type: string + x-oapi-codegen-extra-tags: + db: kind + json: kind + description: Connection Kind + x-go-type-skip-optional-pointer: true + metadata: + type: object + additionalProperties: + x-go-type-skip-optional-pointer: true + format: slices.Map + x-go-type: slices.Map + x-go-type-import: + path: github.com/gobuffalo/pop/slices + x-oapi-codegen-extra-tags: + db: metadata + json: metadata + status: + $ref: '#/components/schemas/ConnectionStatus' + user_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: user_id + json: user_id + x-go-name: UserID + created_at: + x-go-type: time.Time + type: string + format: date-time + x-go-name: CreatedAt + x-oapi-codegen-extra-tags: + db: created_at + yaml: created_at + x-go-type-skip-optional-pointer: true + updated_at: + x-go-type: time.Time + type: string + format: date-time + x-go-name: UpdatedAt + x-oapi-codegen-extra-tags: + db: updated_at + yaml: updated_at + x-go-type-skip-optional-pointer: true + deleted_at: + description: SQL null Timestamp to handle null values of time. + x-go-type: sql.NullTime + type: string + x-go-type-skip-optional-pointer: true + x-oapi-codegen-extra-tags: + db: deleted_at + json: deleted_at + environments: + x-go-type-skip-optional-pointer: true + type: array + x-oapi-codegen-extra-tags: + db: '-' + json: environments + items: + $ref: './environment.yml#/components/schemas/environment' + mesheryInstance: properties: id: - $ref: ./common/core.yml#/components/schemas/id + type: string + x-go-type-skip-optional-pointer: true + x-go-name: ID description: Connection id name: $ref: ./common/core.yml#/components/schemas/text description: Connection name server_id: - $ref: ./common/core.yml#/components/schemas/text + type: string + x-go-type-skip-optional-pointer: true description: Connected server id + x-go-name: ServerID server_version: $ref: ./common/core.yml#/components/schemas/text description: Running server version @@ -46,21 +210,37 @@ components: updated_at: $ref: ./common/core.yml#/components/schemas/time deleted_at: - $ref: ./common/core.yml#/components/schemas/time - status: - $ref: ./common/core.yml#/components/schemas/text - description: Status + $ref: ./common/core.yml#/components/schemas/nullTime connectionPage: - allOf: - - $ref: ./common/core.yml#/components/schemas/resultsPage - - type: object - properties: - connections: - x-go-type-skip-optional-pointer: true - type: array - items: - $ref: "#/components/schemas/connection" + properties: + page: + $ref: ./common/core.yml#/components/schemas/number_nullable + page_size: + $ref: ./common/core.yml#/components/schemas/number_nullable + total_count: + $ref: ./common/core.yml#/components/schemas/number_nullable + connections: + x-go-type-skip-optional-pointer: true + type: array + nullable: true + items: + $ref: "#/components/schemas/connection" + + mesheryInstancePage: + properties: + page: + $ref: ./common/core.yml#/components/schemas/number + page_size: + $ref: ./common/core.yml#/components/schemas/number + total_count: + $ref: ./common/core.yml#/components/schemas/number + mesheryInstances: + x-go-type-skip-optional-pointer: true + type: array + items: + $ref: "#/components/schemas/mesheryInstance" + connectionStatusInfo: properties: status: @@ -73,6 +253,12 @@ components: connectionsStatusPage: properties: + page: + $ref: ./common/core.yml#/components/schemas/number + page_size: + $ref: ./common/core.yml#/components/schemas/number + total_count: + $ref: ./common/core.yml#/components/schemas/number connections_status: x-go-type-skip-optional-pointer: true type: array @@ -85,13 +271,13 @@ components: k8sContext: properties: id: - $ref: ./common/core.yml#/components/schemas/id + $ref: ./common/core.yml#/components/schemas/general_id name: $ref: ./common/core.yml#/components/schemas/text auth: - $ref: ./common/core.yml#/components/schemas/map_object + $ref: ./common/core.yml#/components/schemas/slice_object cluster: - $ref: ./common/core.yml#/components/schemas/map_object + $ref: ./common/core.yml#/components/schemas/slice_object server: type: string owner: @@ -125,16 +311,41 @@ components: kind: $ref: ./common/core.yml#/components/schemas/text description: Kind + connection_id: + type: string + format: uuid + x-go-type: uuid.UUID + x-go-type-import: + path: github.com/gofrs/uuid + x-go-name: ConnectionID + x-oapi-codegen-extra-tags: + json: id + x-go-type-skip-optional-pointer: true type: $ref: ./common/core.yml#/components/schemas/text description: Connection type + name: + $ref: ./common/core.yml#/components/schemas/text + description: Connection name + status: + $ref: ./common/core.yml#/components/schemas/text + description: Connection status sub_type: $ref: ./common/core.yml#/components/schemas/text description: Connection subtype credential_secret: - $ref: ./common/core.yml#/components/schemas/map_object + $ref: ./common/core.yml#/components/schemas/slice_object metadata: - $ref: ./common/core.yml#/components/schemas/map_object + $ref: ./common/core.yml#/components/schemas/slice_object + credential_id: + type: string + format: uuid + x-go-type: uuid.UUID + x-go-type-import: + path: github.com/gofrs/uuid + x-go-name: CredentialID + x-go-type-skip-optional-pointer: false + securitySchemes: jwt: type: http @@ -142,13 +353,6 @@ components: bearerFormat: JWT # any special parameters for this tag parameters: - connectionKind: - name: connectionKind - in: path - description: "Connection kind (eg: Meshery)" - required: true - schema: - $ref: ./common/core.yml#/components/schemas/text connectionId: name: connectionId in: path @@ -164,173 +368,225 @@ components: $ref: ./common/core.yml#/components/schemas/id required: true # any special response for this tag -paths: - /api/integrations/connections: - post: - tags: - - integrations - operationId: RegisterConnection - summary: Register Connection - description: Register with Meshery Cloud - requestBody: - $ref: "#/components/requestBodies/connectionPayload" - responses: - "200": - description: Inserted connection - content: - application/json: - schema: - $ref: "#/components/schemas/connection" - "401": - $ref: ./common/responses.yml#/401 - "500": - $ref: ./common/responses.yml#/500 - get: - tags: - - integrations - operationId: GetConnections - summary: Get connections - description: Get connections - parameters: - - $ref: ./common/parameters.yml#/components/parameters/page - - $ref: ./common/parameters.yml#/components/parameters/page_size - - $ref: ./common/parameters.yml#/components/parameters/search - - $ref: ./common/parameters.yml#/components/parameters/order - responses: - "200": - description: Paginated list of connections - content: - application/json: - schema: - $ref: "#/components/schemas/connectionPage" - "401": - $ref: ./common/responses.yml#/401 - "500": - $ref: ./common/responses.yml#/500 - /api/integrations/connections/{connectionId}: - put: - tags: - - integrations - operationId: EditConnectionByID - summary: Edit Connection by ID - description: Edit registered connection using the connection ID - parameters: - - $ref: "#/components/parameters/connectionId" - requestBody: - $ref: "#/components/requestBodies/connectionPayload" - responses: - "200": - description: Edited connection - content: - application/json: - schema: - $ref: "#/components/schemas/connection" - "401": - $ref: ./common/responses.yml#/401 - "500": - $ref: ./common/responses.yml#/500 - /api/integrations/connections/status: - get: - tags: - - integrations - operationId: GetConnectionStatus - summary: Get status of all connections - description: Get summary about the status of all connections - responses: - "200": - description: Status of connections - content: - application/json: - schema: - $ref: "#/components/schemas/connectionsStatusPage" - "401": - $ref: ./common/responses.yml#/401 - "500": - $ref: ./common/responses.yml#/500 - /api/integrations/connections/{connectionKind}: - get: - tags: - - integrations - operationId: GetConnectionsByKind - summary: Get connections by kind - description: Get connections by kind - parameters: - - $ref: "#/components/parameters/connectionKind" - - $ref: ./common/parameters.yml#/components/parameters/page - - $ref: ./common/parameters.yml#/components/parameters/page_size - - $ref: ./common/parameters.yml#/components/parameters/search - - $ref: ./common/parameters.yml#/components/parameters/order - responses: - "200": - description: Connections by kind - content: - application/json: - schema: - type: object - "401": - $ref: ./common/responses.yml#/401 - "500": - $ref: ./common/responses.yml#/500 - security: [] - delete: - tags: - - integrations - operationId: DeleteConnection - summary: Delete connection - description: Delete registered connection - parameters: - - $ref: "#/components/parameters/connectionKind" - responses: - "200": - description: Deleted connection - content: - application/json: - schema: - $ref: "#/components/schemas/connection" - "401": - $ref: ./common/responses.yml#/401 - "500": - $ref: ./common/responses.yml#/500 - /api/integrations/connections/{connectionKind}/{connectionId}: - get: - tags: - - integrations - operationId: GetConnectionsByKindAndConnectionID - summary: Get connections by kind and connectionID. - description: Get connections by kind (kind is required because this API returns the results in non std format of a connection) - parameters: - - $ref: "#/components/parameters/connectionKind" - - $ref: "#/components/parameters/connectionId" - - $ref: "./common/parameters.yml#/components/parameters/page" - - $ref: ./common/parameters.yml#/components/parameters/page_size - - $ref: "./common/parameters.yml#/components/parameters/search" - - $ref: "./common/parameters.yml#/components/parameters/order" - responses: - "200": - description: Connections by kind - content: - application/json: - schema: - type: object - oneOf: - - $ref: "#/components/schemas/k8sContextPersistResponse" - "401": - $ref: ./common/responses.yml#/401 - "500": - $ref: ./common/responses.yml#/500 - /api/integrations/connections/meshery/{mesheryServerID}: - delete: - tags: - - integrations - operationId: DeleteMesheryConnection - summary: Delete Meshery connection - description: Deletes a given meshery connection. This is generally used for deleting connections from Meshery Server UI where UI is not aware of connection IDs. - parameters: - - $ref: "#/components/parameters/serverId" - responses: - "200": - $ref: ./common/responses.yml#/200 - "401": - $ref: ./common/responses.yml#/401 - "500": - $ref: ./common/responses.yml#/500 +# paths: +# /api/integrations/connections: +# post: +# tags: +# - integrations +# operationId: RegisterConnection +# summary: Register Connection +# description: Register with Meshery Cloud +# requestBody: +# $ref: "#/components/requestBodies/connectionPayload" +# responses: +# '200': +# description: Paginated registered connection +# content: +# application/json: +# schema: +# $ref: '#/components/schemas/connectionPage' +# "401": +# $ref: ./common/responses.yml#/401 +# "500": +# $ref: ./common/responses.yml#/500 +# get: +# tags: +# - integrations +# operationId: GetConnections +# summary: Get connections +# description: Get connections +# parameters: +# - $ref: ./common/parameters.yml#/components/parameters/page +# - $ref: ./common/parameters.yml#/components/parameters/page_size +# - $ref: ./common/parameters.yml#/components/parameters/search +# - $ref: ./common/parameters.yml#/components/parameters/order +# responses: +# "200": +# description: Paginated list of connections +# content: +# application/json: +# schema: +# $ref: "#/components/schemas/connectionPage" +# "401": +# $ref: ./common/responses.yml#/401 +# "500": +# $ref: ./common/responses.yml#/500 +# /api/integrations/connections/{connectionId}: +# put: +# tags: +# - integrations +# operationId: EditConnectionByID +# summary: Edit Connection by ID +# description: Edit registered connection using the connection ID +# parameters: +# - $ref: "#/components/parameters/connectionId" +# requestBody: +# $ref: "#/components/requestBodies/connectionPayload" +# responses: +# "200": +# description: Edited connection +# content: +# application/json: +# schema: +# $ref: "#/components/schemas/connectionPage" +# "401": +# $ref: ./common/responses.yml#/401 +# "500": +# $ref: ./common/responses.yml#/500 +# delete: +# tags: +# - integrations +# operationId: DeleteConnection +# summary: Delete connection +# description: Delete registered connection +# parameters: +# - $ref: '#/components/parameters/connectionId' +# responses: +# '200': +# description: Deleted connection +# content: +# application/json: +# schema: +# $ref: '#/components/schemas/connectionPage' +# '401': +# $ref: './common/responses.yml#/401' +# '500': +# $ref: './common/responses.yml#/500' +# /api/integrations/connections/status/{connectionId}: +# put: +# tags: +# - integrations +# operationId: UpdateConnectionStatusByID +# summary: Update Connection Status by ID +# description: Edit connection status using the connection ID +# parameters: +# - $ref: '#/components/parameters/connectionId' +# requestBody: +# description: Body containing connection status to update. +# required: true +# content: +# text/plain: +# schema: +# type: string +# responses: +# '200': +# description: Updated connection +# content: +# application/json: +# schema: +# $ref: '#/components/schemas/connection' +# '500': +# description: Event containing error details in metadata +# content: +# application/json: +# schema: +# $ref: ./events.yml#/components/schemas/event +# /api/integrations/connections/status: +# get: +# tags: +# - integrations +# operationId: GetConnectionStatus +# summary: Get status of all connections +# description: Get summary about the status of all connections +# responses: +# "200": +# description: Status of connections +# content: +# application/json: +# schema: +# $ref: "#/components/schemas/connectionsStatusPage" +# "401": +# $ref: ./common/responses.yml#/401 +# "500": +# $ref: ./common/responses.yml#/500 +# /api/integrations/connections/{connectionKind}: +# get: +# tags: +# - integrations +# operationId: GetConnectionsByKind +# summary: Get connections by kind +# description: Get connections by kind +# parameters: +# - $ref: "#/components/parameters/connectionKind" +# - $ref: ./common/parameters.yml#/components/parameters/page +# - $ref: ./common/parameters.yml#/components/parameters/page_size +# - $ref: ./common/parameters.yml#/components/parameters/search +# - $ref: ./common/parameters.yml#/components/parameters/order +# responses: +# "200": +# description: Connections by kind +# content: +# application/json: +# schema: +# type: object +# "401": +# $ref: ./common/responses.yml#/401 +# "500": +# $ref: ./common/responses.yml#/500 +# security: [] +# delete: +# tags: +# - integrations +# operationId: DeleteConnection +# summary: Delete connection +# description: Delete registered connection +# parameters: +# - $ref: "#/components/parameters/connectionKind" +# responses: +# "200": +# description: Deleted connection +# content: +# application/json: +# schema: +# $ref: "#/components/schemas/connection" +# "401": +# $ref: ./common/responses.yml#/401 +# "500": +# $ref: ./common/responses.yml#/500 +# /api/integrations/connections/{connectionKind}/{connectionId}: +# get: +# tags: +# - integrations +# operationId: GetConnectionsByKindAndConnectionID +# summary: Get connections by kind and connectionID. +# description: Get connections by kind (kind is required because this API returns the results in non std format of a connection) +# parameters: +# - $ref: "#/components/parameters/connectionKind" +# - $ref: "#/components/parameters/connectionId" +# - $ref: "./common/parameters.yml#/components/parameters/page" +# - $ref: ./common/parameters.yml#/components/parameters/page_size +# - $ref: "./common/parameters.yml#/components/parameters/search" +# - $ref: "./common/parameters.yml#/components/parameters/order" +# responses: +# "200": +# description: Connections by kind +# content: +# application/json: +# schema: +# type: object +# oneOf: +# - $ref: "#/components/schemas/k8sContextPersistResponse" +# "401": +# $ref: ./common/responses.yml#/401 +# "500": +# $ref: ./common/responses.yml#/500 +# /api/integrations/connections/meshery/{mesheryServerID}: +# delete: +# tags: +# - integrations +# operationId: DeleteMesheryConnection +# summary: Delete Meshery connection +# description: Deletes a given meshery connection. This is generally used for deleting connections from Meshery Server UI where UI is not aware of connection IDs. +# parameters: +# - $ref: "#/components/parameters/serverId" +# responses: +# "200": +# description: Deleted Meshery connection +# content: +# application/json: +# schema: +# $ref: '#/components/schemas/connectionPage' +# "401": +# $ref: ./common/responses.yml#/401 +# "500": +# $ref: ./common/responses.yml#/500 diff --git a/schemas/constructs/openapi/environment.yml b/schemas/constructs/openapi/environment.yml index 51bcfa1732..65bf79b4c7 100644 --- a/schemas/constructs/openapi/environment.yml +++ b/schemas/constructs/openapi/environment.yml @@ -35,7 +35,16 @@ components: organization_id: $ref: ./common/core.yml#/components/schemas/organization_id owner: - $ref: ./common/core.yml#/components/schemas/text + type: string + format: uuid + x-go-type: uuid.UUID + x-go-type-import: + path: github.com/gofrs/uuid + x-oapi-codegen-extra-tags: + db: owner + json: owner + metadata: + $ref: ./common/core.yml#/components/schemas/map_object created_at: $ref: ./common/core.yml#/components/schemas/time updated_at: