This document provides details about the new APIs that were added as part of Bulk Mock Services operations (Start/Stop/Delete).
Note: For the rest of the Mock Services API documentation, see http://api.blazemeter.com/mock-services.
- Response Format of SM Bulk APIs
- Bulk Start Mock Services API
- Bulk Stop Mock Services API
- Bulk Delete Mock Services API
Response Format of SM Bulk APIs
When performing a bulk action on service mocks, a tracking object will be given as a response. This tracking object can be monitored in order to know the status of the bulk action.
The trackingID field of the tracking object can be used with the existing tracking API to look up the current status of the bulk action:
Get tracking object by ID - GET /api/v1/trackings/{trackingId}
For bulk actions, a tracking object of the type MASTER_TRACKING is used, which contains one or more child tracking objects in its serviceMockTrackingDtos field; each of these child tracking objects represents the status of the action for one of that service mocks that the bulk action is being performed on.
Sample Bulk Action response
{
"apiVersion": 1,
"error": null,
"result": [
{
"id": null,
"code": 0,
"message": null,
"trackingDto": {
"trackingId": "f03ca79a-610f-4aa9-b708-284aefef7d14",
"status": "RUNNING",
"errors": [
],
"warnings": [
],
"trackingUrl": "/api/v1/trackings/f03ca79a-610f-4aa9-b708-284aefef7d14",
"data": {
"dataType": "MASTER_TRACKING",
"serviceMockTrackingDtos": [
{
"serviceMockId": 1,
"serviceMockName": "MockService-Jan_26_08:57:32:679 PM",
"trackingDto": {
"trackingId": "7676187b-68f7-4508-b380-dcaa310aaf8f",
"status": "PENDING",
"errors": [
],
"warnings": [
],
"trackingUrl": "/api/v1/trackings/7676187b-68f7-4508-b380-dcaa310aaf8f",
"data": {
"dataType": "CONFIGURATION",
"values": [
39488
]
},
"created": 1611698461,
"createdBy": null,
"updated": 1611698461,
"updatedBy": "user@example.com",
"ended": null
}
}
]
},
"created": 1611698461,
"createdBy": null,
"updated": 1611698461,
"updatedBy": "user@example.com",
"ended": null
}
}
],
"requestId": "4035070a00714041"
}
Bulk Start Mock Services API
API - PATCH
/api/v1/workspaces/{workspaceId}/service-mocks
Similar to other bulk operations
- Swagger link - https://mock.blazemeter.com/swagger-ui.html#/Service%20Mock/bulkMockOperationsUsingPATCH
Required request body fields for mock services:
- action (String) - Must be set to "START"
- mockServiceIds (Number[]) - List of Mock Service Ids that need to be deployed
Sample request
curl --request PATCH \
--url http://localhost:3000/api/v1/workspaces/28906/service-mocks \
--header 'Authorization: Basic <credentials>' \
--header 'Content-Type: application/json' \
--data '{
"action": "START",
“mockServiceIds”:[1],
“credentialsId”: “myCredentialsId”,
“username”: “base64EncodedValue”,
“password”: “base64EncodedValue”
}'
Sample response
{
"apiVersion": 1,
"error": null,
"result": [
{
"id": null,
"code": 0,
"message": null,
"trackingDto": {
"trackingId": "f03ca79a-610f-4aa9-b708-284aefef7d14",
"status": "RUNNING",
"errors": [
],
"warnings": [
],
"trackingUrl": "/api/v1/trackings/f03ca79a-610f-4aa9-b708-284aefef7d14",
"data": {
"dataType": "MASTER_TRACKING",
"serviceMockTrackingDtos": [
{
"serviceMockId": 1,
"serviceMockName": "MockService-Jan_26_08:57:32:679 PM",
"trackingDto": {
"trackingId": "7676187b-68f7-4508-b380-dcaa310aaf8f",
"status": "PENDING",
"errors": [
],
"warnings": [
],
"trackingUrl": "/api/v1/trackings/7676187b-68f7-4508-b380-dcaa310aaf8f",
"data": {
"dataType": "CONFIGURATION",
"values": [
39488
]
},
"created": 1611698461,
"createdBy": null,
"updated": 1611698461,
"updatedBy": "user@example.com",
"ended": null
}
}
]
},
"created": 1611698461,
"createdBy": null,
"updated": 1611698461,
"updatedBy": "user@example.com",
"ended": null
}
}
],
"requestId": "4035070a00714041"
}
Bulk Stop Mock Services API
API - PATCH
/api/v1/workspaces/{workspaceId}/service-mocks
Similar to other bulk operations
- Swagger link - https://mock.blazemeter.com/swagger-ui.html#/Service%20Mock/bulkMockOperationsUsingPATCH
Required request body fields for mock services:
- action (String) - Must be set to "STOP"
- mockServiceIds (Number[]) - List of Mock Service Ids that need to be deployed
Sample request
curl --request PATCH \
--url http://localhost:3000/api/v1/workspaces/28906/service-mocks \
--header 'Authorization: Basic <credentials>' \
--header 'Content-Type: application/json' \
--data '{
"action": "STOP",
“mockServiceIds”:[1],
“username”: “base64EncodedValue”,
“password”: “base64EncodedValue”
}'
Sample response
{
"apiVersion": 1,
"error": null,
"result": [
{
"id": null,
"code": 0,
"message": null,
"trackingDto": {
"trackingId": "f03ca79a-610f-4aa9-b708-284aefef7d14",
"status": "RUNNING",
"errors": [
],
"warnings": [
],
"trackingUrl": "/api/v1/trackings/f03ca79a-610f-4aa9-b708-284aefef7d14",
"data": {
"dataType": "MASTER_TRACKING",
"serviceMockTrackingDtos": [
{
"serviceMockId": 1,
"serviceMockName": "MockService-Jan_26_08:57:32:679 PM",
"trackingDto": {
"trackingId": "7676187b-68f7-4508-b380-dcaa310aaf8f",
"status": "PENDING",
"errors": [
],
"warnings": [
],
"trackingUrl": "/api/v1/trackings/7676187b-68f7-4508-b380-dcaa310aaf8f",
"data": {
"dataType": "CONFIGURATION",
"values": [
39488
]
},
"created": 1611698461,
"createdBy": null,
"updated": 1611698461,
"updatedBy": "user@example.com",
"ended": null
}
}
]
},
"created": 1611698461,
"createdBy": null,
"updated": 1611698461,
"updatedBy": "user@example.com",
"ended": null
}
}
],
"requestId": "4035070a00714041"
}
Bulk Delete Mock Services API
API - PATCH
/api/v1/workspaces/{workspaceId}/service-mocks
Similar to other bulk operations
- Swagger link - https://mock.blazemeter.com/swagger-ui.html#/Service%20Mock/bulkMockOperationsUsingPATCH
Required request body fields for mock services:
- action (String) - Must be set to "DELETE"
- mockServiceIds (Number[]) - List of Mock Service Ids that need to be deployed
Sample request
curl --request PATCH \
--url http://localhost:3000/api/v1/workspaces/28906/service-mocks \
--header 'Authorization: Basic <credentials>' \
--header 'Content-Type: application/json' \
--data '{
"action": "DELETE",
“mockServiceIds”:[1]
}'
Sample response
{
"apiVersion": 1,
"error": null,
"result": [
{
"id": null,
"code": 0,
"message": null,
"trackingDto": {
"trackingId": "f03ca79a-610f-4aa9-b708-284aefef7d14",
"status": "RUNNING",
"errors": [
],
"warnings": [
],
"trackingUrl": "/api/v1/trackings/f03ca79a-610f-4aa9-b708-284aefef7d14",
"data": {
"dataType": "MASTER_TRACKING",
"serviceMockTrackingDtos": [
{
"serviceMockId": 1,
"serviceMockName": "MockService-Jan_26_08:57:32:679 PM",
"trackingDto": {
"trackingId": "7676187b-68f7-4508-b380-dcaa310aaf8f",
"status": "PENDING",
"errors": [
],
"warnings": [
],
"trackingUrl": "/api/v1/trackings/7676187b-68f7-4508-b380-dcaa310aaf8f",
"data": {
"dataType": "CONFIGURATION",
"values": [
39488
]
},
"created": 1611698461,
"createdBy": null,
"updated": 1611698461,
"updatedBy": "user@example.com",
"ended": null
}
}
]
},
"created": 1611698461,
"createdBy": null,
"updated": 1611698461,
"updatedBy": "user@example.com",
"ended": null
}
}
],
"requestId": "4035070a00714041"
}
0 Comments