import * as HttpClient from "effect/unstable/http/HttpClient";
import * as S from "effect/Schema";
import * as API from "../client/api.js";
import * as T from "../traits.js";
import * as C from "../category.js";
const svc = T.AwsApiService({
    sdkId: "SageMaker FeatureStore Runtime",
    serviceShapeName: "AmazonSageMakerFeatureStoreRuntime",
});
const auth = T.AwsAuthSigv4({ name: "sagemaker" });
const ver = T.ServiceVersion("2020-07-01");
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://featurestore-runtime.sagemaker-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://featurestore-runtime.sagemaker-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://featurestore-runtime.sagemaker.${Region}.${_.getAttr(PartitionResult, "dualStackDnsSuffix")}`);
                    }
                    return err("DualStack is enabled but this partition does not support DualStack");
                }
                return e(`https://featurestore-runtime.sagemaker.${Region}.${_.getAttr(PartitionResult, "dnsSuffix")}`);
            }
        }
    }
    return err("Invalid Configuration: Missing Region");
});
export const RecordIdentifiers = /*@__PURE__*/ /*#__PURE__*/ S.Array(S.String);
export const FeatureNames = /*@__PURE__*/ /*#__PURE__*/ S.Array(S.String);
export const BatchGetRecordIdentifier = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    FeatureGroupName: S.optional(S.String),
    RecordIdentifiersValueAsString: S.optional(RecordIdentifiers),
    FeatureNames: S.optional(FeatureNames),
})).annotate({
    identifier: "BatchGetRecordIdentifier",
});
export const BatchGetRecordIdentifiers = /*@__PURE__*/ /*#__PURE__*/ S.Array(BatchGetRecordIdentifier);
export const ExpirationTimeResponse = /*@__PURE__*/ /*#__PURE__*/ S.String;
export const BatchGetRecordRequest = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    Identifiers: S.optional(BatchGetRecordIdentifiers),
    ExpirationTimeResponse: S.optional(ExpirationTimeResponse),
}).pipe(T.all(T.Http({ method: "POST", uri: "/BatchGetRecord" }), svc, auth, proto, ver, rules))).annotate({
    identifier: "BatchGetRecordRequest",
});
export const ValueAsStringList = /*@__PURE__*/ /*#__PURE__*/ S.Array(S.String);
export const FeatureValue = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    FeatureName: S.optional(S.String),
    ValueAsString: S.optional(S.String),
    ValueAsStringList: S.optional(ValueAsStringList),
})).annotate({ identifier: "FeatureValue" });
export const Record = /*@__PURE__*/ /*#__PURE__*/ S.Array(FeatureValue);
export const BatchGetRecordResultDetail = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    FeatureGroupName: S.optional(S.String),
    RecordIdentifierValueAsString: S.optional(S.String),
    Record: S.optional(Record),
    ExpiresAt: S.optional(S.String),
})).annotate({
    identifier: "BatchGetRecordResultDetail",
});
export const BatchGetRecordResultDetails = /*@__PURE__*/ /*#__PURE__*/ S.Array(BatchGetRecordResultDetail);
export const BatchGetRecordError_ = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    FeatureGroupName: S.optional(S.String),
    RecordIdentifierValueAsString: S.optional(S.String),
    ErrorCode: S.optional(S.String),
    ErrorMessage: S.optional(S.String),
})).annotate({
    identifier: "BatchGetRecordError",
});
export const BatchGetRecordErrors = 
/*@__PURE__*/ /*#__PURE__*/ S.Array(BatchGetRecordError_);
export const UnprocessedIdentifiers = /*@__PURE__*/ /*#__PURE__*/ S.Array(BatchGetRecordIdentifier);
export const BatchGetRecordResponse = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    Records: S.optional(BatchGetRecordResultDetails),
    Errors: S.optional(BatchGetRecordErrors),
    UnprocessedIdentifiers: S.optional(UnprocessedIdentifiers),
})).annotate({
    identifier: "BatchGetRecordResponse",
});
export const TargetStore = /*@__PURE__*/ /*#__PURE__*/ S.String;
export const TargetStores = /*@__PURE__*/ /*#__PURE__*/ S.Array(TargetStore);
export const DeletionMode = /*@__PURE__*/ /*#__PURE__*/ S.String;
export const DeleteRecordRequest = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    FeatureGroupName: S.String.pipe(T.HttpLabel("FeatureGroupName")),
    RecordIdentifierValueAsString: S.optional(S.String).pipe(T.HttpQuery("RecordIdentifierValueAsString")),
    EventTime: S.optional(S.String).pipe(T.HttpQuery("EventTime")),
    TargetStores: S.optional(TargetStores).pipe(T.HttpQuery("TargetStores")),
    DeletionMode: S.optional(DeletionMode).pipe(T.HttpQuery("DeletionMode")),
}).pipe(T.all(T.Http({ method: "DELETE", uri: "/FeatureGroup/{FeatureGroupName}" }), svc, auth, proto, ver, rules))).annotate({
    identifier: "DeleteRecordRequest",
});
export const DeleteRecordResponse = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({})).annotate({
    identifier: "DeleteRecordResponse",
});
export const GetRecordRequest = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    FeatureGroupName: S.String.pipe(T.HttpLabel("FeatureGroupName")),
    RecordIdentifierValueAsString: S.optional(S.String).pipe(T.HttpQuery("RecordIdentifierValueAsString")),
    FeatureNames: S.optional(FeatureNames).pipe(T.HttpQuery("FeatureName")),
    ExpirationTimeResponse: S.optional(ExpirationTimeResponse).pipe(T.HttpQuery("ExpirationTimeResponse")),
}).pipe(T.all(T.Http({ method: "GET", uri: "/FeatureGroup/{FeatureGroupName}" }), svc, auth, proto, ver, rules))).annotate({
    identifier: "GetRecordRequest",
});
export const GetRecordResponse = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ Record: S.optional(Record), ExpiresAt: S.optional(S.String) })).annotate({
    identifier: "GetRecordResponse",
});
export const TtlDurationUnit = /*@__PURE__*/ /*#__PURE__*/ S.String;
export const TtlDuration = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ Unit: S.optional(TtlDurationUnit), Value: S.optional(S.Number) })).annotate({ identifier: "TtlDuration" });
export const PutRecordRequest = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    FeatureGroupName: S.String.pipe(T.HttpLabel("FeatureGroupName")),
    Record: S.optional(Record),
    TargetStores: S.optional(TargetStores),
    TtlDuration: S.optional(TtlDuration),
}).pipe(T.all(T.Http({ method: "PUT", uri: "/FeatureGroup/{FeatureGroupName}" }), svc, auth, proto, ver, rules))).annotate({
    identifier: "PutRecordRequest",
});
export const PutRecordResponse = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({})).annotate({
    identifier: "PutRecordResponse",
});
//# Errors
export class AccessForbidden extends S.TaggedErrorClass()("AccessForbidden", { Message: S.optional(S.String) }).pipe(C.withAuthError) {
}
export class InternalFailure extends S.TaggedErrorClass()("InternalFailure", { Message: S.optional(S.String) }).pipe(C.withServerError) {
}
export class ServiceUnavailable extends S.TaggedErrorClass()("ServiceUnavailable", { Message: S.optional(S.String) }).pipe(C.withServerError) {
}
export class ValidationError extends S.TaggedErrorClass()("ValidationError", { Message: S.optional(S.String) }).pipe(C.withBadRequestError) {
}
export class ResourceNotFound extends S.TaggedErrorClass()("ResourceNotFound", { Message: S.optional(S.String) }).pipe(C.withBadRequestError) {
}
/**
 * Retrieves a batch of `Records` from a `FeatureGroup`.
 */
export const batchGetRecord = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: BatchGetRecordRequest,
    output: BatchGetRecordResponse,
    errors: [
        AccessForbidden,
        InternalFailure,
        ServiceUnavailable,
        ValidationError,
    ],
}));
/**
 * Deletes a `Record` from a `FeatureGroup` in the
 * `OnlineStore`. Feature Store supports both `SoftDelete` and
 * `HardDelete`. For `SoftDelete` (default), feature columns are set
 * to `null` and the record is no longer retrievable by `GetRecord` or
 * `BatchGetRecord`. For `HardDelete`, the complete
 * `Record` is removed from the `OnlineStore`. In both cases, Feature
 * Store appends the deleted record marker to the `OfflineStore`. The deleted
 * record marker is a record with the same `RecordIdentifer` as the original, but
 * with `is_deleted` value set to `True`, `EventTime` set to
 * the delete input `EventTime`, and other feature values set to
 * `null`.
 *
 * Note that the `EventTime` specified in `DeleteRecord` should be
 * set later than the `EventTime` of the existing record in the
 * `OnlineStore` for that `RecordIdentifer`. If it is not, the
 * deletion does not occur:
 *
 * - For `SoftDelete`, the existing (not deleted) record remains in the
 * `OnlineStore`, though the delete record marker is still written to the
 * `OfflineStore`.
 *
 * - `HardDelete` returns `EventTime`: 400
 * ValidationException to indicate that the delete operation failed. No delete
 * record marker is written to the `OfflineStore`.
 *
 * When a record is deleted from the `OnlineStore`, the deleted record marker is
 * appended to the `OfflineStore`. If you have the Iceberg table format enabled for
 * your `OfflineStore`, you can remove all history of a record from the
 * `OfflineStore` using Amazon Athena or Apache Spark. For information on how to
 * hard delete a record from the `OfflineStore` with the Iceberg table format
 * enabled, see Delete records from the offline store.
 */
export const deleteRecord = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: DeleteRecordRequest,
    output: DeleteRecordResponse,
    errors: [
        AccessForbidden,
        InternalFailure,
        ServiceUnavailable,
        ValidationError,
    ],
}));
/**
 * Use for `OnlineStore` serving from a `FeatureStore`. Only the
 * latest records stored in the `OnlineStore` can be retrieved. If no Record with
 * `RecordIdentifierValue` is found, then an empty result is returned.
 */
export const getRecord = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: GetRecordRequest,
    output: GetRecordResponse,
    errors: [
        AccessForbidden,
        InternalFailure,
        ResourceNotFound,
        ServiceUnavailable,
        ValidationError,
    ],
}));
/**
 * The `PutRecord` API is used to ingest a list of `Records` into
 * your feature group.
 *
 * If a new record’s `EventTime` is greater, the new record is written to both
 * the `OnlineStore` and `OfflineStore`. Otherwise, the record is a
 * historic record and it is written only to the `OfflineStore`.
 *
 * You can specify the ingestion to be applied to the `OnlineStore`,
 * `OfflineStore`, or both by using the `TargetStores` request
 * parameter.
 *
 * You can set the ingested record to expire at a given time to live (TTL) duration after
 * the record’s event time, `ExpiresAt` = `EventTime` +
 * `TtlDuration`, by specifying the `TtlDuration` parameter. A record
 * level `TtlDuration` is set when specifying the `TtlDuration`
 * parameter using the `PutRecord` API call. If the input `TtlDuration`
 * is `null` or unspecified, `TtlDuration` is set to the default feature
 * group level `TtlDuration`. A record level `TtlDuration` supersedes
 * the group level `TtlDuration`.
 */
export const putRecord = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: PutRecordRequest,
    output: PutRecordResponse,
    errors: [
        AccessForbidden,
        InternalFailure,
        ServiceUnavailable,
        ValidationError,
    ],
}));
//# sourceMappingURL=sagemaker-featurestore-runtime.js.map