From 94c2a8c8621c4b4f873c3762dc713daf8f830b7d Mon Sep 17 00:00:00 2001 From: sph Date: Mon, 9 Jan 2023 19:57:33 +0800 Subject: [PATCH] fix v2 api --- openapi/v1/restful/accesstoken.yaml | 169 +++++++++++++---------- openapi/v1/restful/event.yaml | 38 +++--- openapi/v1/restful/member.yaml | 101 ++++++++------ openapi/v1/restful/pipelinerun.yaml | 202 ++++++++++++++++++++++++---- openapi/v1/restful/terminal.yaml | 8 +- openapi/v1/restful/webhook.yaml | 2 +- openapi/v2/restful/accesstoken.yaml | 38 ++++-- openapi/v2/restful/event.yaml | 16 +-- openapi/v2/restful/member.yaml | 96 +++++++------ openapi/v2/restful/pipelinerun.yaml | 165 ++++++++++++++++------- openapi/v2/restful/terminal.yaml | 8 +- 11 files changed, 579 insertions(+), 264 deletions(-) diff --git a/openapi/v1/restful/accesstoken.yaml b/openapi/v1/restful/accesstoken.yaml index 81f4fefb..927453ab 100644 --- a/openapi/v1/restful/accesstoken.yaml +++ b/openapi/v1/restful/accesstoken.yaml @@ -30,14 +30,17 @@ paths: content: application/json: schema: - $ref: "#/definitions/CreateResourceScopedAccessTokenReq" + $ref: "#/components/schemas/CreateResourceScopedAccessTokenReq" responses: "200": description: Success content: application/json: schema: - $ref: "#/definitions/CreateResourceScopedAccessTokenResp" + type: object + properties: + data: + $ref: "#/components/schemas/CreateResourceScopedAccessTokenResp" default: description: Unexpected error content: @@ -55,9 +58,16 @@ paths: content: application/json: schema: - type: array - items: - $ref: "#/definitions/AccessTokenDetailWithRole" + type: object + properties: + data: + type: object + properties: + items: + type: array + $ref: "#/components/schemas/AccessTokenDetailWithRole" + total: + type: integer default: description: Unexpected error content: @@ -75,14 +85,17 @@ paths: content: application/json: schema: - $ref: "#/definitions/CreatePersonalAccessTokenReq" + $ref: "#/components/schemas/CreatePersonalAccessTokenReq" responses: "200": description: Success content: application/json: schema: - $ref: "#/definitions/CreatePersonalAccessTokenResp" + type: object + properties: + data: + $ref: "#/components/schemas/CreatePersonalAccessTokenResp" default: description: Unexpected error content: @@ -100,9 +113,16 @@ paths: content: application/json: schema: - type: array - items: - $ref: "#/definitions/AccessTokenDetail" + type: object + properties: + data: + type: object + properties: + items: + type: array + $ref: "#/components/schemas/AccessTokenDetail" + total: + type: integer default: description: Unexpected error content: @@ -124,68 +144,71 @@ paths: application/json: schema: $ref: "common.yaml#/components/schemas/Error" -definitions: - Role: - type: object - properties: - role: - type: string - enum: ["pe", "owner", "developer", "guest"] - TokenCode: - type: object - properties: - code: - type: string - description: "You could use it to pass authentication when calling the api. When using it, you need to put it in the request header Authorization: Bearer $token for use" - AccessTokenBasicInfo: - type: object - required: [name, expiresAt, role, scopes] - properties: - name: - type: string - description: "name of token" - expiresAt: - type: string - description: "expiration date of token, need to follow the format of 'YYYY-MM-DD' or 'never'" - scopes: - type: array - items: +components: + schemas: + Role: + type: object + properties: + role: type: string - enum: - [ - "applications:read-only", - "applications:read-write", - "clusters:read-only", - "clusters:read-write", - ] - description: "permisson scopes" - CreateResourceScopedAccessTokenReq: - allOf: - - $ref: "#/definitions/AccessTokenBasicInfo" - - $ref: "#/definitions/Role" - CreatePersonalAccessTokenReq: - allOf: - - $ref: "#/definitions/AccessTokenBasicInfo" - AccessTokenDetail: - allOf: - - $ref: "#/definitions/AccessTokenBasicInfo" - - type: object - properties: - createdAt: + enum: ["pe", "owner", "developer", "guest"] + TokenCode: + type: object + properties: + code: + type: string + description: "You could use it to pass authentication when calling the api. When using it, you need to put it in the request header Authorization: Bearer $token for use" + AccessTokenBasicInfo: + type: object + required: [name, expiresAt, role, scopes] + properties: + name: + type: string + description: "name of token" + expiresAt: + type: string + description: "expiration date of token, need to follow the format of 'YYYY-MM-DD' or 'never'" + scopes: + type: array + items: type: string - createdBy: - $ref: "common.yaml#/components/components/User" - id: - type: integer - AccessTokenDetailWithRole: - allOf: - - $ref: "#/definitions/AccessTokenDetail" - - $ref: "#/definitions/Role" - CreatePersonalAccessTokenResp: - allOf: - - $ref: "#/definitions/AccessTokenDetail" - - $ref: "#/definitions/TokenCode" - CreateResourceScopedAccessTokenResp: - allOf: - - $ref: "#/definitions/AccessTokenDetailWithRole" - - $ref: "#/definitions/TokenCode" + enum: + [ + "groups:read-only", + "groups:read-write", + "applications:read-only", + "applications:read-write", + "clusters:read-only", + "clusters:read-write", + ] + description: "permisson scopes" + CreateResourceScopedAccessTokenReq: + allOf: + - $ref: "#/components/schemas/AccessTokenBasicInfo" + - $ref: "#/components/schemas/Role" + CreatePersonalAccessTokenReq: + allOf: + - $ref: "#/components/schemas/AccessTokenBasicInfo" + AccessTokenDetail: + allOf: + - $ref: "#/components/schemas/AccessTokenBasicInfo" + - type: object + properties: + createdAt: + type: string + createdBy: + $ref: "common.yaml#/components/schemas/User" + id: + type: integer + AccessTokenDetailWithRole: + allOf: + - $ref: "#/components/schemas/AccessTokenDetail" + - $ref: "#/components/schemas/Role" + CreatePersonalAccessTokenResp: + allOf: + - $ref: "#/components/schemas/AccessTokenDetail" + - $ref: "#/components/schemas/TokenCode" + CreateResourceScopedAccessTokenResp: + allOf: + - $ref: "#/components/schemas/AccessTokenDetailWithRole" + - $ref: "#/components/schemas/TokenCode" \ No newline at end of file diff --git a/openapi/v1/restful/event.yaml b/openapi/v1/restful/event.yaml index 65d04d19..ececf4f3 100644 --- a/openapi/v1/restful/event.yaml +++ b/openapi/v1/restful/event.yaml @@ -18,9 +18,24 @@ paths: content: application/json: schema: - type: array - items: - $ref: "#/components/schemas/SupportEvents" + type: object + properties: + data: + $ref: "#/components/schemas/SupportEvents" + example: | + { + "data": { + "applications_created": "New application is created", + "applications_deleted": "Application is deleted", + "applications_transferred": "Application is transferred to another group", + "clusters_builddeployed": "Cluster has completed a build task and triggered a deploy task", + "clusters_created": "New cluster is created", + "clusters_deleted": "Cluster is deleted", + "clusters_deployed": "Cluster has triggered a ", + "clusters_freed": "Cluster has been freed", + "clusters_rollbacked": "Cluster has triggered a rollback task" + } + } default: description: Unexpected error content: @@ -31,17 +46,6 @@ components: schemas: SupportEvents: type: object - properties: - applications: - $ref: "#/components/schemas/Actions" - clusters: - $ref: "#/components/schemas/Actions" - Actions: - type: array - items: - type: object - properties: - name: - type: string - description: - type: string + additionalProperties: + type: string + description: "description of scope" diff --git a/openapi/v1/restful/member.yaml b/openapi/v1/restful/member.yaml index a10e3bd5..c06c2628 100644 --- a/openapi/v1/restful/member.yaml +++ b/openapi/v1/restful/member.yaml @@ -4,14 +4,23 @@ info: description: Restful API About Member version: 1.0.0 servers: - - url: 'http://localhost:8080/' + - url: "http://localhost:8080/" paths: - /apis/core/v1/groups/{groupID}/members: + /apis/core/v1/{resourceType}/{resourceID}/members: parameters: - - name: groupID + - name: resourceType in: path - description: group id + description: type of target resource required: true + schema: + type: string + enum: ["groups", "applications", "clusters", "templates"] + - name: resourceID + in: path + description: id of target resource + required: true + schema: + type: integer post: tags: - member @@ -22,7 +31,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/PostMember' + $ref: "#/components/schemas/PostMember" responses: "200": description: Success @@ -31,33 +40,42 @@ paths: content: application/json: schema: - $ref: "common.yaml#/components/schemas/Error" + type: object + properties: + data: + $ref: "#/components/schemas/Member" get: tags: - member operationId: listGroupMember summary: list a group member responses: - '200': + "200": description: Succuss content: application/json: schema: - type: array - items: - $ref: '#/components/schemas/Member' + type: object + properties: + data: + type: object + properties: + items: + $ref: "#/components/schemas/Member" default: description: Unexpected error content: application/json: schema: $ref: "common.yaml#/components/schemas/Error" - /apis/core/v1/members/{memberid}: + /apis/core/v1/members/{memberID}: parameters: - - name: memberid + - name: memberID in: path - description: group id + description: member id required: true + schema: + type: integer put: tags: - member @@ -67,14 +85,17 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/PutMember' + $ref: "#/components/schemas/PutMember" responses: - '200': + "200": description: Success content: application/json: schema: - $ref: '#/components/schemas/Member' + type: object + properties: + data: + $ref: "#/components/schemas/Member" default: description: Unexpected error content: @@ -87,7 +108,7 @@ paths: operationId: deleteMember summary: delete a member responses: - '200': + "200": description: Success default: description: Unexpected error @@ -99,53 +120,53 @@ components: schemas: PostMember: type: object - required: [ resourceType, resourceID, memberType, memberNameID, role ] + required: [resourceType, resourceID, memberType, memberNameID, role] properties: resourceType: - $ref: '#/components/schemas/PostMember' + $ref: "#/components/schemas/PostMember" resourceID: - $ref: '#/components/schemas/ResourceID' + $ref: "#/components/schemas/ResourceID" memberType: - $ref: '#/components/schemas/MemberType' + $ref: "#/components/schemas/MemberType" memberNameID: - $ref: '#/components/schemas/MemberNameID' + $ref: "#/components/schemas/MemberNameID" role: - $ref: '#/components/schemas/Role' + $ref: "#/components/schemas/Role" PutMember: type: object - required: [ role ] + required: [role] properties: role: - $ref: '#/components/schemas/Role' + $ref: "#/components/schemas/Role" Member: type: object properties: id: - $ref: '#/components/schemas/MemberEntryID' + $ref: "#/components/schemas/MemberEntryID" memberName: - $ref: '#/components/schemas/MemberName' + $ref: "#/components/schemas/MemberName" memberNameID: - $ref: '#/components/schemas/MemberNameID' + $ref: "#/components/schemas/MemberNameID" memberType: - $ref: '#/components/schemas/MemberType' + $ref: "#/components/schemas/MemberType" resourceID: - $ref: '#/components/schemas/ResourceID' + $ref: "#/components/schemas/ResourceID" resourceName: - $ref: '#/components/schemas/ResourceName' + $ref: "#/components/schemas/ResourceName" resourcePath: - $ref: '#/components/schemas/ResourcePath' + $ref: "#/components/schemas/ResourcePath" resourceType: - $ref: '#/components/schemas/ResourceType' + $ref: "#/components/schemas/ResourceType" grantTime: $ref: "common.yaml#/components/schemas/Date" grantedBy: - $ref: '#/components/schemas/GrantedBy' + $ref: "#/components/schemas/GrantedBy" grantorName: - $ref: '#/components/schemas/GrantorName' + $ref: "#/components/schemas/GrantorName" role: - $ref: '#/components/schemas/Role' + $ref: "#/components/schemas/Role" MemberEntryID: type: integer @@ -162,7 +183,7 @@ components: MemberType: type: integer format: uint8 - enum: [ 0, 1 ] + enum: [0, 1] description: 0 for user, 1 for group ResourceID: type: integer @@ -176,7 +197,7 @@ components: description: full path of resource ResourceType: type: string - enum: [ "group", "application", "cluster" ] + enum: ["group", "application", "cluster"] description: add member to such resource GrantedBy: type: integer @@ -187,5 +208,5 @@ components: description: name of user who grant this member Role: type: string - enum: [ "owner", "maintainer", "developer", "reporter", "guest" ] - description: the member role + enum: ["owner", "maintainer", "developer", "reporter", "guest"] + description: the member role \ No newline at end of file diff --git a/openapi/v1/restful/pipelinerun.yaml b/openapi/v1/restful/pipelinerun.yaml index ee001a5c..e0305932 100644 --- a/openapi/v1/restful/pipelinerun.yaml +++ b/openapi/v1/restful/pipelinerun.yaml @@ -3,14 +3,11 @@ info: title: Horizon-Pipelinerun-Restful version: 1.0.0 servers: - - url: 'http://localhost:8080/' + - url: "http://localhost:8080/" paths: /apis/core/v1/pipelineruns/{pipelinerunID}/stop: parameters: - - name: pipelinerunID - in: query - description: the pipelinerun ID - required: true + - $ref: "common.yaml#/components/parameters/paramPipelinerunID" post: tags: - pipelinerun @@ -27,14 +24,14 @@ paths: content: application/json: schema: - $ref: "common.yaml#/components/schemas/Error" + type: object + properties: + data: + $ref: "common.yaml#/components/schemas/Error" /apis/core/v1/pipelineruns/{pipelinerunID}/log: parameters: - - name: pipelinerunID - in: query - description: the pipelinerun ID - required: true + - $ref: "common.yaml#/components/parameters/paramPipelinerunID" get: tags: - pipelinerun @@ -60,22 +57,23 @@ paths: /apis/core/v1/pipelineruns/{pipelinerunID}: parameters: - - name: pipelinerunID - in: query - description: the pipelinerun ID - required: true + - $ref: "common.yaml#/components/parameters/paramPipelinerunID" get: tags: - pipelinerun operationId: getPipelinerun summary: | - Get the specified pipelinerun for a cluster. + Get the specified pipelinerun. responses: "200": description: Success content: application/json: schema: + type: object + properties: + data: + $ref: "#/components/schemas/PipelineRun" example: | { "data": @@ -106,24 +104,26 @@ paths: application/json: schema: $ref: "common.yaml#/components/schemas/Error" + /apis/core/v1/pipelineruns/{pipelinerunID}/diffs: parameters: - - name: pipelinerunID - in: query - description: the pipelinerun ID - required: true + - $ref: "common.yaml#/components/parameters/paramPipelinerunID" get: tags: - pipelinerun operationId: getPipelineRunDiff summary: | - Get the specified pipelinerun's diff for a cluster. + Get the specified pipelinerun's diff responses: "200": description: Success content: application/json: schema: + type: object + properties: + data: + $ref: "#/components/schemas/PipelineRunDiff" example: | { "data":{ @@ -131,12 +131,168 @@ paths: "Branch": "master" "CommitMsg": "last commit msg" "CommitID":"6cb5e13a2d3c59f2283fc6b52771729691aa9fc3" - "Link": https://g.hz.netease.com/music-cloud-native/horizon/horizon/-/commits/feature/applications + "Link": https://horizon.com/cloud-native/horizon/horizon/-/commits/feature/applications }, "configDiff ": { "from": "6cb5e13a2d3c59f2283fc6b52771729691aa9fc3" "to": "6cb5e13a2d3c59f2283fc6b52771729691aa9fc3" - "diff":"@@ -1,7 +1,7 @@\n metadata:\n name: web-api\n namespace: music-cicd\n- charVersion: v2.7.3\n+ charVersion: v2.7.4\n \n replicaCount: 2\n \n" + "diff":"@@ -1,7 +1,7 @@\n metadata:\n name: web-api\n namespace: cicd\n- charVersion: v2.7.3\n+ charVersion: v2.7.4\n \n replicaCount: 2\n \n" } } - } \ No newline at end of file + } + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "common.yaml#/components/schemas/Error" + + /apis/core/v1/clusters/:%v/pipelineruns: + parameters: + - $ref: "common.yaml#/components/parameters/paramClusterID" + - $ref: "common.yaml#/components/parameters/pageNumber" + - $ref: "common.yaml#/components/parameters/pageSize" + - name: canRollback + in: query + schema: + type: boolean + description: whether the pipelinerun can rollback + get: + tags: + - pipelinerun + operationId: getClusterPipelineRuns + summary: | + Get pipelineruns of a cluster. + responses: + "200": + description: Success + content: + application/json: + schema: + type: object + properties: + data: + type: object + properties: + items: + type: array + $ref: "#/components/schemas/PipelineRun" + total: + type: integer + example: | + { + "total": 1, + "items": [ + { + "id": 1245735, + "title": "rg", + "description": "", + "action": "builddeploy", + "status": "ok", + "gitURL": "ssh://git@cloudnative.com:22222/xxx/springboot-demo.git", + "gitBranch": "jdk17", + "gitCommit": "da1a46ebfc9e48c7c4af4b89fe35bb209cd89883", + "imageURL": "", + "lastConfigCommit": "00e049bb2dc6f6ccee06e508e8a7c5f9ce71e875", + "configCommit": "5deefff34944b4780ae3c040bfeec29211904756", + "createdAt": "2022-12-30T12:03:01+08:00", + "updatedAt": "2022-12-30T12:03:38+08:00", + "startedAt": "2022-12-30T12:03:01+08:00", + "finishedAt": "2022-12-30T12:03:37+08:00", + "canRollback": false, + "createdBy": { + "userID": 667, + "userName": "admin" + } + } + ] + } + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "common.yaml#/components/schemas/Error" + +components: + schemas: + PipelineRun: + type: object + properties: + action: + type: string + description: "action of pipelinerun" + enum: ["builddeploy", "deploy", "restart", "rollback"] + canRollback: + type: boolean + description: "whether this pipelinerun can be specified to rollback" + configCommit: + type: string + description: "commit of config repository" + createdAt: + type: string + createdBy: + $ref: "common.yaml#/components/schemas/User" + description: + type: string + finishedAt: + type: string + gitBranch: + type: string + description: branch of source code + gitCommit: + type: string + description: commit of source code + gitURL: + type: string + description: url of source code + id: + type: integer + imageURL: + type: string + description: full url of image + lastConfigCommit: + type: string + description: "last commit of config repository" + startedAt: + type: string + description: "start time of pipelinerun" + status: + type: string + enum: ["ok", "waiting", "failed", "canceled"] + title: + type: string + description: "title of pipelinerun" + updatedAt: + type: string + description: "update time of pipelinerun" + PipelineRunDiff: + type: object + properties: + codeInfo: + type: object + properties: + branch: + type: string + description: "branch of source code" + commitID: + type: string + description: "latest commit id of source code" + commitMsg: + type: string + description: "lastest commit message of source code" + link: + type: string + description: "link of lastest commit" + codeDiff: + type: object + properties: + diff: + type: string + description: "changed content of this pipelinerun" + from: + type: string + description: "the last commit before the change" + to: + type: string + description: "the last commit after the change" diff --git a/openapi/v1/restful/terminal.yaml b/openapi/v1/restful/terminal.yaml index 37475950..19df9bf1 100644 --- a/openapi/v1/restful/terminal.yaml +++ b/openapi/v1/restful/terminal.yaml @@ -4,7 +4,7 @@ info: description: Restful API About Terminal version: 1.0.0 servers: - - url: 'ws://localhost:8080/' + - url: 'wss://localhost:8080/' paths: /apis/core/v1/clusters/{clusterID}/shell?podName={podName}&containerName={containerName}: parameters: @@ -12,14 +12,20 @@ paths: in: path description: cluster id required: true + schema: + type: integer - name: podName in: query required: true description: pod name + schema: + type: string - name: containerName in: query required: true description: container name + schema: + type: string get: tags: - terminal diff --git a/openapi/v1/restful/webhook.yaml b/openapi/v1/restful/webhook.yaml index ae90326a..56149b68 100644 --- a/openapi/v1/restful/webhook.yaml +++ b/openapi/v1/restful/webhook.yaml @@ -386,4 +386,4 @@ components: Status: type: string description: "status of webhook log" - enum: ["waiting", "ok", "failed"] + enum: ["waiting", "ok", "failed"] \ No newline at end of file diff --git a/openapi/v2/restful/accesstoken.yaml b/openapi/v2/restful/accesstoken.yaml index 0759ff4c..0dc5e438 100644 --- a/openapi/v2/restful/accesstoken.yaml +++ b/openapi/v2/restful/accesstoken.yaml @@ -37,7 +37,10 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/CreateResourceScopedAccessTokenResp" + type: object + properties: + data: + $ref: "#/components/schemas/CreateResourceScopedAccessTokenResp" default: description: Unexpected error content: @@ -55,9 +58,16 @@ paths: content: application/json: schema: - type: array - items: - $ref: "#/components/schemas/AccessTokenDetailWithRole" + type: object + properties: + data: + type: object + properties: + items: + type: array + $ref: "#/components/schemas/AccessTokenDetailWithRole" + total: + type: integer default: description: Unexpected error content: @@ -82,7 +92,10 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/CreatePersonalAccessTokenResp" + type: object + properties: + data: + $ref: "#/components/schemas/CreatePersonalAccessTokenResp" default: description: Unexpected error content: @@ -100,9 +113,16 @@ paths: content: application/json: schema: - type: array - items: - $ref: "#/components/schemas/AccessTokenDetail" + type: object + properties: + data: + type: object + properties: + items: + type: array + $ref: "#/components/schemas/AccessTokenDetail" + total: + type: integer default: description: Unexpected error content: @@ -124,7 +144,7 @@ paths: application/json: schema: $ref: "common.yaml#/components/schemas/Error" -components: +components: schemas: Role: type: object diff --git a/openapi/v2/restful/event.yaml b/openapi/v2/restful/event.yaml index 7bb916df..70dcbe13 100644 --- a/openapi/v2/restful/event.yaml +++ b/openapi/v2/restful/event.yaml @@ -2,7 +2,7 @@ openapi: 3.0.1 info: title: Horizon-Webhook-Restful description: Restful API About Event - version: 1.0.0 + version: 2.0.0 servers: - url: "http://localhost:8080/" paths: @@ -18,7 +18,10 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/SupportEvents" + type: object + properties: + data: + $ref: "#/components/schemas/SupportEvents" example: | { "data": { @@ -43,9 +46,6 @@ components: schemas: SupportEvents: type: object - properties: - data: - type: object - additionalProperties: - type: string - description: "description of scope" + additionalProperties: + type: string + description: "description of scope" diff --git a/openapi/v2/restful/member.yaml b/openapi/v2/restful/member.yaml index 37b4ab69..ad6cfab2 100644 --- a/openapi/v2/restful/member.yaml +++ b/openapi/v2/restful/member.yaml @@ -4,7 +4,7 @@ info: description: Restful API About Member version: 2.0.0 servers: - - url: 'http://localhost:8080/' + - url: "http://localhost:8080/" paths: /apis/core/v2/{resourceType}/{resourceID}/members: parameters: @@ -12,17 +12,15 @@ paths: in: path description: type of target resource required: true - enum: - [ - "groups", - "applications", - "clusters", - "templates", - ] + schema: + type: string + enum: ["groups", "applications", "clusters", "templates"] - name: resourceID in: path description: id of target resource required: true + schema: + type: integer post: tags: - member @@ -33,7 +31,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/PostMember' + $ref: "#/components/schemas/PostMember" responses: "200": description: Success @@ -42,33 +40,42 @@ paths: content: application/json: schema: - $ref: "common.yaml#/components/schemas/Error" + type: object + properties: + data: + $ref: "#/components/schemas/Member" get: tags: - member operationId: listGroupMember summary: list a group member responses: - '200': + "200": description: Succuss content: application/json: schema: - type: array - items: - $ref: '#/components/schemas/Member' + type: object + properties: + data: + type: object + properties: + items: + $ref: "#/components/schemas/Member" default: description: Unexpected error content: application/json: schema: $ref: "common.yaml#/components/schemas/Error" - /apis/core/v2/members/{memberid}: + /apis/core/v2/members/{memberID}: parameters: - - name: memberid + - name: memberID in: path - description: group id + description: member id required: true + schema: + type: integer put: tags: - member @@ -78,14 +85,17 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/PutMember' + $ref: "#/components/schemas/PutMember" responses: - '200': + "200": description: Success content: application/json: schema: - $ref: '#/components/schemas/Member' + type: object + properties: + data: + $ref: "#/components/schemas/Member" default: description: Unexpected error content: @@ -98,7 +108,7 @@ paths: operationId: deleteMember summary: delete a member responses: - '200': + "200": description: Success default: description: Unexpected error @@ -110,53 +120,53 @@ components: schemas: PostMember: type: object - required: [ resourceType, resourceID, memberType, memberNameID, role ] + required: [resourceType, resourceID, memberType, memberNameID, role] properties: resourceType: - $ref: '#/components/schemas/PostMember' + $ref: "#/components/schemas/PostMember" resourceID: - $ref: '#/components/schemas/ResourceID' + $ref: "#/components/schemas/ResourceID" memberType: - $ref: '#/components/schemas/MemberType' + $ref: "#/components/schemas/MemberType" memberNameID: - $ref: '#/components/schemas/MemberNameID' + $ref: "#/components/schemas/MemberNameID" role: - $ref: '#/components/schemas/Role' + $ref: "#/components/schemas/Role" PutMember: type: object - required: [ role ] + required: [role] properties: role: - $ref: '#/components/schemas/Role' + $ref: "#/components/schemas/Role" Member: type: object properties: id: - $ref: '#/components/schemas/MemberEntryID' + $ref: "#/components/schemas/MemberEntryID" memberName: - $ref: '#/components/schemas/MemberName' + $ref: "#/components/schemas/MemberName" memberNameID: - $ref: '#/components/schemas/MemberNameID' + $ref: "#/components/schemas/MemberNameID" memberType: - $ref: '#/components/schemas/MemberType' + $ref: "#/components/schemas/MemberType" resourceID: - $ref: '#/components/schemas/ResourceID' + $ref: "#/components/schemas/ResourceID" resourceName: - $ref: '#/components/schemas/ResourceName' + $ref: "#/components/schemas/ResourceName" resourcePath: - $ref: '#/components/schemas/ResourcePath' + $ref: "#/components/schemas/ResourcePath" resourceType: - $ref: '#/components/schemas/ResourceType' + $ref: "#/components/schemas/ResourceType" grantTime: $ref: "common.yaml#/components/schemas/Date" grantedBy: - $ref: '#/components/schemas/GrantedBy' + $ref: "#/components/schemas/GrantedBy" grantorName: - $ref: '#/components/schemas/GrantorName' + $ref: "#/components/schemas/GrantorName" role: - $ref: '#/components/schemas/Role' + $ref: "#/components/schemas/Role" MemberEntryID: type: integer @@ -173,7 +183,7 @@ components: MemberType: type: integer format: uint8 - enum: [ 0, 1 ] + enum: [0, 1] description: 0 for user, 1 for group ResourceID: type: integer @@ -187,7 +197,7 @@ components: description: full path of resource ResourceType: type: string - enum: [ "group", "application", "cluster" ] + enum: ["group", "application", "cluster"] description: add member to such resource GrantedBy: type: integer @@ -198,5 +208,5 @@ components: description: name of user who grant this member Role: type: string - enum: [ "owner", "maintainer", "developer", "reporter", "guest" ] + enum: ["owner", "maintainer", "developer", "reporter", "guest"] description: the member role diff --git a/openapi/v2/restful/pipelinerun.yaml b/openapi/v2/restful/pipelinerun.yaml index ee724a64..4d950915 100644 --- a/openapi/v2/restful/pipelinerun.yaml +++ b/openapi/v2/restful/pipelinerun.yaml @@ -3,11 +3,11 @@ info: title: Horizon-Pipelinerun-Restful version: 2.0.0 servers: - - url: 'http://localhost:8080/' + - url: "http://localhost:8080/" paths: /apis/core/v2/pipelineruns/{pipelinerunID}/stop: parameters: - - $ref: 'common.yaml#/components/parameters/paramPipelinerunID' + - $ref: "common.yaml#/components/parameters/paramPipelinerunID" post: tags: - pipelinerun @@ -24,11 +24,14 @@ paths: content: application/json: schema: - $ref: "common.yaml#/components/schemas/Error" + type: object + properties: + data: + $ref: "common.yaml#/components/schemas/Error" /apis/core/v2/pipelineruns/{pipelinerunID}/log: parameters: - - $ref: 'common.yaml#/components/parameters/paramPipelinerunID' + - $ref: "common.yaml#/components/parameters/paramPipelinerunID" get: tags: - pipelinerun @@ -54,7 +57,7 @@ paths: /apis/core/v2/pipelineruns/{pipelinerunID}: parameters: - - $ref: 'common.yaml#/components/parameters/paramPipelinerunID' + - $ref: "common.yaml#/components/parameters/paramPipelinerunID" get: tags: - pipelinerun @@ -67,7 +70,34 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/GetPipelineRunResp" + type: object + properties: + data: + $ref: "#/components/schemas/PipelineRun" + example: | + { + "data": + { + "id":3, + "title":"Feature123", + "description":"release big rocket", + "action":"builddeploy", + "status":"StatusCreated", + "gitURL":"ssh://git@cloudnative.com:22222/app/app-demo.git", + "gitBranch":"master", + "gitCommit":"4234324dsdjasljl43", + "imageURL":"", + "lastConfigCommit":"4234324dsdjasljl43", + "configCommit":"4234324dsdjasljl43", + "startedAt":"2021-11-07 11:19:54", + "finishedAt":"2021-11-07 11:19:54", + "canRollback": false, + "createBy":{ + "userID":0, + "userName":"123" + } + } + } default: description: Unexpected error content: @@ -77,7 +107,7 @@ paths: /apis/core/v2/pipelineruns/{pipelinerunID}/diffs: parameters: - - $ref: 'common.yaml#/components/parameters/paramPipelinerunID' + - $ref: "common.yaml#/components/parameters/paramPipelinerunID" get: tags: - pipelinerun @@ -90,7 +120,26 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/PipelineRunDiff" + type: object + properties: + data: + $ref: "#/components/schemas/PipelineRunDiff" + example: | + { + "data":{ + "codeInfo":{ + "Branch": "master" + "CommitMsg": "last commit msg" + "CommitID":"6cb5e13a2d3c59f2283fc6b52771729691aa9fc3" + "Link": https://horizon.com/cloud-native/horizon/horizon/-/commits/feature/applications + }, + "configDiff ": { + "from": "6cb5e13a2d3c59f2283fc6b52771729691aa9fc3" + "to": "6cb5e13a2d3c59f2283fc6b52771729691aa9fc3" + "diff":"@@ -1,7 +1,7 @@\n metadata:\n name: web-api\n namespace: cicd\n- charVersion: v2.7.3\n+ charVersion: v2.7.4\n \n replicaCount: 2\n \n" + } + } + } default: description: Unexpected error content: @@ -100,9 +149,9 @@ paths: /apis/core/v2/clusters/:%v/pipelineruns: parameters: - - $ref: 'common.yaml#/components/parameters/paramClusterID' - - $ref: 'common.yaml#/components/parameters/pageNumber' - - $ref: 'common.yaml#/components/parameters/pageSize' + - $ref: "common.yaml#/components/parameters/paramClusterID" + - $ref: "common.yaml#/components/parameters/pageNumber" + - $ref: "common.yaml#/components/parameters/pageSize" - name: canRollback in: query schema: @@ -123,13 +172,41 @@ paths: type: object properties: data: + type: object properties: - total: - type: integer items: type: array - items: - $ref: "#/components/schemas/PipelineRun" + $ref: "#/components/schemas/PipelineRun" + total: + type: integer + example: | + { + "total": 1, + "items": [ + { + "id": 1245735, + "title": "rg", + "description": "", + "action": "builddeploy", + "status": "ok", + "gitURL": "ssh://git@cloudnative.com:22222/xxx/springboot-demo.git", + "gitBranch": "jdk17", + "gitCommit": "da1a46ebfc9e48c7c4af4b89fe35bb209cd89883", + "imageURL": "", + "lastConfigCommit": "00e049bb2dc6f6ccee06e508e8a7c5f9ce71e875", + "configCommit": "5deefff34944b4780ae3c040bfeec29211904756", + "createdAt": "2022-12-30T12:03:01+08:00", + "updatedAt": "2022-12-30T12:03:38+08:00", + "startedAt": "2022-12-30T12:03:01+08:00", + "finishedAt": "2022-12-30T12:03:37+08:00", + "canRollback": false, + "createdBy": { + "userID": 667, + "userName": "admin" + } + } + ] + } default: description: Unexpected error content: @@ -189,41 +266,33 @@ components: updatedAt: type: string description: "update time of pipelinerun" - GetPipelineRunResp: - type: object - properties: - data: - $ref: "#/components/schemas/PipelineRun" PipelineRunDiff: type: object properties: - data: + codeInfo: + type: object + properties: + branch: + type: string + description: "branch of source code" + commitID: + type: string + description: "latest commit id of source code" + commitMsg: + type: string + description: "lastest commit message of source code" + link: + type: string + description: "link of lastest commit" + codeDiff: type: object properties: - codeInfo: - type: object - properties: - branch: - type: string - description: "branch of source code" - commitID: - type: string - description: "latest commit id of source code" - commitMsg: - type: string - description: "lastest commit message of source code" - link: - type: string - description: "link of lastest commit" - codeDiff: - type: object - properties: - diff: - type: string - description: "changed content of this pipelinerun" - from: - type: string - description: "the last commit before the change" - to: - type: string - description: "the last commit after the change" \ No newline at end of file + diff: + type: string + description: "changed content of this pipelinerun" + from: + type: string + description: "the last commit before the change" + to: + type: string + description: "the last commit after the change" diff --git a/openapi/v2/restful/terminal.yaml b/openapi/v2/restful/terminal.yaml index 5d5f08e3..eceaaba3 100644 --- a/openapi/v2/restful/terminal.yaml +++ b/openapi/v2/restful/terminal.yaml @@ -4,7 +4,7 @@ info: description: Restful API About Terminal version: 2.0.0 servers: - - url: 'ws://localhost:8080/' + - url: 'wss://localhost:8080/' paths: /apis/core/v2/clusters/{clusterID}/shell?podName={podName}&containerName={containerName}: parameters: @@ -12,14 +12,20 @@ paths: in: path description: cluster id required: true + schema: + type: integer - name: podName in: query required: true description: pod name + schema: + type: string - name: containerName in: query required: true description: container name + schema: + type: string get: tags: - terminal