import * as HttpClient from "effect/unstable/http/HttpClient";
import * as S from "effect/Schema";
import * as stream from "effect/Stream";
import * as API from "../client/api.js";
import * as T from "../traits.js";
import * as C from "../category.js";
const svc = T.AwsApiService({
    sdkId: "Support App",
    serviceShapeName: "SupportApp",
});
const auth = T.AwsAuthSigv4({ name: "supportapp" });
const ver = T.ServiceVersion("2021-08-20");
const proto = T.AwsProtocolsRestJson1();
const rules = T.EndpointResolver((p, _) => {
    const { Region, UseDualStack = false, UseFIPS = false, Endpoint } = p;
    const e = (u, p = {}, h = {}) => ({
        type: "endpoint",
        endpoint: { url: u, properties: p, headers: h },
    });
    const err = (m) => ({
        type: "error",
        message: m,
    });
    if (Endpoint != null) {
        if (UseFIPS === true) {
            return err("Invalid Configuration: FIPS and custom endpoint are not supported");
        }
        if (UseDualStack === true) {
            return err("Invalid Configuration: Dualstack and custom endpoint are not supported");
        }
        return e(Endpoint);
    }
    if (Region != null) {
        {
            const PartitionResult = _.partition(Region);
            if (PartitionResult != null && PartitionResult !== false) {
                if (UseFIPS === true && UseDualStack === true) {
                    if (true === _.getAttr(PartitionResult, "supportsFIPS") &&
                        true === _.getAttr(PartitionResult, "supportsDualStack")) {
                        return e(`https://supportapp-fips.${Region}.${_.getAttr(PartitionResult, "dualStackDnsSuffix")}`);
                    }
                    return err("FIPS and DualStack are enabled, but this partition does not support one or both");
                }
                if (UseFIPS === true) {
                    if (_.getAttr(PartitionResult, "supportsFIPS") === true) {
                        return e(`https://supportapp-fips.${Region}.${_.getAttr(PartitionResult, "dnsSuffix")}`);
                    }
                    return err("FIPS is enabled but this partition does not support FIPS");
                }
                if (UseDualStack === true) {
                    if (true === _.getAttr(PartitionResult, "supportsDualStack")) {
                        return e(`https://supportapp.${Region}.${_.getAttr(PartitionResult, "dualStackDnsSuffix")}`);
                    }
                    return err("DualStack is enabled but this partition does not support DualStack");
                }
                return e(`https://supportapp.${Region}.${_.getAttr(PartitionResult, "dnsSuffix")}`);
            }
        }
    }
    return err("Invalid Configuration: Missing Region");
});
export const CreateSlackChannelConfigurationRequest = 
/*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    teamId: S.String,
    channelId: S.String,
    channelName: S.optional(S.String),
    notifyOnCreateOrReopenCase: S.optional(S.Boolean),
    notifyOnAddCorrespondenceToCase: S.optional(S.Boolean),
    notifyOnResolveCase: S.optional(S.Boolean),
    notifyOnCaseSeverity: S.String,
    channelRoleArn: S.String,
}).pipe(T.all(T.Http({
    method: "POST",
    uri: "/control/create-slack-channel-configuration",
}), svc, auth, proto, ver, rules))).annotate({
    identifier: "CreateSlackChannelConfigurationRequest",
});
export const CreateSlackChannelConfigurationResult = 
/*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({})).annotate({
    identifier: "CreateSlackChannelConfigurationResult",
});
export const DeleteAccountAliasRequest = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({}).pipe(T.all(T.Http({ method: "POST", uri: "/control/delete-account-alias" }), svc, auth, proto, ver, rules))).annotate({
    identifier: "DeleteAccountAliasRequest",
});
export const DeleteAccountAliasResult = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({})).annotate({
    identifier: "DeleteAccountAliasResult",
});
export const DeleteSlackChannelConfigurationRequest = 
/*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ teamId: S.String, channelId: S.String }).pipe(T.all(T.Http({
    method: "POST",
    uri: "/control/delete-slack-channel-configuration",
}), svc, auth, proto, ver, rules))).annotate({
    identifier: "DeleteSlackChannelConfigurationRequest",
});
export const DeleteSlackChannelConfigurationResult = 
/*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({})).annotate({
    identifier: "DeleteSlackChannelConfigurationResult",
});
export const DeleteSlackWorkspaceConfigurationRequest = 
/*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ teamId: S.String }).pipe(T.all(T.Http({
    method: "POST",
    uri: "/control/delete-slack-workspace-configuration",
}), svc, auth, proto, ver, rules))).annotate({
    identifier: "DeleteSlackWorkspaceConfigurationRequest",
});
export const DeleteSlackWorkspaceConfigurationResult = 
/*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({})).annotate({
    identifier: "DeleteSlackWorkspaceConfigurationResult",
});
export const GetAccountAliasRequest = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({}).pipe(T.all(T.Http({ method: "POST", uri: "/control/get-account-alias" }), svc, auth, proto, ver, rules))).annotate({
    identifier: "GetAccountAliasRequest",
});
export const GetAccountAliasResult = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ accountAlias: S.optional(S.String) })).annotate({
    identifier: "GetAccountAliasResult",
});
export const ListSlackChannelConfigurationsRequest = 
/*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ nextToken: S.optional(S.String) }).pipe(T.all(T.Http({
    method: "POST",
    uri: "/control/list-slack-channel-configurations",
}), svc, auth, proto, ver, rules))).annotate({
    identifier: "ListSlackChannelConfigurationsRequest",
});
export const SlackChannelConfiguration = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    teamId: S.String,
    channelId: S.String,
    channelName: S.optional(S.String),
    notifyOnCreateOrReopenCase: S.optional(S.Boolean),
    notifyOnAddCorrespondenceToCase: S.optional(S.Boolean),
    notifyOnResolveCase: S.optional(S.Boolean),
    notifyOnCaseSeverity: S.optional(S.String),
    channelRoleArn: S.optional(S.String),
})).annotate({
    identifier: "SlackChannelConfiguration",
});
export const SlackChannelConfigurationList = 
/*@__PURE__*/ /*#__PURE__*/ S.Array(SlackChannelConfiguration);
export const ListSlackChannelConfigurationsResult = 
/*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    nextToken: S.optional(S.String),
    slackChannelConfigurations: SlackChannelConfigurationList,
})).annotate({
    identifier: "ListSlackChannelConfigurationsResult",
});
export const ListSlackWorkspaceConfigurationsRequest = 
/*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ nextToken: S.optional(S.String) }).pipe(T.all(T.Http({
    method: "POST",
    uri: "/control/list-slack-workspace-configurations",
}), svc, auth, proto, ver, rules))).annotate({
    identifier: "ListSlackWorkspaceConfigurationsRequest",
});
export const SlackWorkspaceConfiguration = 
/*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    teamId: S.String,
    teamName: S.optional(S.String),
    allowOrganizationMemberAccount: S.optional(S.Boolean),
})).annotate({
    identifier: "SlackWorkspaceConfiguration",
});
export const SlackWorkspaceConfigurationList = 
/*@__PURE__*/ /*#__PURE__*/ S.Array(SlackWorkspaceConfiguration);
export const ListSlackWorkspaceConfigurationsResult = 
/*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    nextToken: S.optional(S.String),
    slackWorkspaceConfigurations: S.optional(SlackWorkspaceConfigurationList),
})).annotate({
    identifier: "ListSlackWorkspaceConfigurationsResult",
});
export const PutAccountAliasRequest = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ accountAlias: S.String }).pipe(T.all(T.Http({ method: "POST", uri: "/control/put-account-alias" }), svc, auth, proto, ver, rules))).annotate({
    identifier: "PutAccountAliasRequest",
});
export const PutAccountAliasResult = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({})).annotate({
    identifier: "PutAccountAliasResult",
});
export const RegisterSlackWorkspaceForOrganizationRequest = 
/*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ teamId: S.String }).pipe(T.all(T.Http({
    method: "POST",
    uri: "/control/register-slack-workspace-for-organization",
}), svc, auth, proto, ver, rules))).annotate({
    identifier: "RegisterSlackWorkspaceForOrganizationRequest",
});
export const RegisterSlackWorkspaceForOrganizationResult = 
/*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    teamId: S.optional(S.String),
    teamName: S.optional(S.String),
    accountType: S.optional(S.String),
})).annotate({
    identifier: "RegisterSlackWorkspaceForOrganizationResult",
});
export const UpdateSlackChannelConfigurationRequest = 
/*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    teamId: S.String,
    channelId: S.String,
    channelName: S.optional(S.String),
    notifyOnCreateOrReopenCase: S.optional(S.Boolean),
    notifyOnAddCorrespondenceToCase: S.optional(S.Boolean),
    notifyOnResolveCase: S.optional(S.Boolean),
    notifyOnCaseSeverity: S.optional(S.String),
    channelRoleArn: S.optional(S.String),
}).pipe(T.all(T.Http({
    method: "POST",
    uri: "/control/update-slack-channel-configuration",
}), svc, auth, proto, ver, rules))).annotate({
    identifier: "UpdateSlackChannelConfigurationRequest",
});
export const UpdateSlackChannelConfigurationResult = 
/*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    teamId: S.optional(S.String),
    channelId: S.optional(S.String),
    channelName: S.optional(S.String),
    notifyOnCreateOrReopenCase: S.optional(S.Boolean),
    notifyOnAddCorrespondenceToCase: S.optional(S.Boolean),
    notifyOnResolveCase: S.optional(S.Boolean),
    notifyOnCaseSeverity: S.optional(S.String),
    channelRoleArn: S.optional(S.String),
})).annotate({
    identifier: "UpdateSlackChannelConfigurationResult",
});
//# Errors
export class AccessDeniedException extends S.TaggedErrorClass()("AccessDeniedException", { message: S.optional(S.String) }).pipe(C.withAuthError) {
}
export class ConflictException extends S.TaggedErrorClass()("ConflictException", { message: S.optional(S.String) }).pipe(C.withConflictError) {
}
export class InternalServerException extends S.TaggedErrorClass()("InternalServerException", { message: S.optional(S.String) }).pipe(C.withServerError) {
}
export class ServiceQuotaExceededException extends S.TaggedErrorClass()("ServiceQuotaExceededException", { message: S.optional(S.String) }).pipe(C.withQuotaError) {
}
export class ValidationException extends S.TaggedErrorClass()("ValidationException", { message: S.optional(S.String) }).pipe(C.withBadRequestError) {
}
export class ResourceNotFoundException extends S.TaggedErrorClass()("ResourceNotFoundException", { message: S.optional(S.String) }).pipe(C.withBadRequestError) {
}
/**
 * Creates a Slack channel configuration for your Amazon Web Services account.
 *
 * - You can add up to 5 Slack workspaces for your account.
 *
 * - You can add up to 20 Slack channels for your account.
 *
 * A Slack channel can have up to 100 Amazon Web Services accounts. This means that only 100 accounts can
 * add the same Slack channel to the Amazon Web Services Support App. We recommend that you only add the accounts that
 * you need to manage support cases for your organization. This can reduce the notifications
 * about case updates that you receive in the Slack channel.
 *
 * We recommend that you choose a private Slack channel so that only members in that
 * channel have read and write access to your support cases. Anyone in your Slack channel can
 * create, update, or resolve support cases for your account. Users require an invitation to
 * join private channels.
 */
export const createSlackChannelConfiguration = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: CreateSlackChannelConfigurationRequest,
    output: CreateSlackChannelConfigurationResult,
    errors: [
        AccessDeniedException,
        ConflictException,
        InternalServerException,
        ServiceQuotaExceededException,
        ValidationException,
    ],
}));
/**
 * Deletes an alias for an Amazon Web Services account ID. The alias appears in the Amazon Web Services Support App page of the
 * Amazon Web Services Support Center. The alias also appears in Slack messages from the Amazon Web Services Support App.
 */
export const deleteAccountAlias = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: DeleteAccountAliasRequest,
    output: DeleteAccountAliasResult,
    errors: [
        AccessDeniedException,
        InternalServerException,
        ResourceNotFoundException,
    ],
}));
/**
 * Deletes a Slack channel configuration from your Amazon Web Services account. This operation doesn't
 * delete your Slack channel.
 */
export const deleteSlackChannelConfiguration = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: DeleteSlackChannelConfigurationRequest,
    output: DeleteSlackChannelConfigurationResult,
    errors: [
        AccessDeniedException,
        ConflictException,
        InternalServerException,
        ResourceNotFoundException,
        ValidationException,
    ],
}));
/**
 * Deletes a Slack workspace configuration from your Amazon Web Services account. This operation doesn't
 * delete your Slack workspace.
 */
export const deleteSlackWorkspaceConfiguration = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: DeleteSlackWorkspaceConfigurationRequest,
    output: DeleteSlackWorkspaceConfigurationResult,
    errors: [
        AccessDeniedException,
        ConflictException,
        InternalServerException,
        ResourceNotFoundException,
        ValidationException,
    ],
}));
/**
 * Retrieves the alias from an Amazon Web Services account ID. The alias appears in the Amazon Web Services Support App page of
 * the Amazon Web Services Support Center. The alias also appears in Slack messages from the Amazon Web Services Support App.
 */
export const getAccountAlias = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: GetAccountAliasRequest,
    output: GetAccountAliasResult,
    errors: [InternalServerException],
}));
/**
 * Lists the Slack channel configurations for an Amazon Web Services account.
 */
export const listSlackChannelConfigurations = /*@__PURE__*/ /*#__PURE__*/ API.makePaginated(() => ({
    input: ListSlackChannelConfigurationsRequest,
    output: ListSlackChannelConfigurationsResult,
    errors: [AccessDeniedException, InternalServerException],
    pagination: { inputToken: "nextToken", outputToken: "nextToken" },
}));
/**
 * Lists the Slack workspace configurations for an Amazon Web Services account.
 */
export const listSlackWorkspaceConfigurations = /*@__PURE__*/ /*#__PURE__*/ API.makePaginated(() => ({
    input: ListSlackWorkspaceConfigurationsRequest,
    output: ListSlackWorkspaceConfigurationsResult,
    errors: [AccessDeniedException, InternalServerException],
    pagination: { inputToken: "nextToken", outputToken: "nextToken" },
}));
/**
 * Creates or updates an individual alias for each Amazon Web Services account ID. The alias appears in the
 * Amazon Web Services Support App page of the Amazon Web Services Support Center. The alias also appears in Slack messages from the
 * Amazon Web Services Support App.
 */
export const putAccountAlias = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: PutAccountAliasRequest,
    output: PutAccountAliasResult,
    errors: [AccessDeniedException, InternalServerException, ValidationException],
}));
/**
 * Registers a Slack workspace for your Amazon Web Services account. To call this API, your account must be
 * part of an organization in Organizations.
 *
 * If you're the *management account* and you want to register Slack
 * workspaces for your organization, you must complete the following tasks:
 *
 * - Sign in to the Amazon Web Services Support Center and
 * authorize the Slack workspaces where you want your organization to have access to. See
 * Authorize a Slack workspace in the Amazon Web Services Support User
 * Guide.
 *
 * - Call the `RegisterSlackWorkspaceForOrganization` API to authorize each
 * Slack workspace for the organization.
 *
 * After the management account authorizes the Slack workspace, member accounts can call this
 * API to authorize the same Slack workspace for their individual accounts. Member accounts don't
 * need to authorize the Slack workspace manually through the Amazon Web Services Support Center.
 *
 * To use the Amazon Web Services Support App, each account must then complete the following tasks:
 *
 * - Create an Identity and Access Management (IAM) role with the required permission. For more information,
 * see Managing access to the Amazon Web Services Support App.
 *
 * - Configure a Slack channel to use the Amazon Web Services Support App for support cases for that account. For
 * more information, see Configuring a Slack channel.
 */
export const registerSlackWorkspaceForOrganization = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: RegisterSlackWorkspaceForOrganizationRequest,
    output: RegisterSlackWorkspaceForOrganizationResult,
    errors: [
        AccessDeniedException,
        ConflictException,
        InternalServerException,
        ResourceNotFoundException,
        ValidationException,
    ],
}));
/**
 * Updates the configuration for a Slack channel, such as case update notifications.
 */
export const updateSlackChannelConfiguration = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: UpdateSlackChannelConfigurationRequest,
    output: UpdateSlackChannelConfigurationResult,
    errors: [
        AccessDeniedException,
        ConflictException,
        InternalServerException,
        ResourceNotFoundException,
        ValidationException,
    ],
}));
//# sourceMappingURL=support-app.js.map