Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: environments as resources #2415

Merged
merged 21 commits into from
May 2, 2023
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions api/environments.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@ openapi: 3.0.0

components:
schemas:
EnvironmentResource:
type: object
description: "Represents an environment structured into the Resources format."
properties:
type:
type: string
description: "Represents the type of this resource. It should always be set as 'Environment'."
enum:
- Environment
spec:
$ref: "#/components/schemas/Environment"
Environment:
type: object
properties:
Expand Down
271 changes: 140 additions & 131 deletions api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -643,136 +643,6 @@ paths:
items:
$ref: "./testEvents.yaml#/components/schemas/TestRunEvent"

# Environments
/environments:
get:
tags:
- api
summary: "Get Environments"
description: "Get Environments"
operationId: getEnvironments
parameters:
- $ref: "./parameters.yaml#/components/parameters/take"
- $ref: "./parameters.yaml#/components/parameters/skip"
- $ref: "./parameters.yaml#/components/parameters/query"
- $ref: "./parameters.yaml#/components/parameters/sortBy"
- $ref: "./parameters.yaml#/components/parameters/sortDirection"
responses:
200:
description: successful operation
headers:
X-Total-Count:
schema:
type: integer
description: Total records count
content:
application/json:
schema:
type: array
items:
$ref: "./environments.yaml#/components/schemas/Environment"
500:
description: "problem with getting environments"
post:
tags:
- api
summary: "Create new environment"
description: "Create new environment action"
operationId: createEnvironment
requestBody:
content:
application/json:
schema:
$ref: "./environments.yaml#/components/schemas/Environment"
responses:
200:
description: successful operation
content:
application/json:
schema:
$ref: "./environments.yaml#/components/schemas/Environment"
400:
description: "trying to create a environment with an already existing ID"
/environments/{environmentId}:
get:
tags:
- api
parameters:
- in: path
name: environmentId
schema:
type: string
required: true
summary: "get environment"
description: "get environment"
operationId: getEnvironment
responses:
200:
description: successful operation
content:
application/json:
schema:
$ref: "./environments.yaml#/components/schemas/Environment"
500:
description: "problem with getting a environment"
put:
tags:
- api
parameters:
- in: path
name: environmentId
schema:
type: string
required: true
summary: "update environment"
description: "update environment action"
operationId: updateEnvironment
requestBody:
content:
application/json:
schema:
$ref: "./environments.yaml#/components/schemas/Environment"
responses:
204:
description: successful operation
500:
description: "problem with updating environment"
delete:
tags:
- api
parameters:
- in: path
name: environmentId
schema:
type: string
required: true
summary: "delete a environment"
description: "delete a environment"
operationId: deleteEnvironment
responses:
"204":
description: OK
/environments/{environmentId}/definition.yaml:
get:
tags:
- api
parameters:
- in: path
name: environmentId
schema:
type: string
required: true
summary: Get the environment definition as an YAML file
description: Get the environment as an YAML file
operationId: getEnvironmentDefinitionFile
responses:
200:
description: OK
content:
application/yaml:
schema:
type: string

# Expressions
/expressions/resolve:
post:
Expand Down Expand Up @@ -1139,8 +1009,147 @@ paths:
summary: "Delete a Data Store"
description: "Delete a Data Store"
operationId: deleteDataStore
responses:
"204":
description: OK

# Environments
/environments:
get:
tags:
- resource-api
summary: "List environments"
description: "List environments available in Tracetest."
operationId: listEnvironments
parameters:
- $ref: "./parameters.yaml#/components/parameters/take"
- $ref: "./parameters.yaml#/components/parameters/skip"
- $ref: "./parameters.yaml#/components/parameters/switchableResourceSortBy"
- $ref: "./parameters.yaml#/components/parameters/sortDirection"
responses:
200:
description: successful operation
content:
application/json:
schema:
type: object
properties:
count:
type: integer
items:
type: array
items:
$ref: "./environments.yaml#/components/schemas/EnvironmentResource"
text/yaml:
schema:
type: object
properties:
count:
type: integer
items:
type: array
items:
$ref: "./environments.yaml#/components/schemas/EnvironmentResource"
400:
description: "invalid query for environments, some data was sent in incorrect format."
500:
description: "problem listing environments"
post:
tags:
- resource-api
summary: "Create an environment"
description: "Create an environment that can be used by tests and transactions"
operationId: createEnvironment
requestBody:
content:
application/json:
schema:
$ref: "./environments.yaml#/components/schemas/EnvironmentResource"
text/yaml:
schema:
$ref: "./environments.yaml#/components/schemas/EnvironmentResource"
responses:
201:
description: successful operation
content:
application/json:
schema:
$ref: "./environments.yaml#/components/schemas/EnvironmentResource"
text/yaml:
schema:
$ref: "./environments.yaml#/components/schemas/EnvironmentResource"
500:
description: "problem creating an environment"

/environments/{environmentId}:
get:
tags:
- resource-api
parameters:
- $ref: "./parameters.yaml#/components/parameters/environmentId"
summary: "Get a specific environment"
description: "Get one environment by its id"
operationId: getEnvironment
responses:
200:
description: successful operation
content:
application/json:
schema:
$ref: "./environments.yaml#/components/schemas/EnvironmentResource"
text/yaml:
schema:
$ref: "./environments.yaml#/components/schemas/EnvironmentResource"
404:
description: "environment not found"
500:
description: "problem getting an environment"
put:
tags:
- resource-api
parameters:
- $ref: "./parameters.yaml#/components/parameters/environmentId"
summary: "Update an environment"
description: "Update an environment used on Tracetest"
operationId: updateEnvironment
requestBody:
content:
application/json:
schema:
$ref: "./environments.yaml#/components/schemas/EnvironmentResource"
text/yaml:
schema:
$ref: "./environments.yaml#/components/schemas/EnvironmentResource"
responses:
200:
description: successful operation
content:
application/json:
schema:
$ref: "./environments.yaml#/components/schemas/EnvironmentResource"
text/yaml:
schema:
$ref: "./environments.yaml#/components/schemas/EnvironmentResource"
400:
description: "invalid environment, some data was sent in incorrect format."
404:
description: "environment not found"
500:
description: "problem updating an environment"
delete:
tags:
- resource-api
parameters:
- $ref: "./parameters.yaml#/components/parameters/environmentId"
summary: "Delete an environment"
description: "Delete an environment from Tracetest"
operationId: deleteEnvironment
responses:
204:
description: successful operation
400:
description: "invalid environment, some data was sent in incorrect format."
404:
description: "environment not found"
500:
description: "problem with data store deletion"
description: "problem deleting an environment"
8 changes: 8 additions & 0 deletions api/parameters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,11 @@ components:
description: "ID of a datastore used on Tracetest to configure how to fetch traces in a test"
schema:
type: string

environmentId:
in: path
name: environmentId
required: true
description: "ID of an environment used on Tracetest to inject values into tests and transactions"
schema:
type: string
73 changes: 0 additions & 73 deletions cli/actions/apply_environment_action.go

This file was deleted.