/*
* Copyright (c) Microsoft Corporation.
* Licensed under the MIT License.
*
* Code generated by Microsoft (R) AutoRest Code Generator.
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/
import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging";
import { setContinuationToken } from "../pagingHelper";
import { StreamingLocators } from "../operationsInterfaces";
import * as coreClient from "@azure/core-client";
import * as Mappers from "../models/mappers";
import * as Parameters from "../models/parameters";
import { AzureMediaServices } from "../azureMediaServices";
import {
StreamingLocator,
StreamingLocatorsListNextOptionalParams,
StreamingLocatorsListOptionalParams,
StreamingLocatorsListResponse,
StreamingLocatorsGetOptionalParams,
StreamingLocatorsGetResponse,
StreamingLocatorsCreateOptionalParams,
StreamingLocatorsCreateResponse,
StreamingLocatorsDeleteOptionalParams,
StreamingLocatorsListContentKeysOptionalParams,
StreamingLocatorsListContentKeysResponse,
StreamingLocatorsListPathsOptionalParams,
StreamingLocatorsListPathsResponse,
StreamingLocatorsListNextResponse
} from "../models";
///
/** Class containing StreamingLocators operations. */
export class StreamingLocatorsImpl implements StreamingLocators {
private readonly client: AzureMediaServices;
/**
* Initialize a new instance of the class StreamingLocators class.
* @param client Reference to the service client
*/
constructor(client: AzureMediaServices) {
this.client = client;
}
/**
* Lists the Streaming Locators in the account
* @param resourceGroupName The name of the resource group within the Azure subscription.
* @param accountName The Media Services account name.
* @param options The options parameters.
*/
public list(
resourceGroupName: string,
accountName: string,
options?: StreamingLocatorsListOptionalParams
): PagedAsyncIterableIterator {
const iter = this.listPagingAll(resourceGroupName, accountName, options);
return {
next() {
return iter.next();
},
[Symbol.asyncIterator]() {
return this;
},
byPage: (settings?: PageSettings) => {
if (settings?.maxPageSize) {
throw new Error("maxPageSize is not supported by this operation.");
}
return this.listPagingPage(
resourceGroupName,
accountName,
options,
settings
);
}
};
}
private async *listPagingPage(
resourceGroupName: string,
accountName: string,
options?: StreamingLocatorsListOptionalParams,
settings?: PageSettings
): AsyncIterableIterator {
let result: StreamingLocatorsListResponse;
let continuationToken = settings?.continuationToken;
if (!continuationToken) {
result = await this._list(resourceGroupName, accountName, options);
let page = result.value || [];
continuationToken = result.odataNextLink;
setContinuationToken(page, continuationToken);
yield page;
}
while (continuationToken) {
result = await this._listNext(
resourceGroupName,
accountName,
continuationToken,
options
);
continuationToken = result.odataNextLink;
let page = result.value || [];
setContinuationToken(page, continuationToken);
yield page;
}
}
private async *listPagingAll(
resourceGroupName: string,
accountName: string,
options?: StreamingLocatorsListOptionalParams
): AsyncIterableIterator {
for await (const page of this.listPagingPage(
resourceGroupName,
accountName,
options
)) {
yield* page;
}
}
/**
* Lists the Streaming Locators in the account
* @param resourceGroupName The name of the resource group within the Azure subscription.
* @param accountName The Media Services account name.
* @param options The options parameters.
*/
private _list(
resourceGroupName: string,
accountName: string,
options?: StreamingLocatorsListOptionalParams
): Promise {
return this.client.sendOperationRequest(
{ resourceGroupName, accountName, options },
listOperationSpec
);
}
/**
* Get the details of a Streaming Locator in the Media Services account
* @param resourceGroupName The name of the resource group within the Azure subscription.
* @param accountName The Media Services account name.
* @param streamingLocatorName The Streaming Locator name.
* @param options The options parameters.
*/
get(
resourceGroupName: string,
accountName: string,
streamingLocatorName: string,
options?: StreamingLocatorsGetOptionalParams
): Promise {
return this.client.sendOperationRequest(
{ resourceGroupName, accountName, streamingLocatorName, options },
getOperationSpec
);
}
/**
* Create a Streaming Locator in the Media Services account
* @param resourceGroupName The name of the resource group within the Azure subscription.
* @param accountName The Media Services account name.
* @param streamingLocatorName The Streaming Locator name.
* @param parameters The request parameters
* @param options The options parameters.
*/
create(
resourceGroupName: string,
accountName: string,
streamingLocatorName: string,
parameters: StreamingLocator,
options?: StreamingLocatorsCreateOptionalParams
): Promise {
return this.client.sendOperationRequest(
{
resourceGroupName,
accountName,
streamingLocatorName,
parameters,
options
},
createOperationSpec
);
}
/**
* Deletes a Streaming Locator in the Media Services account
* @param resourceGroupName The name of the resource group within the Azure subscription.
* @param accountName The Media Services account name.
* @param streamingLocatorName The Streaming Locator name.
* @param options The options parameters.
*/
delete(
resourceGroupName: string,
accountName: string,
streamingLocatorName: string,
options?: StreamingLocatorsDeleteOptionalParams
): Promise {
return this.client.sendOperationRequest(
{ resourceGroupName, accountName, streamingLocatorName, options },
deleteOperationSpec
);
}
/**
* List Content Keys used by this Streaming Locator
* @param resourceGroupName The name of the resource group within the Azure subscription.
* @param accountName The Media Services account name.
* @param streamingLocatorName The Streaming Locator name.
* @param options The options parameters.
*/
listContentKeys(
resourceGroupName: string,
accountName: string,
streamingLocatorName: string,
options?: StreamingLocatorsListContentKeysOptionalParams
): Promise {
return this.client.sendOperationRequest(
{ resourceGroupName, accountName, streamingLocatorName, options },
listContentKeysOperationSpec
);
}
/**
* List Paths supported by this Streaming Locator
* @param resourceGroupName The name of the resource group within the Azure subscription.
* @param accountName The Media Services account name.
* @param streamingLocatorName The Streaming Locator name.
* @param options The options parameters.
*/
listPaths(
resourceGroupName: string,
accountName: string,
streamingLocatorName: string,
options?: StreamingLocatorsListPathsOptionalParams
): Promise {
return this.client.sendOperationRequest(
{ resourceGroupName, accountName, streamingLocatorName, options },
listPathsOperationSpec
);
}
/**
* ListNext
* @param resourceGroupName The name of the resource group within the Azure subscription.
* @param accountName The Media Services account name.
* @param nextLink The nextLink from the previous successful call to the List method.
* @param options The options parameters.
*/
private _listNext(
resourceGroupName: string,
accountName: string,
nextLink: string,
options?: StreamingLocatorsListNextOptionalParams
): Promise {
return this.client.sendOperationRequest(
{ resourceGroupName, accountName, nextLink, options },
listNextOperationSpec
);
}
}
// Operation Specifications
const serializer = coreClient.createSerializer(Mappers, /* isXml */ false);
const listOperationSpec: coreClient.OperationSpec = {
path:
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingLocators",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.StreamingLocatorCollection
},
default: {
bodyMapper: Mappers.ErrorResponse
}
},
queryParameters: [
Parameters.apiVersion,
Parameters.filter,
Parameters.top,
Parameters.orderby
],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.resourceGroupName,
Parameters.accountName
],
headerParameters: [Parameters.accept],
serializer
};
const getOperationSpec: coreClient.OperationSpec = {
path:
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingLocators/{streamingLocatorName}",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.StreamingLocator
},
default: {
bodyMapper: Mappers.ErrorResponse
}
},
queryParameters: [Parameters.apiVersion],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.resourceGroupName,
Parameters.accountName,
Parameters.streamingLocatorName
],
headerParameters: [Parameters.accept],
serializer
};
const createOperationSpec: coreClient.OperationSpec = {
path:
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingLocators/{streamingLocatorName}",
httpMethod: "PUT",
responses: {
201: {
bodyMapper: Mappers.StreamingLocator
},
default: {
bodyMapper: Mappers.ErrorResponse
}
},
requestBody: Parameters.parameters15,
queryParameters: [Parameters.apiVersion],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.resourceGroupName,
Parameters.accountName,
Parameters.streamingLocatorName
],
headerParameters: [Parameters.accept, Parameters.contentType],
mediaType: "json",
serializer
};
const deleteOperationSpec: coreClient.OperationSpec = {
path:
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingLocators/{streamingLocatorName}",
httpMethod: "DELETE",
responses: {
200: {},
204: {},
default: {
bodyMapper: Mappers.ErrorResponse
}
},
queryParameters: [Parameters.apiVersion],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.resourceGroupName,
Parameters.accountName,
Parameters.streamingLocatorName
],
headerParameters: [Parameters.accept],
serializer
};
const listContentKeysOperationSpec: coreClient.OperationSpec = {
path:
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingLocators/{streamingLocatorName}/listContentKeys",
httpMethod: "POST",
responses: {
200: {
bodyMapper: Mappers.ListContentKeysResponse
},
default: {
bodyMapper: Mappers.ErrorResponse
}
},
queryParameters: [Parameters.apiVersion],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.resourceGroupName,
Parameters.accountName,
Parameters.streamingLocatorName
],
headerParameters: [Parameters.accept],
serializer
};
const listPathsOperationSpec: coreClient.OperationSpec = {
path:
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/streamingLocators/{streamingLocatorName}/listPaths",
httpMethod: "POST",
responses: {
200: {
bodyMapper: Mappers.ListPathsResponse
},
default: {
bodyMapper: Mappers.ErrorResponse
}
},
queryParameters: [Parameters.apiVersion],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.resourceGroupName,
Parameters.accountName,
Parameters.streamingLocatorName
],
headerParameters: [Parameters.accept],
serializer
};
const listNextOperationSpec: coreClient.OperationSpec = {
path: "{nextLink}",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.StreamingLocatorCollection
},
default: {
bodyMapper: Mappers.ErrorResponse
}
},
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.resourceGroupName,
Parameters.accountName,
Parameters.nextLink
],
headerParameters: [Parameters.accept],
serializer
};