/* 
  AUTOGENERATED FILE
  Run "npm run generateARMClients" to regenerate
  Edting this file directly should be done with extreme caution as not to diverge from ARM REST specs

  Generated from: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/stable/2021-04-15/notebook.json
*/

import { configContext } from "../../../../ConfigContext";
import { armRequest } from "../../request";
import * as Types from "./types";
const apiVersion = "2021-04-15";

/* Gets the notebook workspace resources of an existing Cosmos DB account. */
export async function listByDatabaseAccount(
  subscriptionId: string,
  resourceGroupName: string,
  accountName: string,
): Promise<Types.NotebookWorkspaceListResult> {
  const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/notebookWorkspaces`;
  return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "GET", apiVersion });
}

/* Gets the notebook workspace for a Cosmos DB account. */
export async function get(
  subscriptionId: string,
  resourceGroupName: string,
  accountName: string,
  notebookWorkspaceName: string,
): Promise<Types.NotebookWorkspace> {
  const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/notebookWorkspaces/${notebookWorkspaceName}`;
  return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "GET", apiVersion });
}

/* Creates the notebook workspace for a Cosmos DB account. */
export async function createOrUpdate(
  subscriptionId: string,
  resourceGroupName: string,
  accountName: string,
  notebookWorkspaceName: string,
): Promise<Types.NotebookWorkspace> {
  const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/notebookWorkspaces/${notebookWorkspaceName}`;
  return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, body: {} });
}

/* Deletes the notebook workspace for a Cosmos DB account. */
export async function destroy(
  subscriptionId: string,
  resourceGroupName: string,
  accountName: string,
  notebookWorkspaceName: string,
): Promise<void> {
  const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/notebookWorkspaces/${notebookWorkspaceName}`;
  return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "DELETE", apiVersion });
}

/* Retrieves the connection info for the notebook workspace */
export async function listConnectionInfo(
  subscriptionId: string,
  resourceGroupName: string,
  accountName: string,
  notebookWorkspaceName: string,
): Promise<Types.NotebookWorkspaceConnectionInfoResult> {
  const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/notebookWorkspaces/${notebookWorkspaceName}/listConnectionInfo`;
  return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "POST", apiVersion });
}

/* Regenerates the auth token for the notebook workspace */
export async function regenerateAuthToken(
  subscriptionId: string,
  resourceGroupName: string,
  accountName: string,
  notebookWorkspaceName: string,
): Promise<void> {
  const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/notebookWorkspaces/${notebookWorkspaceName}/regenerateAuthToken`;
  return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "POST", apiVersion });
}

/* Starts the notebook workspace */
export async function start(
  subscriptionId: string,
  resourceGroupName: string,
  accountName: string,
  notebookWorkspaceName: string,
): Promise<void> {
  const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/${accountName}/notebookWorkspaces/${notebookWorkspaceName}/start`;
  return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "POST", apiVersion });
}
