Skip to content

Commit

Permalink
feat(COR-683): add api to create, update, delete and list variable en…
Browse files Browse the repository at this point in the history
…dpoint (#419)
  • Loading branch information
pggb25 authored Jul 24, 2023
1 parent bf9c1c3 commit 4944362
Show file tree
Hide file tree
Showing 8 changed files with 168 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ tags:
- name: Referral & Rewards
- name: Container Registries
- name: User Sign Up
- name: Variable Main Calls
x-tagGroups:
- name: Organization
tags:
Expand Down Expand Up @@ -744,10 +745,14 @@ paths:
$ref: './resources/JobClone.yaml'
/service/{serviceId}/deploymentStage:
$ref: './resources/deploymentStage/ServiceDeploymentStage.yaml'
/variable:
$ref: './resources/variable/Variable.yaml'
/variable/{variableId}/alias:
$ref: './resources/variable/VariableAlias.yaml'
/variable/{variableId}/override:
$ref: './resources/variable/VariableOverride.yaml'
/variable/{variableId}:
$ref: './resources/variable/VariableRef.yaml'
#/organization/{organizationId}/job/preview:
#/organization/{organizationId}/job/deploy:
components:
Expand Down
65 changes: 65 additions & 0 deletions src/resources/variable/Variable.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
get:
summary: 'List variables'
description: Returns a list of variables
operationId: listVariables
parameters:
- in: query
name: parent_id
schema:
type: string
format: uuid
description: the id where the variable will be added
- in: query
name: scope
schema:
$ref: '../../schemas/enums/APIVariableScope.yaml'
description: the scope of the parent where the variable will be added
- in: query
name: is_secret
schema:
type: boolean
nullable: true
description: true if the variable is a secret
tags:
- Variable Main Calls
responses:
'200':
description: 'List variables'
content:
application/json:
schema:
$ref: '../../schemas/variable/VariableResponseList.yaml'
'401':
$ref: '../../responses/NotAuthorized.yaml'
'403':
$ref: '../../responses/Forbidden.yaml'
'404':
$ref: '../../responses/NotFound.yaml'
post:
summary: 'Create a variable'
description: |
- Create a variable at the level defined in the request body.
operationId: createVariable

tags:
- Variable Main Calls
requestBody:
content:
application/json:
schema:
$ref: '../../schemas/variable/VariableRequest.yaml'
responses:
'201':
description: 'Create a variable'
content:
application/json:
schema:
$ref: '../../schemas/variable/VariableResponse.yaml'
'400':
$ref: '../../responses/BadRequest.yaml'
'401':
$ref: '../../responses/NotAuthorized.yaml'
'403':
$ref: '../../responses/Forbidden.yaml'
'404':
$ref: '../../responses/NotFound.yaml'
1 change: 0 additions & 1 deletion src/resources/variable/VariableOverride.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ post:
operationId: createVariableOverride
parameters:
- $ref: '../../parameters/path/variableId.yaml'

tags:
- Variable Main Calls
requestBody:
Expand Down
55 changes: 55 additions & 0 deletions src/resources/variable/VariableRef.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
delete:
summary: 'Delete a variable'
description: |
- To delete a variable
- You can't delete a BUILT_IN variable
- If you delete a variable having override or alias, the associated override/alias will be deleted as well
operationId: deleteVariable
parameters:
- $ref: '../../parameters/path/variableId.yaml'

tags:
- Variable Main Calls
responses:
'204':
$ref: '../../responses/Deleted.yaml'
'401':
$ref: '../../responses/NotAuthorized.yaml'
'403':
$ref: '../../responses/Forbidden.yaml'
'404':
$ref: '../../responses/NotFound.yaml'

put:
summary: 'Edit a variable'
description: |
- You can't edit a BUILT_IN variable
- For an override, you can't edit the key
- For an alias, you can't edit the value
operationId: editVariable
parameters:
- $ref: '../../parameters/path/variableId.yaml'

tags:
- Variable Main Calls
requestBody:
required: true
content:
application/json:
schema:
$ref: '../../schemas/variable/VariableEditRequest.yaml'
responses:
'200':
description: 'Edited variable value'
content:
application/json:
schema:
$ref: '../../schemas/variable/VariableResponse.yaml'
'400':
$ref: '../../responses/BadRequest.yaml'
'401':
$ref: '../../responses/NotAuthorized.yaml'
'403':
$ref: '../../responses/Forbidden.yaml'
'404':
$ref: '../../responses/NotFound.yaml'
6 changes: 6 additions & 0 deletions src/schemas/_index.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -652,8 +652,14 @@ VariableAliasRequest:
$ref: ./variable/VariableAliasRequest.yaml
VariableOverrideRequest:
$ref: ./variable/VariableOverrideRequest.yaml
VariableRequest:
$ref: ./variable/VariableRequest.yaml
VariableEditRequest:
$ref: ./variable/VariableEditRequest.yaml
VariableResponse:
$ref: ./variable/VariableResponse.yaml
VariableResponseList:
$ref: ./variable/VariableResponseList.yaml
VariableAlias:
$ref: ./variable/VariableAlias.yaml
VariableOverride:
Expand Down
9 changes: 9 additions & 0 deletions src/schemas/variable/VariableEditRequest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
type: object
required:
- key
- value
properties:
key:
type: string
value:
type: string
22 changes: 22 additions & 0 deletions src/schemas/variable/VariableRequest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
type: object
required:
- key
- value
- is_secret
- variable_scope
- variable_parent_id
properties:
key:
type: string
value:
type: string
mount_path:
type: string
nullable: true
is_secret:
type: boolean
variable_scope:
$ref: '../enums/APIVariableScope.yaml'
variable_parent_id:
type: string
format: uuid
6 changes: 6 additions & 0 deletions src/schemas/variable/VariableResponseList.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
type: object
properties:
results:
type: array
items:
$ref: './VariableResponse.yaml'

0 comments on commit 4944362

Please sign in to comment.