import * as HttpClient from "effect/unstable/http/HttpClient";
import * as redacted from "effect/Redacted";
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";
import { SensitiveString } from "../sensitive.js";
const svc = T.AwsApiService({
    sdkId: "NotificationsContacts",
    serviceShapeName: "NotificationsContacts",
});
const auth = T.AwsAuthSigv4({ name: "notifications-contacts" });
const ver = T.ServiceVersion("2018-05-10");
const proto = T.AwsProtocolsRestJson1();
const rules = T.EndpointResolver((p, _) => {
    const { UseFIPS = false, Endpoint, Region } = p;
    const e = (u, p = {}, h = {}) => ({
        type: "endpoint",
        endpoint: { url: u, properties: p, headers: h },
    });
    const err = (m) => ({
        type: "error",
        message: m,
    });
    const _p0 = (_0) => ({
        authSchemes: [
            {
                name: "sigv4",
                signingRegion: `${_.getAttr(_0, "implicitGlobalRegion")}`,
            },
        ],
    });
    if (Endpoint != null) {
        if (UseFIPS === true) {
            return err("Invalid Configuration: FIPS and custom endpoint are not supported");
        }
        return e(Endpoint);
    }
    if (Region != null) {
        {
            const PartitionResult = _.partition(Region);
            if (PartitionResult != null && PartitionResult !== false) {
                if (UseFIPS === true) {
                    return e(`https://notifications-contacts-fips.${_.getAttr(PartitionResult, "implicitGlobalRegion")}.${_.getAttr(PartitionResult, "dualStackDnsSuffix")}`, _p0(PartitionResult), {});
                }
                return e(`https://notifications-contacts.${_.getAttr(PartitionResult, "implicitGlobalRegion")}.${_.getAttr(PartitionResult, "dualStackDnsSuffix")}`, _p0(PartitionResult), {});
            }
        }
    }
    return err("Invalid Configuration: Missing Region");
});
export const ListTagsForResourceRequest = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ arn: S.String.pipe(T.HttpLabel("arn")) }).pipe(T.all(T.Http({ method: "GET", uri: "/tags/{arn}" }), svc, auth, proto, ver, rules))).annotate({
    identifier: "ListTagsForResourceRequest",
});
export const TagMap = /*@__PURE__*/ /*#__PURE__*/ S.Record(S.String, S.String.pipe(S.optional));
export const ListTagsForResourceResponse = 
/*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ tags: S.optional(TagMap) })).annotate({
    identifier: "ListTagsForResourceResponse",
});
export const ValidationExceptionReason = /*@__PURE__*/ /*#__PURE__*/ S.String;
export const ValidationExceptionField = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ name: S.String, message: S.String })).annotate({
    identifier: "ValidationExceptionField",
});
export const ValidationExceptionFieldList = /*@__PURE__*/ /*#__PURE__*/ S.Array(ValidationExceptionField);
export const TagResourceRequest = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ arn: S.String.pipe(T.HttpLabel("arn")), tags: TagMap }).pipe(T.all(T.Http({ method: "POST", uri: "/tags/{arn}" }), svc, auth, proto, ver, rules))).annotate({
    identifier: "TagResourceRequest",
});
export const TagResourceResponse = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({})).annotate({
    identifier: "TagResourceResponse",
});
export const TagKeys = /*@__PURE__*/ /*#__PURE__*/ S.Array(S.String);
export const UntagResourceRequest = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    arn: S.String.pipe(T.HttpLabel("arn")),
    tagKeys: TagKeys.pipe(T.HttpQuery("tagKeys")),
}).pipe(T.all(T.Http({ method: "DELETE", uri: "/tags/{arn}" }), svc, auth, proto, ver, rules))).annotate({
    identifier: "UntagResourceRequest",
});
export const UntagResourceResponse = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({})).annotate({
    identifier: "UntagResourceResponse",
});
export const CreateEmailContactRequest = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    name: SensitiveString,
    emailAddress: S.String,
    tags: S.optional(TagMap),
}).pipe(T.all(T.Http({ method: "POST", uri: "/2022-09-19/emailcontacts" }), svc, auth, proto, ver, rules))).annotate({
    identifier: "CreateEmailContactRequest",
});
export const CreateEmailContactResponse = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ arn: S.String })).annotate({
    identifier: "CreateEmailContactResponse",
});
export const GetEmailContactRequest = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ arn: S.String.pipe(T.HttpLabel("arn")) }).pipe(T.all(T.Http({ method: "GET", uri: "/emailcontacts/{arn}" }), svc, auth, proto, ver, rules))).annotate({
    identifier: "GetEmailContactRequest",
});
export const EmailContact = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    arn: S.String,
    name: SensitiveString,
    address: SensitiveString,
    status: S.String,
    creationTime: T.DateFromString.pipe(T.TimestampFormat("date-time")),
    updateTime: T.DateFromString.pipe(T.TimestampFormat("date-time")),
})).annotate({ identifier: "EmailContact" });
export const GetEmailContactResponse = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ emailContact: EmailContact })).annotate({
    identifier: "GetEmailContactResponse",
});
export const DeleteEmailContactRequest = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ arn: S.String.pipe(T.HttpLabel("arn")) }).pipe(T.all(T.Http({ method: "DELETE", uri: "/emailcontacts/{arn}" }), svc, auth, proto, ver, rules))).annotate({
    identifier: "DeleteEmailContactRequest",
});
export const DeleteEmailContactResponse = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({})).annotate({
    identifier: "DeleteEmailContactResponse",
});
export const ListEmailContactsRequest = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    maxResults: S.optional(S.Number).pipe(T.HttpQuery("maxResults")),
    nextToken: S.optional(S.String).pipe(T.HttpQuery("nextToken")),
}).pipe(T.all(T.Http({ method: "GET", uri: "/emailcontacts" }), svc, auth, proto, ver, rules))).annotate({
    identifier: "ListEmailContactsRequest",
});
export const EmailContacts = /*@__PURE__*/ /*#__PURE__*/ S.Array(EmailContact);
export const ListEmailContactsResponse = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ nextToken: S.optional(S.String), emailContacts: EmailContacts })).annotate({
    identifier: "ListEmailContactsResponse",
});
export const ActivateEmailContactRequest = 
/*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    arn: S.String.pipe(T.HttpLabel("arn")),
    code: SensitiveString.pipe(T.HttpLabel("code")),
}).pipe(T.all(T.Http({ method: "PUT", uri: "/emailcontacts/{arn}/activate/{code}" }), svc, auth, proto, ver, rules))).annotate({
    identifier: "ActivateEmailContactRequest",
});
export const ActivateEmailContactResponse = 
/*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({})).annotate({
    identifier: "ActivateEmailContactResponse",
});
export const SendActivationCodeRequest = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ arn: S.String.pipe(T.HttpLabel("arn")) }).pipe(T.all(T.Http({
    method: "POST",
    uri: "/2022-10-31/emailcontacts/{arn}/activate/send",
}), svc, auth, proto, ver, rules))).annotate({
    identifier: "SendActivationCodeRequest",
});
export const SendActivationCodeResponse = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({})).annotate({
    identifier: "SendActivationCodeResponse",
});
//# Errors
export class AccessDeniedException extends S.TaggedErrorClass()("AccessDeniedException", { message: S.String }).pipe(C.withAuthError) {
}
export class InternalServerException extends S.TaggedErrorClass()("InternalServerException", { message: S.String }, T.Retryable()).pipe(C.withServerError, C.withRetryableError) {
}
export class ResourceNotFoundException extends S.TaggedErrorClass()("ResourceNotFoundException", { message: S.String, resourceId: S.String, resourceType: S.String }).pipe(C.withBadRequestError) {
}
export class ThrottlingException extends S.TaggedErrorClass()("ThrottlingException", {
    message: S.String,
    serviceCode: S.optional(S.String),
    quotaCode: S.optional(S.String),
    retryAfterSeconds: S.optional(S.Number).pipe(T.HttpHeader("Retry-After")),
}, T.Retryable({ throttling: true })).pipe(C.withThrottlingError, C.withRetryableError) {
}
export class ValidationException extends S.TaggedErrorClass()("ValidationException", {
    message: S.String,
    reason: ValidationExceptionReason,
    fieldList: S.optional(ValidationExceptionFieldList),
}).pipe(C.withBadRequestError) {
}
export class ConflictException extends S.TaggedErrorClass()("ConflictException", { message: S.String, resourceId: S.String, resourceType: S.String }).pipe(C.withConflictError) {
}
export class ServiceQuotaExceededException extends S.TaggedErrorClass()("ServiceQuotaExceededException", {
    message: S.String,
    resourceId: S.String,
    resourceType: S.String,
    serviceCode: S.String,
    quotaCode: S.String,
}).pipe(C.withQuotaError) {
}
/**
 * Lists all of the tags associated with the Amazon Resource Name (ARN) that you specify. The resource can be a user, server, or role.
 */
export const listTagsForResource = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: ListTagsForResourceRequest,
    output: ListTagsForResourceResponse,
    errors: [
        AccessDeniedException,
        InternalServerException,
        ResourceNotFoundException,
        ThrottlingException,
        ValidationException,
    ],
}));
/**
 * Attaches a key-value pair to a resource, as identified by its Amazon Resource Name (ARN). Taggable resources in AWS User Notifications Contacts include email contacts.
 */
export const tagResource = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: TagResourceRequest,
    output: TagResourceResponse,
    errors: [
        AccessDeniedException,
        InternalServerException,
        ResourceNotFoundException,
        ThrottlingException,
        ValidationException,
    ],
}));
/**
 * Detaches a key-value pair from a resource, as identified by its Amazon Resource Name (ARN). Taggable resources in AWS User Notifications Contacts include email contacts..
 */
export const untagResource = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: UntagResourceRequest,
    output: UntagResourceResponse,
    errors: [
        AccessDeniedException,
        InternalServerException,
        ResourceNotFoundException,
        ThrottlingException,
        ValidationException,
    ],
}));
/**
 * Creates an email contact for the provided email address.
 */
export const createEmailContact = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: CreateEmailContactRequest,
    output: CreateEmailContactResponse,
    errors: [
        AccessDeniedException,
        ConflictException,
        InternalServerException,
        ServiceQuotaExceededException,
        ThrottlingException,
        ValidationException,
    ],
}));
/**
 * Returns an email contact.
 */
export const getEmailContact = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: GetEmailContactRequest,
    output: GetEmailContactResponse,
    errors: [
        AccessDeniedException,
        InternalServerException,
        ResourceNotFoundException,
        ThrottlingException,
        ValidationException,
    ],
}));
/**
 * Deletes an email contact.
 *
 * Deleting an email contact removes it from all associated notification configurations.
 */
export const deleteEmailContact = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: DeleteEmailContactRequest,
    output: DeleteEmailContactResponse,
    errors: [
        AccessDeniedException,
        ConflictException,
        InternalServerException,
        ResourceNotFoundException,
        ThrottlingException,
        ValidationException,
    ],
}));
/**
 * Lists all email contacts created under the Account.
 */
export const listEmailContacts = /*@__PURE__*/ /*#__PURE__*/ API.makePaginated(() => ({
    input: ListEmailContactsRequest,
    output: ListEmailContactsResponse,
    errors: [
        AccessDeniedException,
        InternalServerException,
        ThrottlingException,
        ValidationException,
    ],
    pagination: {
        inputToken: "nextToken",
        outputToken: "nextToken",
        items: "emailContacts",
        pageSize: "maxResults",
    },
}));
/**
 * Activates an email contact using an activation code. This code is in the activation email sent to the email address associated with this email contact.
 */
export const activateEmailContact = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: ActivateEmailContactRequest,
    output: ActivateEmailContactResponse,
    errors: [
        AccessDeniedException,
        ConflictException,
        InternalServerException,
        ResourceNotFoundException,
        ThrottlingException,
        ValidationException,
    ],
}));
/**
 * Sends an activation email to the email address associated with the specified email contact.
 *
 * It might take a few minutes for the activation email to arrive. If it doesn't arrive, check in your spam folder or try sending another activation email.
 */
export const sendActivationCode = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: SendActivationCodeRequest,
    output: SendActivationCodeResponse,
    errors: [
        AccessDeniedException,
        ConflictException,
        InternalServerException,
        ResourceNotFoundException,
        ThrottlingException,
        ValidationException,
    ],
}));
//# sourceMappingURL=notificationscontacts.js.map