diff --git a/apis/sauce.json b/apis/sauce.json index 3b787927..63c5e0ed 100644 --- a/apis/sauce.json +++ b/apis/sauce.json @@ -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": { @@ -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", @@ -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", @@ -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", @@ -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", @@ -1539,6 +1607,12 @@ }, { "$ref": "#/parameters/full" + }, + { + "$ref": "#/parameters/filter" + }, + { + "$ref": "#/parameters/protocol" } ], "responses": { @@ -1577,6 +1651,12 @@ }, { "$ref": "#/parameters/id" + }, + { + "$ref": "#/parameters/reason" + }, + { + "$ref": "#/parameters/wait_for_jobs" } ], "responses": { @@ -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", diff --git a/src/index.js b/src/index.js index 3e2ffda8..8bec5f1c 100644 --- a/src/index.js +++ b/src/index.js @@ -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); } }