Skip to content

Commit

Permalink
apis: updating sauce connect api
Browse files Browse the repository at this point in the history
  • Loading branch information
waggledans committed Aug 15, 2024
1 parent 631ac0e commit a69773e
Show file tree
Hide file tree
Showing 2 changed files with 121 additions and 5 deletions.
112 changes: 112 additions & 0 deletions apis/sauce.json
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,30 @@
},
"type": "object"
},
"SauceConnectVersions": {
"type": "object",
"properties": {
"latest_version": {
"type": "string"
},
"client_version": {
"type": "string"
},
"status": {
"type": "string",
"enum": ["LATEST", "UPGRADE", "PRERELEASE", "UNKNOWN", "EOL"]
},
"info_url": {
"type": "string"
},
"download_url": {
"type": "string"
},
"sha1": {
"type": "string"
}
}
},
"SauceStatus": {
"properties": {
"service_operational": {
Expand Down Expand Up @@ -742,6 +766,20 @@
"required": true,
"type": "string"
},
"clientHost": {
"description": "SC client host OS and CPU arch",
"in": "query",
"name": "client_host",
"required": false,
"type": "string"
},
"clientVersion": {
"description": "SC client version",
"in": "query",
"name": "client_version",
"required": false,
"type": "string"
},
"filepath": {
"description": "file path to store the asset at",
"in": "path",
Expand All @@ -756,6 +794,14 @@
"required": true,
"type": "string"
},
"filter": {
"description": "Filter expression to apply before returning query results",
"in": "query",
"name": "filter",
"enum": ["v2alpha", "one_per_pool"],
"required": false,
"type": "string"
},
"full": {
"description": "Should the response result contain everything or just the basics",
"in": "query",
Expand Down Expand Up @@ -811,6 +857,21 @@
"type": "object"
}
},
"protocol": {
"description": "Sauce Connect Protocol",
"in": "query",
"name": "protocol",
"required": false,
"enum": ["kgp", "h2c"],
"type": "string"
},
"reason": {
"description": "Reason for stopping a tunnel",
"in": "query",
"name": "reason",
"required": true,
"type": "string"
},
"subaccounts": {
"default": false,
"description": "Include subaccounts in list of jobs",
Expand All @@ -825,6 +886,13 @@
"required": true,
"type": "string"
},
"wait_for_jobs": {
"default": true,
"description": "Wait for jobs to finish",
"in": "query",
"name": "wait_for_jobs",
"type": "boolean"
},
"jobIds": {
"description": "list of jobIds",
"in": "query",
Expand Down Expand Up @@ -1539,6 +1607,12 @@
},
{
"$ref": "#/parameters/full"
},
{
"$ref": "#/parameters/filter"
},
{
"$ref": "#/parameters/protocol"
}
],
"responses": {
Expand Down Expand Up @@ -1577,6 +1651,12 @@
},
{
"$ref": "#/parameters/id"
},
{
"$ref": "#/parameters/reason"
},
{
"$ref": "#/parameters/wait_for_jobs"
}
],
"responses": {
Expand Down Expand Up @@ -1633,6 +1713,38 @@
"tags": ["Tunnel"]
}
},
"/v1/public/tunnels/info/versions": {
"get": {
"operationId": "sc_versions",
"parameters": [
{
"$ref": "#/parameters/clientVersion"
},
{
"$ref": "#/parameters/clientHost"
},
{
"$ref": "#/parameters/all"
}
],
"responses": {
"200": {
"description": "Tunnels",
"schema": {
"$ref": "#/definitions/SauceConnectVersions"
}
},
"default": {
"description": "Unexpected error",
"schema": {
"$ref": "#/definitions/Error"
}
}
},
"summary": "Get tunnels for the user or all the users in the team",
"tags": ["Tunnel"]
}
},
"/v1/jobs/{id}/{assetName}": {
"get": {
"operationId": "download_job_asset",
Expand Down
14 changes: 9 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -529,20 +529,24 @@ export default class SauceLabs {
const options = args.slice(pathParams.length)[0] || {};
for (const optionParam of params.filter((p) => p.in === 'query')) {
const expectedType = optionParam.type.replace('integer', 'number');
// I'm not sure why query param name is camelcased here, underscore params do exist in Sauce Labs.
const optionName = camelCase(optionParam.name);
const option = options[optionName];
const optionValue = options[optionName] || options[optionParam.name];
const isRequired =
Boolean(optionParam.required) ||
(typeof optionParam.required === 'undefined' &&
typeof optionParam.default === 'undefined');
if ((isRequired || option) && !isValidType(option, expectedType)) {
if (
(isRequired || optionValue) &&
!isValidType(optionValue, expectedType)
) {
throw new Error(
`Expected parameter for option '${optionName}' from type '${expectedType}', found '${typeof option}'`
`Expected parameter for option '${optionName}' from type '${expectedType}', found '${typeof optionValue}'`
);
}

if (typeof option !== 'undefined') {
bodyMap.set(optionParam.name, option);
if (typeof optionValue !== 'undefined') {
bodyMap.set(optionParam.name, optionValue);
}
}

Expand Down

0 comments on commit a69773e

Please sign in to comment.