diff --git a/api/overview.md b/api/overview.md index c9b5c07..2a35d1a 100644 --- a/api/overview.md +++ b/api/overview.md @@ -51,7 +51,7 @@ Any endpoint that needs an API key can answer: - `403` with `"error": "API_KEY_SCOPE"`: the key's access doesn't cover this endpoint, such as a key limited to **Device sessions only** calling `GET /uploads/list`. - `503` with the message "Could not validate the API key right now": the API couldn't check your key. Retry. It doesn't mean the key is invalid. -The [JUnit report](results.md#download-junit-report) and [HTML report](results.md#download-html-report) downloads answer an error with a `message` only. +The [JUnit report](results.md#download-junit-report) and [HTML report](results.md#download-html-report) downloads, and the [bundle manifests](results.md#download-zips-through-the-cdn), answer an error with a `message` only. Three endpoints report client errors differently: [`GET /results/:uploadId`](results.md#get-results), [`GET /flows`](flows.md#get-flow-summaries) and [`GET /flows/runs`](flows.md#get-runs-for-a-flow) respond with HTTP `200` and report the error in the body instead: diff --git a/api/results.md b/api/results.md index cd643c0..b6268e4 100644 --- a/api/results.md +++ b/api/results.md @@ -135,6 +135,10 @@ curl https://api.devicecloud.dev/results/7e12345f-eb12-12ec-a30b-bb1234f1d12a/re ## Download HTML report +::: warning +This endpoint is deprecated. We're targeting its removal on **1 March 2027**, subject to change based on usage, and its responses carry `Deprecation` and `Sunset` headers. Use [Download ZIPs through the CDN](#download-zips-through-the-cdn) instead: `report-bundle` gives the same ZIP. +::: + Returns a ZIP containing the HTML report together with the screenshots, videos and logs of every test in an upload (the latest attempt of each). An upload with no results in your team answers HTTP `404`. ``` @@ -153,6 +157,10 @@ curl https://api.devicecloud.dev/results/7e12345f-eb12-12ec-a30b-bb1234f1d12a/ht ## Download artifacts +::: warning +This endpoint is deprecated. We're targeting its removal on **1 March 2027**, subject to change based on usage, and its responses carry `Deprecation` and `Sunset` headers. Use [Download ZIPs through the CDN](#download-zips-through-the-cdn) instead: `artifacts-bundle` gives the same ZIP and takes the same `results` and `resultId` filters. +::: + Returns a zip file containing logs, screenshots, and videos. Filter to all results or failing only. Each test's files sit in a folder named after its result ID (`/logs/`, `/screenshots/`, `/videos/`), and a merged JUnit `report.xml` covering the whole upload is added at the root — see [Artifact Archive Structure](../artifacts/artifacts.md#artifact-archive-structure). ``` @@ -185,3 +193,98 @@ curl -X POST https://api.devicecloud.dev/results/7e12345f-eb12-12ec-a30b-bb1234f -d '{"results": "ALL", "resultId": 4446290}' \ -o artifacts.zip ``` + +--- + +## Download ZIPs through the CDN + +Gets the artifacts ZIP or the HTML report ZIP from DeviceCloud's CDN, which builds it. It takes two requests: one to the API for a signed manifest, then one to the CDN with that manifest, which answers with the ZIP. The ZIPs have the same layout as the [HTML report](#download-html-report) and [artifacts](#download-artifacts) downloads, which they replace (see [Artifact Archive Structure](../artifacts/artifacts.md#artifact-archive-structure)). The `dcd` CLI downloads them this way: the CDN builds and serves the ZIP, so a large download doesn't have to pass through the API. + +### 1. Get a manifest + +``` +GET /results/:uploadId/artifacts-bundle +GET /results/:uploadId/report-bundle +``` + +`artifacts-bundle` is for the artifacts ZIP and `report-bundle` for the HTML report ZIP. `artifacts-bundle` takes the same filters as [Download artifacts](#download-artifacts), as query parameters: + +| Parameter | Values | Description | +|-----------|--------|-------------| +| `results` | `FAILED`, `ALL` | Which test artifacts to include. Leave it out for `ALL`. | +| `resultId` | A result ID (optional) | Only the files of the flow run this result belongs to: its first attempt and every retry, on that one device. `report.xml` then covers just that run. A value that isn't a positive whole number is a `400`, and a result that isn't in this upload is a `404`. | + +**Response** + +```json +{ + "bundleUrl": "https://cdn.devicecloud.dev/bundle", + "manifest": "{\"version\":1,\"filename\":\"artifacts-failed.zip\",...}", + "sig": "Vb2y0pQ8xJ3kM1nR5tW7zA9cE4fH6iL0oS2uX8dG1qY", + "filename": "artifacts-failed.zip", + "entryCount": 42 +} +``` + +* `bundleUrl` is where to send the manifest. Use it as given rather than hard-coding it. +* `manifest` and `sig` go to the CDN unchanged. Don't parse `manifest`: its contents may change. +* `filename` is a name you can save the ZIP under. +* `entryCount` is how many stored files the ZIP holds, not counting the generated `report.xml` or `report.html`. + +A manifest expires an hour after it's issued, so get a new one for each download. + +An upload with no results in your team answers HTTP `404`, with only a `message`. An upload with more than 9,000 files answers HTTP `413` with `message`, `entryCount` and `maxEntries`. To download one, ask `artifacts-bundle` for fewer files at a time, with `resultId` or `results=FAILED`. + +### 2. Download the ZIP + +Send `manifest` and `sig` as JSON to `bundleUrl`. Don't send your API key: the signature is what authorizes the request. + +``` +POST +``` + +```json +{ "manifest": "", "sig": "" } +``` + +The answer is the ZIP, streamed as it's built. If a file can't be fetched partway through, the download ends early and leaves a truncated ZIP, so get a new manifest and try again. An error before the ZIP starts comes as plain text: `401` once the manifest has expired, `403` if `manifest` or `sig` doesn't match what the API issued, `400` for a malformed body, and `502` for a temporary problem on our side (retry). + +**Example** + +```bash +curl "https://api.devicecloud.dev/results/7e12345f-eb12-12ec-a30b-bb1234f1d12a/artifacts-bundle?results=FAILED" \ + -H "x-app-api-key: " \ + -o bundle.json + +jq '{manifest, sig}' bundle.json | curl -X POST "$(jq -r .bundleUrl bundle.json)" \ + -H "Content-Type: application/json" \ + --data-binary @- \ + -o artifacts.zip +``` + +The same in Python, with only the standard library: + +```python +import json +import shutil +import urllib.request + +upload_id = "7e12345f-eb12-12ec-a30b-bb1234f1d12a" +manifest_request = urllib.request.Request( + f"https://api.devicecloud.dev/results/{upload_id}/artifacts-bundle?results=FAILED", + headers={"x-app-api-key": ""}, +) +with urllib.request.urlopen(manifest_request) as response: + bundle = json.load(response) + +zip_request = urllib.request.Request( + bundle["bundleUrl"], + data=json.dumps({"manifest": bundle["manifest"], "sig": bundle["sig"]}).encode(), + headers={"Content-Type": "application/json"}, + method="POST", +) +with urllib.request.urlopen(zip_request) as response, open("artifacts.zip", "wb") as out: + shutil.copyfileobj(response, out) +``` + +For the HTML report, request `report-bundle` instead of `artifacts-bundle`, with no query parameters. diff --git a/getting-started/deprecations.md b/getting-started/deprecations.md index 1cc7e66..ab83e12 100644 --- a/getting-started/deprecations.md +++ b/getting-started/deprecations.md @@ -1,10 +1,10 @@ --- -description: "The devices, OS versions, Maestro versions, report formats and runner types DeviceCloud is retiring, when, and what to move to, plus what was removed recently." +description: "The devices, OS versions, Maestro versions, report formats, runner types and API endpoints DeviceCloud is retiring, when, and what to move to, plus what was removed recently." --- # Deprecations & Removals -Before we remove a device, an OS version, a Maestro version, a report format or a runner type, we mark it as deprecated and set a target date for its removal. This page lists what's deprecated now, and what was removed recently. +Before we remove a device, an OS version, a Maestro version, a report format, a runner type or an API endpoint, we mark it as deprecated and set a target date for its removal. This page lists what's deprecated now, and what was removed recently. ## Upcoming @@ -17,6 +17,7 @@ Removal dates are targets, subject to change based on usage. | Pixel 7 (`pixel-7`) | Android device | 14 December 2026 | `pixel-8` or `pixel-10` (`pixel-6` for API level 33). On Google Play, `pixel-8` keeps API level 34 | | Maestro 2.2.0 | Maestro version | 14 December 2026 | 2.6.1 or newer | | Google Play on `cpu1` | Runner type change | 14 December 2026 | Nothing: Google Play runs move to `m1` on their own. Test your app on `m1` first, see [Moving to Apple Silicon](../configuration/google-play-apis.md#moving-to-apple-silicon-m1) | +| `GET /results/:uploadId/html-report` and `POST /results/:uploadId/download` | REST API endpoints | 1 March 2027 | `report-bundle` and `artifacts-bundle`, see [Download ZIPs through the CDN](../api/results.md#download-zips-through-the-cdn). The `dcd` CLI already uses them | `dcd live` is deprecated too, with no removal date set. Use [`dcd device`](../cli/dcd-device.md) instead. diff --git a/public/openapi.yaml b/public/openapi.yaml index 0050e42..37f1810 100644 --- a/public/openapi.yaml +++ b/public/openapi.yaml @@ -29,8 +29,9 @@ info: - **Full access** reaches every endpoint. - **CI: run tests only** reaches `GET /uploads/status`, `GET /results/{uploadId}`, - the report endpoints and `POST /results/{uploadId}/download`, and only for - runs that key started. Any other run answers `404` with + the report endpoints, `POST /results/{uploadId}/download` and the bundle + manifests (`GET /results/{uploadId}/artifacts-bundle` and + `GET /results/{uploadId}/report-bundle`), and only for runs that key started. Any other run answers `404` with `"error": "UPLOAD_NOT_FOUND"`, the same as a run that doesn't exist. - **Device sessions only** reaches the `/device/*` endpoints. @@ -427,9 +428,14 @@ paths: operationId: getHtmlReport tags: [Results] summary: Download HTML report + deprecated: true description: | A ZIP holding the HTML report (`report.html`) with the screenshots, videos and logs of the latest attempt of every test in the upload. + + Deprecated: removal is targeted for 1 March 2027, subject to change based + on usage. Use `getReportBundle` instead. Every response carries + `Deprecation`, `Sunset` and `Link` headers. parameters: - $ref: '#/components/parameters/UploadId' responses: @@ -440,6 +446,12 @@ paths: description: '`attachment; filename="report-.zip"`' schema: type: string + Deprecation: + $ref: '#/components/headers/Deprecation' + Sunset: + $ref: '#/components/headers/Sunset' + Link: + $ref: '#/components/headers/DeprecationLink' content: application/zip: schema: @@ -462,6 +474,7 @@ paths: operationId: downloadArtifacts tags: [Results] summary: Download artifacts + deprecated: true description: | A ZIP of the upload's logs, screenshots and videos. Each test's files sit in a folder named after its result ID (`/logs/`, @@ -474,6 +487,11 @@ paths: The ZIP is streamed as it is built. An error after streaming starts ends the download early, leaving a truncated ZIP. + + Deprecated: removal is targeted for 1 March 2027, subject to change based + on usage. Use `getArtifactsBundle` instead, which takes the same `results` + and `resultId` filters. Every response carries `Deprecation`, `Sunset` and + `Link` headers. parameters: - $ref: '#/components/parameters/UploadId' requestBody: @@ -492,6 +510,12 @@ paths: description: '`attachment; filename="artifacts.zip"`' schema: type: string + Deprecation: + $ref: '#/components/headers/Deprecation' + Sunset: + $ref: '#/components/headers/Sunset' + Link: + $ref: '#/components/headers/DeprecationLink' content: application/zip: schema: @@ -556,6 +580,187 @@ paths: $ref: '#/components/responses/RateLimited' '503': $ref: '#/components/responses/KeyCheckUnavailable' + /results/{uploadId}/artifacts-bundle: + get: + operationId: getArtifactsBundle + tags: [Results] + summary: Get an artifacts bundle manifest + description: | + A signed manifest for the artifacts ZIP, which DeviceCloud's CDN builds. + The ZIP has the same layout as `downloadArtifacts`: each test's files in + a folder named after its result ID, every attempt included, and a JUnit + `report.xml` at the root. + + To get the ZIP, `POST` `{"manifest": "", "sig": ""}` as + JSON to `bundleUrl`, as given, without your API key: the signature + authorizes the request. The answer is the ZIP, streamed as it is built. + A file that can't be fetched partway through ends the download early, + leaving a truncated ZIP. Errors before the ZIP starts are plain text: + `401` once the manifest has expired, `403` if `manifest` or `sig` doesn't + match what the API issued, `400` for a malformed body, and `502` for a + temporary problem on DeviceCloud's side (retry). + + A manifest expires an hour after it's issued, so get a new one for each + download. + parameters: + - $ref: '#/components/parameters/UploadId' + - name: results + in: query + description: | + `FAILED` for the failed tests' files only, `ALL` for every test's. + Leave it out, or pass any other value, for `ALL`. + schema: + type: string + enum: [FAILED, ALL] + default: ALL + - name: resultId + in: query + description: | + Only the files of the flow run this result belongs to: its first + attempt and every retry, on that one device. `report.xml` then covers + just that run. Result IDs are the `id` of each entry in + `GET /results/{uploadId}`. Leave it out for the whole upload. + schema: + type: integer + minimum: 1 + responses: + '200': + description: The signed manifest. + content: + application/json: + schema: + $ref: '#/components/schemas/BundleManifest' + example: + bundleUrl: https://cdn.devicecloud.dev/bundle + manifest: '{"version":1,"filename":"artifacts-failed.zip",...}' + sig: Vb2y0pQ8xJ3kM1nR5tW7zA9cE4fH6iL0oS2uX8dG1qY + filename: artifacts-failed.zip + entryCount: 42 + '400': + description: '`uploadId` isn''t a UUID, or `resultId` isn''t a positive whole number.' + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorEnvelope' + examples: + badUploadId: + summary: uploadId isn't a UUID + value: + statusCode: 400 + message: Validation failed (uuid is expected) + error: Bad Request + badResultId: + summary: resultId isn't a positive whole number + value: + statusCode: 400 + message: resultId must be a positive whole number + error: Bad Request + '403': + $ref: '#/components/responses/Forbidden' + '404': + description: | + The upload has no results in your team, or doesn't exist. With + `resultId`, also a result that isn't in this upload. This body has only + a `message`. For a key with **CI: run tests only** access, a run that + key didn't start also answers `404`, but with the standard error + envelope and `"error": "UPLOAD_NOT_FOUND"`. + content: + application/json: + schema: + anyOf: + - $ref: '#/components/schemas/MessageOnlyError' + - $ref: '#/components/schemas/ErrorEnvelope' + examples: + noResults: + summary: No results + value: + message: No results found for uploadId=7e12345f-eb12-12ec-a30b-bb1234f1d12a + resultNotInUpload: + summary: A resultId from another upload + value: + message: Result 4446290 not found in upload 7e12345f-eb12-12ec-a30b-bb1234f1d12a + notStartedByKey: + summary: A CI-only key, and a run it didn't start + value: + statusCode: 404 + message: Upload not found + error: UPLOAD_NOT_FOUND + '413': + $ref: '#/components/responses/BundleTooLarge' + '429': + $ref: '#/components/responses/RateLimited' + '500': + $ref: '#/components/responses/MessageOnlyServerError' + '501': + $ref: '#/components/responses/BundleUnavailable' + '503': + $ref: '#/components/responses/KeyCheckUnavailable' + /results/{uploadId}/report-bundle: + get: + operationId: getReportBundle + tags: [Results] + summary: Get an HTML report bundle manifest + description: | + A signed manifest for the HTML report ZIP, which DeviceCloud's CDN builds. + The ZIP has the same layout as `getHtmlReport`: the HTML report + (`report.html`) with the screenshots, videos and logs of the latest + attempt of every test in the upload. + + To get the ZIP, `POST` `{"manifest": "", "sig": ""}` as + JSON to `bundleUrl`, as given, without your API key, the same as for + `getArtifactsBundle`. A manifest expires an hour after it's issued. + parameters: + - $ref: '#/components/parameters/UploadId' + responses: + '200': + description: The signed manifest. + content: + application/json: + schema: + $ref: '#/components/schemas/BundleManifest' + example: + bundleUrl: https://cdn.devicecloud.dev/bundle + manifest: '{"version":1,"filename":"report-7e12345f-eb12-12ec-a30b-bb1234f1d12a.zip",...}' + sig: Vb2y0pQ8xJ3kM1nR5tW7zA9cE4fH6iL0oS2uX8dG1qY + filename: report-7e12345f-eb12-12ec-a30b-bb1234f1d12a.zip + entryCount: 42 + '400': + $ref: '#/components/responses/InvalidUploadId' + '403': + $ref: '#/components/responses/Forbidden' + '404': + description: | + The upload has no results in your team, or doesn't exist. This body has + only a `message`. For a key with **CI: run tests only** access, a run + that key didn't start also answers `404`, but with the standard error + envelope and `"error": "UPLOAD_NOT_FOUND"`. + content: + application/json: + schema: + anyOf: + - $ref: '#/components/schemas/MessageOnlyError' + - $ref: '#/components/schemas/ErrorEnvelope' + examples: + noResults: + summary: No results + value: + message: No results found for uploadId=7e12345f-eb12-12ec-a30b-bb1234f1d12a + notStartedByKey: + summary: A CI-only key, and a run it didn't start + value: + statusCode: 404 + message: Upload not found + error: UPLOAD_NOT_FOUND + '413': + $ref: '#/components/responses/BundleTooLarge' + '429': + $ref: '#/components/responses/RateLimited' + '500': + $ref: '#/components/responses/MessageOnlyServerError' + '501': + $ref: '#/components/responses/BundleUnavailable' + '503': + $ref: '#/components/responses/KeyCheckUnavailable' /flows: get: operationId: getFlowSummaries @@ -3378,6 +3583,23 @@ components: description: Seconds to wait before retrying. schema: type: integer + Deprecation: + description: | + The endpoint is deprecated (RFC 9745): `@` and the Unix time it was + deprecated at. + schema: + type: string + example: '@1795564800' + Sunset: + description: When the endpoint is targeted for removal (RFC 8594), as an HTTP date. + schema: + type: string + example: Mon, 01 Mar 2027 00:00:00 GMT + DeprecationLink: + description: Where the replacement is documented. + schema: + type: string + example: ; rel="deprecation" responses: Forbidden: description: | @@ -3475,6 +3697,23 @@ components: statusCode: 404 message: Upload not found error: UPLOAD_NOT_FOUND + BundleTooLarge: + description: | + The ZIP would hold more than 9,000 files. Ask for fewer at a time: with + `getArtifactsBundle`, one flow run with `resultId` or the failed tests + with `results=FAILED`. + content: + application/json: + schema: + $ref: '#/components/schemas/BundleTooLargeError' + BundleUnavailable: + description: | + This deployment can't deliver ZIPs through a CDN. `api.devicecloud.dev` + always can. + content: + application/json: + schema: + $ref: '#/components/schemas/MessageOnlyError' MessageOnlyServerError: description: The report couldn't be built. content: @@ -3637,7 +3876,7 @@ components: type: string MessageOnlyError: type: object - description: The error body of the JUnit and HTML report downloads. + description: The error body of the JUnit and HTML report downloads and the bundle manifests. required: [message] properties: message: @@ -3873,6 +4112,46 @@ components: first attempt and every retry, on that one device. Result IDs are the `id` of each entry in `GET /results/{uploadId}`. Leave it out for the whole upload. + BundleManifest: + type: object + required: [bundleUrl, manifest, sig, filename, entryCount] + properties: + bundleUrl: + type: string + format: uri + description: Where to `POST` the manifest for the ZIP. Use it as given rather than hard-coding it. + manifest: + type: string + description: | + The signed manifest, a JSON document as a string. Send it back unchanged + and don't parse it: its contents may change. + sig: + type: string + description: The manifest's signature. Send it back unchanged. + filename: + type: string + description: | + A name to save the ZIP under: `artifacts-all.zip` or + `artifacts-failed.zip`, `artifacts-result--all.zip` or + `artifacts-result--failed.zip` with `resultId` (`` is the flow + run's first attempt), or `report-.zip`. + entryCount: + type: integer + description: | + How many stored files the ZIP holds, not counting the generated + `report.xml` or `report.html`. + BundleTooLargeError: + type: object + required: [message, entryCount, maxEntries] + properties: + message: + type: string + entryCount: + type: integer + description: How many files the ZIP would hold. + maxEntries: + type: integer + description: The most files one ZIP can hold (9,000). FlowSummaries: type: object required: [statusCode, flows]