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: "Route53 Recovery Cluster",
    serviceShapeName: "ToggleCustomerAPI",
});
const auth = T.AwsAuthSigv4({ name: "route53-recovery-cluster" });
const ver = T.ServiceVersion("2019-12-02");
const proto = T.AwsProtocolsAwsJson1_0();
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://route53-recovery-cluster-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://route53-recovery-cluster-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://route53-recovery-cluster.${Region}.${_.getAttr(PartitionResult, "dualStackDnsSuffix")}`);
                    }
                    return err("DualStack is enabled but this partition does not support DualStack");
                }
                return e(`https://route53-recovery-cluster.${Region}.${_.getAttr(PartitionResult, "dnsSuffix")}`);
            }
        }
    }
    return err("Invalid Configuration: Missing Region");
});
export const GetRoutingControlStateRequest = 
/*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ RoutingControlArn: S.String }).pipe(T.all(T.Http({ method: "POST", uri: "/" }), svc, auth, proto, ver, rules))).annotate({
    identifier: "GetRoutingControlStateRequest",
});
export const RoutingControlState = /*@__PURE__*/ /*#__PURE__*/ S.String;
export const GetRoutingControlStateResponse = 
/*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    RoutingControlArn: S.String,
    RoutingControlState: RoutingControlState,
    RoutingControlName: S.optional(S.String),
})).annotate({
    identifier: "GetRoutingControlStateResponse",
});
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 ListRoutingControlsRequest = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    ControlPanelArn: S.optional(S.String),
    NextToken: S.optional(S.String),
    MaxResults: S.optional(S.Number),
}).pipe(T.all(T.Http({ method: "POST", uri: "/" }), svc, auth, proto, ver, rules))).annotate({
    identifier: "ListRoutingControlsRequest",
});
export const RoutingControl = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    ControlPanelArn: S.optional(S.String),
    ControlPanelName: S.optional(S.String),
    RoutingControlArn: S.optional(S.String),
    RoutingControlName: S.optional(S.String),
    RoutingControlState: S.optional(RoutingControlState),
    Owner: S.optional(S.String),
})).annotate({ identifier: "RoutingControl" });
export const RoutingControls = 
/*@__PURE__*/ /*#__PURE__*/ S.Array(RoutingControl);
export const ListRoutingControlsResponse = 
/*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    RoutingControls: RoutingControls,
    NextToken: S.optional(S.String),
})).annotate({
    identifier: "ListRoutingControlsResponse",
});
export const Arns = /*@__PURE__*/ /*#__PURE__*/ S.Array(S.String);
export const UpdateRoutingControlStateRequest = 
/*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    RoutingControlArn: S.String,
    RoutingControlState: RoutingControlState,
    SafetyRulesToOverride: S.optional(Arns),
}).pipe(T.all(T.Http({ method: "POST", uri: "/" }), svc, auth, proto, ver, rules))).annotate({
    identifier: "UpdateRoutingControlStateRequest",
});
export const UpdateRoutingControlStateResponse = 
/*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({})).annotate({
    identifier: "UpdateRoutingControlStateResponse",
});
export const UpdateRoutingControlStateEntry = 
/*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    RoutingControlArn: S.String,
    RoutingControlState: RoutingControlState,
})).annotate({
    identifier: "UpdateRoutingControlStateEntry",
});
export const UpdateRoutingControlStateEntries = 
/*@__PURE__*/ /*#__PURE__*/ S.Array(UpdateRoutingControlStateEntry);
export const UpdateRoutingControlStatesRequest = 
/*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    UpdateRoutingControlStateEntries: UpdateRoutingControlStateEntries,
    SafetyRulesToOverride: S.optional(Arns),
}).pipe(T.all(T.Http({ method: "POST", uri: "/" }), svc, auth, proto, ver, rules))).annotate({
    identifier: "UpdateRoutingControlStatesRequest",
});
export const UpdateRoutingControlStatesResponse = 
/*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({})).annotate({
    identifier: "UpdateRoutingControlStatesResponse",
});
//# Errors
export class AccessDeniedException extends S.TaggedErrorClass()("AccessDeniedException", { message: S.String }).pipe(C.withAuthError) {
}
export class EndpointTemporarilyUnavailableException extends S.TaggedErrorClass()("EndpointTemporarilyUnavailableException", { message: S.String }).pipe(C.withServerError) {
}
export class InternalServerException extends S.TaggedErrorClass()("InternalServerException", {
    message: S.String,
    retryAfterSeconds: S.optional(S.Number).pipe(T.HttpHeader("Retry-After")),
}).pipe(C.withServerError) {
}
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,
    retryAfterSeconds: S.optional(S.Number).pipe(T.HttpHeader("Retry-After")),
}).pipe(C.withThrottlingError) {
}
export class ValidationException extends S.TaggedErrorClass()("ValidationException", {
    message: S.String,
    reason: S.optional(ValidationExceptionReason),
    fields: 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 ServiceLimitExceededException extends S.TaggedErrorClass()("ServiceLimitExceededException", {
    message: S.String,
    resourceId: S.optional(S.String),
    resourceType: S.optional(S.String),
    limitCode: S.String,
    serviceCode: S.String,
}).pipe(C.withQuotaError) {
}
/**
 * Get the state for a routing control. A routing control is a simple on/off switch that you
 * can use to route traffic to cells. When a routing control state is set to ON, traffic flows to a cell. When
 * the state is set to OFF, traffic does not flow.
 *
 * Before you can create a routing control, you must first create a cluster, and then host the control
 * in a control panel on the cluster. For more information, see
 * Create routing control structures in the Amazon Route 53 Application Recovery Controller Developer Guide.
 * You access one of the endpoints for the cluster to get or update the routing control state to
 * redirect traffic for your application.
 *
 * You must specify Regional endpoints when you work with API cluster operations
 * to get or update routing control states in Route 53 ARC.
 *
 * To see a code example for getting a routing control state, including accessing Regional cluster endpoints
 * in sequence, see API examples
 * in the Amazon Route 53 Application Recovery Controller Developer Guide.
 *
 * Learn more about working with routing controls in the following topics in the
 * Amazon Route 53 Application Recovery Controller Developer Guide:
 *
 * -
 * Viewing and updating routing control states
 *
 * - Working with
 * routing controls in Route 53 ARC
 */
export const getRoutingControlState = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: GetRoutingControlStateRequest,
    output: GetRoutingControlStateResponse,
    errors: [
        AccessDeniedException,
        EndpointTemporarilyUnavailableException,
        InternalServerException,
        ResourceNotFoundException,
        ThrottlingException,
        ValidationException,
    ],
}));
/**
 * List routing control names and Amazon Resource Names (ARNs), as well as the routing control
 * state for each routing control, along with the control panel name and control panel ARN for the routing controls.
 * If you specify a control panel ARN, this call lists the routing controls in the control panel. Otherwise, it lists
 * all the routing controls in the cluster.
 *
 * A routing control is a simple on/off switch in Route 53 ARC that you
 * can use to route traffic to cells. When a routing control state is set to ON, traffic flows to a cell. When
 * the state is set to OFF, traffic does not flow.
 *
 * Before you can create a routing control, you must first create a cluster, and then host the control
 * in a control panel on the cluster. For more information, see
 * Create routing control structures in the Amazon Route 53 Application Recovery Controller Developer Guide.
 * You access one of the endpoints for the cluster to get or update the routing control state to
 * redirect traffic for your application.
 *
 * You must specify Regional endpoints when you work with API cluster operations
 * to use this API operation to list routing controls in Route 53 ARC.
 *
 * Learn more about working with routing controls in the following topics in the
 * Amazon Route 53 Application Recovery Controller Developer Guide:
 *
 * -
 * Viewing and updating routing control states
 *
 * - Working with
 * routing controls in Route 53 ARC
 */
export const listRoutingControls = /*@__PURE__*/ /*#__PURE__*/ API.makePaginated(() => ({
    input: ListRoutingControlsRequest,
    output: ListRoutingControlsResponse,
    errors: [
        AccessDeniedException,
        EndpointTemporarilyUnavailableException,
        InternalServerException,
        ResourceNotFoundException,
        ThrottlingException,
        ValidationException,
    ],
    pagination: {
        inputToken: "NextToken",
        outputToken: "NextToken",
        items: "RoutingControls",
        pageSize: "MaxResults",
    },
}));
/**
 * Set the state of the routing control to reroute traffic. You can set the value to ON or
 * OFF. When the state is ON, traffic flows to a cell. When the state is OFF, traffic does not
 * flow.
 *
 * With Route 53 ARC, you can add safety rules for routing controls, which are safeguards for routing
 * control state updates that help prevent unexpected outcomes, like fail open traffic routing. However,
 * there are scenarios when you might want to bypass the routing control safeguards that are enforced with
 * safety rules that you've configured. For example, you might want to fail over quickly for disaster recovery,
 * and one or more safety rules might be unexpectedly preventing you from updating a routing control state to
 * reroute traffic. In a "break glass" scenario like this, you can override one or more safety rules to change
 * a routing control state and fail over your application.
 *
 * The `SafetyRulesToOverride` property enables you override one or more safety rules and
 * update routing control states. For more information, see
 *
 * Override safety rules to reroute traffic in the Amazon Route 53 Application Recovery Controller Developer Guide.
 *
 * You must specify Regional endpoints when you work with API cluster operations
 * to get or update routing control states in Route 53 ARC.
 *
 * To see a code example for getting a routing control state, including accessing Regional cluster endpoints
 * in sequence, see API examples
 * in the Amazon Route 53 Application Recovery Controller Developer Guide.
 *
 * -
 * Viewing and updating routing control states
 *
 * - Working with routing controls overall
 */
export const updateRoutingControlState = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: UpdateRoutingControlStateRequest,
    output: UpdateRoutingControlStateResponse,
    errors: [
        AccessDeniedException,
        ConflictException,
        EndpointTemporarilyUnavailableException,
        InternalServerException,
        ResourceNotFoundException,
        ThrottlingException,
        ValidationException,
    ],
}));
/**
 * Set multiple routing control states. You can set the value for each state to be ON or OFF.
 * When the state is ON, traffic flows to a cell. When it's OFF, traffic does not
 * flow.
 *
 * With Route 53 ARC, you can add safety rules for routing controls, which are safeguards for routing
 * control state updates that help prevent unexpected outcomes, like fail open traffic routing. However,
 * there are scenarios when you might want to bypass the routing control safeguards that are enforced with
 * safety rules that you've configured. For example, you might want to fail over quickly for disaster recovery,
 * and one or more safety rules might be unexpectedly preventing you from updating a routing control state to
 * reroute traffic. In a "break glass" scenario like this, you can override one or more safety rules to change
 * a routing control state and fail over your application.
 *
 * The `SafetyRulesToOverride` property enables you override one or more safety rules and
 * update routing control states. For more information, see
 *
 * Override safety rules to reroute traffic in the Amazon Route 53 Application Recovery Controller Developer Guide.
 *
 * You must specify Regional endpoints when you work with API cluster operations
 * to get or update routing control states in Route 53 ARC.
 *
 * To see a code example for getting a routing control state, including accessing Regional cluster endpoints
 * in sequence, see API examples
 * in the Amazon Route 53 Application Recovery Controller Developer Guide.
 *
 * -
 * Viewing and updating routing control states
 *
 * - Working with routing controls overall
 */
export const updateRoutingControlStates = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: UpdateRoutingControlStatesRequest,
    output: UpdateRoutingControlStatesResponse,
    errors: [
        AccessDeniedException,
        ConflictException,
        EndpointTemporarilyUnavailableException,
        InternalServerException,
        ResourceNotFoundException,
        ServiceLimitExceededException,
        ThrottlingException,
        ValidationException,
    ],
}));
//# sourceMappingURL=route53-recovery-cluster.js.map