/* 
  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/synapse/resource-manager/Microsoft.Synapse/stable/2021-03-01/workspace.json
*/

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

/* Gets a workspace SQL active directory admin */
export async function get(
  subscriptionId: string,
  resourceGroupName: string,
  workspaceName: string,
): Promise<Types.WorkspaceAadAdminInfo> {
  const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.Synapse/workspaces/${workspaceName}/sqlAdministrators/activeDirectory`;
  return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "GET", apiVersion });
}

/* Creates or updates a workspace SQL active directory admin */
export async function createOrUpdate(
  subscriptionId: string,
  resourceGroupName: string,
  workspaceName: string,
  body: Types.WorkspaceAadAdminInfo,
): Promise<Types.WorkspaceAadAdminInfo> {
  const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.Synapse/workspaces/${workspaceName}/sqlAdministrators/activeDirectory`;
  return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "PUT", apiVersion, body });
}

/* Deletes a workspace SQL active directory admin */
export async function destroy(subscriptionId: string, resourceGroupName: string, workspaceName: string): Promise<void> {
  const path = `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.Synapse/workspaces/${workspaceName}/sqlAdministrators/activeDirectory`;
  return armRequest({ host: configContext.ARM_ENDPOINT, path, method: "DELETE", apiVersion });
}
