From f9f54276ab610033fb2dddc1e4e86a4e7ce8c498 Mon Sep 17 00:00:00 2001 From: jrea Date: Tue, 31 May 2022 13:32:26 -0400 Subject: [PATCH] fix: updateInstances -> updateInstance --- lib/nile/spec/api.yaml | 744 ++++++++++++++------------------ lib/nile/src/test/index.test.ts | 2 +- 2 files changed, 335 insertions(+), 411 deletions(-) diff --git a/lib/nile/spec/api.yaml b/lib/nile/spec/api.yaml index eb9ec07f..18454275 100644 --- a/lib/nile/spec/api.yaml +++ b/lib/nile/spec/api.yaml @@ -9,32 +9,32 @@ paths: /auth/login: post: tags: - - Developers + - Developers description: login a developer to nile operationId: loginDeveloper requestBody: content: - "*/*": + '*/*': schema: - $ref: "#/components/schemas/LoginInfo" + $ref: '#/components/schemas/LoginInfo' responses: default: description: default response content: application/json: schema: - $ref: "#/components/schemas/Token" + $ref: '#/components/schemas/Token' /auth/validate: post: tags: - - Developers + - Developers description: validate a developer token operationId: validateDeveloper requestBody: content: - "*/*": + '*/*': schema: - $ref: "#/components/schemas/Token" + $ref: '#/components/schemas/Token' responses: "204": description: valid token @@ -43,27 +43,19 @@ paths: /workspaces/{workspace}/auth/login: post: tags: - - Users + - Users summary: Login user - description: - "Login a user to Nile. This operation returns a JWT token. Most\ + description: "Login a user to Nile. This operation returns a JWT token. Most\ \ Nile operations require authentication and expect this token in the 'Authorization:\ \ Bearer ' header" operationId: loginUser parameters: - - name: workspace - in: path - description: - The name of the Nile workspace where all the data-plane metadata - for this user is stored - required: true - schema: - type: string + - $ref: '#/components/parameters/workspace' requestBody: content: application/json: schema: - $ref: "#/components/schemas/LoginInfo" + $ref: '#/components/schemas/LoginInfo' required: true responses: "200": @@ -71,58 +63,49 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/Token" + $ref: '#/components/schemas/Token' "401": description: Unauthorized x-code-samples: - - lang: cUrl - source: - "curl -X POST https://app.thenile.dev:443/auth/login -H 'Content-Type:\ - \ application/json' -D '{\"email\": \"shaun@colton.demo\", \"password\"\ - : \"mycatname\"}" - - lang: JS - source: |- - import Nile from "@theniledev/js"; - const nile = new Nile({ apiUrl: "http://localhost:8080", workspace: "1" }); + - lang: cURL + source: "curl -X POST https://app.thenile.dev:443/auth/login -H 'Content-Type:\ + \ application/json' -D '{\"email\": \"shaun@colton.demo\", \"password\"\ + : \"mycatname\"}" + - lang: JS + source: |- + import Nile from "@theniledev/js"; + const nile = new Nile({ apiUrl: "http://localhost:8080", workspace: "1" }); - const body = { - workspace: 56, - loginInfo: { - email: "shaun@colton.demo", - password: "mycatname", - }, - }; + const body = { + workspace: 56, + loginInfo: { + email: "shaun@colton.demo", + password: "mycatname", + }, + }; - nile - .loginUser(body) - .then((data) => { - console.log("API called successfully. Returned data: " + data); - }) - .catch((error: any) => console.error(error)); + nile + .loginUser(body) + .then((data) => { + console.log("API called successfully. Returned data: " + data); + }) + .catch((error: any) => console.error(error)); /workspaces/{workspace}/auth/validate: post: tags: - - Users + - Users summary: Validate User Token - description: - "Validates a user token. Use this when using Nile authentication\ + description: "Validates a user token. Use this when using Nile authentication\ \ to validate access to non-Nile resources. See the [Add Authentication Guide](https://nile-docs.vercel.app/docs/current/guides/how-to/add_signup_authn#decorating-the-endpoint)\ \ for a full example" operationId: validateUser parameters: - - name: workspace - in: path - description: - The name of the Nile workspace where all the data-plane metadata - for this user is stored - required: true - schema: - type: string + - $ref: '#/components/parameters/workspace' requestBody: content: application/json: schema: - $ref: "#/components/schemas/Token" + $ref: '#/components/schemas/Token' required: true responses: "204": @@ -130,38 +113,37 @@ paths: "400": description: The token is invalid x-code-samples: - - lang: cUrl - source: - "curl -X POST https://app.thenile.dev:443/auth/validate -H 'Content-Type:\ - \ application/json' -D '{\"token\": \"token\"}'" - - lang: JS - source: |- - import Nile from "@theniledev/js"; + - lang: cURL + source: "curl -X POST https://app.thenile.dev:443/auth/validate -H 'Content-Type:\ + \ application/json' -D '{\"token\": \"token\"}'" + - lang: JS + source: |- + import Nile from "@theniledev/js"; - const nile = new Nile({ apiUrl: "http://localhost:8080", workspace: "1" }); + const nile = new Nile({ apiUrl: "http://localhost:8080", workspace: "1" }); - const body = { - workspace: 56, - token: { token: "token" }, - }; + const body = { + workspace: 56, + token: { token: "token" }, + }; - nile - .validateUserToken(body) - .then((data) => { - console.log("API called successfully. Returned data: " + data); - }) - .catch((error: any) => console.error(error)); + nile + .validateUserToken(body) + .then((data) => { + console.log("API called successfully. Returned data: " + data); + }) + .catch((error: any) => console.error(error)); /developers: post: tags: - - Developers + - Developers description: Create a developer operationId: createDeveloper requestBody: content: - "*/*": + '*/*': schema: - $ref: "#/components/schemas/CreateUserRequest" + $ref: '#/components/schemas/CreateUserRequest' required: true responses: "201": @@ -169,19 +151,15 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/User" + $ref: '#/components/schemas/User' /workspaces/{workspace}/entities: get: tags: - - Entities + - Entities description: List all Entities operationId: listEntities parameters: - - name: workspace - in: path - required: true - schema: - type: string + - $ref: '#/components/parameters/workspace' responses: "200": description: list of entities @@ -190,23 +168,19 @@ paths: schema: type: array items: - $ref: "#/components/schemas/Entity" + $ref: '#/components/schemas/Entity' post: tags: - - Entities + - Entities description: Create Entity operationId: createEntity parameters: - - name: workspace - in: path - required: true - schema: - type: string + - $ref: '#/components/parameters/workspace' requestBody: content: - "*/*": + '*/*': schema: - $ref: "#/components/schemas/Entity" + $ref: '#/components/schemas/Entity' required: true responses: "200": @@ -214,52 +188,44 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/Entity" + $ref: '#/components/schemas/Entity' /workspaces/{workspace}/entities/{type}: get: tags: - - Entities + - Entities description: Get Entity operationId: getEntity parameters: - - name: workspace - in: path - required: true - schema: - type: string - - name: type - in: path - required: true - schema: - type: string + - $ref: '#/components/parameters/workspace' + - name: type + in: path + required: true + schema: + type: string responses: "200": description: the entity with the requested type content: application/json: schema: - $ref: "#/components/schemas/Entity" + $ref: '#/components/schemas/Entity' patch: tags: - - Entities + - Entities description: Update an Entity operationId: updateEntity parameters: - - name: workspace - in: path - required: true - schema: - type: string - - name: type - in: path - required: true - schema: - type: string + - $ref: '#/components/parameters/workspace' + - name: type + in: path + required: true + schema: + type: string requestBody: content: - "*/*": + '*/*': schema: - $ref: "#/components/schemas/PatchEntityRequest" + $ref: '#/components/schemas/PatchEntityRequest' required: true responses: "200": @@ -267,24 +233,20 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/Entity" + $ref: '#/components/schemas/Entity' /workspaces/{workspace}/entities/{type}/openapi: get: tags: - - Entities + - Entities description: Get a yaml openapi description of an entity operationId: getOpenAPI parameters: - - name: workspace - in: path - required: true - schema: - type: string - - name: type - in: path - required: true - schema: - type: string + - $ref: '#/components/parameters/workspace' + - name: type + in: path + required: true + schema: + type: string responses: default: description: default response @@ -295,26 +257,22 @@ paths: /workspaces/{workspace}/orgs/{org}/instances/{type}: get: tags: - - Entities - description: " List all instances" + - Entities + description: ' List all instances' operationId: listInstances parameters: - - name: workspace - in: path - required: true - schema: - type: string - - name: org - in: path - required: true - schema: - type: integer - format: int32 - - name: type - in: path - required: true - schema: - type: string + - $ref: '#/components/parameters/workspace' + - name: org + in: path + required: true + schema: + type: integer + format: int32 + - name: type + in: path + required: true + schema: + type: string responses: default: description: default response @@ -323,34 +281,30 @@ paths: schema: type: array items: - $ref: "#/components/schemas/Instance" + $ref: '#/components/schemas/Instance' post: tags: - - Entities + - Entities description: Create a new Instance operationId: createInstance parameters: - - name: workspace - in: path - required: true - schema: - type: string - - name: org - in: path - required: true - schema: - type: integer - format: int32 - - name: type - in: path - required: true - schema: - type: string + - $ref: '#/components/parameters/workspace' + - name: org + in: path + required: true + schema: + type: integer + format: int32 + - name: type + in: path + required: true + schema: + type: string requestBody: content: application/json: schema: - $ref: "#/components/schemas/Json" + $ref: '#/components/schemas/Json' required: true responses: "201": @@ -358,76 +312,68 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/Instance" + $ref: '#/components/schemas/Instance' /workspaces/{workspace}/orgs/{org}/instances/{type}/{id}: get: tags: - - Entities + - Entities description: Get an instance operationId: getInstance parameters: - - name: workspace - in: path - required: true - schema: - type: string - - name: org - in: path - required: true - schema: - type: integer - format: int32 - - name: type - in: path - required: true - schema: - type: string - - name: id - in: path - required: true - schema: - type: integer - format: int32 + - $ref: '#/components/parameters/workspace' + - name: org + in: path + required: true + schema: + type: integer + format: int32 + - name: type + in: path + required: true + schema: + type: string + - name: id + in: path + required: true + schema: + type: integer + format: int32 responses: default: description: default response content: application/json: schema: - $ref: "#/components/schemas/Instance" + $ref: '#/components/schemas/Instance' put: tags: - - Entities + - Entities description: Update an instance - operationId: updateInstances + operationId: updateInstance parameters: - - name: workspace - in: path - required: true - schema: - type: string - - name: org - in: path - required: true - schema: - type: integer - format: int32 - - name: type - in: path - required: true - schema: - type: string - - name: id - in: path - required: true - schema: - type: integer - format: int32 + - $ref: '#/components/parameters/workspace' + - name: org + in: path + required: true + schema: + type: integer + format: int32 + - name: type + in: path + required: true + schema: + type: string + - name: id + in: path + required: true + schema: + type: integer + format: int32 requestBody: content: application/json: schema: - $ref: "#/components/schemas/PatchInstanceRequest" + $ref: '#/components/schemas/PatchInstanceRequest' required: true responses: default: @@ -435,83 +381,71 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/Instance" + $ref: '#/components/schemas/Instance' delete: tags: - - Entities + - Entities description: Delete an instance operationId: deleteInstance parameters: - - name: workspace - in: path - required: true - schema: - type: string - - name: org - in: path - required: true - schema: - type: integer - format: int32 - - name: type - in: path - required: true - schema: - type: string - - name: id - in: path - required: true - schema: - type: integer - format: int32 + - $ref: '#/components/parameters/workspace' + - name: org + in: path + required: true + schema: + type: integer + format: int32 + - name: type + in: path + required: true + schema: + type: string + - name: id + in: path + required: true + schema: + type: integer + format: int32 responses: "204": description: Successful instance deletion /workspaces/{workspace}/orgs/{org}/invites/{code}/accept: post: tags: - - Organizations + - Organizations description: Accept an invite operationId: acceptInvite parameters: - - name: workspace - in: path - required: true - schema: - type: string - - name: org - in: path - required: true - schema: - type: integer - format: int32 - - name: code - in: path - required: true - schema: - type: integer - format: int32 + - $ref: '#/components/parameters/workspace' + - name: org + in: path + required: true + schema: + type: integer + format: int32 + - name: code + in: path + required: true + schema: + type: integer + format: int32 responses: "204": description: Successful invite acceptance /workspaces/{workspace}/orgs/{org}/invites: get: tags: - - Organizations + - Organizations description: List all Invites operationId: listInvites parameters: - - name: workspace - in: path - required: true - schema: - type: string - - name: org - in: path - required: true - schema: - type: integer - format: int32 + - $ref: '#/components/parameters/workspace' + - name: org + in: path + required: true + schema: + type: integer + format: int32 responses: default: description: default response @@ -520,19 +454,15 @@ paths: schema: type: array items: - $ref: "#/components/schemas/Invite" + $ref: '#/components/schemas/Invite' /workspaces/{workspace}/orgs: get: tags: - - Organizations + - Organizations description: List all Organizations operationId: listOrganizations parameters: - - name: workspace - in: path - required: true - schema: - type: string + - $ref: '#/components/parameters/workspace' responses: default: description: default response @@ -541,108 +471,92 @@ paths: schema: type: array items: - $ref: "#/components/schemas/Organization" + $ref: '#/components/schemas/Organization' post: tags: - - Organizations + - Organizations description: Create a new organization operationId: createOrganization parameters: - - name: workspace - in: path - required: true - schema: - type: string + - $ref: '#/components/parameters/workspace' requestBody: content: - "*/*": + '*/*': schema: - $ref: "#/components/schemas/CreateOrganizationRequest" + $ref: '#/components/schemas/CreateOrganizationRequest' responses: "201": description: The newly created organization content: application/json: schema: - $ref: "#/components/schemas/Organization" + $ref: '#/components/schemas/Organization' /workspaces/{workspace}/orgs/{org}: get: tags: - - Organizations + - Organizations description: Get an organization by name operationId: getOrganization parameters: - - name: workspace - in: path - required: true - schema: - type: string - - name: org - in: path - required: true - schema: - type: integer - format: int32 + - $ref: '#/components/parameters/workspace' + - name: org + in: path + required: true + schema: + type: integer + format: int32 responses: default: description: default response content: application/json: schema: - $ref: "#/components/schemas/Organization" + $ref: '#/components/schemas/Organization' delete: tags: - - Organizations + - Organizations description: Delete an organization by name operationId: deleteOrganization parameters: - - name: workspace - in: path - required: true - schema: - type: string - - name: org - in: path - required: true - schema: - type: integer - format: int32 + - $ref: '#/components/parameters/workspace' + - name: org + in: path + required: true + schema: + type: integer + format: int32 responses: "204": description: Successful org deletion patch: tags: - - Organizations + - Organizations description: Update an organization operationId: updateOrganization parameters: - - name: workspace - in: path - required: true - schema: - type: string - - name: org - in: path - required: true - schema: - type: integer - format: int32 + - $ref: '#/components/parameters/workspace' + - name: org + in: path + required: true + schema: + type: integer + format: int32 requestBody: content: - "*/*": + '*/*': schema: - $ref: "#/components/schemas/PatchOrganizationRequest" + $ref: '#/components/schemas/PatchOrganizationRequest' responses: default: description: default response content: application/json: schema: - $ref: "#/components/schemas/Organization" + $ref: '#/components/schemas/Organization' /me: get: tags: - - Users + - Users description: Get information about current authenticated user operationId: me responses: @@ -651,19 +565,15 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/User" + $ref: '#/components/schemas/User' /workspaces/{workspace}/users: get: tags: - - Users + - Users description: List all users for an org operationId: listUsers parameters: - - name: workspace - in: path - required: true - schema: - type: string + - $ref: '#/components/parameters/workspace' responses: default: description: default response @@ -672,23 +582,19 @@ paths: schema: type: array items: - $ref: "#/components/schemas/User" + $ref: '#/components/schemas/User' post: tags: - - Users + - Users description: Create a user operationId: createUser parameters: - - name: workspace - in: path - required: true - schema: - type: string + - $ref: '#/components/parameters/workspace' requestBody: content: application/json: schema: - $ref: "#/components/schemas/CreateUserRequest" + $ref: '#/components/schemas/CreateUserRequest' required: true responses: "201": @@ -696,56 +602,48 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/User" + $ref: '#/components/schemas/User' /workspaces/{workspace}/users/{id}: get: tags: - - Users + - Users description: Get a user by id operationId: getUser parameters: - - name: workspace - in: path - required: true - schema: - type: string - - name: id - in: path - required: true - schema: - type: integer - format: int32 + - $ref: '#/components/parameters/workspace' + - name: id + in: path + required: true + schema: + type: integer + format: int32 responses: default: description: default response content: application/json: schema: - $ref: "#/components/schemas/User" + $ref: '#/components/schemas/User' delete: tags: - - Users + - Users description: Delete a user operationId: deleteUser parameters: - - name: workspace - in: path - required: true - schema: - type: string - - name: id - in: path - required: true - schema: - type: integer - format: int32 + - $ref: '#/components/parameters/workspace' + - name: id + in: path + required: true + schema: + type: integer + format: int32 responses: "204": description: Successful user deletion /workspaces: get: tags: - - Workspaces + - Workspaces description: List all workspaces operationId: listWorkspaces responses: @@ -756,17 +654,17 @@ paths: schema: type: array items: - $ref: "#/components/schemas/Organization" + $ref: '#/components/schemas/Organization' post: tags: - - Workspaces + - Workspaces description: Create a workspace operationId: createWorkspace requestBody: content: - "*/*": + '*/*': schema: - $ref: "#/components/schemas/CreateOrganizationRequest" + $ref: '#/components/schemas/CreateOrganizationRequest' required: true responses: "201": @@ -774,26 +672,29 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/Organization" + $ref: '#/components/schemas/Organization' components: schemas: Json: type: object + example: + id: lkc-123 + memory: 4096 + cpus: 4 Token: required: - - token + - token type: object properties: token: type: string - description: - JWT authentication token. Most Nile operations the caller to + description: JWT authentication token. Most Nile operations the caller to pass a valid token in Authorization HTTP header using Bearer schema example: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c LoginInfo: required: - - email - - password + - email + - password type: object properties: email: @@ -808,9 +709,9 @@ components: example: mycatname User: required: - - email - - id - - type + - email + - id + - type type: object properties: id: @@ -819,15 +720,15 @@ components: type: type: string enum: - - user - - developer + - user + - developer email: type: string format: email CreateUserRequest: required: - - email - - password + - email + - password type: object properties: email: @@ -838,26 +739,38 @@ components: type: string Entity: required: - - name - - schema + - name + - schema type: object properties: name: type: string + example: clusters schema: - $ref: "#/components/schemas/Json" + $ref: '#/components/schemas/JsonSchema' + JsonSchema: + type: object + example: + type: object + properties: + id: + type: string + memory: + type: integer + cpus: + type: integer PatchEntityRequest: required: - - schema + - schema type: object properties: schema: - $ref: "#/components/schemas/Json" + $ref: '#/components/schemas/JsonSchema' Instance: required: - - id - - properties - - type + - id + - properties + - type type: object properties: id: @@ -865,21 +778,23 @@ components: format: int32 type: type: string + description: The entity type of this instance + example: clusters properties: - $ref: "#/components/schemas/Json" + $ref: '#/components/schemas/Json' PatchInstanceRequest: required: - - properties + - properties type: object properties: properties: - $ref: "#/components/schemas/Json" + $ref: '#/components/schemas/Json' Invite: required: - - code - - inviter - - org - - status + - code + - inviter + - org + - status type: object properties: code: @@ -894,12 +809,12 @@ components: status: type: string enum: - - active + - active Organization: required: - - id - - name - - type + - id + - name + - type type: object properties: id: @@ -908,21 +823,30 @@ components: type: type: string enum: - - organization - - workspace + - organization + - workspace name: type: string CreateOrganizationRequest: required: - - name + - name type: object properties: name: type: string PatchOrganizationRequest: required: - - name + - name type: object properties: name: type: string + parameters: + workspace: + name: workspace + in: path + description: The name of the Nile workspace where all the data-plane metadata + for this user is stored + required: true + schema: + type: string diff --git a/lib/nile/src/test/index.test.ts b/lib/nile/src/test/index.test.ts index df68edde..ca15dc7e 100644 --- a/lib/nile/src/test/index.test.ts +++ b/lib/nile/src/test/index.test.ts @@ -54,7 +54,7 @@ describe('index', () => { 'listEntities', 'listInstances', 'updateEntity', - 'updateInstances', + 'updateInstance', ]); } if (k === 'developers') {