-
Notifications
You must be signed in to change notification settings - Fork 61
/
Copy pathplayback-restrictions.ts
294 lines (263 loc) · 9.92 KB
/
playback-restrictions.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from '../../resource';
import { isRequestOptions } from '../../core';
import * as Core from '../../core';
import { BasePage, type BasePageParams } from '../../pagination';
export class PlaybackRestrictions extends APIResource {
/**
* Create a new Playback Restriction.
*/
create(
body: PlaybackRestrictionCreateParams,
options?: Core.RequestOptions,
): Core.APIPromise<PlaybackRestriction> {
return (
this._client.post('/video/v1/playback-restrictions', { body, ...options }) as Core.APIPromise<{
data: PlaybackRestriction;
}>
)._thenUnwrap((obj) => obj.data);
}
/**
* Retrieves a Playback Restriction associated with the unique identifier.
*/
retrieve(
playbackRestrictionId: string,
options?: Core.RequestOptions,
): Core.APIPromise<PlaybackRestriction> {
return (
this._client.get(
`/video/v1/playback-restrictions/${playbackRestrictionId}`,
options,
) as Core.APIPromise<{ data: PlaybackRestriction }>
)._thenUnwrap((obj) => obj.data);
}
/**
* Returns a list of all Playback Restrictions.
*/
list(
query?: PlaybackRestrictionListParams,
options?: Core.RequestOptions,
): Core.PagePromise<PlaybackRestrictionsBasePage, PlaybackRestriction>;
list(options?: Core.RequestOptions): Core.PagePromise<PlaybackRestrictionsBasePage, PlaybackRestriction>;
list(
query: PlaybackRestrictionListParams | Core.RequestOptions = {},
options?: Core.RequestOptions,
): Core.PagePromise<PlaybackRestrictionsBasePage, PlaybackRestriction> {
if (isRequestOptions(query)) {
return this.list({}, query);
}
return this._client.getAPIList('/video/v1/playback-restrictions', PlaybackRestrictionsBasePage, {
query,
...options,
});
}
/**
* Deletes a single Playback Restriction.
*/
delete(playbackRestrictionId: string, options?: Core.RequestOptions): Core.APIPromise<void> {
return this._client.delete(`/video/v1/playback-restrictions/${playbackRestrictionId}`, {
...options,
headers: { Accept: '*/*', ...options?.headers },
});
}
/**
* Allows you to modify the list of domains or change how Mux validates playback
* requests without the `Referer` HTTP header. The Referrer restriction fully
* replaces the old list with this new list of domains.
*/
updateReferrer(
playbackRestrictionId: string,
body: PlaybackRestrictionUpdateReferrerParams,
options?: Core.RequestOptions,
): Core.APIPromise<PlaybackRestriction> {
return (
this._client.put(`/video/v1/playback-restrictions/${playbackRestrictionId}/referrer`, {
body,
...options,
}) as Core.APIPromise<{ data: PlaybackRestriction }>
)._thenUnwrap((obj) => obj.data);
}
/**
* Allows you to modify how Mux validates playback requests with different user
* agents. Please see
* [Using User-Agent HTTP header for validation](https://docs.mux.com/guides/secure-video-playback#using-user-agent-http-header-for-validation)
* for more details on this feature.
*/
updateUserAgent(
playbackRestrictionId: string,
body: PlaybackRestrictionUpdateUserAgentParams,
options?: Core.RequestOptions,
): Core.APIPromise<PlaybackRestriction> {
return (
this._client.put(`/video/v1/playback-restrictions/${playbackRestrictionId}/user_agent`, {
body,
...options,
}) as Core.APIPromise<{ data: PlaybackRestriction }>
)._thenUnwrap((obj) => obj.data);
}
}
export class PlaybackRestrictionsBasePage extends BasePage<PlaybackRestriction> {}
export interface PlaybackRestriction {
/**
* Unique identifier for the Playback Restriction. Max 255 characters.
*/
id: string;
/**
* Time the Playback Restriction was created, defined as a Unix timestamp (seconds
* since epoch).
*/
created_at: string;
/**
* A list of domains allowed to play your videos.
*/
referrer: PlaybackRestriction.Referrer;
/**
* Time the Playback Restriction was last updated, defined as a Unix timestamp
* (seconds since epoch).
*/
updated_at: string;
/**
* Rules that control what user agents are allowed to play your videos. Please see
* [Using User-Agent HTTP header for validation](https://docs.mux.com/guides/secure-video-playback#using-user-agent-http-header-for-validation)
* for more details on this feature.
*/
user_agent: PlaybackRestriction.UserAgent;
}
export namespace PlaybackRestriction {
/**
* A list of domains allowed to play your videos.
*/
export interface Referrer {
/**
* A boolean to determine whether to allow or deny HTTP requests without `Referer`
* HTTP request header. Playback requests coming from non-web/native applications
* like iOS, Android or smart TVs will not have a `Referer` HTTP header. Set this
* value to `true` to allow these playback requests.
*/
allow_no_referrer?: boolean;
/**
* List of domains allowed to play videos. Possible values are
*
* - `[]` Empty Array indicates deny video playback requests for all domains
* - `["*"]` A Single Wildcard `*` entry means allow video playback requests from
* any domain
* - `["*.example.com", "foo.com"]` A list of up to 10 domains or valid dns-style
* wildcards
*/
allowed_domains?: Array<string>;
}
/**
* Rules that control what user agents are allowed to play your videos. Please see
* [Using User-Agent HTTP header for validation](https://docs.mux.com/guides/secure-video-playback#using-user-agent-http-header-for-validation)
* for more details on this feature.
*/
export interface UserAgent {
/**
* Whether or not to allow high risk user agents. The high risk user agents are
* defined by Mux.
*/
allow_high_risk_user_agent?: boolean;
/**
* Whether or not to allow views without a `User-Agent` HTTP request header.
*/
allow_no_user_agent?: boolean;
}
}
export interface PlaybackRestrictionResponse {
data: PlaybackRestriction;
}
export interface PlaybackRestrictionCreateParams {
/**
* A list of domains allowed to play your videos.
*/
referrer: PlaybackRestrictionCreateParams.Referrer;
/**
* Rules that control what user agents are allowed to play your videos. Please see
* [Using User-Agent HTTP header for validation](https://docs.mux.com/guides/secure-video-playback#using-user-agent-http-header-for-validation)
* for more details on this feature.
*/
user_agent: PlaybackRestrictionCreateParams.UserAgent;
}
export namespace PlaybackRestrictionCreateParams {
/**
* A list of domains allowed to play your videos.
*/
export interface Referrer {
/**
* List of domains allowed to play videos. Possible values are
*
* - `[]` Empty Array indicates deny video playback requests for all domains
* - `["*"]` A Single Wildcard `*` entry means allow video playback requests from
* any domain
* - `["*.example.com", "foo.com"]` A list of up to 10 domains or valid dns-style
* wildcards
*/
allowed_domains: Array<string>;
/**
* A boolean to determine whether to allow or deny HTTP requests without `Referer`
* HTTP request header. Playback requests coming from non-web/native applications
* like iOS, Android or smart TVs will not have a `Referer` HTTP header. Set this
* value to `true` to allow these playback requests.
*/
allow_no_referrer?: boolean;
}
/**
* Rules that control what user agents are allowed to play your videos. Please see
* [Using User-Agent HTTP header for validation](https://docs.mux.com/guides/secure-video-playback#using-user-agent-http-header-for-validation)
* for more details on this feature.
*/
export interface UserAgent {
/**
* Whether or not to allow high risk user agents. The high risk user agents are
* defined by Mux.
*/
allow_high_risk_user_agent?: boolean;
/**
* Whether or not to allow views without a `User-Agent` HTTP request header.
*/
allow_no_user_agent?: boolean;
}
}
export interface PlaybackRestrictionListParams extends BasePageParams {}
export interface PlaybackRestrictionUpdateReferrerParams {
/**
* List of domains allowed to play videos. Possible values are
*
* - `[]` Empty Array indicates deny video playback requests for all domains
* - `["*"]` A Single Wildcard `*` entry means allow video playback requests from
* any domain
* - `["*.example.com", "foo.com"]` A list of up to 10 domains or valid dns-style
* wildcards
*/
allowed_domains: Array<string>;
/**
* A boolean to determine whether to allow or deny HTTP requests without `Referer`
* HTTP request header. Playback requests coming from non-web/native applications
* like iOS, Android or smart TVs will not have a `Referer` HTTP header. Set this
* value to `true` to allow these playback requests.
*/
allow_no_referrer?: boolean;
}
export interface PlaybackRestrictionUpdateUserAgentParams {
/**
* Whether or not to allow high risk user agents. The high risk user agents are
* defined by Mux.
*/
allow_high_risk_user_agent: boolean;
/**
* Whether or not to allow views without a `User-Agent` HTTP request header.
*/
allow_no_user_agent: boolean;
}
PlaybackRestrictions.PlaybackRestrictionsBasePage = PlaybackRestrictionsBasePage;
export declare namespace PlaybackRestrictions {
export {
type PlaybackRestriction as PlaybackRestriction,
type PlaybackRestrictionResponse as PlaybackRestrictionResponse,
PlaybackRestrictionsBasePage as PlaybackRestrictionsBasePage,
type PlaybackRestrictionCreateParams as PlaybackRestrictionCreateParams,
type PlaybackRestrictionListParams as PlaybackRestrictionListParams,
type PlaybackRestrictionUpdateReferrerParams as PlaybackRestrictionUpdateReferrerParams,
type PlaybackRestrictionUpdateUserAgentParams as PlaybackRestrictionUpdateUserAgentParams,
};
}