Skip to content

Commit 34b37be

Browse files
feat(api): add drm configuration endpoints (#424)
1 parent 65dc525 commit 34b37be

File tree

6 files changed

+139
-1
lines changed

6 files changed

+139
-1
lines changed

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
configured_endpoints: 95
1+
configured_endpoints: 97
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/mux%2Fmux-6aab47a3857727b9d53429d9b367c0fbd1e7d86e42e4c59335bab5770907d18c.yml

api.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,17 @@ Methods:
177177
- <code title="put /video/v1/web-inputs/{WEB_INPUT_ID}/shutdown">client.video.webInputs.<a href="./src/resources/video/web-inputs.ts">shutdown</a>(webInputId) -> WebInputShutdownResponse</code>
178178
- <code title="put /video/v1/web-inputs/{WEB_INPUT_ID}/url">client.video.webInputs.<a href="./src/resources/video/web-inputs.ts">updateURL</a>(webInputId, { ...params }) -> WebInputUpdateURLResponse</code>
179179

180+
## DrmConfigurations
181+
182+
Types:
183+
184+
- <code><a href="./src/resources/video/drm-configurations.ts">DrmConfiguration</a></code>
185+
186+
Methods:
187+
188+
- <code title="get /video/v1/drm-configurations/{DRM_CONFIGURATION_ID}">client.video.drmConfigurations.<a href="./src/resources/video/drm-configurations.ts">retrieve</a>(drmConfigurationId) -> DrmConfiguration</code>
189+
- <code title="get /video/v1/drm-configurations">client.video.drmConfigurations.<a href="./src/resources/video/drm-configurations.ts">list</a>({ ...params }) -> DrmConfigurationsBasePage</code>
190+
180191
# Data
181192

182193
## Dimensions
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
import * as Core from '@mux/mux-node/core';
4+
import { APIResource } from '@mux/mux-node/resource';
5+
import { isRequestOptions } from '@mux/mux-node/core';
6+
import * as DrmConfigurationsAPI from '@mux/mux-node/resources/video/drm-configurations';
7+
import { BasePage, type BasePageParams } from '@mux/mux-node/pagination';
8+
9+
export class DrmConfigurations extends APIResource {
10+
/**
11+
* Retrieves a single DRM Configuration.
12+
*/
13+
retrieve(drmConfigurationId: string, options?: Core.RequestOptions): Core.APIPromise<DrmConfiguration> {
14+
return (
15+
this._client.get(`/video/v1/drm-configurations/${drmConfigurationId}`, options) as Core.APIPromise<{
16+
data: DrmConfiguration;
17+
}>
18+
)._thenUnwrap((obj) => obj.data);
19+
}
20+
21+
/**
22+
* Returns a list of DRM Configurations
23+
*/
24+
list(
25+
query?: DrmConfigurationListParams,
26+
options?: Core.RequestOptions,
27+
): Core.PagePromise<DrmConfigurationsBasePage, DrmConfiguration>;
28+
list(options?: Core.RequestOptions): Core.PagePromise<DrmConfigurationsBasePage, DrmConfiguration>;
29+
list(
30+
query: DrmConfigurationListParams | Core.RequestOptions = {},
31+
options?: Core.RequestOptions,
32+
): Core.PagePromise<DrmConfigurationsBasePage, DrmConfiguration> {
33+
if (isRequestOptions(query)) {
34+
return this.list({}, query);
35+
}
36+
return this._client.getAPIList('/video/v1/drm-configurations', DrmConfigurationsBasePage, {
37+
query,
38+
...options,
39+
});
40+
}
41+
}
42+
43+
export class DrmConfigurationsBasePage extends BasePage<DrmConfiguration> {}
44+
45+
export interface DrmConfiguration {
46+
/**
47+
* Unique identifier for the DRM Configuration. Max 255 characters.
48+
*/
49+
id: string;
50+
}
51+
52+
export interface DrmConfigurationListParams extends BasePageParams {}
53+
54+
export namespace DrmConfigurations {
55+
export import DrmConfiguration = DrmConfigurationsAPI.DrmConfiguration;
56+
export import DrmConfigurationsBasePage = DrmConfigurationsAPI.DrmConfigurationsBasePage;
57+
export import DrmConfigurationListParams = DrmConfigurationsAPI.DrmConfigurationListParams;
58+
}

src/resources/video/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ export {
4141
DeliveryReportsPageWithTotal,
4242
DeliveryUsage,
4343
} from './delivery-usage';
44+
export {
45+
DrmConfiguration,
46+
DrmConfigurationListParams,
47+
DrmConfigurationsBasePage,
48+
DrmConfigurations,
49+
} from './drm-configurations';
4450
export {
4551
LiveStream,
4652
SimulcastTarget,

src/resources/video/video.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import { APIResource } from '@mux/mux-node/resource';
44
import * as AssetsAPI from '@mux/mux-node/resources/video/assets';
55
import * as DeliveryUsageAPI from '@mux/mux-node/resources/video/delivery-usage';
6+
import * as DrmConfigurationsAPI from '@mux/mux-node/resources/video/drm-configurations';
67
import * as LiveStreamsAPI from '@mux/mux-node/resources/video/live-streams';
78
import * as PlaybackIDsAPI from '@mux/mux-node/resources/video/playback-ids';
89
import * as PlaybackRestrictionsAPI from '@mux/mux-node/resources/video/playback-restrictions';
@@ -23,6 +24,9 @@ export class Video extends APIResource {
2324
new TranscriptionVocabulariesAPI.TranscriptionVocabularies(this._client);
2425
uploads: UploadsAPI.Uploads = new UploadsAPI.Uploads(this._client);
2526
webInputs: WebInputsAPI.WebInputs = new WebInputsAPI.WebInputs(this._client);
27+
drmConfigurations: DrmConfigurationsAPI.DrmConfigurations = new DrmConfigurationsAPI.DrmConfigurations(
28+
this._client,
29+
);
2630
}
2731

2832
export namespace Video {
@@ -107,4 +111,8 @@ export namespace Video {
107111
export import WebInputCreateParams = WebInputsAPI.WebInputCreateParams;
108112
export import WebInputListParams = WebInputsAPI.WebInputListParams;
109113
export import WebInputUpdateURLParams = WebInputsAPI.WebInputUpdateURLParams;
114+
export import DrmConfigurations = DrmConfigurationsAPI.DrmConfigurations;
115+
export import DrmConfiguration = DrmConfigurationsAPI.DrmConfiguration;
116+
export import DrmConfigurationsBasePage = DrmConfigurationsAPI.DrmConfigurationsBasePage;
117+
export import DrmConfigurationListParams = DrmConfigurationsAPI.DrmConfigurationListParams;
110118
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
import Mux from '@mux/mux-node';
4+
import { Response } from 'node-fetch';
5+
6+
const mux = new Mux({
7+
tokenId: 'my token id',
8+
tokenSecret: 'my secret',
9+
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
10+
});
11+
12+
describe('resource drmConfigurations', () => {
13+
test('retrieve', async () => {
14+
const responsePromise = mux.video.drmConfigurations.retrieve('string');
15+
const rawResponse = await responsePromise.asResponse();
16+
expect(rawResponse).toBeInstanceOf(Response);
17+
const response = await responsePromise;
18+
expect(response).not.toBeInstanceOf(Response);
19+
const dataAndResponse = await responsePromise.withResponse();
20+
expect(dataAndResponse.data).toBe(response);
21+
expect(dataAndResponse.response).toBe(rawResponse);
22+
});
23+
24+
test('retrieve: request options instead of params are passed correctly', async () => {
25+
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
26+
await expect(
27+
mux.video.drmConfigurations.retrieve('string', { path: '/_stainless_unknown_path' }),
28+
).rejects.toThrow(Mux.NotFoundError);
29+
});
30+
31+
test('list', async () => {
32+
const responsePromise = mux.video.drmConfigurations.list();
33+
const rawResponse = await responsePromise.asResponse();
34+
expect(rawResponse).toBeInstanceOf(Response);
35+
const response = await responsePromise;
36+
expect(response).not.toBeInstanceOf(Response);
37+
const dataAndResponse = await responsePromise.withResponse();
38+
expect(dataAndResponse.data).toBe(response);
39+
expect(dataAndResponse.response).toBe(rawResponse);
40+
});
41+
42+
test('list: request options instead of params are passed correctly', async () => {
43+
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
44+
await expect(mux.video.drmConfigurations.list({ path: '/_stainless_unknown_path' })).rejects.toThrow(
45+
Mux.NotFoundError,
46+
);
47+
});
48+
49+
test('list: request options and params are passed correctly', async () => {
50+
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
51+
await expect(
52+
mux.video.drmConfigurations.list({ limit: 0, page: 0 }, { path: '/_stainless_unknown_path' }),
53+
).rejects.toThrow(Mux.NotFoundError);
54+
});
55+
});

0 commit comments

Comments
 (0)