diff --git a/config/android.yaml b/config/android.yaml index dde14241..af13b4fb 100644 --- a/config/android.yaml +++ b/config/android.yaml @@ -1,4 +1,6 @@ changelog: + - 1.6.5 (2024-10-21): + - Add summary feature - 1.6.4 (2024-10-08): - Add transcript feature - 1.6.3 (2024-09-30): diff --git a/config/csharp.yaml b/config/csharp.yaml index 50e188ba..c1faa6f3 100644 --- a/config/csharp.yaml +++ b/config/csharp.yaml @@ -1,4 +1,6 @@ changelog: + - 1.6.5 (2024-10-21): + - Add summary feature - 1.6.4 (2024-10-08): - Add transcript feature - 1.6.3 (2024-09-30): diff --git a/config/go.yaml b/config/go.yaml index 10ced6d5..e2f639a8 100644 --- a/config/go.yaml +++ b/config/go.yaml @@ -1,4 +1,6 @@ changelog: + - 1.4.5 (2024-10-21): + - Add summary feature - 1.4.4 (2024-10-08): - Add transcript feature - 1.4.3 (2024-09-30): diff --git a/config/java.yaml b/config/java.yaml index abeac760..5fd2b147 100644 --- a/config/java.yaml +++ b/config/java.yaml @@ -1,4 +1,6 @@ changelog: + - 1.4.5 (2024-10-21): + - Add summary feature - 1.4.4 (2024-10-08): - Add transcript feature - 1.4.3 (2024-09-30): diff --git a/config/nodejs.yaml b/config/nodejs.yaml index 836bb659..6d8d9dc0 100644 --- a/config/nodejs.yaml +++ b/config/nodejs.yaml @@ -1,4 +1,6 @@ changelog: + - 2.6.6 (2024-10-21): + - Add summary feature - 2.6.5 (2024-10-17): - Fix postinstall script - 2.6.4 (2024-10-08): diff --git a/config/php.yaml b/config/php.yaml index de983220..abbcac8b 100644 --- a/config/php.yaml +++ b/config/php.yaml @@ -1,4 +1,6 @@ changelog: + - 1.4.5 (2024-10-21): + - Add summary feature - 1.4.4 (2024-10-08): - Add transcript feature - 1.4.3 (2024-09-30): diff --git a/config/python.yaml b/config/python.yaml index 6f7bacd2..abb449df 100644 --- a/config/python.yaml +++ b/config/python.yaml @@ -1,4 +1,6 @@ changelog: + - 1.4.5 (2024-10-21): + - Add summary feature - 1.4.4 (2024-10-08): - Add transcript feature - 1.4.3 (2024-09-30): diff --git a/config/swift5-uploader.yaml b/config/swift5-uploader.yaml index 2a0e6294..8d8f137f 100644 --- a/config/swift5-uploader.yaml +++ b/config/swift5-uploader.yaml @@ -1,4 +1,6 @@ changelog: + - 1.2.5 (2024-10-21): + - Add support for Alamofire 5.10 - 1.2.4 (2024-10-08): - Add transcript feature - 1.2.3 (2024-04-25): diff --git a/config/swift5.yaml b/config/swift5.yaml index 6ea4aed9..6d2c9e74 100644 --- a/config/swift5.yaml +++ b/config/swift5.yaml @@ -1,4 +1,7 @@ changelog: + - 1.3.5 (2024-10-21): + - Add summary feature + - Add support for Alamofire 5.10 - 1.3.4 (2024-10-08): - Add transcript feature - 1.3.3 (2024-09-30): diff --git a/oas_apivideo.yaml b/oas_apivideo.yaml index 29de866c..027cb484 100644 --- a/oas_apivideo.yaml +++ b/oas_apivideo.yaml @@ -1044,6 +1044,379 @@ paths: type: 'https://docs.api.video/reference/too-many-requests' title: Too many requests. status: 429 + /summaries: + post: + tags: + - Summaries + summary: Generate video summary + description: Generate a title, abstract, and key takeaways for a video. + x-client-action: create + x-client-description: + default: 'Generate a title, abstract, and key takeaways for a video.' + operationId: POST_summaries + security: + - apiKey: [] + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/summary-creation-payload' + responses: + '201': + headers: + X-RateLimit-Limit: + schema: + type: integer + description: The request limit per minute. + X-RateLimit-Remaining: + schema: + type: integer + description: The number of available requests left for the current time window. + X-RateLimit-Retry-After: + schema: + type: integer + description: The number of seconds left until the current rate limit window resets. + description: Created + content: + application/json: + schema: + $ref: '#/components/schemas/summary' + examples: + Summary created: + value: + summaryId: 'summary_1CGHWuXjhxmeH4WiZ51234' + createdAt: '2024-07-14T23:36:07+00:00' + updatedAt: '2024-07-14T23:36:07+00:00' + videoId: 'vilkR8K3N7yrRcxcMt91234' + origin: auto + sourceStatus: completed + '409': + headers: + X-RateLimit-Limit: + schema: + type: integer + description: The request limit per minute. + X-RateLimit-Remaining: + schema: + type: integer + description: The number of available requests left for the current time window. + X-RateLimit-Retry-After: + schema: + type: integer + description: The number of seconds left until the current rate limit window resets. + description: Conflict + content: + application/json: + schema: + $ref: '#/components/schemas/conflict-error' + examples: + Summary already exists: + value: + type: https://docs.api.video/reference/summary-already-exists + title: A summary already exists or is being created on this video. + status: 409 + detail: You can delete the existing summary and generate a new one. + name: videoId + get: + tags: + - Summaries + summary: List summaries + description: List all summarries for your videos in a project. + x-client-action: list + x-client-description: + default: 'List all summarries for your videos in a project.' + operationId: GET_summaries + parameters: + - name: videoId + in: query + required: false + description: Use this parameter to filter for a summary that belongs to a specific video. + schema: + type: string + example: vilkR8K3N7yrRcxcMt91234 + - name: origin + in: query + required: false + description: 'Use this parameter to filter for summaries based on the way they were created: automatically or manually via the API.' + schema: + type: string + enum: [auto, api] + example: auto + - name: sourceStatus + in: query + required: false + description: | + Use this parameter to filter for summaries based on the current status of the summary source. + + These are the available statuses: + + `missing`: the input for a summary is not present. + `waiting` : the input video is being processed and a summary will be generated. + `failed`: a technical issue prevented summary generation. + `completed`: the summary is generated. + `unprocessable`: the API rules the source video to be unsuitable for summary generation. An example for this is an input video that has no audio. + schema: + type: string + enum: [missing, waiting, failed, completed, unprocessable] + example: auto + - name: sortBy + in: query + description: | + Use this parameter to choose which field the API will use to sort the response data. The default is `value`. + + These are the available fields to sort by: + + - `createdAt`: Sorts the results based on date and timestamps when summaries were created. + - `updatedAt`: Sorts the results based on date and timestamps when summaries were last updated. + - `videoId`: Sorts the results based on video IDs. + required: false + style: form + explode: true + schema: + type: string + enum: [createdAt, updatedAt, videoId] + example: createdAt + - name: sortOrder + in: query + description: 'Use this parameter to sort results. `asc` is ascending and sorts from A to Z. `desc` is descending and sorts from Z to A.' + required: false + style: form + explode: true + schema: + type: string + enum: [asc, desc] + example: asc + - $ref: '#/components/parameters/current-page' + - $ref: '#/components/parameters/page-size' + x-group-parameters: true + x-client-paginated: true + responses: + '200': + headers: + X-RateLimit-Limit: + schema: + type: integer + description: The request limit per minute. + X-RateLimit-Remaining: + schema: + type: integer + description: The number of available requests left for the current time window. + X-RateLimit-Retry-After: + schema: + type: integer + description: The number of seconds left until the current rate limit window resets. + description: Created + content: + application/json: + schema: + $ref: '#/components/schemas/summaries-list-response' + examples: + List all summaries: + value: + data: + - summaryId: 'summary_1CGHWuXjhxmeH4WiZ51234' + createdAt: '2024-07-14T23:36:07+00:00' + updatedAt: '2024-07-14T23:36:07+00:00' + videoId: 'vilkR8K3N7yrRcxcMt91234' + origin: auto + sourceStatus: completed + - summaryId: 'summary_123HWuXjhxmeH4WiZ55678' + createdAt: '2024-07-15T23:36:07+00:00' + updatedAt: '2024-07-15T23:36:07+00:00' + videoId: 'vibaBXK3N7yrRcxcMt95678' + origin: auto + sourceStatus: waiting + pagination: + currentPage: 1 + pageSize: 25 + pagesTotal: 1 + itemsTotal: 11 + currentPageItems: 11 + links: + - rel: self + uri: 'https://ws.api.video/summaries?currentPage=1' + - rel: first + uri: 'https://ws.api.video/summaries?currentPage=1' + - rel: last + uri: 'https://ws.api.video/summaries?currentPage=1' + /summaries/{summaryId}: + delete: + tags: + - Summaries + summary: Delete video summary + description: Delete a summary tied to a video. + x-client-action: delete + x-client-description: + default: 'Delete a summary tied to a video.' + operationId: DELETE_summaries-summaryId + security: + - apiKey: [] + parameters: + - name: summaryId + in: path + description: The unique identifier of the summary you want to delete. + required: true + style: simple + explode: false + schema: + type: string + example: 'summary_1CGHWuXjhxmeH4WiZ51234' + responses: + '204': + headers: + X-RateLimit-Limit: + schema: + type: integer + description: The request limit per minute. + X-RateLimit-Remaining: + schema: + type: integer + description: The number of available requests left for the current time window. + X-RateLimit-Retry-After: + schema: + type: integer + description: The number of seconds left until the current rate limit window resets. + description: No Content + /summaries/{summaryId}/source: + get: + tags: + - Summaries + summary: Get summary details + description: Get all details for a summary + x-client-action: getSummarySource + x-client-description: + default: 'Get all details for a summary.' + operationId: GET_summaries-summaryId-source + security: + - apiKey: [] + parameters: + - name: summaryId + in: path + description: The unique identifier of the summary source you want to retrieve. + required: true + style: simple + explode: false + schema: + type: string + example: 'summary_1CGHWuXjhxmeH4WiZ51234' + responses: + '200': + headers: + X-RateLimit-Limit: + schema: + type: integer + description: The request limit per minute. + X-RateLimit-Remaining: + schema: + type: integer + description: The number of available requests left for the current time window. + X-RateLimit-Retry-After: + schema: + type: integer + description: The number of seconds left until the current rate limit window resets. + description: Success + content: + application/json: + schema: + $ref: '#/components/schemas/summary-source' + '404': + headers: + X-RateLimit-Limit: + schema: + type: integer + description: The request limit per minute. + X-RateLimit-Remaining: + schema: + type: integer + description: The number of available requests left for the current time window. + X-RateLimit-Retry-After: + schema: + type: integer + description: The number of seconds left until the current rate limit window resets. + description: Not Found + content: + application/json: + schema: + $ref: '#/components/schemas/not-found' + examples: + response: + value: + type: 'https://docs.api.video/reference/resource-not-found' + title: The requested resource was not found. + name: summaryId + status: 404 + patch: + tags: + - Summaries + summary: Update summary details + description: Update details for a summary. Note that this operation is only allowed for summary objects where `sourceStatus` is `missing`. + x-client-action: update + x-client-description: + default: 'Update details for a summary. Note that this operation is only allowed for summary objects where `sourceStatus` is `missing`.' + operationId: PATCH_summaries-summaryId-source + parameters: + - name: summaryId + in: path + description: The unique identifier of the summary source you want to update. + required: true + style: simple + explode: false + schema: + type: string + example: 'summary_1CGHWuXjhxmeH4WiZ51234' + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/summary-update-payload' + responses: + '201': + headers: + X-RateLimit-Limit: + schema: + type: integer + description: The request limit per minute. + X-RateLimit-Remaining: + schema: + type: integer + description: The number of available requests left for the current time window. + X-RateLimit-Retry-After: + schema: + type: integer + description: The number of seconds left until the current rate limit window resets. + description: Created + content: + application/json: + schema: + $ref: '#/components/schemas/summary-source' + '409': + headers: + X-RateLimit-Limit: + schema: + type: integer + description: The request limit per minute. + X-RateLimit-Remaining: + schema: + type: integer + description: The number of available requests left for the current time window. + X-RateLimit-Retry-After: + schema: + type: integer + description: The number of seconds left until the current rate limit window resets. + description: Conflict + content: + application/json: + schema: + $ref: '#/components/schemas/conflict-error' + examples: + Summary already exists: + value: + type: https://docs.api.video/reference/summary-already-exists + title: A summary already exists or is being created on this video. + status: 409 + detail: You can delete the existing summary and generate a new one. '/videos/{videoId}/source': post: tags: @@ -3366,6 +3739,33 @@ paths: title: The requested resource was not found. name: videoId status: 404 + '409': + headers: + X-RateLimit-Limit: + schema: + type: integer + description: The request limit per minute. + X-RateLimit-Remaining: + schema: + type: integer + description: The number of available requests left for the current time window. + X-RateLimit-Retry-After: + schema: + type: integer + description: The number of seconds left until the current rate limit window resets. + description: Conflict + content: + application/json: + schema: + $ref: '#/components/schemas/conflict-error' + examples: + Summary already exists: + value: + type: https://docs.api.video/reference/summary-already-exists + title: A summary already exists or is being created on this video. + status: 409 + detail: You can delete the existing summary and generate a new one. + name: transcriptSummary '429': headers: X-RateLimit-Limit: @@ -14646,12 +15046,16 @@ components: type: object properties: type: + description: A link to the error documentation. type: string title: + description: A description of the error that occurred. type: string name: + description: The name of the parameter that caused the error. type: string status: + description: The HTTP status code. type: integer too-many-requests: title: TooManyRequests @@ -15465,8 +15869,151 @@ components: - The default value is `false`. - If you define a video language using the `language` parameter, the API uses that language to transcribe the video. If you do not define a language, the API detects it based on the video. - When the API generates a transcript, it will be available as a caption for the video. + transcriptSummary: + type: boolean + description: |- + Use this parameter to enable summarization. We recommend using this parameter together with `transcript: true`. + + - When `true`, the API generates a summary for the video, based on the transcription. + - The default value is `false`. + - If you define a video language using the `language` parameter, the API uses that language to summarize the video. If you do not define a language, the API detects it based on the video. required: - title + summary-creation-payload: + required: + - videoId + type: object + properties: + videoId: + type: string + description: Create a summary of a video using the video ID. + example: vi4k0jvEUuaTdRAEjQ4Jfrgz + origin: + type: string + enum: [auto] + description: |- + Use this parameter to define how the API generates the summary. The only allowed value is `auto`, which means that the API generates a summary automatically. + + If you do not set this parameter, **the API will not generate a summary automatically**. + + In this case, `sourceStatus` will return `missing`, and you have to manually add a summary using the `PATCH /summaries/{summaryId}/source` endpoint operation. + example: auto + summary-update-payload: + type: object + properties: + title: + type: string + description: A video title, based on the contents of the video. + example: 'A short lecture on quantum theory' + abstract: + type: string + description: A short outline of the contents of the video. + example: 'In this lecture, we discuss how complicated quantum theory is, using the famous example of Schrödingers cat. We also discuss practical applications like quantum computing.' + takeaways: + type: array + description: A list of 3 key points from the video, in chronological order. + maxItems: 3 + items: + type: string + example: + - Quantum theory is complicated. + - Schrödinger's cat is neither dead, nor alive. + - Quantum computers are super cool. + conflict-error: + type: object + properties: + type: + description: A link to the error documentation. + type: string + title: + description: A description of the error that occurred. + type: string + name: + description: The name of the parameter that caused the error. + type: string + status: + description: The HTTP status code. + type: integer + detail: + description: A solution for the error. + type: string + summary-source: + type: object + properties: + title: + type: string + description: A video title, based on the contents of the video. + example: 'A short lecture on quantum theory' + abstract: + type: string + description: A short outline of the contents of the video. The length of an `abstract` depends on the amount of content in a video that can be transcribed. The API condenses the contents into minimum 20, maximum 300 words. + example: 'In this lecture, we discuss how complicated quantum theory is, using the famous example of Schrödingers cat. We also discuss practical applications like quantum computing.' + takeaways: + type: array + description: A list of 3 key points from the video, in chronological order. + maxItems: 3 + items: + type: string + example: + - Quantum theory is complicated. + - Schrödinger's cat is neither dead, nor alive. + - Quantum computers are super cool. + summaries-list-response: + type: object + title: Summaries + properties: + data: + type: array + description: An array of summary objects. + items: + $ref: '#/components/schemas/summary' + pagination: + $ref: '#/components/schemas/pagination' + required: + - data + - pagination + summary: + type: object + properties: + summaryId: + type: string + description: The unique identifier of the summary object. + example: 'summary_1CGHWuXjhxmeH4WiZ51234' + createdAt: + description: Returns the date and time when the summary was created in ATOM date-time format. + type: string + format: date-time + example: '2024-05-28T11:15:07+00:00' + updatedAt: + description: Returns the date and time when the summary was last updated in ATOM date-time format. + type: string + format: date-time + example: '2024-05-28T11:15:07+00:00' + videoId: + type: string + description: The unique identifier of the video object. + example: 'vi4k0jvEUuaTdRAEjQ4Prklg' + origin: + type: string + enum: + - api + - auto + description: |- + Returns the origin of how the summary was created. + + - `api` means that no summary was generated automatically. You can add summary manually using the `PATCH /summaries/{summaryId}/source` endpoint operation. Until this happens, `sourceStatus` returns `missing`. + - `auto` means that the API generated the summary automatically. + sourceStatus: + type: string + description: |- + Returns the current status of summary generation. + + `missing`: the input for a summary is not present. + `waiting` : the input video is being processed and a summary will be generated. + `failed`: a technical issue prevented summary generation. + `completed`: the summary is generated. + `unprocessable`: the API rules the source video to be unsuitable for summary generation. An example for this is an input video that has no audio. + enum: [missing, waiting, failed, completed, unprocessable] video-upload-payload: required: - file @@ -15564,6 +16111,14 @@ components: - The default value is `false`. - If you define a video language using the `language` parameter, the API uses that language to transcribe the video. If you do not define a language, the API detects it based on the video. - When the API generates a transcript, it will be available as a caption for the video. + transcriptSummary: + type: boolean + description: |- + Use this parameter to enable summarization. + + - When `true`, the API generates a summary for the video, based on the transcription. + - The default value is `false`. + - If you define a video language using the `language` parameter, the API uses that language to summarize the video. If you do not define a language, the API detects it based on the video. example: playerId: pl45KFKdlddgk654dspkze title: String theory @@ -15571,6 +16126,7 @@ components: public: false language: 'en' transcript: true + transcriptSummary: true panoramic: false mp4Support: true tags: diff --git a/templates/java/statics/android/src/test/java/video/api/client/api/clients/SummariesApiTest.java b/templates/java/statics/android/src/test/java/video/api/client/api/clients/SummariesApiTest.java new file mode 100644 index 00000000..505dee6c --- /dev/null +++ b/templates/java/statics/android/src/test/java/video/api/client/api/clients/SummariesApiTest.java @@ -0,0 +1,163 @@ +/* + * api.video Java API client + * api.video is an API that encodes on the go to facilitate immediate playback, enhancing viewer streaming experiences across multiple devices and platforms. You can stream live or on-demand online videos within minutes. + * + * The version of the OpenAPI document: 1 + * Contact: ecosystem@api.video + * + * NOTE: This class is auto generated. + * Do not edit the class manually. + */ + +package video.api.client.api.clients; + +import video.api.client.api.ApiException; +import video.api.client.api.models.*; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatNoException; +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +/** + * API tests for SummariesApi + */ +@DisplayName("SummariesApi") +public class SummariesApiTest extends AbstractApiTest { + + private final SummariesApi api = apiClientMock.summaries(); + + @Nested + @DisplayName("create") + class create { + private static final String PAYLOADS_PATH = "/payloads/summaries/create/"; + + @Test + @DisplayName("required parameters") + public void requiredParametersTest() { + answerOnAnyRequest(201, "{}"); + + assertThatThrownBy(() -> api.create(new SummaryCreationPayload())) + .hasMessage("Missing the required parameter 'summaryCreationPayload.videoId' when calling create"); + + assertThatThrownBy(() -> api.create(null)) + .hasMessage("Missing the required parameter 'summaryCreationPayload' when calling create"); + + assertThatNoException().isThrownBy(() -> api.create(new SummaryCreationPayload().videoId("123"))); + } + + @Test + @DisplayName("409 response") + public void responseWithStatus409Test() throws ApiException { + answerOnAnyRequest(409, readResourceFile(PAYLOADS_PATH + "responses/409.json")); + + assertThatThrownBy(() -> api.create(new SummaryCreationPayload().videoId("123"))) + .isInstanceOf(ApiException.class) + .satisfies(e -> assertThat(((ApiException) e).getCode()).isEqualTo(409)) + .hasMessage("A summary already exists or is being created on this video."); + + } + } + + @Nested + @DisplayName("get") + class get { + private static final String PAYLOADS_PATH = "/payloads/summaries/getSummarySource/"; + + @Test + @DisplayName("required parameters") + public void requiredParametersTest() { + answerOnAnyRequest(201, "{}"); + + assertThatNoException().isThrownBy(() -> api.getSummarySource("summary_1CGHWuXjhxmeH4WiZ51234")); + + assertThatThrownBy(() -> api.getSummarySource(null)) + .hasMessage("Missing the required parameter 'summaryId' when calling getSummarySource"); + } + + @Test + @DisplayName("404 response") + public void responseWithStatus404Test() throws ApiException { + answerOnAnyRequest(404, readResourceFile(PAYLOADS_PATH + "responses/404.json")); + + assertThatThrownBy(() -> api.getSummarySource("summary_1CGHWuXjhxmeH4WiZ51234")) + .isInstanceOf(ApiException.class) + .satisfies(e -> assertThat(((ApiException) e).getCode()).isEqualTo(404)) + .hasMessage("The requested resource was not found."); + + } + } + + @Nested + @DisplayName("update") + class update { + private static final String PAYLOADS_PATH = "/payloads/summaries/update/"; + + @Test + @DisplayName("required parameters") + public void requiredParametersTest() { + answerOnAnyRequest(201, "{}"); + + assertThatNoException() + .isThrownBy(() -> api.update("summary_1CGHWuXjhxmeH4WiZ51234", new SummaryUpdatePayload())); + assertThatThrownBy(() -> api.update(null, null)) + .hasMessage("Missing the required parameter 'summaryId' when calling update"); + } + + @Test + @DisplayName("409 response") + public void responseWithStatus409Test() throws ApiException { + answerOnAnyRequest(409, readResourceFile(PAYLOADS_PATH + "responses/409.json")); + + assertThatThrownBy(() -> api.update("summary_1CGHWuXjhxmeH4WiZ51234", new SummaryUpdatePayload())) + .isInstanceOf(ApiException.class) + .satisfies(e -> assertThat(((ApiException) e).getCode()).isEqualTo(409)) + .hasMessage("A summary already exists or is being created on this video."); + } + } + + @Nested + @DisplayName("delete") + class delete { + private static final String PAYLOADS_PATH = "/payloads/summaries/delete/"; + + @Test + @DisplayName("required parameters") + public void requiredParametersTest() { + answerOnAnyRequest(201, "{}"); + + assertThatNoException().isThrownBy(() -> api.delete("summary_1CGHWuXjhxmeH4WiZ51234")); + assertThatThrownBy(() -> api.delete(null)) + .hasMessage("Missing the required parameter 'summaryId' when calling delete"); + } + } + + @Nested + @DisplayName("list") + class list { + private static final String PAYLOADS_PATH = "/payloads/summaries/list/"; + + @Test + @DisplayName("required parameters") + public void requiredParametersTest() { + answerOnAnyRequest(201, "{}"); + + assertThatNoException().isThrownBy(() -> api.list()); + assertThatNoException().isThrownBy(() -> api.list()); + // + } + + @Test + @DisplayName("200 response") + public void responseWithStatus200Test() throws ApiException { + answerOnAnyRequest(200, readResourceFile(PAYLOADS_PATH + "responses/200.json")); + + Page execute = api.list().execute(); + + } + } + +} diff --git a/templates/java/statics/java/src/test/java/video/api/client/api/clients/SummariesApiTest.java b/templates/java/statics/java/src/test/java/video/api/client/api/clients/SummariesApiTest.java new file mode 100644 index 00000000..c602ff1d --- /dev/null +++ b/templates/java/statics/java/src/test/java/video/api/client/api/clients/SummariesApiTest.java @@ -0,0 +1,162 @@ +/* + * api.video Java API client + * api.video is an API that encodes on the go to facilitate immediate playback, enhancing viewer streaming experiences across multiple devices and platforms. You can stream live or on-demand online videos within minutes. + * + * The version of the OpenAPI document: 1 + * Contact: ecosystem@api.video + * + * NOTE: This class is auto generated. + * Do not edit the class manually. + */ + +package video.api.client.api.clients; + +import video.api.client.api.ApiException; +import video.api.client.api.models.*; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatNoException; +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +/** + * API tests for SummariesApi + */ +@DisplayName("SummariesApi") +public class SummariesApiTest extends AbstractApiTest { + + private final SummariesApi api = apiClientMock.summaries(); + + @Nested + @DisplayName("create") + class create { + private static final String PAYLOADS_PATH = "/payloads/summaries/create/"; + + @Test + @DisplayName("required parameters") + public void requiredParametersTest() { + answerOnAnyRequest(201, "{}"); + + assertThatThrownBy(() -> api.create(new SummaryCreationPayload())) + .hasMessage("Missing the required parameter 'summaryCreationPayload.videoId' when calling create"); + + assertThatThrownBy(() -> api.create(null)) + .hasMessage("Missing the required parameter 'summaryCreationPayload' when calling create"); + + assertThatNoException().isThrownBy(() -> api.create(new SummaryCreationPayload().videoId("123"))); + } + + @Test + @DisplayName("409 response") + public void responseWithStatus409Test() throws ApiException { + answerOnAnyRequest(409, readResourceFile(PAYLOADS_PATH + "responses/409.json")); + + assertThatThrownBy(() -> api.create(new SummaryCreationPayload().videoId("123"))) + .isInstanceOf(ApiException.class) + .satisfies(e -> assertThat(((ApiException) e).getCode()).isEqualTo(409)) + .hasMessage("A summary already exists or is being created on this video."); + + } + } + + @Nested + @DisplayName("get") + class get { + private static final String PAYLOADS_PATH = "/payloads/summaries/getSummarySource/"; + + @Test + @DisplayName("required parameters") + public void requiredParametersTest() { + answerOnAnyRequest(201, "{}"); + + assertThatNoException().isThrownBy(() -> api.getSummarySource("summary_1CGHWuXjhxmeH4WiZ51234")); + + assertThatThrownBy(() -> api.getSummarySource(null)) + .hasMessage("Missing the required parameter 'summaryId' when calling getSummarySource"); + } + + @Test + @DisplayName("404 response") + public void responseWithStatus404Test() throws ApiException { + answerOnAnyRequest(404, readResourceFile(PAYLOADS_PATH + "responses/404.json")); + + assertThatThrownBy(() -> api.getSummarySource("summary_1CGHWuXjhxmeH4WiZ51234")).isInstanceOf(ApiException.class) + .satisfies(e -> assertThat(((ApiException) e).getCode()).isEqualTo(404)) + .hasMessage("The requested resource was not found."); + + } + } + + @Nested + @DisplayName("update") + class update { + private static final String PAYLOADS_PATH = "/payloads/summaries/update/"; + + @Test + @DisplayName("required parameters") + public void requiredParametersTest() { + answerOnAnyRequest(201, "{}"); + + assertThatNoException() + .isThrownBy(() -> api.update("summary_1CGHWuXjhxmeH4WiZ51234", new SummaryUpdatePayload())); + assertThatThrownBy(() -> api.update(null, null)) + .hasMessage("Missing the required parameter 'summaryId' when calling update"); + } + + @Test + @DisplayName("409 response") + public void responseWithStatus409Test() throws ApiException { + answerOnAnyRequest(409, readResourceFile(PAYLOADS_PATH + "responses/409.json")); + + assertThatThrownBy(() -> api.update("summary_1CGHWuXjhxmeH4WiZ51234", new SummaryUpdatePayload())) + .isInstanceOf(ApiException.class) + .satisfies(e -> assertThat(((ApiException) e).getCode()).isEqualTo(409)) + .hasMessage("A summary already exists or is being created on this video."); + } + } + + @Nested + @DisplayName("delete") + class delete { + private static final String PAYLOADS_PATH = "/payloads/summaries/delete/"; + + @Test + @DisplayName("required parameters") + public void requiredParametersTest() { + answerOnAnyRequest(201, "{}"); + + assertThatNoException().isThrownBy(() -> api.delete("summary_1CGHWuXjhxmeH4WiZ51234")); + assertThatThrownBy(() -> api.delete(null)) + .hasMessage("Missing the required parameter 'summaryId' when calling delete"); + } + } + + @Nested + @DisplayName("list") + class list { + private static final String PAYLOADS_PATH = "/payloads/summaries/list/"; + + @Test + @DisplayName("required parameters") + public void requiredParametersTest() { + answerOnAnyRequest(201, "{}"); + + assertThatNoException().isThrownBy(() -> api.list()); + assertThatNoException().isThrownBy(() -> api.list()); + // + } + + @Test + @DisplayName("200 response") + public void responseWithStatus200Test() throws ApiException { + answerOnAnyRequest(200, readResourceFile(PAYLOADS_PATH + "responses/200.json")); + + Page execute = api.list().execute(); + + } + } + +}