Skip to content

Add method to export an API test in Synthetics #334

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

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:43:44.620545",
"spec_repo_commit": "1906d5b"
"regenerated": "2021-03-23 16:40:45.271782",
"spec_repo_commit": "b13ee4f"
},
"v2": {
"apigentools_version": "1.4.1.dev6",
"regenerated": "2021-03-23 15:44:24.067727",
"spec_repo_commit": "1906d5b"
"regenerated": "2021-03-23 16:41:26.242708",
"spec_repo_commit": "b13ee4f"
}
}
}
1 change: 1 addition & 0 deletions docs/v1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ Class | Method | HTTP request | Description
*SyntheticsApi* | [**delete_private_location**](SyntheticsApi.md#delete_private_location) | **DELETE** /api/v1/synthetics/private-locations/{location_id} | Delete a private location
*SyntheticsApi* | [**delete_tests**](SyntheticsApi.md#delete_tests) | **POST** /api/v1/synthetics/tests/delete | Delete tests
*SyntheticsApi* | [**edit_global_variable**](SyntheticsApi.md#edit_global_variable) | **PUT** /api/v1/synthetics/variables/{variable_id} | Edit a global variable
*SyntheticsApi* | [**get_api_test**](SyntheticsApi.md#get_api_test) | **GET** /api/v1/synthetics/tests/api/{public_id} | Get an API test
*SyntheticsApi* | [**get_api_test_latest_results**](SyntheticsApi.md#get_api_test_latest_results) | **GET** /api/v1/synthetics/tests/{public_id}/results | Get the test's latest results summaries (API)
*SyntheticsApi* | [**get_api_test_result**](SyntheticsApi.md#get_api_test_result) | **GET** /api/v1/synthetics/tests/{public_id}/results/{result_id} | Get a test result (API)
*SyntheticsApi* | [**get_browser_test**](SyntheticsApi.md#get_browser_test) | **GET** /api/v1/synthetics/tests/browser/{public_id} | Get a test configuration (browser)
Expand Down
77 changes: 77 additions & 0 deletions docs/v1/SyntheticsApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Method | HTTP request | Description
[**delete_private_location**](SyntheticsApi.md#delete_private_location) | **DELETE** /api/v1/synthetics/private-locations/{location_id} | Delete a private location
[**delete_tests**](SyntheticsApi.md#delete_tests) | **POST** /api/v1/synthetics/tests/delete | Delete tests
[**edit_global_variable**](SyntheticsApi.md#edit_global_variable) | **PUT** /api/v1/synthetics/variables/{variable_id} | Edit a global variable
[**get_api_test**](SyntheticsApi.md#get_api_test) | **GET** /api/v1/synthetics/tests/api/{public_id} | Get an API test
[**get_api_test_latest_results**](SyntheticsApi.md#get_api_test_latest_results) | **GET** /api/v1/synthetics/tests/{public_id}/results | Get the test's latest results summaries (API)
[**get_api_test_result**](SyntheticsApi.md#get_api_test_result) | **GET** /api/v1/synthetics/tests/{public_id}/results/{result_id} | Get a test result (API)
[**get_browser_test**](SyntheticsApi.md#get_browser_test) | **GET** /api/v1/synthetics/tests/browser/{public_id} | Get a test configuration (browser)
Expand Down Expand Up @@ -1059,6 +1060,82 @@ Name | Type | Description | Notes

[[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)

# **get_api_test**
> SyntheticsAPITest get_api_test(public_id)

Get an API test

Get the detailed configuration associated with a Synthetic API test.

### Example

* Api Key Authentication (apiKeyAuth):
* Api Key Authentication (appKeyAuth):
```python
import os
from dateutil.parser import parse as dateutil_parser
from datadog_api_client.v1 import ApiClient, ApiException, Configuration
from datadog_api_client.v1.api import synthetics_api
from datadog_api_client.v1.models import *
from pprint import pprint
# See configuration.py for a list of all supported configuration parameters.
configuration = Configuration()

# Defining the site is optional and defaults to datadoghq.com
if "DD_SITE" in os.environ:
configuration.server_variables["site"] = os.environ["DD_SITE"]

# Configure API key authorization: apiKeyAuth
configuration.api_key['apiKeyAuth'] = os.getenv('DD_CLIENT_API_KEY')

# Configure API key authorization: appKeyAuth
configuration.api_key['appKeyAuth'] = os.getenv('DD_CLIENT_APP_KEY')

# Enter a context with an instance of the API client
with ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = synthetics_api.SyntheticsApi(api_client)
public_id = "public_id_example" # str | The public ID of the test to get details from.

# example passing only required values which don't have defaults set
try:
# Get an API test
api_response = api_instance.get_api_test(public_id)
pprint(api_response)
except ApiException as e:
print("Exception when calling SyntheticsApi->get_api_test: %s\n" % e)
```


### Parameters

Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**public_id** | **str**| The public ID of the test to get details from. |

### Return type

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

### Authorization

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

### HTTP request headers

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


### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
**200** | OK | - |
**403** | Forbidden | - |
**404** | - Synthetic Monitoring is not activated for the user - Test is not owned by the user | - |

[[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)

# **get_api_test_latest_results**
> SyntheticsGetAPITestLatestResultsResponse get_api_test_latest_results(public_id)

Expand Down
91 changes: 91 additions & 0 deletions src/datadog_api_client/v1/api/synthetics_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -848,6 +848,97 @@ def __edit_global_variable(self, variable_id, body, **kwargs):
callable=__edit_global_variable,
)

def __get_api_test(self, public_id, **kwargs):
"""Get an API test # noqa: E501

Get the detailed configuration associated with a Synthetic API test. # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True

>>> thread = api.get_api_test(public_id, async_req=True)
>>> result = thread.get()

Args:
public_id (str): The public ID of the test to get details from.

Keyword Args:
_return_http_data_only (bool): response data without head status
code and headers. Default is True.
_preload_content (bool): if False, the urllib3.HTTPResponse object
will be returned without reading/decoding response data.
Default is True.
_request_timeout (float/tuple): timeout setting for this request. If one
number provided, it will be total request timeout. It can also
be a pair (tuple) of (connection, read) timeouts.
Default is None.
_check_input_type (bool): specifies if type checking
should be done one the data sent to the server.
Default is True.
_check_return_type (bool): specifies if type checking
should be done one the data received from the server.
Default is True.
_host_index (int/None): specifies the index of the server
that we want to use.
Default is read from the configuration.
async_req (bool): execute request asynchronously

Returns:
SyntheticsAPITest
If the method is called asynchronously, returns the request
thread.
"""
kwargs["async_req"] = kwargs.get("async_req", False)
kwargs["_return_http_data_only"] = kwargs.get("_return_http_data_only", True)
kwargs["_preload_content"] = kwargs.get("_preload_content", True)
kwargs["_request_timeout"] = kwargs.get("_request_timeout", None)
kwargs["_check_input_type"] = kwargs.get("_check_input_type", True)
kwargs["_check_return_type"] = kwargs.get("_check_return_type", True)
kwargs["_host_index"] = kwargs.get("_host_index")
kwargs["public_id"] = public_id
return self.call_with_http_info(**kwargs)

self.get_api_test = _Endpoint(
settings={
"response_type": (SyntheticsAPITest,),
"auth": ["apiKeyAuth", "appKeyAuth"],
"endpoint_path": "/api/v1/synthetics/tests/api/{public_id}",
"operation_id": "get_api_test",
"http_method": "GET",
"servers": None,
},
params_map={
"all": [
"public_id",
],
"required": [
"public_id",
],
"nullable": [],
"enum": [],
"validation": [],
},
root_map={
"validations": {},
"allowed_values": {},
"openapi_types": {
"public_id": (str,),
},
"attribute_map": {
"public_id": "public_id",
},
"location_map": {
"public_id": "path",
},
"collection_format_map": {},
},
headers_map={
"accept": ["application/json"],
"content_type": [],
},
api_client=api_client,
callable=__get_api_test,
)

def __get_api_test_latest_results(self, public_id, **kwargs):
"""Get the test's latest results summaries (API) # noqa: E501

Expand Down
38 changes: 38 additions & 0 deletions src/datadog_api_client/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16451,6 +16451,44 @@ 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.
in: path
name: public_id
required: true
schema:
type: string
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
14 changes: 14 additions & 0 deletions tests/v1/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/v1/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