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

Add method to export an API test in Synthetics #807

Merged
merged 1 commit into from
Mar 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"spec_versions": {
"v1": {
"apigentools_version": "1.4.1.dev6",
"regenerated": "2021-03-23 15:42:18.063977",
"spec_repo_commit": "1906d5b"
"regenerated": "2021-03-23 16:39:48.254739",
"spec_repo_commit": "b13ee4f"
},
"v2": {
"apigentools_version": "1.4.1.dev6",
"regenerated": "2021-03-23 15:42:27.625670",
"spec_repo_commit": "1906d5b"
"regenerated": "2021-03-23 16:39:55.856984",
"spec_repo_commit": "b13ee4f"
}
}
}
1 change: 1 addition & 0 deletions api/v1/datadog/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ Class | Method | HTTP request | Description
*SyntheticsApi* | [**DeletePrivateLocation**](docs/SyntheticsApi.md#deleteprivatelocation) | **Delete** /api/v1/synthetics/private-locations/{location_id} | Delete a private location
*SyntheticsApi* | [**DeleteTests**](docs/SyntheticsApi.md#deletetests) | **Post** /api/v1/synthetics/tests/delete | Delete tests
*SyntheticsApi* | [**EditGlobalVariable**](docs/SyntheticsApi.md#editglobalvariable) | **Put** /api/v1/synthetics/variables/{variable_id} | Edit a global variable
*SyntheticsApi* | [**GetAPITest**](docs/SyntheticsApi.md#getapitest) | **Get** /api/v1/synthetics/tests/api/{public_id} | Get an API test
*SyntheticsApi* | [**GetAPITestLatestResults**](docs/SyntheticsApi.md#getapitestlatestresults) | **Get** /api/v1/synthetics/tests/{public_id}/results | Get the test's latest results summaries (API)
*SyntheticsApi* | [**GetAPITestResult**](docs/SyntheticsApi.md#getapitestresult) | **Get** /api/v1/synthetics/tests/{public_id}/results/{result_id} | Get a test result (API)
*SyntheticsApi* | [**GetBrowserTest**](docs/SyntheticsApi.md#getbrowsertest) | **Get** /api/v1/synthetics/tests/browser/{public_id} | Get a test configuration (browser)
Expand Down
40 changes: 40 additions & 0 deletions api/v1/datadog/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5793,6 +5793,46 @@ paths:
parameters: []
type: unsafe
/api/v1/synthetics/tests/api/{public_id}:
get:
description: |-
Get the detailed configuration associated with
a Synthetic API test.
operationId: GetAPITest
parameters:
- description: The public ID of the test to get details from.
explode: false
in: path
name: public_id
required: true
schema:
type: string
style: simple
responses:
"200":
content:
application/json:
schema:
$ref: '#/components/schemas/SyntheticsAPITest'
description: OK
"403":
content:
application/json:
schema:
$ref: '#/components/schemas/APIErrorResponse'
description: Forbidden
"404":
content:
application/json:
schema:
$ref: '#/components/schemas/APIErrorResponse'
description: |-
- Synthetic Monitoring is not activated for the user
- Test is not owned by the user
summary: Get an API test
tags:
- Synthetics
x-undo:
type: safe
put:
description: Edit the configuration of a Synthetic API test.
operationId: UpdateAPITest
Expand Down
157 changes: 157 additions & 0 deletions api/v1/datadog/api_synthetics.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

95 changes: 95 additions & 0 deletions api/v1/datadog/docs/SyntheticsApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Method | HTTP request | Description
[**DeletePrivateLocation**](SyntheticsApi.md#DeletePrivateLocation) | **Delete** /api/v1/synthetics/private-locations/{location_id} | Delete a private location
[**DeleteTests**](SyntheticsApi.md#DeleteTests) | **Post** /api/v1/synthetics/tests/delete | Delete tests
[**EditGlobalVariable**](SyntheticsApi.md#EditGlobalVariable) | **Put** /api/v1/synthetics/variables/{variable_id} | Edit a global variable
[**GetAPITest**](SyntheticsApi.md#GetAPITest) | **Get** /api/v1/synthetics/tests/api/{public_id} | Get an API test
[**GetAPITestLatestResults**](SyntheticsApi.md#GetAPITestLatestResults) | **Get** /api/v1/synthetics/tests/{public_id}/results | Get the test's latest results summaries (API)
[**GetAPITestResult**](SyntheticsApi.md#GetAPITestResult) | **Get** /api/v1/synthetics/tests/{public_id}/results/{result_id} | Get a test result (API)
[**GetBrowserTest**](SyntheticsApi.md#GetBrowserTest) | **Get** /api/v1/synthetics/tests/browser/{public_id} | Get a test configuration (browser)
Expand Down Expand Up @@ -848,6 +849,100 @@ Name | Type | Description | Notes
[[Back to README]](../README.md)


## GetAPITest

> SyntheticsAPITest GetAPITest(ctx, publicId).Execute()

Get an API test



### Example

```go
package main

import (
"context"
"encoding/json"
"fmt"
"os"
datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
ctx := context.WithValue(
context.Background(),
datadog.ContextAPIKeys,
map[string]datadog.APIKey{
"apiKeyAuth": {
Key: os.Getenv("DD_CLIENT_API_KEY"),
},
"appKeyAuth": {
Key: os.Getenv("DD_CLIENT_APP_KEY"),
},
},
)

if site, ok := os.LookupEnv("DD_SITE"); ok {
ctx = context.WithValue(
ctx,
datadog.ContextServerVariables,
map[string]string{"site": site},
)
}

publicId := "publicId_example" // string | The public ID of the test to get details from.

configuration := datadog.NewConfiguration()

api_client := datadog.NewAPIClient(configuration)
resp, r, err := api_client.SyntheticsApi.GetAPITest(ctx, publicId).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `SyntheticsApi.GetAPITest``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
// response from `GetAPITest`: SyntheticsAPITest
response_content, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from SyntheticsApi.GetAPITest:\n%s\n", response_content)
}
```

### Path Parameters


Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc.
**publicId** | **string** | The public ID of the test to get details from. |

### Other Parameters

Other parameters are passed through a pointer to a apiGetAPITestRequest struct via the builder pattern


Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------


### Return type

[**SyntheticsAPITest**](SyntheticsAPITest.md)

### Authorization

[apiKeyAuth](../README.md#apiKeyAuth), [appKeyAuth](../README.md#appKeyAuth)

### HTTP request headers

- **Content-Type**: Not defined
- **Accept**: application/json

[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints)
[[Back to Model list]](../README.md#documentation-for-models)
[[Back to README]](../README.md)


## GetAPITestLatestResults

> SyntheticsGetAPITestLatestResultsResponse GetAPITestLatestResults(ctx, publicId).FromTs(fromTs).ToTs(toTs).ProbeDc(probeDc).Execute()
Expand Down
14 changes: 14 additions & 0 deletions tests/api/v1/datadog/features/synthetics.feature
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,20 @@ Feature: Synthetics
When the request is sent
Then the response status is 200 OK

@generated @skip
Scenario: Get an API test returns "- Synthetic Monitoring is not activated for the user" response
Given new "GetAPITest" request
And request contains "public_id" parameter from "<PATH>"
When the request is sent
Then the response status is 404 - Synthetic Monitoring is not activated for the user

@generated @skip
Scenario: Get an API test returns "OK" response
Given new "GetAPITest" request
And request contains "public_id" parameter from "<PATH>"
When the request is sent
Then the response status is 200 OK

@generated @skip
Scenario: Get the list of all tests returns "OK - Returns the list of all Synthetic tests." response
Given new "ListTests" request
Expand Down
6 changes: 6 additions & 0 deletions tests/api/v1/datadog/features/undo.json
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,12 @@
"type": "unsafe"
}
},
"GetAPITest": {
"tag": "Synthetics",
"undo": {
"type": "safe"
}
},
"UpdateAPITest": {
"tag": "Synthetics",
"undo": {
Expand Down