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: "FreeTier",
    serviceShapeName: "AWSFreeTierService",
});
const auth = T.AwsAuthSigv4({ name: "freetier" });
const ver = T.ServiceVersion("2023-09-07");
const proto = T.AwsProtocolsAwsJson1_0();
const rules = T.EndpointResolver((p, _) => {
    const { Region, 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,
    });
    const _p0 = () => ({
        authSchemes: [
            {
                name: "sigv4",
                signingName: "freetier",
                signingRegion: "cn-northwest-1",
            },
        ],
    });
    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 (_.getAttr(PartitionResult, "name") === "aws") {
                    if (UseFIPS === true) {
                        if (_.getAttr(PartitionResult, "supportsFIPS") === true) {
                            return e(`https://freetier-fips.${Region}.api.aws`);
                        }
                        return err("FIPS is enabled but this partition does not support FIPS");
                    }
                    return e("https://freetier.us-east-1.api.aws", {
                        authSchemes: [
                            {
                                name: "sigv4",
                                signingName: "freetier",
                                signingRegion: "us-east-1",
                            },
                        ],
                    }, {});
                }
                if (true === _.getAttr(PartitionResult, "supportsDualStack")) {
                    if (UseFIPS === true) {
                        if (_.getAttr(PartitionResult, "supportsFIPS") === true) {
                            return e(`https://freetier-fips.${Region}.${_.getAttr(PartitionResult, "dualStackDnsSuffix")}`);
                        }
                        return err("FIPS is enabled but this partition does not support FIPS");
                    }
                    if (Region === "aws-cn-global") {
                        return e("https://freetier.cn-northwest-1.api.amazonwebservices.com.cn", _p0(), {});
                    }
                    return e(`https://freetier.${Region}.${_.getAttr(PartitionResult, "dualStackDnsSuffix")}`);
                }
                if (UseFIPS === true) {
                    if (_.getAttr(PartitionResult, "supportsFIPS") === true) {
                        return e(`https://freetier-fips.${Region}.${_.getAttr(PartitionResult, "dnsSuffix")}`);
                    }
                    return err("FIPS is enabled but this partition does not support FIPS");
                }
                if (Region === "aws-cn-global") {
                    return e("https://freetier.cn-northwest-1.api.amazonwebservices.com.cn", _p0(), {});
                }
                return e(`https://freetier.${Region}.${_.getAttr(PartitionResult, "dnsSuffix")}`);
            }
        }
    }
    return err("Invalid Configuration: Missing Region");
});
export const LanguageCode = /*@__PURE__*/ /*#__PURE__*/ S.String;
export const GetAccountActivityRequest = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    activityId: S.String,
    languageCode: S.optional(LanguageCode),
}).pipe(T.all(T.Http({ method: "POST", uri: "/" }), svc, auth, proto, ver, rules))).annotate({
    identifier: "GetAccountActivityRequest",
});
export const ActivityStatus = /*@__PURE__*/ /*#__PURE__*/ S.String;
export const CurrencyCode = /*@__PURE__*/ /*#__PURE__*/ S.String;
export const MonetaryAmount = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ amount: S.Number, unit: CurrencyCode })).annotate({ identifier: "MonetaryAmount" });
export const ActivityReward = /*@__PURE__*/ /*#__PURE__*/ S.Union([
    S.Struct({ credit: MonetaryAmount }),
]);
export const GetAccountActivityResponse = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    activityId: S.String,
    title: S.String,
    description: S.String,
    status: ActivityStatus,
    instructionsUrl: S.String,
    reward: ActivityReward,
    estimatedTimeToCompleteInMinutes: S.optional(S.Number),
    expiresAt: S.optional(T.DateFromString.pipe(T.TimestampFormat("date-time"))),
    startedAt: S.optional(T.DateFromString.pipe(T.TimestampFormat("date-time"))),
    completedAt: S.optional(T.DateFromString.pipe(T.TimestampFormat("date-time"))),
})).annotate({
    identifier: "GetAccountActivityResponse",
});
export const GetAccountPlanStateRequest = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({}).pipe(T.all(T.Http({ method: "POST", uri: "/" }), svc, auth, proto, ver, rules))).annotate({
    identifier: "GetAccountPlanStateRequest",
});
export const AccountPlanType = /*@__PURE__*/ /*#__PURE__*/ S.String;
export const AccountPlanStatus = /*@__PURE__*/ /*#__PURE__*/ S.String;
export const GetAccountPlanStateResponse = 
/*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    accountId: S.String,
    accountPlanType: AccountPlanType,
    accountPlanStatus: AccountPlanStatus,
    accountPlanRemainingCredits: S.optional(MonetaryAmount),
    accountPlanExpirationDate: S.optional(T.DateFromString.pipe(T.TimestampFormat("date-time"))),
})).annotate({
    identifier: "GetAccountPlanStateResponse",
});
export const Expressions = /*@__PURE__*/ /*#__PURE__*/ S.Array(S.suspend(() => Expression).annotate({
    identifier: "Expression",
}));
export const Dimension = /*@__PURE__*/ /*#__PURE__*/ S.String;
export const Values = /*@__PURE__*/ /*#__PURE__*/ S.Array(S.String);
export const MatchOption = /*@__PURE__*/ /*#__PURE__*/ S.String;
export const MatchOptions = /*@__PURE__*/ /*#__PURE__*/ S.Array(MatchOption);
export const DimensionValues = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ Key: Dimension, Values: Values, MatchOptions: MatchOptions })).annotate({
    identifier: "DimensionValues",
});
export const Expression = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    Or: S.optional(S.suspend(() => Expressions).annotate({ identifier: "Expressions" })),
    And: S.optional(S.suspend(() => Expressions).annotate({ identifier: "Expressions" })),
    Not: S.optional(S.suspend(() => Expression).annotate({
        identifier: "Expression",
    })),
    Dimensions: S.optional(DimensionValues),
})).annotate({ identifier: "Expression" });
export const GetFreeTierUsageRequest = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    filter: S.optional(Expression),
    maxResults: S.optional(S.Number),
    nextToken: S.optional(S.String),
}).pipe(T.all(T.Http({ method: "POST", uri: "/" }), svc, auth, proto, ver, rules))).annotate({
    identifier: "GetFreeTierUsageRequest",
});
export const FreeTierUsage = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    service: S.optional(S.String),
    operation: S.optional(S.String),
    usageType: S.optional(S.String),
    region: S.optional(S.String),
    actualUsageAmount: S.optional(S.Number),
    forecastedUsageAmount: S.optional(S.Number),
    limit: S.optional(S.Number),
    unit: S.optional(S.String),
    description: S.optional(S.String),
    freeTierType: S.optional(S.String),
})).annotate({ identifier: "FreeTierUsage" });
export const FreeTierUsages = 
/*@__PURE__*/ /*#__PURE__*/ S.Array(FreeTierUsage);
export const GetFreeTierUsageResponse = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    freeTierUsages: FreeTierUsages,
    nextToken: S.optional(S.String),
})).annotate({
    identifier: "GetFreeTierUsageResponse",
});
export const FilterActivityStatuses = 
/*@__PURE__*/ /*#__PURE__*/ S.Array(ActivityStatus);
export const ListAccountActivitiesRequest = 
/*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    filterActivityStatuses: S.optional(FilterActivityStatuses),
    nextToken: S.optional(S.String),
    maxResults: S.optional(S.Number),
    languageCode: S.optional(LanguageCode),
}).pipe(T.all(T.Http({ method: "POST", uri: "/" }), svc, auth, proto, ver, rules))).annotate({
    identifier: "ListAccountActivitiesRequest",
});
export const ActivitySummary = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    activityId: S.String,
    title: S.String,
    reward: ActivityReward,
    status: ActivityStatus,
})).annotate({
    identifier: "ActivitySummary",
});
export const Activities = /*@__PURE__*/ /*#__PURE__*/ S.Array(ActivitySummary);
export const ListAccountActivitiesResponse = 
/*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ activities: Activities, nextToken: S.optional(S.String) })).annotate({
    identifier: "ListAccountActivitiesResponse",
});
export const UpgradeAccountPlanRequest = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ accountPlanType: AccountPlanType }).pipe(T.all(T.Http({ method: "POST", uri: "/" }), svc, auth, proto, ver, rules))).annotate({
    identifier: "UpgradeAccountPlanRequest",
});
export const UpgradeAccountPlanResponse = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    accountId: S.String,
    accountPlanType: AccountPlanType,
    accountPlanStatus: AccountPlanStatus,
})).annotate({
    identifier: "UpgradeAccountPlanResponse",
});
//# Errors
export class InternalServerException extends S.TaggedErrorClass()("InternalServerException", { message: S.String }).pipe(C.withServerError) {
}
export class ResourceNotFoundException extends S.TaggedErrorClass()("ResourceNotFoundException", { message: S.String }).pipe(C.withBadRequestError) {
}
export class ThrottlingException extends S.TaggedErrorClass()("ThrottlingException", { message: S.String }).pipe(C.withThrottlingError) {
}
export class ValidationException extends S.TaggedErrorClass()("ValidationException", { message: S.String }).pipe(C.withBadRequestError) {
}
export class AccessDeniedException extends S.TaggedErrorClass()("AccessDeniedException", { message: S.String }).pipe(C.withAuthError) {
}
/**
 * Returns a specific activity record that is available to the customer.
 */
export const getAccountActivity = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: GetAccountActivityRequest,
    output: GetAccountActivityResponse,
    errors: [
        InternalServerException,
        ResourceNotFoundException,
        ThrottlingException,
        ValidationException,
    ],
}));
/**
 * This returns all of the information related to the state of the account plan related to Free Tier.
 */
export const getAccountPlanState = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: GetAccountPlanStateRequest,
    output: GetAccountPlanStateResponse,
    errors: [
        AccessDeniedException,
        InternalServerException,
        ResourceNotFoundException,
        ThrottlingException,
        ValidationException,
    ],
}));
/**
 * Returns a list of all Free Tier usage objects that match your filters.
 */
export const getFreeTierUsage = /*@__PURE__*/ /*#__PURE__*/ API.makePaginated(() => ({
    input: GetFreeTierUsageRequest,
    output: GetFreeTierUsageResponse,
    errors: [InternalServerException, ThrottlingException, ValidationException],
    pagination: {
        inputToken: "nextToken",
        outputToken: "nextToken",
        items: "freeTierUsages",
        pageSize: "maxResults",
    },
}));
/**
 * Returns a list of activities that are available. This operation supports pagination and filtering by status.
 */
export const listAccountActivities = /*@__PURE__*/ /*#__PURE__*/ API.makePaginated(() => ({
    input: ListAccountActivitiesRequest,
    output: ListAccountActivitiesResponse,
    errors: [InternalServerException, ThrottlingException, ValidationException],
    pagination: {
        inputToken: "nextToken",
        outputToken: "nextToken",
        items: "activities",
        pageSize: "maxResults",
    },
}));
/**
 * The account plan type for the Amazon Web Services account.
 */
export const upgradeAccountPlan = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: UpgradeAccountPlanRequest,
    output: UpgradeAccountPlanResponse,
    errors: [
        AccessDeniedException,
        InternalServerException,
        ResourceNotFoundException,
        ThrottlingException,
        ValidationException,
    ],
}));
//# sourceMappingURL=freetier.js.map