From b5429381188993ff257eacc88059c9fea427cb35 Mon Sep 17 00:00:00 2001 From: olivierapivideo Date: Wed, 2 Oct 2024 12:43:11 +0000 Subject: [PATCH] Add video tags endpoint --- CHANGELOG.md | 3 + README.md | 27 +- api/openapi.yaml | 205 +++++++ build.gradle | 2 +- docs/ListTagsResponse.md | 18 + docs/ListTagsResponseData.md | 18 + docs/TagsApi.md | 92 ++++ maven-push.gradle | 4 +- pom.xml | 2 +- .../java/video/api/client/ApiVideoClient.java | 11 + .../java/video/api/client/api/ApiClient.java | 2 +- .../video/api/client/api/clients/TagsApi.java | 510 ++++++++++++++++++ .../client/api/models/ListTagsResponse.java | 133 +++++ .../api/models/ListTagsResponseData.java | 121 +++++ .../api/client/api/clients/TagsApiTest.java | 49 ++ .../payloads/tags/list/responses/200.json | 26 + .../payloads/tags/list/responses/429.json | 5 + 17 files changed, 1220 insertions(+), 8 deletions(-) create mode 100644 docs/ListTagsResponse.md create mode 100644 docs/ListTagsResponseData.md create mode 100644 docs/TagsApi.md create mode 100644 src/main/java/video/api/client/api/clients/TagsApi.java create mode 100644 src/main/java/video/api/client/api/models/ListTagsResponse.java create mode 100644 src/main/java/video/api/client/api/models/ListTagsResponseData.java create mode 100644 src/test/java/video/api/client/api/clients/TagsApiTest.java create mode 100644 src/test/resources/payloads/tags/list/responses/200.json create mode 100644 src/test/resources/payloads/tags/list/responses/429.json diff --git a/CHANGELOG.md b/CHANGELOG.md index 2cc2cf0..ad9aa26 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ # Changelog All changes to this project will be documented in this file. +## [1.6.3] - 2024-09-30 +- Add /tags API endpoint + ## [1.6.2] - 2024-09-16 - Add discarded video endpoints diff --git a/README.md b/README.md index 31ca94d..4c70a11 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,7 @@ - [ChaptersApi](#chaptersapi) - [LiveStreamsApi](#livestreamsapi) - [PlayerThemesApi](#playerthemesapi) + - [TagsApi](#tagsapi) - [UploadTokensApi](#uploadtokensapi) - [VideosApi](#videosapi) - [WatermarksApi](#watermarksapi) @@ -70,7 +71,7 @@ Add this dependency to your project's POM: video.api android-api-client - 1.6.2 + 1.6.3 compile ``` @@ -80,7 +81,7 @@ Add this dependency to your project's POM: Add this dependency to your project's build file: ```groovy -implementation "video.api:android-api-client:1.6.2" +implementation "video.api:android-api-client:1.6.3" ``` #### Others @@ -93,7 +94,7 @@ mvn clean package Then manually install the following JARs: -* `target/android-api-client-1.6.2.jar` +* `target/android-api-client-1.6.3.jar` * `target/lib/*.jar` ### Code sample @@ -303,6 +304,24 @@ Method | HTTP request | Description [**deleteLogo**](https://github.com/apivideo/api.video-android-client/blob/main/docs/PlayerThemesApi.md#deleteLogo) | **DELETE** `/players/{playerId}/logo` | Delete logo +### TagsApi + + +#### Retrieve an instance of TagsApi: +```kotlin +val client = ApiVideoClient("YOUR_API_KEY") +val tags = client.tags() +``` + + + +#### Endpoints + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**list**](https://github.com/apivideo/api.video-android-client/blob/main/docs/TagsApi.md#list) | **GET** `/tags` | List all video tags + + ### UploadTokensApi @@ -425,6 +444,8 @@ Method | HTTP request | Description - [FilterBy1](https://github.com/apivideo/api.video-android-client/blob/main/docs/FilterBy1.md) - [FilterBy2](https://github.com/apivideo/api.video-android-client/blob/main/docs/FilterBy2.md) - [Link](https://github.com/apivideo/api.video-android-client/blob/main/docs/Link.md) + - [ListTagsResponse](https://github.com/apivideo/api.video-android-client/blob/main/docs/ListTagsResponse.md) + - [ListTagsResponseData](https://github.com/apivideo/api.video-android-client/blob/main/docs/ListTagsResponseData.md) - [LiveStream](https://github.com/apivideo/api.video-android-client/blob/main/docs/LiveStream.md) - [LiveStreamAssets](https://github.com/apivideo/api.video-android-client/blob/main/docs/LiveStreamAssets.md) - [LiveStreamCreationPayload](https://github.com/apivideo/api.video-android-client/blob/main/docs/LiveStreamCreationPayload.md) diff --git a/api/openapi.yaml b/api/openapi.yaml index eb5442d..104a381 100644 --- a/api/openapi.yaml +++ b/api/openapi.yaml @@ -981,6 +981,164 @@ paths: // Documentation: https://github.com/apivideo/api.video-swift-client/blob/main/docs/VideosAPI.md#create x-contentType: application/json x-accepts: application/json + /tags: + get: + description: This endpoint enables you to search for video tags in a project + and see how many videos are tagged with them. If you do not define any query + parameters, the endpoint lists all video tags and the numbers of times they + are used in a project. + operationId: LIST-tags + parameters: + - description: | + Use this parameter to search for specific video tags. The API filters results even on partial values, and ignores accents, uppercase, and lowercase. + explode: true + in: query + name: value + required: false + schema: + type: string + style: form + - 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: + + - `value`: Sorts the results based on tag values in alphabetic order. + - `videoCount`: Sorts the results based on the number of times a video tag is used. + example: value + explode: true + in: query + name: sortBy + required: false + schema: + enum: + - value + - videoCount + type: string + style: form + - 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. + example: asc + explode: true + in: query + name: sortOrder + required: false + schema: + enum: + - asc + - desc + type: string + style: form + - description: 'Choose the number of search results to return per page. Minimum + value: 1' + example: 2 + explode: true + in: query + name: currentPage + required: false + schema: + default: 1 + type: integer + style: form + - description: Results per page. Allowed values 1-100, default is 25. + example: 30 + explode: true + in: query + name: pageSize + required: false + schema: + default: 25 + type: integer + style: form + responses: + "200": + content: + application/json: + examples: + response: + value: + data: + - value: maths + videoCount: "33" + - value: tutorials + videoCount: "10" + pagination: + currentPage: 1 + pageSize: 25 + pagesTotal: 1 + itemsTotal: 2 + currentPageItems: 2 + links: + - rel: self + uri: /tags?currentPage=1&pageSize=25 + - rel: first + uri: /tags?currentPage=1&pageSize=25 + - rel: last + uri: /tags?currentPage=1&pageSize=25 + schema: + $ref: '#/components/schemas/list-tags-response' + description: Success + headers: + X-RateLimit-Limit: + description: The request limit per minute. + explode: false + schema: + type: integer + style: simple + X-RateLimit-Remaining: + description: The number of available requests left for the current time + window. + explode: false + schema: + type: integer + style: simple + X-RateLimit-Retry-After: + description: The number of seconds left until the current rate limit + window resets. + explode: false + schema: + type: integer + style: simple + "429": + content: + application/json: + examples: + Too many requests: + value: + type: https://docs.api.video/reference/too-many-requests + title: Too many requests. + status: 429 + schema: + $ref: '#/components/schemas/too-many-requests' + description: Too Many Requests + headers: + X-RateLimit-Limit: + description: The request limit per minute. + explode: false + schema: + type: integer + style: simple + X-RateLimit-Remaining: + description: The number of available requests left for the current time + window. + explode: false + schema: + type: integer + style: simple + X-RateLimit-Retry-After: + description: The number of seconds left until the current rate limit + window resets. + explode: false + schema: + type: integer + style: simple + summary: List all video tags + tags: + - Tags + x-client-action: list + x-group-parameters: true + x-client-paginated: true + x-accepts: application/json /videos/{videoId}/source: post: description: Ingest a video from a source or file. @@ -14839,6 +14997,41 @@ components: - videoId title: Video type: object + list-tags-response: + example: + pagination: + itemsTotal: 123 + pagesTotal: 7 + pageSize: 20 + currentPage: 3 + currentPageItems: 20 + links: + first: + rel: first + uri: /videos/search?currentPage=1&pageSize=20 + previous: + rel: previous + uri: /videos/search?currentPage=2&pageSize=20 + next: + rel: next + uri: /videos/search?currentPage=4&pageSize=20 + last: + rel: last + uri: /videos/search?currentPage=6&pageSize=20 + data: + - videoCount: 0 + value: value + - videoCount: 0 + value: value + properties: + data: + items: + $ref: '#/components/schemas/list_tags_response_data' + type: array + pagination: + $ref: '#/components/schemas/pagination' + title: Tags + type: object watermark: example: watermarkId: watermark_1BWr2L5MTQwxGkuxKjzh6i @@ -16977,6 +17170,18 @@ components: type: string type: object x-is-deep-object: true + list_tags_response_data: + example: + videoCount: 0 + value: value + properties: + value: + description: Returns the value of a video tag used in your project. + type: string + videoCount: + description: Returns the number of times a video tag is used. + type: integer + type: object player_theme_assets: example: link: path/to/my/logo/mylogo.jpg diff --git a/build.gradle b/build.gradle index 98246a3..759059d 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ apply plugin: 'maven-publish' apply plugin: 'kotlin-android' group = 'video.api' -version = '1.6.2' +version = '1.6.3' buildscript { repositories { diff --git a/docs/ListTagsResponse.md b/docs/ListTagsResponse.md new file mode 100644 index 0000000..9ca1ed5 --- /dev/null +++ b/docs/ListTagsResponse.md @@ -0,0 +1,18 @@ + + +# ListTagsResponse + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**data** | [**List<ListTagsResponseData>**](ListTagsResponseData.md) | | [optional] +**pagination** | [**Pagination**](Pagination.md) | | [optional] + + +## Implemented Interfaces + +* Serializable +* DeepObject + + diff --git a/docs/ListTagsResponseData.md b/docs/ListTagsResponseData.md new file mode 100644 index 0000000..ab1251c --- /dev/null +++ b/docs/ListTagsResponseData.md @@ -0,0 +1,18 @@ + + +# ListTagsResponseData + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**value** | **String** | Returns the value of a video tag used in your project. | [optional] +**videoCount** | **Integer** | Returns the number of times a video tag is used. | [optional] + + +## Implemented Interfaces + +* Serializable +* DeepObject + + diff --git a/docs/TagsApi.md b/docs/TagsApi.md new file mode 100644 index 0000000..1d1fe24 --- /dev/null +++ b/docs/TagsApi.md @@ -0,0 +1,92 @@ +# TagsApi + +All URIs are relative to *https://ws.api.video* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**list**](TagsApi.md#list) | **GET** /tags | List all video tags + + + +# **list** +> ListTagsResponse list().value(value).sortBy(sortBy).sortOrder(sortOrder).currentPage(currentPage).pageSize(pageSize).execute() +> okhttp3.Call executeAsync(callback) +> ApiResponse executeWithHttpInfo() + +List all video tags + +This endpoint enables you to search for video tags in a project and see how many videos are tagged with them. If you do not define any query parameters, the endpoint lists all video tags and the numbers of times they are used in a project. + +### Example +```java +// Import classes: +import video.api.client.ApiVideoClient; +import video.api.client.api.ApiException; +import video.api.client.api.models.*; +import video.api.client.api.clients.TagsApi; +import java.util.*; + +public class Example { + public static void main(String[] args) { + ApiVideoClient client = new ApiVideoClient(); + // if you rather like to use the sandbox environment: + // ApiVideoClient client = new ApiVideoClient(Environment.SANDBOX); + + TagsApi apiInstance = client.tags(); + + String value = "value_example"; // Use this parameter to search for specific video tags. The API filters results even on partial values, and ignores accents, uppercase, and lowercase. + String sortBy = "value"; // 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: - `value`: Sorts the results based on tag values in alphabetic order. - `videoCount`: Sorts the results based on the number of times a video tag is used. + String sortOrder = "asc"; // Use this parameter to sort results. `asc` is ascending and sorts from A to Z. `desc` is descending and sorts from Z to A. + Integer currentPage = 1; // Choose the number of search results to return per page. Minimum value: 1 + Integer pageSize = 25; // Results per page. Allowed values 1-100, default is 25. + + try { + Page result = apiInstance.list() + .value(value) + .sortBy(sortBy) + .sortOrder(sortOrder) + .currentPage(currentPage) + .pageSize(pageSize) + .execute(); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling TagsApi#list"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getMessage()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **value** | **String**| Use this parameter to search for specific video tags. The API filters results even on partial values, and ignores accents, uppercase, and lowercase. | [optional] + **sortBy** | **String**| 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: - `value`: Sorts the results based on tag values in alphabetic order. - `videoCount`: Sorts the results based on the number of times a video tag is used. | [optional] [enum: value, videoCount] + **sortOrder** | **String**| Use this parameter to sort results. `asc` is ascending and sorts from A to Z. `desc` is descending and sorts from Z to A. | [optional] [enum: asc, desc] + **currentPage** | **Integer**| Choose the number of search results to return per page. Minimum value: 1 | [optional] [default to 1] + **pageSize** | **Integer**| Results per page. Allowed values 1-100, default is 25. | [optional] [default to 25] + +### Return type + +[**Page**](pagination.md)<[**ListTagsResponseData**](ListTagsResponseData.md)> + + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Success | * X-RateLimit-Limit - The request limit per minute.
* X-RateLimit-Remaining - The number of available requests left for the current time window.
* X-RateLimit-Retry-After - The number of seconds left until the current rate limit window resets.
| +**429** | Too Many Requests | * X-RateLimit-Limit - The request limit per minute.
* X-RateLimit-Remaining - The number of available requests left for the current time window.
* X-RateLimit-Retry-After - The number of seconds left until the current rate limit window resets.
| + diff --git a/maven-push.gradle b/maven-push.gradle index 60a93a9..6cb8472 100644 --- a/maven-push.gradle +++ b/maven-push.gradle @@ -18,7 +18,7 @@ apply plugin: 'maven-publish' apply plugin: 'signing' def isReleaseBuild() { - return !"1.6.2".contains("SNAPSHOT") + return !"1.6.3".contains("SNAPSHOT") } def getReleaseRepositoryUrl() { @@ -57,7 +57,7 @@ afterEvaluate { groupId = "video.api" artifactId = "android-api-client" - version = "1.6.2" + version = "1.6.3" pom { name = "video.api:android-api-client" diff --git a/pom.xml b/pom.xml index 057ebec..26cb202 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ android-api-client jar ${project.groupId}:${project.artifactId} - 1.6.2 + 1.6.3 https://github.com/apivideo/api.video-android-client The official Android api.video client diff --git a/src/main/java/video/api/client/ApiVideoClient.java b/src/main/java/video/api/client/ApiVideoClient.java index c5dfef9..29db65b 100644 --- a/src/main/java/video/api/client/ApiVideoClient.java +++ b/src/main/java/video/api/client/ApiVideoClient.java @@ -13,6 +13,7 @@ public class ApiVideoClient { private final ChaptersApi chapters; private final LiveStreamsApi liveStreams; private final PlayerThemesApi playerThemes; + private final TagsApi tags; private final UploadTokensApi uploadTokens; private final VideosApi videos; private final WatermarksApi watermarks; @@ -87,6 +88,7 @@ public ApiVideoClient(ApiClient apiClient) { this.chapters = new ChaptersApi(this.apiClient); this.liveStreams = new LiveStreamsApi(this.apiClient); this.playerThemes = new PlayerThemesApi(this.apiClient); + this.tags = new TagsApi(this.apiClient); this.uploadTokens = new UploadTokensApi(this.apiClient); this.videos = new VideosApi(this.apiClient); this.watermarks = new WatermarksApi(this.apiClient); @@ -138,6 +140,15 @@ public PlayerThemesApi playerThemes() { return this.playerThemes; } + /** + * Get an TagsApi instance + * + * @return TagsApi + */ + public TagsApi tags() { + return this.tags; + } + /** * Get an UploadTokensApi instance * diff --git a/src/main/java/video/api/client/api/ApiClient.java b/src/main/java/video/api/client/api/ApiClient.java index 78519a9..1ccd8de 100644 --- a/src/main/java/video/api/client/api/ApiClient.java +++ b/src/main/java/video/api/client/api/ApiClient.java @@ -120,7 +120,7 @@ private OkHttpClient initHttpClient(List interceptors) { private void init() { verifyingSsl = true; json = new JSON(); - addDefaultHeader("AV-Origin-Client", "android:1.6.2"); + addDefaultHeader("AV-Origin-Client", "android:1.6.3"); } private boolean isValid(String regex, String field) { diff --git a/src/main/java/video/api/client/api/clients/TagsApi.java b/src/main/java/video/api/client/api/clients/TagsApi.java new file mode 100644 index 0000000..429ea90 --- /dev/null +++ b/src/main/java/video/api/client/api/clients/TagsApi.java @@ -0,0 +1,510 @@ +/* + * 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 com.google.gson.reflect.TypeToken; + +import java.io.IOException; + +import video.api.client.api.models.ListTagsResponse; +import video.api.client.api.models.TooManyRequests; + +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import video.api.client.api.models.*; +import video.api.client.api.upload.*; +import video.api.client.api.*; + +public class TagsApi { + private ApiClient localVarApiClient; + + public TagsApi(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + /** + * Constructor for TagsApi production environment where API key is not required. + */ + public TagsApi() { + this.localVarApiClient = new ApiClient(Environment.PRODUCTION.basePath); + } + + /** + * Constructor for TagsApi with custom API base path where API key is not required. + * + * @param basePath + * the api base path. Expected Environment.PRODUCTION.basePath (default) or Environment.SANDBOX.basePath. + */ + public TagsApi(String basePath) { + this.localVarApiClient = new ApiClient(basePath); + } + + /** + * Constructor for TagsApi with custom API base path where API key is not required. + * + * @param environment + * the target environment. Expected Environment.PRODUCTION (default) or Environment.SANDBOX. + */ + public TagsApi(Environment environment) { + this.localVarApiClient = new ApiClient(environment.basePath); + } + + /** + * Constructor for TagsApi with custom API base path + * + * @param apiKey + * the api key to use to authenticate to the API + * @param basePath + * the api base path. Expected Environment.PRODUCTION.basePath (default) or Environment.SANDBOX.basePath. + */ + public TagsApi(String apiKey, String basePath) { + this.localVarApiClient = new ApiClient(apiKey, basePath); + } + + /** + * Constructor for TagsApi with custom API base path + * + * @param apiKey + * the api key to use to authenticate to the API + * @param environment + * the target environment. Expected Environment.PRODUCTION (default) or Environment.SANDBOX. + */ + public TagsApi(String apiKey, Environment environment) { + this.localVarApiClient = new ApiClient(apiKey, environment.basePath); + } + + public ApiClient getApiClient() { + return localVarApiClient; + } + + public void setApiClient(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + private okhttp3.Call listCall(String value, String sortBy, String sortOrder, Integer currentPage, Integer pageSize, + final ApiCallback _callback) throws ApiException { + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/tags"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + if (value != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("value", value)); + } + + if (sortBy != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("sortBy", sortBy)); + } + + if (sortOrder != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("sortOrder", sortOrder)); + } + + if (currentPage != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("currentPage", currentPage)); + } + + if (pageSize != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("pageSize", pageSize)); + } + + final String[] localVarAccepts = { "application/json" }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, + localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call listValidateBeforeCall(String value, String sortBy, String sortOrder, Integer currentPage, + Integer pageSize, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = listCall(value, sortBy, sortOrder, currentPage, pageSize, _callback); + return localVarCall; + } + + private ApiResponse listWithHttpInfo(String value, String sortBy, String sortOrder, + Integer currentPage, Integer pageSize) throws ApiException { + okhttp3.Call localVarCall = listValidateBeforeCall(value, sortBy, sortOrder, currentPage, pageSize, null); + Type localVarReturnType = new TypeToken() { + }.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + private okhttp3.Call listAsync(String value, String sortBy, String sortOrder, Integer currentPage, Integer pageSize, + final ApiCallback _callback) throws ApiException { + okhttp3.Call localVarCall = listValidateBeforeCall(value, sortBy, sortOrder, currentPage, pageSize, _callback); + Type localVarReturnType = new TypeToken() { + }.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + public class APIlistRequest { + private String value; + private String sortBy; + private String sortOrder; + private Integer currentPage; + private Integer pageSize; + + private APIlistRequest() { + } + + /** + * Set value + * + * @param value + * Use this parameter to search for specific video tags. The API filters results even on partial + * values, and ignores accents, uppercase, and lowercase. (optional) + * + * @return APIlistRequest + */ + public APIlistRequest value(String value) { + this.value = value; + return this; + } + + /** + * Set sortBy + * + * @param sortBy + * 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: - `value`: Sorts the + * results based on tag values in alphabetic order. - `videoCount`: Sorts the results based + * on the number of times a video tag is used. (optional) + * + * @return APIlistRequest + */ + public APIlistRequest sortBy(String sortBy) { + this.sortBy = sortBy; + return this; + } + + /** + * Set sortOrder + * + * @param sortOrder + * Use this parameter to sort results. `asc` is ascending and sorts from A to Z. + * `desc` is descending and sorts from Z to A. (optional) + * + * @return APIlistRequest + */ + public APIlistRequest sortOrder(String sortOrder) { + this.sortOrder = sortOrder; + return this; + } + + /** + * Set currentPage + * + * @param currentPage + * Choose the number of search results to return per page. Minimum value: 1 (optional, default to 1) + * + * @return APIlistRequest + */ + public APIlistRequest currentPage(Integer currentPage) { + this.currentPage = currentPage; + return this; + } + + /** + * Set pageSize + * + * @param pageSize + * Results per page. Allowed values 1-100, default is 25. (optional, default to 25) + * + * @return APIlistRequest + */ + public APIlistRequest pageSize(Integer pageSize) { + this.pageSize = pageSize; + return this; + } + + /** + * Build call for list + * + * @param _callback + * ApiCallback API callback + * + * @return Call to execute + * + * @throws ApiException + * If fail to serialize the request body object + * + * @http.response.details + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Status CodeDescriptionResponse Headers
200Success* X-RateLimit-Limit - The request limit per minute.
+ * * X-RateLimit-Remaining - The number of available requests left for the current time + * window.
+ * * X-RateLimit-Retry-After - The number of seconds left until the current rate limit + * window resets.
+ *
429Too Many Requests* X-RateLimit-Limit - The request limit per minute.
+ * * X-RateLimit-Remaining - The number of available requests left for the current time + * window.
+ * * X-RateLimit-Retry-After - The number of seconds left until the current rate limit + * window resets.
+ *
+ */ + public okhttp3.Call buildCall(final ApiCallback _callback) throws ApiException { + return listCall(value, sortBy, sortOrder, currentPage, pageSize, _callback); + } + + /** + * Execute list request + * + * @return ListTagsResponse + * + * @throws ApiException + * If fail to call the API, e.g. server error or cannot deserialize the response body + * + * @http.response.details + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Status CodeDescriptionResponse Headers
200Success* X-RateLimit-Limit - The request limit per minute.
+ * * X-RateLimit-Remaining - The number of available requests left for the current time + * window.
+ * * X-RateLimit-Retry-After - The number of seconds left until the current rate limit + * window resets.
+ *
429Too Many Requests* X-RateLimit-Limit - The request limit per minute.
+ * * X-RateLimit-Remaining - The number of available requests left for the current time + * window.
+ * * X-RateLimit-Retry-After - The number of seconds left until the current rate limit + * window resets.
+ *
+ */ + public Page execute() throws ApiException { + ApiResponse localVarResp = listWithHttpInfo(value, sortBy, sortOrder, currentPage, + pageSize); + return new Page<>(localVarResp.getData().getData(), localVarResp.getData().getPagination(), () -> { + try { + return copy().currentPage((currentPage == null ? 1 : currentPage) + 1).execute(); + } catch (ApiException e) { + throw new RuntimeException(e); + } + }); // + } + + private APIlistRequest copy() { + APIlistRequest copy = new APIlistRequest(); + copy.value(value); + copy.sortBy(sortBy); + copy.sortOrder(sortOrder); + copy.currentPage(currentPage); + copy.pageSize(pageSize); + return copy; + } + + /** + * Execute list request with HTTP info returned + * + * @return ApiResponse<ListTagsResponse> + * + * @throws ApiException + * If fail to call the API, e.g. server error or cannot deserialize the response body + * + * @http.response.details + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Status CodeDescriptionResponse Headers
200Success* X-RateLimit-Limit - The request limit per minute.
+ * * X-RateLimit-Remaining - The number of available requests left for the current time + * window.
+ * * X-RateLimit-Retry-After - The number of seconds left until the current rate limit + * window resets.
+ *
429Too Many Requests* X-RateLimit-Limit - The request limit per minute.
+ * * X-RateLimit-Remaining - The number of available requests left for the current time + * window.
+ * * X-RateLimit-Retry-After - The number of seconds left until the current rate limit + * window resets.
+ *
+ */ + public ApiResponse executeWithHttpInfo() throws ApiException { + return listWithHttpInfo(value, sortBy, sortOrder, currentPage, pageSize); + } + + /** + * Execute list request (asynchronously) + * + * @param _callback + * The callback to be executed when the API call finishes + * + * @return The request call + * + * @throws ApiException + * If fail to process the API call, e.g. serializing the request body object + * + * @http.response.details + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Status CodeDescriptionResponse Headers
200Success* X-RateLimit-Limit - The request limit per minute.
+ * * X-RateLimit-Remaining - The number of available requests left for the current time + * window.
+ * * X-RateLimit-Retry-After - The number of seconds left until the current rate limit + * window resets.
+ *
429Too Many Requests* X-RateLimit-Limit - The request limit per minute.
+ * * X-RateLimit-Remaining - The number of available requests left for the current time + * window.
+ * * X-RateLimit-Retry-After - The number of seconds left until the current rate limit + * window resets.
+ *
+ */ + public okhttp3.Call executeAsync(final ApiCallback> _callback) throws ApiException { + ApiCallback apiCallback = new ApiCallback() { + + @Override + public void onFailure(ApiException e, int statusCode, Map> responseHeaders) { + _callback.onFailure(e, statusCode, responseHeaders); + } + + @Override + public void onSuccess(ListTagsResponse result, int statusCode, + Map> responseHeaders) { + _callback.onSuccess(new Page<>(result.getData(), result.getPagination(), () -> { + try { + return copy().currentPage((currentPage == null ? 1 : currentPage) + 1).execute(); + } catch (ApiException e) { + throw new RuntimeException(e); + } + }), statusCode, responseHeaders); + } + + @Override + public void onUploadProgress(long bytesWritten, long contentLength, boolean done) { + _callback.onUploadProgress(bytesWritten, contentLength, done); + } + + @Override + public void onDownloadProgress(long bytesRead, long contentLength, boolean done) { + _callback.onDownloadProgress(bytesRead, contentLength, done); + } + }; + return listAsync(value, sortBy, sortOrder, currentPage, pageSize, apiCallback); + } + } + + /** + * List all video tags + * + * This endpoint enables you to search for video tags in a project and see how many videos are tagged with them. If + * you do not define any query parameters, the endpoint lists all video tags and the numbers of times they are used + * in a project. + * + * @return APIlistRequest + * + * @http.response.details + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Status CodeDescriptionResponse Headers
200Success* X-RateLimit-Limit - The request limit per minute.
+ * * X-RateLimit-Remaining - The number of available requests left for the current time + * window.
+ * * X-RateLimit-Retry-After - The number of seconds left until the current rate limit window + * resets.
+ *
429Too Many Requests* X-RateLimit-Limit - The request limit per minute.
+ * * X-RateLimit-Remaining - The number of available requests left for the current time + * window.
+ * * X-RateLimit-Retry-After - The number of seconds left until the current rate limit window + * resets.
+ *
+ */ + public APIlistRequest list() { + return new APIlistRequest(); + } +} diff --git a/src/main/java/video/api/client/api/models/ListTagsResponse.java b/src/main/java/video/api/client/api/models/ListTagsResponse.java new file mode 100644 index 0000000..f472246 --- /dev/null +++ b/src/main/java/video/api/client/api/models/ListTagsResponse.java @@ -0,0 +1,133 @@ +/* + * 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.models; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import video.api.client.api.models.ListTagsResponseData; +import video.api.client.api.models.Pagination; +import java.io.Serializable; + +/** + * ListTagsResponse + */ + +public class ListTagsResponse implements Serializable, DeepObject { + private static final long serialVersionUID = 1L; + + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private List data = null; + + public static final String SERIALIZED_NAME_PAGINATION = "pagination"; + @SerializedName(SERIALIZED_NAME_PAGINATION) + private Pagination pagination; + + public ListTagsResponse data(List data) { + this.data = data; + return this; + } + + public ListTagsResponse addDataItem(ListTagsResponseData dataItem) { + if (this.data == null) { + this.data = new ArrayList<>(); + } + this.data.add(dataItem); + return this; + } + + /** + * Get data + * + * @return data + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } + + public ListTagsResponse pagination(Pagination pagination) { + this.pagination = pagination; + return this; + } + + /** + * Get pagination + * + * @return pagination + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public Pagination getPagination() { + return pagination; + } + + public void setPagination(Pagination pagination) { + this.pagination = pagination; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ListTagsResponse listTagsResponse = (ListTagsResponse) o; + return Objects.equals(this.data, listTagsResponse.data) + && Objects.equals(this.pagination, listTagsResponse.pagination); + } + + @Override + public int hashCode() { + return Objects.hash(data, pagination); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ListTagsResponse {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" pagination: ").append(toIndentedString(pagination)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} diff --git a/src/main/java/video/api/client/api/models/ListTagsResponseData.java b/src/main/java/video/api/client/api/models/ListTagsResponseData.java new file mode 100644 index 0000000..2c1c394 --- /dev/null +++ b/src/main/java/video/api/client/api/models/ListTagsResponseData.java @@ -0,0 +1,121 @@ +/* + * 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.models; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import java.io.Serializable; + +/** + * ListTagsResponseData + */ + +public class ListTagsResponseData implements Serializable, DeepObject { + private static final long serialVersionUID = 1L; + + public static final String SERIALIZED_NAME_VALUE = "value"; + @SerializedName(SERIALIZED_NAME_VALUE) + private String value; + + public static final String SERIALIZED_NAME_VIDEO_COUNT = "videoCount"; + @SerializedName(SERIALIZED_NAME_VIDEO_COUNT) + private Integer videoCount; + + public ListTagsResponseData value(String value) { + this.value = value; + return this; + } + + /** + * Returns the value of a video tag used in your project. + * + * @return value + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "Returns the value of a video tag used in your project.") + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public ListTagsResponseData videoCount(Integer videoCount) { + this.videoCount = videoCount; + return this; + } + + /** + * Returns the number of times a video tag is used. + * + * @return videoCount + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "Returns the number of times a video tag is used.") + + public Integer getVideoCount() { + return videoCount; + } + + public void setVideoCount(Integer videoCount) { + this.videoCount = videoCount; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ListTagsResponseData listTagsResponseData = (ListTagsResponseData) o; + return Objects.equals(this.value, listTagsResponseData.value) + && Objects.equals(this.videoCount, listTagsResponseData.videoCount); + } + + @Override + public int hashCode() { + return Objects.hash(value, videoCount); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ListTagsResponseData {\n"); + sb.append(" value: ").append(toIndentedString(value)).append("\n"); + sb.append(" videoCount: ").append(toIndentedString(videoCount)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} diff --git a/src/test/java/video/api/client/api/clients/TagsApiTest.java b/src/test/java/video/api/client/api/clients/TagsApiTest.java new file mode 100644 index 0000000..835a2d0 --- /dev/null +++ b/src/test/java/video/api/client/api/clients/TagsApiTest.java @@ -0,0 +1,49 @@ +package video.api.client.api.clients; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import video.api.client.api.ApiException; +import video.api.client.api.models.ListTagsResponseData; +import video.api.client.api.models.Page; +import video.api.client.api.models.PaginationLink; + +import java.net.URI; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * API tests for TagsApi + */ +@DisplayName("TagsApi") +public class TagsApiTest extends AbstractApiTest { + private final TagsApi api = apiClientMock.tags(); + + @Nested + @DisplayName("list") + class listTags { + private static final String PAYLOADS_PATH = "/payloads/tags/list/"; + + @Test + @DisplayName("200 response") + public void responseWithStatus200Test() throws ApiException { + answerOnAnyRequest(200, readResourceFile(PAYLOADS_PATH + "responses/200.json")); + + Page res = api.list().execute(); + + assertThat(res.getCurrentPage()).isEqualTo(1); + assertThat(res.getPageSize()).isEqualTo(25); + assertThat(res.getPagesTotal()).isEqualTo(1); + assertThat(res.getCurrentPageItems()).isEqualTo(2); + assertThat(res.getLinks()).containsExactlyInAnyOrder( + new PaginationLink().rel("self").uri(URI.create("/tags?currentPage=1&pageSize=25")), + new PaginationLink().rel("first").uri(URI.create("/tags?currentPage=1&pageSize=25")), + new PaginationLink().rel("last").uri(URI.create("/tags?currentPage=1&pageSize=25"))); + + assertThat(res.getItems()).containsExactlyInAnyOrder( + new ListTagsResponseData().value("maths").videoCount(33), + new ListTagsResponseData().value("tutorials").videoCount(10)); + } + } + +} diff --git a/src/test/resources/payloads/tags/list/responses/200.json b/src/test/resources/payloads/tags/list/responses/200.json new file mode 100644 index 0000000..3501e31 --- /dev/null +++ b/src/test/resources/payloads/tags/list/responses/200.json @@ -0,0 +1,26 @@ +{ + "data" : [ { + "value" : "maths", + "videoCount" : "33" + }, { + "value" : "tutorials", + "videoCount" : "10" + } ], + "pagination" : { + "currentPage" : 1, + "pageSize" : 25, + "pagesTotal" : 1, + "itemsTotal" : 2, + "currentPageItems" : 2, + "links" : [ { + "rel" : "self", + "uri" : "/tags?currentPage=1&pageSize=25" + }, { + "rel" : "first", + "uri" : "/tags?currentPage=1&pageSize=25" + }, { + "rel" : "last", + "uri" : "/tags?currentPage=1&pageSize=25" + } ] + } +} \ No newline at end of file diff --git a/src/test/resources/payloads/tags/list/responses/429.json b/src/test/resources/payloads/tags/list/responses/429.json new file mode 100644 index 0000000..d312e2b --- /dev/null +++ b/src/test/resources/payloads/tags/list/responses/429.json @@ -0,0 +1,5 @@ +{ + "type" : "https://docs.api.video/reference/too-many-requests", + "title" : "Too many requests.", + "status" : 429 +} \ No newline at end of file