From 90bdd536653b8bc2d3ed389c7d7c248a40f6c3d0 Mon Sep 17 00:00:00 2001 From: olivierapivideo Date: Fri, 27 Sep 2024 12:41:04 +0000 Subject: [PATCH] Add video tags endpoint --- CHANGELOG.md | 3 + README.md | 10 ++ docs/api/TagsApi.md | 35 ++++++ docs/model/ListTagsResponse.md | 12 +++ docs/model/ListTagsResponseData.md | 12 +++ package.json | 2 +- src/HttpClient.ts | 2 +- src/ObjectSerializer.ts | 4 + src/api/TagsApi.ts | 125 ++++++++++++++++++++++ src/index.ts | 11 ++ src/model/ListTagsResponse.ts | 40 +++++++ src/model/ListTagsResponseData.ts | 44 ++++++++ test/client.spec.ts | 5 + test/payloads/tags/list/responses200.json | 26 +++++ test/payloads/tags/list/responses429.json | 5 + 15 files changed, 334 insertions(+), 2 deletions(-) create mode 100644 docs/api/TagsApi.md create mode 100644 docs/model/ListTagsResponse.md create mode 100644 docs/model/ListTagsResponseData.md create mode 100644 src/api/TagsApi.ts create mode 100644 src/model/ListTagsResponse.ts create mode 100644 src/model/ListTagsResponseData.ts create mode 100644 test/payloads/tags/list/responses200.json create mode 100644 test/payloads/tags/list/responses429.json diff --git a/CHANGELOG.md b/CHANGELOG.md index 783e16a..b69c7e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ # Changelog All changes to this project will be documented in this file. +## [2.6.3] - 2024-09-30 +- Add /tags API endpoint + ## [2.6.2] - 2024-09-16 - Add discarded video endpoints diff --git a/README.md b/README.md index 8e591aa..02f47af 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ - [ChaptersApi](#chaptersapi) - [LiveStreamsApi](#livestreamsapi) - [PlayerThemesApi](#playerthemesapi) + - [TagsApi](#tagsapi) - [UploadTokensApi](#uploadtokensapi) - [VideosApi](#videosapi) - [WatermarksApi](#watermarksapi) @@ -161,6 +162,13 @@ Method | Description | HTTP request [**deleteLogo()**](https://github.com/apivideo/api.video-nodejs-client/blob/main/docs/api/PlayerThemesApi.md#deleteLogo) | Delete logo | **DELETE** `/players/{playerId}/logo` +#### TagsApi + +Method | Description | HTTP request +------------- | ------------- | ------------- +[**list()**](https://github.com/apivideo/api.video-nodejs-client/blob/main/docs/api/TagsApi.md#list) | List all video tags | **GET** `/tags` + + #### UploadTokensApi Method | Description | HTTP request @@ -239,6 +247,8 @@ Method | Description | HTTP request - [FilterBy1](https://github.com/apivideo/api.video-nodejs-client/blob/main/docs/model/FilterBy1.md) - [FilterBy2](https://github.com/apivideo/api.video-nodejs-client/blob/main/docs/model/FilterBy2.md) - [Link](https://github.com/apivideo/api.video-nodejs-client/blob/main/docs/model/Link.md) + - [ListTagsResponse](https://github.com/apivideo/api.video-nodejs-client/blob/main/docs/model/ListTagsResponse.md) + - [ListTagsResponseData](https://github.com/apivideo/api.video-nodejs-client/blob/main/docs/model/ListTagsResponseData.md) - [LiveStream](https://github.com/apivideo/api.video-nodejs-client/blob/main/docs/model/LiveStream.md) - [LiveStreamAssets](https://github.com/apivideo/api.video-nodejs-client/blob/main/docs/model/LiveStreamAssets.md) - [LiveStreamCreationPayload](https://github.com/apivideo/api.video-nodejs-client/blob/main/docs/model/LiveStreamCreationPayload.md) diff --git a/docs/api/TagsApi.md b/docs/api/TagsApi.md new file mode 100644 index 0000000..1fa50ce --- /dev/null +++ b/docs/api/TagsApi.md @@ -0,0 +1,35 @@ +# TagsApi + +All URIs are relative to *https://ws.api.video* + +| Method | Description | HTTP request | +| ------------- | ------------- | ------------- | +| [**list()**](TagsApi.md#list) | List all video tags | **GET** /tags | + + + +## **`list()` - 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. + +### Parameters + +| Name | Type | Required | Description | +| ------------- | ------------- | ------------- | ------------- | + | **value** | **string**| no| Use this parameter to search for specific video tags. The API filters results even on partial values, and ignores accents, uppercase, and lowercase. | + | **sortBy** | **'value' \| 'videoCount'**| no| 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. | + | **sortOrder** | **'asc' \| 'desc'**| no| Use this parameter to sort results. `asc` is ascending and sorts from A to Z. `desc` is descending and sorts from Z to A. | + | **currentPage** | **number**| no| Choose the number of search results to return per page. Minimum value: 1 | + | **pageSize** | **number**| no| Results per page. Allowed values 1-100, default is 25. | + + +### Return type + +Promise<[**ListTagsResponse**](../model/ListTagsResponse.md)>. + + + + +--- + diff --git a/docs/model/ListTagsResponse.md b/docs/model/ListTagsResponse.md new file mode 100644 index 0000000..b174fa9 --- /dev/null +++ b/docs/model/ListTagsResponse.md @@ -0,0 +1,12 @@ + +# ListTagsResponse + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**data** | [**Array<ListTagsResponseData>**](ListTagsResponseData.md) | | [optional] +**pagination** | [**Pagination**](Pagination.md) | | [optional] + + + diff --git a/docs/model/ListTagsResponseData.md b/docs/model/ListTagsResponseData.md new file mode 100644 index 0000000..c0bc9f3 --- /dev/null +++ b/docs/model/ListTagsResponseData.md @@ -0,0 +1,12 @@ + +# ListTagsResponseData + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**value** | **string** | Returns the value of a video tag used in your project. | [optional] +**videoCount** | **number** | Returns the number of times a video tag is used. | [optional] + + + diff --git a/package.json b/package.json index 0468b83..ce3e0b8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@api.video/nodejs-client", - "version": "2.6.2", + "version": "2.6.3", "description": "api.video nodejs API client", "keywords": [ "api.video", diff --git a/src/HttpClient.ts b/src/HttpClient.ts index 2a2f620..994d992 100644 --- a/src/HttpClient.ts +++ b/src/HttpClient.ts @@ -59,7 +59,7 @@ export default class HttpClient { this.chunkSize = params.chunkSize; this.headers = new AxiosHeaders({ Accept: 'application/json, */*;q=0.8', - 'AV-Origin-Client': 'nodejs:2.6.2', + 'AV-Origin-Client': 'nodejs:2.6.3', Authorization: this.apiKey ? `Basic ${encode(`${this.apiKey}:`)}` : '', ...(params.applicationName && params.applicationVersion ? { diff --git a/src/ObjectSerializer.ts b/src/ObjectSerializer.ts index f0b667a..1aade28 100644 --- a/src/ObjectSerializer.ts +++ b/src/ObjectSerializer.ts @@ -37,6 +37,8 @@ import FilterBy from './model/FilterBy'; import FilterBy1 from './model/FilterBy1'; import FilterBy2 from './model/FilterBy2'; import Link from './model/Link'; +import ListTagsResponse from './model/ListTagsResponse'; +import ListTagsResponseData from './model/ListTagsResponseData'; import LiveStream from './model/LiveStream'; import LiveStreamAssets from './model/LiveStreamAssets'; import LiveStreamCreationPayload from './model/LiveStreamCreationPayload'; @@ -152,6 +154,8 @@ const typeMap: { [index: string]: any } = { FilterBy1: FilterBy1, FilterBy2: FilterBy2, Link: Link, + ListTagsResponse: ListTagsResponse, + ListTagsResponseData: ListTagsResponseData, LiveStream: LiveStream, LiveStreamAssets: LiveStreamAssets, LiveStreamCreationPayload: LiveStreamCreationPayload, diff --git a/src/api/TagsApi.ts b/src/api/TagsApi.ts new file mode 100644 index 0000000..6254b11 --- /dev/null +++ b/src/api/TagsApi.ts @@ -0,0 +1,125 @@ +/** + * @api.video/nodejs-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 + * + * + * NOTE: This class is auto generated. + * Do not edit the class manually. + */ + +import { URLSearchParams } from 'url'; +import ObjectSerializer from '../ObjectSerializer'; +import HttpClient, { QueryOptions, ApiResponseHeaders } from '../HttpClient'; +import ListTagsResponse from '../model/ListTagsResponse'; + +/** + * no description + */ +export default class TagsApi { + private httpClient: HttpClient; + + constructor(httpClient: HttpClient) { + this.httpClient = httpClient; + } + + /** + * 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. + * List all video tags + * @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. + * @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. + * @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. + * @param currentPage Choose the number of search results to return per page. Minimum value: 1 + * @param pageSize Results per page. Allowed values 1-100, default is 25. + */ + public async list( + value?: string, + sortBy?: 'value' | 'videoCount', + sortOrder?: 'asc' | 'desc', + currentPage?: number, + pageSize?: number + ): Promise { + return this.listWithResponseHeaders( + value, + sortBy, + sortOrder, + currentPage, + pageSize + ).then((res) => res.body); + } + + /** + * 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. + * List all video tags + * @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. + * @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. + * @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. + * @param currentPage Choose the number of search results to return per page. Minimum value: 1 + * @param pageSize Results per page. Allowed values 1-100, default is 25. + */ + public async listWithResponseHeaders( + value?: string, + sortBy?: 'value' | 'videoCount', + sortOrder?: 'asc' | 'desc', + currentPage?: number, + pageSize?: number + ): Promise<{ headers: ApiResponseHeaders; body: ListTagsResponse }> { + const queryParams: QueryOptions = {}; + queryParams.headers = {}; + // Path Params + const localVarPath = '/tags'.substring(1); + + // Query Params + const urlSearchParams = new URLSearchParams(); + + if (value !== undefined) { + urlSearchParams.append( + 'value', + ObjectSerializer.serialize(value, 'string', '') + ); + } + if (sortBy !== undefined) { + urlSearchParams.append( + 'sortBy', + ObjectSerializer.serialize(sortBy, "'value' | 'videoCount'", '') + ); + } + if (sortOrder !== undefined) { + urlSearchParams.append( + 'sortOrder', + ObjectSerializer.serialize(sortOrder, "'asc' | 'desc'", '') + ); + } + if (currentPage !== undefined) { + urlSearchParams.append( + 'currentPage', + ObjectSerializer.serialize(currentPage, 'number', '') + ); + } + if (pageSize !== undefined) { + urlSearchParams.append( + 'pageSize', + ObjectSerializer.serialize(pageSize, 'number', '') + ); + } + + queryParams.searchParams = urlSearchParams; + + queryParams.method = 'GET'; + + return this.httpClient.call(localVarPath, queryParams).then((response) => { + return { + headers: response.headers, + body: ObjectSerializer.deserialize( + ObjectSerializer.parse( + response.body, + response.headers['content-type'] + ), + 'ListTagsResponse', + '' + ) as ListTagsResponse, + }; + }); + } +} diff --git a/src/index.ts b/src/index.ts index 4de407c..88a45a1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -16,6 +16,7 @@ import CaptionsApi from './api/CaptionsApi'; import ChaptersApi from './api/ChaptersApi'; import LiveStreamsApi from './api/LiveStreamsApi'; import PlayerThemesApi from './api/PlayerThemesApi'; +import TagsApi from './api/TagsApi'; import UploadTokensApi from './api/UploadTokensApi'; import VideosApi from './api/VideosApi'; import WatermarksApi from './api/WatermarksApi'; @@ -35,6 +36,7 @@ class ApiVideoClient { private _chapters: ChaptersApi; private _liveStreams: LiveStreamsApi; private _playerThemes: PlayerThemesApi; + private _tags: TagsApi; private _uploadTokens: UploadTokensApi; private _videos: VideosApi; private _watermarks: WatermarksApi; @@ -81,6 +83,7 @@ class ApiVideoClient { this._chapters = new ChaptersApi(this.httpClient); this._liveStreams = new LiveStreamsApi(this.httpClient); this._playerThemes = new PlayerThemesApi(this.httpClient); + this._tags = new TagsApi(this.httpClient); this._uploadTokens = new UploadTokensApi(this.httpClient); this._videos = new VideosApi(this.httpClient); this._watermarks = new WatermarksApi(this.httpClient); @@ -131,6 +134,14 @@ class ApiVideoClient { return this._playerThemes; } + /** + * Get an TagsApi instance + * @return TagsApi + */ + public get tags(): TagsApi { + return this._tags; + } + /** * Get an UploadTokensApi instance * @return UploadTokensApi diff --git a/src/model/ListTagsResponse.ts b/src/model/ListTagsResponse.ts new file mode 100644 index 0000000..2332cf9 --- /dev/null +++ b/src/model/ListTagsResponse.ts @@ -0,0 +1,40 @@ +/** + * @api.video/nodejs-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 + * + * + * NOTE: This class is auto generated. + * Do not edit the class manually. + */ + +import AttributeType from './AttributeType.js'; +import ListTagsResponseData from './ListTagsResponseData.js'; +import Pagination from './Pagination.js'; + +export default class ListTagsResponse { + 'data'?: Array; + 'pagination'?: Pagination; + + static readonly discriminator?: string = undefined; + + static readonly attributeTypeMap: Array = [ + { + name: 'data', + baseName: 'data', + type: 'Array', + format: '', + }, + { + name: 'pagination', + baseName: 'pagination', + type: 'Pagination', + format: '', + }, + ]; + + static getAttributeTypeMap(): Array { + return ListTagsResponse.attributeTypeMap; + } +} diff --git a/src/model/ListTagsResponseData.ts b/src/model/ListTagsResponseData.ts new file mode 100644 index 0000000..8d6d731 --- /dev/null +++ b/src/model/ListTagsResponseData.ts @@ -0,0 +1,44 @@ +/** + * @api.video/nodejs-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 + * + * + * NOTE: This class is auto generated. + * Do not edit the class manually. + */ + +import AttributeType from './AttributeType.js'; + +export default class ListTagsResponseData { + /** + * Returns the value of a video tag used in your project. + */ + 'value'?: string; + /** + * Returns the number of times a video tag is used. + */ + 'videoCount'?: number; + + static readonly discriminator?: string = undefined; + + static readonly attributeTypeMap: Array = [ + { + name: 'value', + baseName: 'value', + type: 'string', + format: '', + }, + { + name: 'videoCount', + baseName: 'videoCount', + type: 'number', + format: '', + }, + ]; + + static getAttributeTypeMap(): Array { + return ListTagsResponseData.attributeTypeMap; + } +} diff --git a/test/client.spec.ts b/test/client.spec.ts index 3afe896..6e853cc 100644 --- a/test/client.spec.ts +++ b/test/client.spec.ts @@ -4,6 +4,7 @@ import CaptionsApi from '../src/api/CaptionsApi'; import ChaptersApi from '../src/api/ChaptersApi'; import LiveStreamsApi from '../src/api/LiveStreamsApi'; import PlayerThemesApi from '../src/api/PlayerThemesApi'; +import TagsApi from '../src/api/TagsApi'; import UploadTokensApi from '../src/api/UploadTokensApi'; import VideosApi from '../src/api/VideosApi'; import WatermarksApi from '../src/api/WatermarksApi'; @@ -30,6 +31,10 @@ describe('ApiVideoClient', () => { const client = new ApiVideoClient({ apiKey: 'test' }); expect(client.playerThemes).toBeInstanceOf(PlayerThemesApi); }); + it('should use the TagsApi class', () => { + const client = new ApiVideoClient({ apiKey: 'test' }); + expect(client.tags).toBeInstanceOf(TagsApi); + }); it('should use the UploadTokensApi class', () => { const client = new ApiVideoClient({ apiKey: 'test' }); expect(client.uploadTokens).toBeInstanceOf(UploadTokensApi); diff --git a/test/payloads/tags/list/responses200.json b/test/payloads/tags/list/responses200.json new file mode 100644 index 0000000..fd895e6 --- /dev/null +++ b/test/payloads/tags/list/responses200.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" : "https://ws.api.video/watermarks?currentPage=1" + }, { + "rel" : "first", + "uri" : "https://ws.api.video/watermarks?currentPage=1" + }, { + "rel" : "last", + "uri" : "https://ws.api.video/watermarks?currentPage=1" + } ] + } +} \ No newline at end of file diff --git a/test/payloads/tags/list/responses429.json b/test/payloads/tags/list/responses429.json new file mode 100644 index 0000000..d312e2b --- /dev/null +++ b/test/payloads/tags/list/responses429.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