/*
* 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 { ManagedDatabases } from "../operationsInterfaces";
import * as coreClient from "@azure/core-client";
import * as Mappers from "../models/mappers";
import * as Parameters from "../models/parameters";
import { SqlManagementClient } from "../sqlManagementClient";
import {
SimplePollerLike,
OperationState,
createHttpPoller
} from "@azure/core-lro";
import { createLroSpec } from "../lroImpl";
import {
ManagedDatabase,
ManagedDatabasesListByInstanceNextOptionalParams,
ManagedDatabasesListByInstanceOptionalParams,
ManagedDatabasesListByInstanceResponse,
ManagedDatabasesListInaccessibleByInstanceNextOptionalParams,
ManagedDatabasesListInaccessibleByInstanceOptionalParams,
ManagedDatabasesListInaccessibleByInstanceResponse,
ManagedDatabasesGetOptionalParams,
ManagedDatabasesGetResponse,
ManagedDatabasesCreateOrUpdateOptionalParams,
ManagedDatabasesCreateOrUpdateResponse,
ManagedDatabasesDeleteOptionalParams,
ManagedDatabaseUpdate,
ManagedDatabasesUpdateOptionalParams,
ManagedDatabasesUpdateResponse,
ManagedDatabaseMoveDefinition,
ManagedDatabasesCancelMoveOptionalParams,
ManagedDatabasesCompleteMoveOptionalParams,
CompleteDatabaseRestoreDefinition,
ManagedDatabasesCompleteRestoreOptionalParams,
ManagedDatabaseStartMoveDefinition,
ManagedDatabasesStartMoveOptionalParams,
ManagedDatabasesListByInstanceNextResponse,
ManagedDatabasesListInaccessibleByInstanceNextResponse
} from "../models";
///
/** Class containing ManagedDatabases operations. */
export class ManagedDatabasesImpl implements ManagedDatabases {
private readonly client: SqlManagementClient;
/**
* Initialize a new instance of the class ManagedDatabases class.
* @param client Reference to the service client
*/
constructor(client: SqlManagementClient) {
this.client = client;
}
/**
* Gets a list of managed databases.
* @param resourceGroupName The name of the resource group that contains the resource. You can obtain
* this value from the Azure Resource Manager API or the portal.
* @param managedInstanceName The name of the managed instance.
* @param options The options parameters.
*/
public listByInstance(
resourceGroupName: string,
managedInstanceName: string,
options?: ManagedDatabasesListByInstanceOptionalParams
): PagedAsyncIterableIterator {
const iter = this.listByInstancePagingAll(
resourceGroupName,
managedInstanceName,
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.listByInstancePagingPage(
resourceGroupName,
managedInstanceName,
options,
settings
);
}
};
}
private async *listByInstancePagingPage(
resourceGroupName: string,
managedInstanceName: string,
options?: ManagedDatabasesListByInstanceOptionalParams,
settings?: PageSettings
): AsyncIterableIterator {
let result: ManagedDatabasesListByInstanceResponse;
let continuationToken = settings?.continuationToken;
if (!continuationToken) {
result = await this._listByInstance(
resourceGroupName,
managedInstanceName,
options
);
let page = result.value || [];
continuationToken = result.nextLink;
setContinuationToken(page, continuationToken);
yield page;
}
while (continuationToken) {
result = await this._listByInstanceNext(
resourceGroupName,
managedInstanceName,
continuationToken,
options
);
continuationToken = result.nextLink;
let page = result.value || [];
setContinuationToken(page, continuationToken);
yield page;
}
}
private async *listByInstancePagingAll(
resourceGroupName: string,
managedInstanceName: string,
options?: ManagedDatabasesListByInstanceOptionalParams
): AsyncIterableIterator {
for await (const page of this.listByInstancePagingPage(
resourceGroupName,
managedInstanceName,
options
)) {
yield* page;
}
}
/**
* Gets a list of inaccessible managed databases in a managed instance
* @param resourceGroupName The name of the resource group that contains the resource. You can obtain
* this value from the Azure Resource Manager API or the portal.
* @param managedInstanceName The name of the managed instance.
* @param options The options parameters.
*/
public listInaccessibleByInstance(
resourceGroupName: string,
managedInstanceName: string,
options?: ManagedDatabasesListInaccessibleByInstanceOptionalParams
): PagedAsyncIterableIterator {
const iter = this.listInaccessibleByInstancePagingAll(
resourceGroupName,
managedInstanceName,
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.listInaccessibleByInstancePagingPage(
resourceGroupName,
managedInstanceName,
options,
settings
);
}
};
}
private async *listInaccessibleByInstancePagingPage(
resourceGroupName: string,
managedInstanceName: string,
options?: ManagedDatabasesListInaccessibleByInstanceOptionalParams,
settings?: PageSettings
): AsyncIterableIterator {
let result: ManagedDatabasesListInaccessibleByInstanceResponse;
let continuationToken = settings?.continuationToken;
if (!continuationToken) {
result = await this._listInaccessibleByInstance(
resourceGroupName,
managedInstanceName,
options
);
let page = result.value || [];
continuationToken = result.nextLink;
setContinuationToken(page, continuationToken);
yield page;
}
while (continuationToken) {
result = await this._listInaccessibleByInstanceNext(
resourceGroupName,
managedInstanceName,
continuationToken,
options
);
continuationToken = result.nextLink;
let page = result.value || [];
setContinuationToken(page, continuationToken);
yield page;
}
}
private async *listInaccessibleByInstancePagingAll(
resourceGroupName: string,
managedInstanceName: string,
options?: ManagedDatabasesListInaccessibleByInstanceOptionalParams
): AsyncIterableIterator {
for await (const page of this.listInaccessibleByInstancePagingPage(
resourceGroupName,
managedInstanceName,
options
)) {
yield* page;
}
}
/**
* Gets a list of managed databases.
* @param resourceGroupName The name of the resource group that contains the resource. You can obtain
* this value from the Azure Resource Manager API or the portal.
* @param managedInstanceName The name of the managed instance.
* @param options The options parameters.
*/
private _listByInstance(
resourceGroupName: string,
managedInstanceName: string,
options?: ManagedDatabasesListByInstanceOptionalParams
): Promise {
return this.client.sendOperationRequest(
{ resourceGroupName, managedInstanceName, options },
listByInstanceOperationSpec
);
}
/**
* Gets a managed database.
* @param resourceGroupName The name of the resource group that contains the resource. You can obtain
* this value from the Azure Resource Manager API or the portal.
* @param managedInstanceName The name of the managed instance.
* @param databaseName The name of the database.
* @param options The options parameters.
*/
get(
resourceGroupName: string,
managedInstanceName: string,
databaseName: string,
options?: ManagedDatabasesGetOptionalParams
): Promise {
return this.client.sendOperationRequest(
{ resourceGroupName, managedInstanceName, databaseName, options },
getOperationSpec
);
}
/**
* Creates a new database or updates an existing database.
* @param resourceGroupName The name of the resource group that contains the resource. You can obtain
* this value from the Azure Resource Manager API or the portal.
* @param managedInstanceName The name of the managed instance.
* @param databaseName The name of the database.
* @param parameters The requested database resource state.
* @param options The options parameters.
*/
async beginCreateOrUpdate(
resourceGroupName: string,
managedInstanceName: string,
databaseName: string,
parameters: ManagedDatabase,
options?: ManagedDatabasesCreateOrUpdateOptionalParams
): Promise<
SimplePollerLike<
OperationState,
ManagedDatabasesCreateOrUpdateResponse
>
> {
const directSendOperation = async (
args: coreClient.OperationArguments,
spec: coreClient.OperationSpec
): Promise => {
return this.client.sendOperationRequest(args, spec);
};
const sendOperationFn = async (
args: coreClient.OperationArguments,
spec: coreClient.OperationSpec
) => {
let currentRawResponse:
| coreClient.FullOperationResponse
| undefined = undefined;
const providedCallback = args.options?.onResponse;
const callback: coreClient.RawResponseCallback = (
rawResponse: coreClient.FullOperationResponse,
flatResponse: unknown
) => {
currentRawResponse = rawResponse;
providedCallback?.(rawResponse, flatResponse);
};
const updatedArgs = {
...args,
options: {
...args.options,
onResponse: callback
}
};
const flatResponse = await directSendOperation(updatedArgs, spec);
return {
flatResponse,
rawResponse: {
statusCode: currentRawResponse!.status,
body: currentRawResponse!.parsedBody,
headers: currentRawResponse!.headers.toJSON()
}
};
};
const lro = createLroSpec({
sendOperationFn,
args: {
resourceGroupName,
managedInstanceName,
databaseName,
parameters,
options
},
spec: createOrUpdateOperationSpec
});
const poller = await createHttpPoller<
ManagedDatabasesCreateOrUpdateResponse,
OperationState
>(lro, {
restoreFrom: options?.resumeFrom,
intervalInMs: options?.updateIntervalInMs
});
await poller.poll();
return poller;
}
/**
* Creates a new database or updates an existing database.
* @param resourceGroupName The name of the resource group that contains the resource. You can obtain
* this value from the Azure Resource Manager API or the portal.
* @param managedInstanceName The name of the managed instance.
* @param databaseName The name of the database.
* @param parameters The requested database resource state.
* @param options The options parameters.
*/
async beginCreateOrUpdateAndWait(
resourceGroupName: string,
managedInstanceName: string,
databaseName: string,
parameters: ManagedDatabase,
options?: ManagedDatabasesCreateOrUpdateOptionalParams
): Promise {
const poller = await this.beginCreateOrUpdate(
resourceGroupName,
managedInstanceName,
databaseName,
parameters,
options
);
return poller.pollUntilDone();
}
/**
* Deletes a managed database.
* @param resourceGroupName The name of the resource group that contains the resource. You can obtain
* this value from the Azure Resource Manager API or the portal.
* @param managedInstanceName The name of the managed instance.
* @param databaseName The name of the database.
* @param options The options parameters.
*/
async beginDelete(
resourceGroupName: string,
managedInstanceName: string,
databaseName: string,
options?: ManagedDatabasesDeleteOptionalParams
): Promise, void>> {
const directSendOperation = async (
args: coreClient.OperationArguments,
spec: coreClient.OperationSpec
): Promise => {
return this.client.sendOperationRequest(args, spec);
};
const sendOperationFn = async (
args: coreClient.OperationArguments,
spec: coreClient.OperationSpec
) => {
let currentRawResponse:
| coreClient.FullOperationResponse
| undefined = undefined;
const providedCallback = args.options?.onResponse;
const callback: coreClient.RawResponseCallback = (
rawResponse: coreClient.FullOperationResponse,
flatResponse: unknown
) => {
currentRawResponse = rawResponse;
providedCallback?.(rawResponse, flatResponse);
};
const updatedArgs = {
...args,
options: {
...args.options,
onResponse: callback
}
};
const flatResponse = await directSendOperation(updatedArgs, spec);
return {
flatResponse,
rawResponse: {
statusCode: currentRawResponse!.status,
body: currentRawResponse!.parsedBody,
headers: currentRawResponse!.headers.toJSON()
}
};
};
const lro = createLroSpec({
sendOperationFn,
args: { resourceGroupName, managedInstanceName, databaseName, options },
spec: deleteOperationSpec
});
const poller = await createHttpPoller>(lro, {
restoreFrom: options?.resumeFrom,
intervalInMs: options?.updateIntervalInMs
});
await poller.poll();
return poller;
}
/**
* Deletes a managed database.
* @param resourceGroupName The name of the resource group that contains the resource. You can obtain
* this value from the Azure Resource Manager API or the portal.
* @param managedInstanceName The name of the managed instance.
* @param databaseName The name of the database.
* @param options The options parameters.
*/
async beginDeleteAndWait(
resourceGroupName: string,
managedInstanceName: string,
databaseName: string,
options?: ManagedDatabasesDeleteOptionalParams
): Promise {
const poller = await this.beginDelete(
resourceGroupName,
managedInstanceName,
databaseName,
options
);
return poller.pollUntilDone();
}
/**
* Updates an existing database.
* @param resourceGroupName The name of the resource group that contains the resource. You can obtain
* this value from the Azure Resource Manager API or the portal.
* @param managedInstanceName The name of the managed instance.
* @param databaseName The name of the database.
* @param parameters The requested database resource state.
* @param options The options parameters.
*/
async beginUpdate(
resourceGroupName: string,
managedInstanceName: string,
databaseName: string,
parameters: ManagedDatabaseUpdate,
options?: ManagedDatabasesUpdateOptionalParams
): Promise<
SimplePollerLike<
OperationState,
ManagedDatabasesUpdateResponse
>
> {
const directSendOperation = async (
args: coreClient.OperationArguments,
spec: coreClient.OperationSpec
): Promise => {
return this.client.sendOperationRequest(args, spec);
};
const sendOperationFn = async (
args: coreClient.OperationArguments,
spec: coreClient.OperationSpec
) => {
let currentRawResponse:
| coreClient.FullOperationResponse
| undefined = undefined;
const providedCallback = args.options?.onResponse;
const callback: coreClient.RawResponseCallback = (
rawResponse: coreClient.FullOperationResponse,
flatResponse: unknown
) => {
currentRawResponse = rawResponse;
providedCallback?.(rawResponse, flatResponse);
};
const updatedArgs = {
...args,
options: {
...args.options,
onResponse: callback
}
};
const flatResponse = await directSendOperation(updatedArgs, spec);
return {
flatResponse,
rawResponse: {
statusCode: currentRawResponse!.status,
body: currentRawResponse!.parsedBody,
headers: currentRawResponse!.headers.toJSON()
}
};
};
const lro = createLroSpec({
sendOperationFn,
args: {
resourceGroupName,
managedInstanceName,
databaseName,
parameters,
options
},
spec: updateOperationSpec
});
const poller = await createHttpPoller<
ManagedDatabasesUpdateResponse,
OperationState
>(lro, {
restoreFrom: options?.resumeFrom,
intervalInMs: options?.updateIntervalInMs
});
await poller.poll();
return poller;
}
/**
* Updates an existing database.
* @param resourceGroupName The name of the resource group that contains the resource. You can obtain
* this value from the Azure Resource Manager API or the portal.
* @param managedInstanceName The name of the managed instance.
* @param databaseName The name of the database.
* @param parameters The requested database resource state.
* @param options The options parameters.
*/
async beginUpdateAndWait(
resourceGroupName: string,
managedInstanceName: string,
databaseName: string,
parameters: ManagedDatabaseUpdate,
options?: ManagedDatabasesUpdateOptionalParams
): Promise {
const poller = await this.beginUpdate(
resourceGroupName,
managedInstanceName,
databaseName,
parameters,
options
);
return poller.pollUntilDone();
}
/**
* Cancels a managed database move operation.
* @param resourceGroupName The name of the resource group that contains the resource. You can obtain
* this value from the Azure Resource Manager API or the portal.
* @param managedInstanceName The name of the managed instance.
* @param databaseName The name of the database.
* @param parameters Parameters of the cancel managed database move operation.
* @param options The options parameters.
*/
async beginCancelMove(
resourceGroupName: string,
managedInstanceName: string,
databaseName: string,
parameters: ManagedDatabaseMoveDefinition,
options?: ManagedDatabasesCancelMoveOptionalParams
): Promise, void>> {
const directSendOperation = async (
args: coreClient.OperationArguments,
spec: coreClient.OperationSpec
): Promise => {
return this.client.sendOperationRequest(args, spec);
};
const sendOperationFn = async (
args: coreClient.OperationArguments,
spec: coreClient.OperationSpec
) => {
let currentRawResponse:
| coreClient.FullOperationResponse
| undefined = undefined;
const providedCallback = args.options?.onResponse;
const callback: coreClient.RawResponseCallback = (
rawResponse: coreClient.FullOperationResponse,
flatResponse: unknown
) => {
currentRawResponse = rawResponse;
providedCallback?.(rawResponse, flatResponse);
};
const updatedArgs = {
...args,
options: {
...args.options,
onResponse: callback
}
};
const flatResponse = await directSendOperation(updatedArgs, spec);
return {
flatResponse,
rawResponse: {
statusCode: currentRawResponse!.status,
body: currentRawResponse!.parsedBody,
headers: currentRawResponse!.headers.toJSON()
}
};
};
const lro = createLroSpec({
sendOperationFn,
args: {
resourceGroupName,
managedInstanceName,
databaseName,
parameters,
options
},
spec: cancelMoveOperationSpec
});
const poller = await createHttpPoller>(lro, {
restoreFrom: options?.resumeFrom,
intervalInMs: options?.updateIntervalInMs
});
await poller.poll();
return poller;
}
/**
* Cancels a managed database move operation.
* @param resourceGroupName The name of the resource group that contains the resource. You can obtain
* this value from the Azure Resource Manager API or the portal.
* @param managedInstanceName The name of the managed instance.
* @param databaseName The name of the database.
* @param parameters Parameters of the cancel managed database move operation.
* @param options The options parameters.
*/
async beginCancelMoveAndWait(
resourceGroupName: string,
managedInstanceName: string,
databaseName: string,
parameters: ManagedDatabaseMoveDefinition,
options?: ManagedDatabasesCancelMoveOptionalParams
): Promise {
const poller = await this.beginCancelMove(
resourceGroupName,
managedInstanceName,
databaseName,
parameters,
options
);
return poller.pollUntilDone();
}
/**
* Completes a managed database move operation.
* @param resourceGroupName The name of the resource group that contains the resource. You can obtain
* this value from the Azure Resource Manager API or the portal.
* @param managedInstanceName The name of the managed instance.
* @param databaseName The name of the database.
* @param parameters Parameters of the complete managed database move operation.
* @param options The options parameters.
*/
async beginCompleteMove(
resourceGroupName: string,
managedInstanceName: string,
databaseName: string,
parameters: ManagedDatabaseMoveDefinition,
options?: ManagedDatabasesCompleteMoveOptionalParams
): Promise, void>> {
const directSendOperation = async (
args: coreClient.OperationArguments,
spec: coreClient.OperationSpec
): Promise => {
return this.client.sendOperationRequest(args, spec);
};
const sendOperationFn = async (
args: coreClient.OperationArguments,
spec: coreClient.OperationSpec
) => {
let currentRawResponse:
| coreClient.FullOperationResponse
| undefined = undefined;
const providedCallback = args.options?.onResponse;
const callback: coreClient.RawResponseCallback = (
rawResponse: coreClient.FullOperationResponse,
flatResponse: unknown
) => {
currentRawResponse = rawResponse;
providedCallback?.(rawResponse, flatResponse);
};
const updatedArgs = {
...args,
options: {
...args.options,
onResponse: callback
}
};
const flatResponse = await directSendOperation(updatedArgs, spec);
return {
flatResponse,
rawResponse: {
statusCode: currentRawResponse!.status,
body: currentRawResponse!.parsedBody,
headers: currentRawResponse!.headers.toJSON()
}
};
};
const lro = createLroSpec({
sendOperationFn,
args: {
resourceGroupName,
managedInstanceName,
databaseName,
parameters,
options
},
spec: completeMoveOperationSpec
});
const poller = await createHttpPoller>(lro, {
restoreFrom: options?.resumeFrom,
intervalInMs: options?.updateIntervalInMs
});
await poller.poll();
return poller;
}
/**
* Completes a managed database move operation.
* @param resourceGroupName The name of the resource group that contains the resource. You can obtain
* this value from the Azure Resource Manager API or the portal.
* @param managedInstanceName The name of the managed instance.
* @param databaseName The name of the database.
* @param parameters Parameters of the complete managed database move operation.
* @param options The options parameters.
*/
async beginCompleteMoveAndWait(
resourceGroupName: string,
managedInstanceName: string,
databaseName: string,
parameters: ManagedDatabaseMoveDefinition,
options?: ManagedDatabasesCompleteMoveOptionalParams
): Promise {
const poller = await this.beginCompleteMove(
resourceGroupName,
managedInstanceName,
databaseName,
parameters,
options
);
return poller.pollUntilDone();
}
/**
* Completes the restore operation on a managed database.
* @param resourceGroupName The name of the resource group that contains the resource. You can obtain
* this value from the Azure Resource Manager API or the portal.
* @param managedInstanceName The name of the managed instance.
* @param databaseName The name of the database.
* @param parameters The definition for completing the restore of this managed database.
* @param options The options parameters.
*/
async beginCompleteRestore(
resourceGroupName: string,
managedInstanceName: string,
databaseName: string,
parameters: CompleteDatabaseRestoreDefinition,
options?: ManagedDatabasesCompleteRestoreOptionalParams
): Promise, void>> {
const directSendOperation = async (
args: coreClient.OperationArguments,
spec: coreClient.OperationSpec
): Promise => {
return this.client.sendOperationRequest(args, spec);
};
const sendOperationFn = async (
args: coreClient.OperationArguments,
spec: coreClient.OperationSpec
) => {
let currentRawResponse:
| coreClient.FullOperationResponse
| undefined = undefined;
const providedCallback = args.options?.onResponse;
const callback: coreClient.RawResponseCallback = (
rawResponse: coreClient.FullOperationResponse,
flatResponse: unknown
) => {
currentRawResponse = rawResponse;
providedCallback?.(rawResponse, flatResponse);
};
const updatedArgs = {
...args,
options: {
...args.options,
onResponse: callback
}
};
const flatResponse = await directSendOperation(updatedArgs, spec);
return {
flatResponse,
rawResponse: {
statusCode: currentRawResponse!.status,
body: currentRawResponse!.parsedBody,
headers: currentRawResponse!.headers.toJSON()
}
};
};
const lro = createLroSpec({
sendOperationFn,
args: {
resourceGroupName,
managedInstanceName,
databaseName,
parameters,
options
},
spec: completeRestoreOperationSpec
});
const poller = await createHttpPoller>(lro, {
restoreFrom: options?.resumeFrom,
intervalInMs: options?.updateIntervalInMs
});
await poller.poll();
return poller;
}
/**
* Completes the restore operation on a managed database.
* @param resourceGroupName The name of the resource group that contains the resource. You can obtain
* this value from the Azure Resource Manager API or the portal.
* @param managedInstanceName The name of the managed instance.
* @param databaseName The name of the database.
* @param parameters The definition for completing the restore of this managed database.
* @param options The options parameters.
*/
async beginCompleteRestoreAndWait(
resourceGroupName: string,
managedInstanceName: string,
databaseName: string,
parameters: CompleteDatabaseRestoreDefinition,
options?: ManagedDatabasesCompleteRestoreOptionalParams
): Promise {
const poller = await this.beginCompleteRestore(
resourceGroupName,
managedInstanceName,
databaseName,
parameters,
options
);
return poller.pollUntilDone();
}
/**
* Starts a managed database move operation.
* @param resourceGroupName The name of the resource group that contains the resource. You can obtain
* this value from the Azure Resource Manager API or the portal.
* @param managedInstanceName The name of the managed instance.
* @param databaseName The name of the database.
* @param parameters Parameters of the start managed database move operation.
* @param options The options parameters.
*/
async beginStartMove(
resourceGroupName: string,
managedInstanceName: string,
databaseName: string,
parameters: ManagedDatabaseStartMoveDefinition,
options?: ManagedDatabasesStartMoveOptionalParams
): Promise, void>> {
const directSendOperation = async (
args: coreClient.OperationArguments,
spec: coreClient.OperationSpec
): Promise => {
return this.client.sendOperationRequest(args, spec);
};
const sendOperationFn = async (
args: coreClient.OperationArguments,
spec: coreClient.OperationSpec
) => {
let currentRawResponse:
| coreClient.FullOperationResponse
| undefined = undefined;
const providedCallback = args.options?.onResponse;
const callback: coreClient.RawResponseCallback = (
rawResponse: coreClient.FullOperationResponse,
flatResponse: unknown
) => {
currentRawResponse = rawResponse;
providedCallback?.(rawResponse, flatResponse);
};
const updatedArgs = {
...args,
options: {
...args.options,
onResponse: callback
}
};
const flatResponse = await directSendOperation(updatedArgs, spec);
return {
flatResponse,
rawResponse: {
statusCode: currentRawResponse!.status,
body: currentRawResponse!.parsedBody,
headers: currentRawResponse!.headers.toJSON()
}
};
};
const lro = createLroSpec({
sendOperationFn,
args: {
resourceGroupName,
managedInstanceName,
databaseName,
parameters,
options
},
spec: startMoveOperationSpec
});
const poller = await createHttpPoller>(lro, {
restoreFrom: options?.resumeFrom,
intervalInMs: options?.updateIntervalInMs
});
await poller.poll();
return poller;
}
/**
* Starts a managed database move operation.
* @param resourceGroupName The name of the resource group that contains the resource. You can obtain
* this value from the Azure Resource Manager API or the portal.
* @param managedInstanceName The name of the managed instance.
* @param databaseName The name of the database.
* @param parameters Parameters of the start managed database move operation.
* @param options The options parameters.
*/
async beginStartMoveAndWait(
resourceGroupName: string,
managedInstanceName: string,
databaseName: string,
parameters: ManagedDatabaseStartMoveDefinition,
options?: ManagedDatabasesStartMoveOptionalParams
): Promise {
const poller = await this.beginStartMove(
resourceGroupName,
managedInstanceName,
databaseName,
parameters,
options
);
return poller.pollUntilDone();
}
/**
* Gets a list of inaccessible managed databases in a managed instance
* @param resourceGroupName The name of the resource group that contains the resource. You can obtain
* this value from the Azure Resource Manager API or the portal.
* @param managedInstanceName The name of the managed instance.
* @param options The options parameters.
*/
private _listInaccessibleByInstance(
resourceGroupName: string,
managedInstanceName: string,
options?: ManagedDatabasesListInaccessibleByInstanceOptionalParams
): Promise {
return this.client.sendOperationRequest(
{ resourceGroupName, managedInstanceName, options },
listInaccessibleByInstanceOperationSpec
);
}
/**
* ListByInstanceNext
* @param resourceGroupName The name of the resource group that contains the resource. You can obtain
* this value from the Azure Resource Manager API or the portal.
* @param managedInstanceName The name of the managed instance.
* @param nextLink The nextLink from the previous successful call to the ListByInstance method.
* @param options The options parameters.
*/
private _listByInstanceNext(
resourceGroupName: string,
managedInstanceName: string,
nextLink: string,
options?: ManagedDatabasesListByInstanceNextOptionalParams
): Promise {
return this.client.sendOperationRequest(
{ resourceGroupName, managedInstanceName, nextLink, options },
listByInstanceNextOperationSpec
);
}
/**
* ListInaccessibleByInstanceNext
* @param resourceGroupName The name of the resource group that contains the resource. You can obtain
* this value from the Azure Resource Manager API or the portal.
* @param managedInstanceName The name of the managed instance.
* @param nextLink The nextLink from the previous successful call to the ListInaccessibleByInstance
* method.
* @param options The options parameters.
*/
private _listInaccessibleByInstanceNext(
resourceGroupName: string,
managedInstanceName: string,
nextLink: string,
options?: ManagedDatabasesListInaccessibleByInstanceNextOptionalParams
): Promise {
return this.client.sendOperationRequest(
{ resourceGroupName, managedInstanceName, nextLink, options },
listInaccessibleByInstanceNextOperationSpec
);
}
}
// Operation Specifications
const serializer = coreClient.createSerializer(Mappers, /* isXml */ false);
const listByInstanceOperationSpec: coreClient.OperationSpec = {
path:
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.ManagedDatabaseListResult
},
default: {}
},
queryParameters: [Parameters.apiVersion8],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.resourceGroupName,
Parameters.managedInstanceName
],
headerParameters: [Parameters.accept],
serializer
};
const getOperationSpec: coreClient.OperationSpec = {
path:
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.ManagedDatabase
},
default: {}
},
queryParameters: [Parameters.apiVersion8],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.resourceGroupName,
Parameters.databaseName,
Parameters.managedInstanceName
],
headerParameters: [Parameters.accept],
serializer
};
const createOrUpdateOperationSpec: coreClient.OperationSpec = {
path:
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}",
httpMethod: "PUT",
responses: {
200: {
bodyMapper: Mappers.ManagedDatabase
},
201: {
bodyMapper: Mappers.ManagedDatabase
},
202: {
bodyMapper: Mappers.ManagedDatabase
},
204: {
bodyMapper: Mappers.ManagedDatabase
},
default: {}
},
requestBody: Parameters.parameters91,
queryParameters: [Parameters.apiVersion8],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.resourceGroupName,
Parameters.databaseName,
Parameters.managedInstanceName
],
headerParameters: [Parameters.contentType, Parameters.accept],
mediaType: "json",
serializer
};
const deleteOperationSpec: coreClient.OperationSpec = {
path:
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}",
httpMethod: "DELETE",
responses: { 200: {}, 201: {}, 202: {}, 204: {}, default: {} },
queryParameters: [Parameters.apiVersion8],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.resourceGroupName,
Parameters.databaseName,
Parameters.managedInstanceName
],
serializer
};
const updateOperationSpec: coreClient.OperationSpec = {
path:
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}",
httpMethod: "PATCH",
responses: {
200: {
bodyMapper: Mappers.ManagedDatabase
},
201: {
bodyMapper: Mappers.ManagedDatabase
},
202: {
bodyMapper: Mappers.ManagedDatabase
},
204: {
bodyMapper: Mappers.ManagedDatabase
},
default: {}
},
requestBody: Parameters.parameters92,
queryParameters: [Parameters.apiVersion8],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.resourceGroupName,
Parameters.databaseName,
Parameters.managedInstanceName
],
headerParameters: [Parameters.contentType, Parameters.accept],
mediaType: "json",
serializer
};
const cancelMoveOperationSpec: coreClient.OperationSpec = {
path:
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/cancelMove",
httpMethod: "POST",
responses: { 200: {}, 201: {}, 202: {}, 204: {}, default: {} },
requestBody: Parameters.parameters93,
queryParameters: [Parameters.apiVersion8],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.resourceGroupName,
Parameters.databaseName,
Parameters.managedInstanceName
],
headerParameters: [Parameters.contentType],
mediaType: "json",
serializer
};
const completeMoveOperationSpec: coreClient.OperationSpec = {
path:
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/completeMove",
httpMethod: "POST",
responses: { 200: {}, 201: {}, 202: {}, 204: {}, default: {} },
requestBody: Parameters.parameters93,
queryParameters: [Parameters.apiVersion8],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.resourceGroupName,
Parameters.databaseName,
Parameters.managedInstanceName
],
headerParameters: [Parameters.contentType],
mediaType: "json",
serializer
};
const completeRestoreOperationSpec: coreClient.OperationSpec = {
path:
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/completeRestore",
httpMethod: "POST",
responses: { 200: {}, 201: {}, 202: {}, 204: {}, default: {} },
requestBody: Parameters.parameters94,
queryParameters: [Parameters.apiVersion8],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.resourceGroupName,
Parameters.databaseName,
Parameters.managedInstanceName
],
headerParameters: [Parameters.contentType],
mediaType: "json",
serializer
};
const startMoveOperationSpec: coreClient.OperationSpec = {
path:
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/startMove",
httpMethod: "POST",
responses: { 200: {}, 201: {}, 202: {}, 204: {}, default: {} },
requestBody: Parameters.parameters95,
queryParameters: [Parameters.apiVersion8],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.resourceGroupName,
Parameters.databaseName,
Parameters.managedInstanceName
],
headerParameters: [Parameters.contentType],
mediaType: "json",
serializer
};
const listInaccessibleByInstanceOperationSpec: coreClient.OperationSpec = {
path:
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/inaccessibleManagedDatabases",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.ManagedDatabaseListResult
},
default: {}
},
queryParameters: [Parameters.apiVersion8],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.resourceGroupName,
Parameters.managedInstanceName
],
headerParameters: [Parameters.accept],
serializer
};
const listByInstanceNextOperationSpec: coreClient.OperationSpec = {
path: "{nextLink}",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.ManagedDatabaseListResult
},
default: {}
},
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.resourceGroupName,
Parameters.nextLink,
Parameters.managedInstanceName
],
headerParameters: [Parameters.accept],
serializer
};
const listInaccessibleByInstanceNextOperationSpec: coreClient.OperationSpec = {
path: "{nextLink}",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.ManagedDatabaseListResult
},
default: {}
},
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.resourceGroupName,
Parameters.nextLink,
Parameters.managedInstanceName
],
headerParameters: [Parameters.accept],
serializer
};