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: "Timestream Write",
    serviceShapeName: "Timestream_20181101",
});
const auth = T.AwsAuthSigv4({ name: "timestream" });
const ver = T.ServiceVersion("2018-11-01");
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")) {
                        if ("aws" === _.getAttr(PartitionResult, "name")) {
                            return e(`https://timestream-ingest-fips.${Region}.api.aws`);
                        }
                        if ("aws-us-gov" === _.getAttr(PartitionResult, "name")) {
                            return e(`https://timestream-ingest.${Region}.api.aws`);
                        }
                        return e(`https://ingest.timestream-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) {
                        if (_.getAttr(PartitionResult, "name") === "aws-us-gov") {
                            return e(`https://ingest.timestream.${Region}.amazonaws.com`);
                        }
                        return e(`https://ingest.timestream-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")) {
                        if ("aws" === _.getAttr(PartitionResult, "name")) {
                            return e(`https://timestream-ingest.${Region}.api.aws`);
                        }
                        if ("aws-us-gov" === _.getAttr(PartitionResult, "name")) {
                            return e(`https://timestream-ingest.${Region}.api.aws`);
                        }
                        return e(`https://ingest.timestream.${Region}.${_.getAttr(PartitionResult, "dualStackDnsSuffix")}`);
                    }
                    return err("DualStack is enabled but this partition does not support DualStack");
                }
                return e(`https://ingest.timestream.${Region}.${_.getAttr(PartitionResult, "dnsSuffix")}`);
            }
        }
    }
    return err("Invalid Configuration: Missing Region");
});
export const TimeUnit = /*@__PURE__*/ /*#__PURE__*/ S.String;
export const DimensionMapping = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    SourceColumn: S.optional(S.String),
    DestinationColumn: S.optional(S.String),
})).annotate({
    identifier: "DimensionMapping",
});
export const DimensionMappings = 
/*@__PURE__*/ /*#__PURE__*/ S.Array(DimensionMapping);
export const ScalarMeasureValueType = /*@__PURE__*/ /*#__PURE__*/ S.String;
export const MultiMeasureAttributeMapping = 
/*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    SourceColumn: S.String,
    TargetMultiMeasureAttributeName: S.optional(S.String),
    MeasureValueType: S.optional(ScalarMeasureValueType),
})).annotate({
    identifier: "MultiMeasureAttributeMapping",
});
export const MultiMeasureAttributeMappingList = 
/*@__PURE__*/ /*#__PURE__*/ S.Array(MultiMeasureAttributeMapping);
export const MultiMeasureMappings = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    TargetMultiMeasureName: S.optional(S.String),
    MultiMeasureAttributeMappings: MultiMeasureAttributeMappingList,
})).annotate({
    identifier: "MultiMeasureMappings",
});
export const MeasureValueType = /*@__PURE__*/ /*#__PURE__*/ S.String;
export const MixedMeasureMapping = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    MeasureName: S.optional(S.String),
    SourceColumn: S.optional(S.String),
    TargetMeasureName: S.optional(S.String),
    MeasureValueType: MeasureValueType,
    MultiMeasureAttributeMappings: S.optional(MultiMeasureAttributeMappingList),
})).annotate({
    identifier: "MixedMeasureMapping",
});
export const MixedMeasureMappingList = 
/*@__PURE__*/ /*#__PURE__*/ S.Array(MixedMeasureMapping);
export const DataModel = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    TimeColumn: S.optional(S.String),
    TimeUnit: S.optional(TimeUnit),
    DimensionMappings: DimensionMappings,
    MultiMeasureMappings: S.optional(MultiMeasureMappings),
    MixedMeasureMappings: S.optional(MixedMeasureMappingList),
    MeasureNameColumn: S.optional(S.String),
})).annotate({ identifier: "DataModel" });
export const DataModelS3Configuration = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    BucketName: S.optional(S.String),
    ObjectKey: S.optional(S.String),
})).annotate({
    identifier: "DataModelS3Configuration",
});
export const DataModelConfiguration = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    DataModel: S.optional(DataModel),
    DataModelS3Configuration: S.optional(DataModelS3Configuration),
})).annotate({
    identifier: "DataModelConfiguration",
});
export const DataSourceS3Configuration = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ BucketName: S.String, ObjectKeyPrefix: S.optional(S.String) })).annotate({
    identifier: "DataSourceS3Configuration",
});
export const CsvConfiguration = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    ColumnSeparator: S.optional(S.String),
    EscapeChar: S.optional(S.String),
    QuoteChar: S.optional(S.String),
    NullValue: S.optional(S.String),
    TrimWhiteSpace: S.optional(S.Boolean),
})).annotate({
    identifier: "CsvConfiguration",
});
export const BatchLoadDataFormat = /*@__PURE__*/ /*#__PURE__*/ S.String;
export const DataSourceConfiguration = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    DataSourceS3Configuration: DataSourceS3Configuration,
    CsvConfiguration: S.optional(CsvConfiguration),
    DataFormat: BatchLoadDataFormat,
})).annotate({
    identifier: "DataSourceConfiguration",
});
export const S3EncryptionOption = /*@__PURE__*/ /*#__PURE__*/ S.String;
export const ReportS3Configuration = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    BucketName: S.String,
    ObjectKeyPrefix: S.optional(S.String),
    EncryptionOption: S.optional(S3EncryptionOption),
    KmsKeyId: S.optional(S.String),
})).annotate({
    identifier: "ReportS3Configuration",
});
export const ReportConfiguration = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ ReportS3Configuration: S.optional(ReportS3Configuration) })).annotate({
    identifier: "ReportConfiguration",
});
export const CreateBatchLoadTaskRequest = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    ClientToken: S.optional(SensitiveString).pipe(T.IdempotencyToken()),
    DataModelConfiguration: S.optional(DataModelConfiguration),
    DataSourceConfiguration: DataSourceConfiguration,
    ReportConfiguration: ReportConfiguration,
    TargetDatabaseName: S.String,
    TargetTableName: S.String,
    RecordVersion: S.optional(S.Number),
}).pipe(T.all(T.Http({ method: "POST", uri: "/" }), svc, auth, proto, ver, rules))).annotate({
    identifier: "CreateBatchLoadTaskRequest",
});
export const CreateBatchLoadTaskResponse = 
/*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ TaskId: S.String })).annotate({
    identifier: "CreateBatchLoadTaskResponse",
});
export const Tag = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ Key: S.String, Value: S.String })).annotate({ identifier: "Tag" });
export const TagList = /*@__PURE__*/ /*#__PURE__*/ S.Array(Tag);
export const CreateDatabaseRequest = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    DatabaseName: S.String,
    KmsKeyId: S.optional(S.String),
    Tags: S.optional(TagList),
}).pipe(T.all(T.Http({ method: "POST", uri: "/" }), svc, auth, proto, ver, rules))).annotate({
    identifier: "CreateDatabaseRequest",
});
export const Database = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    Arn: S.optional(S.String),
    DatabaseName: S.optional(S.String),
    TableCount: S.optional(S.Number),
    KmsKeyId: S.optional(S.String),
    CreationTime: S.optional(S.Date.pipe(T.TimestampFormat("epoch-seconds"))),
    LastUpdatedTime: S.optional(S.Date.pipe(T.TimestampFormat("epoch-seconds"))),
})).annotate({ identifier: "Database" });
export const CreateDatabaseResponse = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ Database: S.optional(Database) })).annotate({
    identifier: "CreateDatabaseResponse",
});
export const RetentionProperties = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    MemoryStoreRetentionPeriodInHours: S.Number,
    MagneticStoreRetentionPeriodInDays: S.Number,
})).annotate({
    identifier: "RetentionProperties",
});
export const S3Configuration = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    BucketName: S.optional(S.String),
    ObjectKeyPrefix: S.optional(S.String),
    EncryptionOption: S.optional(S3EncryptionOption),
    KmsKeyId: S.optional(S.String),
})).annotate({
    identifier: "S3Configuration",
});
export const MagneticStoreRejectedDataLocation = 
/*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ S3Configuration: S.optional(S3Configuration) })).annotate({
    identifier: "MagneticStoreRejectedDataLocation",
});
export const MagneticStoreWriteProperties = 
/*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    EnableMagneticStoreWrites: S.Boolean,
    MagneticStoreRejectedDataLocation: S.optional(MagneticStoreRejectedDataLocation),
})).annotate({
    identifier: "MagneticStoreWriteProperties",
});
export const PartitionKeyType = /*@__PURE__*/ /*#__PURE__*/ S.String;
export const PartitionKeyEnforcementLevel = 
/*@__PURE__*/ /*#__PURE__*/ S.String;
export const PartitionKey = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    Type: PartitionKeyType,
    Name: S.optional(S.String),
    EnforcementInRecord: S.optional(PartitionKeyEnforcementLevel),
})).annotate({ identifier: "PartitionKey" });
export const PartitionKeyList = 
/*@__PURE__*/ /*#__PURE__*/ S.Array(PartitionKey);
export const Schema = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ CompositePartitionKey: S.optional(PartitionKeyList) })).annotate({ identifier: "Schema" });
export const CreateTableRequest = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    DatabaseName: S.String,
    TableName: S.String,
    RetentionProperties: S.optional(RetentionProperties),
    Tags: S.optional(TagList),
    MagneticStoreWriteProperties: S.optional(MagneticStoreWriteProperties),
    Schema: S.optional(Schema),
}).pipe(T.all(T.Http({ method: "POST", uri: "/" }), svc, auth, proto, ver, rules))).annotate({
    identifier: "CreateTableRequest",
});
export const TableStatus = /*@__PURE__*/ /*#__PURE__*/ S.String;
export const Table = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    Arn: S.optional(S.String),
    TableName: S.optional(S.String),
    DatabaseName: S.optional(S.String),
    TableStatus: S.optional(TableStatus),
    RetentionProperties: S.optional(RetentionProperties),
    CreationTime: S.optional(S.Date.pipe(T.TimestampFormat("epoch-seconds"))),
    LastUpdatedTime: S.optional(S.Date.pipe(T.TimestampFormat("epoch-seconds"))),
    MagneticStoreWriteProperties: S.optional(MagneticStoreWriteProperties),
    Schema: S.optional(Schema),
})).annotate({ identifier: "Table" });
export const CreateTableResponse = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ Table: S.optional(Table) })).annotate({
    identifier: "CreateTableResponse",
});
export const DeleteDatabaseRequest = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ DatabaseName: S.String }).pipe(T.all(T.Http({ method: "POST", uri: "/" }), svc, auth, proto, ver, rules))).annotate({
    identifier: "DeleteDatabaseRequest",
});
export const DeleteDatabaseResponse = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({})).annotate({
    identifier: "DeleteDatabaseResponse",
});
export const DeleteTableRequest = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ DatabaseName: S.String, TableName: S.String }).pipe(T.all(T.Http({ method: "POST", uri: "/" }), svc, auth, proto, ver, rules))).annotate({
    identifier: "DeleteTableRequest",
});
export const DeleteTableResponse = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({})).annotate({
    identifier: "DeleteTableResponse",
});
export const DescribeBatchLoadTaskRequest = 
/*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ TaskId: S.String }).pipe(T.all(T.Http({ method: "POST", uri: "/" }), svc, auth, proto, ver, rules))).annotate({
    identifier: "DescribeBatchLoadTaskRequest",
});
export const BatchLoadProgressReport = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    RecordsProcessed: S.optional(S.Number),
    RecordsIngested: S.optional(S.Number),
    ParseFailures: S.optional(S.Number),
    RecordIngestionFailures: S.optional(S.Number),
    FileFailures: S.optional(S.Number),
    BytesMetered: S.optional(S.Number),
})).annotate({
    identifier: "BatchLoadProgressReport",
});
export const BatchLoadStatus = /*@__PURE__*/ /*#__PURE__*/ S.String;
export const BatchLoadTaskDescription = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    TaskId: S.optional(S.String),
    ErrorMessage: S.optional(S.String),
    DataSourceConfiguration: S.optional(DataSourceConfiguration),
    ProgressReport: S.optional(BatchLoadProgressReport),
    ReportConfiguration: S.optional(ReportConfiguration),
    DataModelConfiguration: S.optional(DataModelConfiguration),
    TargetDatabaseName: S.optional(S.String),
    TargetTableName: S.optional(S.String),
    TaskStatus: S.optional(BatchLoadStatus),
    RecordVersion: S.optional(S.Number),
    CreationTime: S.optional(S.Date.pipe(T.TimestampFormat("epoch-seconds"))),
    LastUpdatedTime: S.optional(S.Date.pipe(T.TimestampFormat("epoch-seconds"))),
    ResumableUntil: S.optional(S.Date.pipe(T.TimestampFormat("epoch-seconds"))),
})).annotate({
    identifier: "BatchLoadTaskDescription",
});
export const DescribeBatchLoadTaskResponse = 
/*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ BatchLoadTaskDescription: BatchLoadTaskDescription })).annotate({
    identifier: "DescribeBatchLoadTaskResponse",
});
export const DescribeDatabaseRequest = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ DatabaseName: S.String }).pipe(T.all(T.Http({ method: "POST", uri: "/" }), svc, auth, proto, ver, rules))).annotate({
    identifier: "DescribeDatabaseRequest",
});
export const DescribeDatabaseResponse = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ Database: S.optional(Database) })).annotate({
    identifier: "DescribeDatabaseResponse",
});
export const DescribeEndpointsRequest = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({}).pipe(T.all(T.Http({ method: "POST", uri: "/" }), svc, auth, proto, ver, rules))).annotate({
    identifier: "DescribeEndpointsRequest",
});
export const Endpoint = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ Address: S.String, CachePeriodInMinutes: S.Number })).annotate({ identifier: "Endpoint" });
export const Endpoints = /*@__PURE__*/ /*#__PURE__*/ S.Array(Endpoint);
export const DescribeEndpointsResponse = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ Endpoints: Endpoints })).annotate({
    identifier: "DescribeEndpointsResponse",
});
export const DescribeTableRequest = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ DatabaseName: S.String, TableName: S.String }).pipe(T.all(T.Http({ method: "POST", uri: "/" }), svc, auth, proto, ver, rules))).annotate({
    identifier: "DescribeTableRequest",
});
export const DescribeTableResponse = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ Table: S.optional(Table) })).annotate({
    identifier: "DescribeTableResponse",
});
export const ListBatchLoadTasksRequest = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    NextToken: S.optional(S.String),
    MaxResults: S.optional(S.Number),
    TaskStatus: S.optional(BatchLoadStatus),
}).pipe(T.all(T.Http({ method: "POST", uri: "/" }), svc, auth, proto, ver, rules))).annotate({
    identifier: "ListBatchLoadTasksRequest",
});
export const BatchLoadTask = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    TaskId: S.optional(S.String),
    TaskStatus: S.optional(BatchLoadStatus),
    DatabaseName: S.optional(S.String),
    TableName: S.optional(S.String),
    CreationTime: S.optional(S.Date.pipe(T.TimestampFormat("epoch-seconds"))),
    LastUpdatedTime: S.optional(S.Date.pipe(T.TimestampFormat("epoch-seconds"))),
    ResumableUntil: S.optional(S.Date.pipe(T.TimestampFormat("epoch-seconds"))),
})).annotate({ identifier: "BatchLoadTask" });
export const BatchLoadTaskList = 
/*@__PURE__*/ /*#__PURE__*/ S.Array(BatchLoadTask);
export const ListBatchLoadTasksResponse = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    NextToken: S.optional(S.String),
    BatchLoadTasks: S.optional(BatchLoadTaskList),
})).annotate({
    identifier: "ListBatchLoadTasksResponse",
});
export const ListDatabasesRequest = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    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: "ListDatabasesRequest",
});
export const DatabaseList = /*@__PURE__*/ /*#__PURE__*/ S.Array(Database);
export const ListDatabasesResponse = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    Databases: S.optional(DatabaseList),
    NextToken: S.optional(S.String),
})).annotate({
    identifier: "ListDatabasesResponse",
});
export const ListTablesRequest = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    DatabaseName: 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: "ListTablesRequest",
});
export const TableList = /*@__PURE__*/ /*#__PURE__*/ S.Array(Table);
export const ListTablesResponse = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ Tables: S.optional(TableList), NextToken: S.optional(S.String) })).annotate({
    identifier: "ListTablesResponse",
});
export const ListTagsForResourceRequest = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ ResourceARN: S.String }).pipe(T.all(T.Http({ method: "POST", uri: "/" }), svc, auth, proto, ver, rules))).annotate({
    identifier: "ListTagsForResourceRequest",
});
export const ListTagsForResourceResponse = 
/*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ Tags: S.optional(TagList) })).annotate({
    identifier: "ListTagsForResourceResponse",
});
export const ResumeBatchLoadTaskRequest = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ TaskId: S.String }).pipe(T.all(T.Http({ method: "POST", uri: "/" }), svc, auth, proto, ver, rules))).annotate({
    identifier: "ResumeBatchLoadTaskRequest",
});
export const ResumeBatchLoadTaskResponse = 
/*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({})).annotate({
    identifier: "ResumeBatchLoadTaskResponse",
});
export const TagResourceRequest = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ ResourceARN: S.String, Tags: TagList }).pipe(T.all(T.Http({ method: "POST", uri: "/" }), svc, auth, proto, ver, rules))).annotate({
    identifier: "TagResourceRequest",
});
export const TagResourceResponse = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({})).annotate({
    identifier: "TagResourceResponse",
});
export const TagKeyList = /*@__PURE__*/ /*#__PURE__*/ S.Array(S.String);
export const UntagResourceRequest = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ ResourceARN: S.String, TagKeys: TagKeyList }).pipe(T.all(T.Http({ method: "POST", uri: "/" }), svc, auth, proto, ver, rules))).annotate({
    identifier: "UntagResourceRequest",
});
export const UntagResourceResponse = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({})).annotate({
    identifier: "UntagResourceResponse",
});
export const UpdateDatabaseRequest = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ DatabaseName: S.String, KmsKeyId: S.String }).pipe(T.all(T.Http({ method: "POST", uri: "/" }), svc, auth, proto, ver, rules))).annotate({
    identifier: "UpdateDatabaseRequest",
});
export const UpdateDatabaseResponse = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ Database: S.optional(Database) })).annotate({
    identifier: "UpdateDatabaseResponse",
});
export const UpdateTableRequest = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    DatabaseName: S.String,
    TableName: S.String,
    RetentionProperties: S.optional(RetentionProperties),
    MagneticStoreWriteProperties: S.optional(MagneticStoreWriteProperties),
    Schema: S.optional(Schema),
}).pipe(T.all(T.Http({ method: "POST", uri: "/" }), svc, auth, proto, ver, rules))).annotate({
    identifier: "UpdateTableRequest",
});
export const UpdateTableResponse = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ Table: S.optional(Table) })).annotate({
    identifier: "UpdateTableResponse",
});
export const DimensionValueType = /*@__PURE__*/ /*#__PURE__*/ S.String;
export const Dimension = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    Name: S.String,
    Value: S.String,
    DimensionValueType: S.optional(DimensionValueType),
})).annotate({ identifier: "Dimension" });
export const Dimensions = /*@__PURE__*/ /*#__PURE__*/ S.Array(Dimension);
export const MeasureValue = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ Name: S.String, Value: S.String, Type: MeasureValueType })).annotate({ identifier: "MeasureValue" });
export const MeasureValues = /*@__PURE__*/ /*#__PURE__*/ S.Array(MeasureValue);
export const Record = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    Dimensions: S.optional(Dimensions),
    MeasureName: S.optional(S.String),
    MeasureValue: S.optional(S.String),
    MeasureValueType: S.optional(MeasureValueType),
    Time: S.optional(S.String),
    TimeUnit: S.optional(TimeUnit),
    Version: S.optional(S.Number),
    MeasureValues: S.optional(MeasureValues),
})).annotate({ identifier: "Record" });
export const Records = /*@__PURE__*/ /*#__PURE__*/ S.Array(Record);
export const WriteRecordsRequest = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    DatabaseName: S.String,
    TableName: S.String,
    CommonAttributes: S.optional(Record),
    Records: Records,
}).pipe(T.all(T.Http({ method: "POST", uri: "/" }), svc, auth, proto, ver, rules))).annotate({
    identifier: "WriteRecordsRequest",
});
export const RecordsIngested = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    Total: S.optional(S.Number),
    MemoryStore: S.optional(S.Number),
    MagneticStore: S.optional(S.Number),
})).annotate({
    identifier: "RecordsIngested",
});
export const WriteRecordsResponse = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ RecordsIngested: S.optional(RecordsIngested) })).annotate({
    identifier: "WriteRecordsResponse",
});
export const RejectedRecord = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    RecordIndex: S.optional(S.Number),
    Reason: S.optional(S.String),
    ExistingVersion: S.optional(S.Number),
})).annotate({ identifier: "RejectedRecord" });
export const RejectedRecords = 
/*@__PURE__*/ /*#__PURE__*/ S.Array(RejectedRecord);
//# Errors
export class AccessDeniedException extends S.TaggedErrorClass()("AccessDeniedException", { Message: S.String }).pipe(C.withAuthError) {
}
export class ConflictException extends S.TaggedErrorClass()("ConflictException", { Message: S.String }).pipe(C.withConflictError) {
}
export class InternalServerException extends S.TaggedErrorClass()("InternalServerException", { Message: S.String }).pipe(C.withServerError) {
}
export class InvalidEndpointException extends S.TaggedErrorClass()("InvalidEndpointException", { Message: S.optional(S.String) }) {
}
export class ResourceNotFoundException extends S.TaggedErrorClass()("ResourceNotFoundException", { Message: S.optional(S.String) }).pipe(C.withBadRequestError) {
}
export class ServiceQuotaExceededException extends S.TaggedErrorClass()("ServiceQuotaExceededException", { Message: S.optional(S.String) }).pipe(C.withQuotaError) {
}
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 RejectedRecordsException extends S.TaggedErrorClass()("RejectedRecordsException", {
    Message: S.optional(S.String),
    RejectedRecords: S.optional(RejectedRecords),
}) {
}
/**
 * Creates a new Timestream batch load task. A batch load task processes data from
 * a CSV source in an S3 location and writes to a Timestream table. A mapping from
 * source to target is defined in a batch load task. Errors and events are written to a report
 * at an S3 location. For the report, if the KMS key is not specified, the
 * report will be encrypted with an S3 managed key when `SSE_S3` is the option.
 * Otherwise an error is thrown. For more information, see Amazon Web Services managed
 * keys. Service quotas apply. For
 * details, see code
 * sample.
 */
export const createBatchLoadTask = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: CreateBatchLoadTaskRequest,
    output: CreateBatchLoadTaskResponse,
    errors: [
        AccessDeniedException,
        ConflictException,
        InternalServerException,
        InvalidEndpointException,
        ResourceNotFoundException,
        ServiceQuotaExceededException,
        ThrottlingException,
        ValidationException,
    ],
}));
/**
 * Creates a new Timestream database. If the KMS key is not
 * specified, the database will be encrypted with a Timestream managed KMS key located in your account. For more information, see Amazon Web Services managed keys. Service quotas apply. For
 * details, see code sample.
 */
export const createDatabase = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: CreateDatabaseRequest,
    output: CreateDatabaseResponse,
    errors: [
        AccessDeniedException,
        ConflictException,
        InternalServerException,
        InvalidEndpointException,
        ServiceQuotaExceededException,
        ThrottlingException,
        ValidationException,
    ],
}));
/**
 * Adds a new table to an existing database in your account. In an Amazon Web Services account, table names must be at least unique within each Region if they are in the same
 * database. You might have identical table names in the same Region if the tables are in
 * separate databases. While creating the table, you must specify the table name, database
 * name, and the retention properties. Service quotas apply. See
 * code
 * sample for details.
 */
export const createTable = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: CreateTableRequest,
    output: CreateTableResponse,
    errors: [
        AccessDeniedException,
        ConflictException,
        InternalServerException,
        InvalidEndpointException,
        ResourceNotFoundException,
        ServiceQuotaExceededException,
        ThrottlingException,
        ValidationException,
    ],
}));
/**
 * Deletes a given Timestream database. This is an irreversible
 * operation. After a database is deleted, the time-series data from its tables cannot be
 * recovered.
 *
 * All tables in the database must be deleted first, or a ValidationException error will
 * be thrown.
 *
 * Due to the nature of distributed retries, the operation can return either success or
 * a ResourceNotFoundException. Clients should consider them equivalent.
 *
 * See code sample
 * for details.
 */
export const deleteDatabase = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: DeleteDatabaseRequest,
    output: DeleteDatabaseResponse,
    errors: [
        AccessDeniedException,
        InternalServerException,
        InvalidEndpointException,
        ResourceNotFoundException,
        ThrottlingException,
        ValidationException,
    ],
}));
/**
 * Deletes a given Timestream table. This is an irreversible operation. After a
 * Timestream database table is deleted, the time-series data stored in the table
 * cannot be recovered.
 *
 * Due to the nature of distributed retries, the operation can return either success or
 * a ResourceNotFoundException. Clients should consider them equivalent.
 *
 * See code
 * sample for details.
 */
export const deleteTable = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: DeleteTableRequest,
    output: DeleteTableResponse,
    errors: [
        AccessDeniedException,
        InternalServerException,
        InvalidEndpointException,
        ResourceNotFoundException,
        ThrottlingException,
        ValidationException,
    ],
}));
/**
 * Returns information about the batch load task, including configurations, mappings,
 * progress, and other details. Service quotas apply. See
 * code
 * sample for details.
 */
export const describeBatchLoadTask = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: DescribeBatchLoadTaskRequest,
    output: DescribeBatchLoadTaskResponse,
    errors: [
        AccessDeniedException,
        InternalServerException,
        InvalidEndpointException,
        ResourceNotFoundException,
        ThrottlingException,
    ],
}));
/**
 * Returns information about the database, including the database name, time that the
 * database was created, and the total number of tables found within the database. Service
 * quotas apply. See code sample
 * for details.
 */
export const describeDatabase = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: DescribeDatabaseRequest,
    output: DescribeDatabaseResponse,
    errors: [
        AccessDeniedException,
        InternalServerException,
        InvalidEndpointException,
        ResourceNotFoundException,
        ThrottlingException,
        ValidationException,
    ],
}));
/**
 * Returns a list of available endpoints to make Timestream API calls against.
 * This API operation is available through both the Write and Query APIs.
 *
 * Because the Timestream SDKs are designed to transparently work with the
 * service’s architecture, including the management and mapping of the service endpoints,
 * *we don't recommend that you use this API operation unless*:
 *
 * - You are using VPC endpoints (Amazon Web Services PrivateLink) with Timestream
 *
 * - Your application uses a programming language that does not yet have SDK
 * support
 *
 * - You require better control over the client-side implementation
 *
 * For detailed information on how and when to use and implement DescribeEndpoints, see
 * The
 * Endpoint Discovery Pattern.
 */
export const describeEndpoints = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: DescribeEndpointsRequest,
    output: DescribeEndpointsResponse,
    errors: [InternalServerException, ThrottlingException, ValidationException],
}));
/**
 * Returns information about the table, including the table name, database name, retention
 * duration of the memory store and the magnetic store. Service quotas apply. See
 * code
 * sample for details.
 */
export const describeTable = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: DescribeTableRequest,
    output: DescribeTableResponse,
    errors: [
        AccessDeniedException,
        InternalServerException,
        InvalidEndpointException,
        ResourceNotFoundException,
        ThrottlingException,
        ValidationException,
    ],
}));
/**
 * Provides a list of batch load tasks, along with the name, status, when the task is
 * resumable until, and other details. See code
 * sample for details.
 */
export const listBatchLoadTasks = /*@__PURE__*/ /*#__PURE__*/ API.makePaginated(() => ({
    input: ListBatchLoadTasksRequest,
    output: ListBatchLoadTasksResponse,
    errors: [
        AccessDeniedException,
        InternalServerException,
        InvalidEndpointException,
        ThrottlingException,
        ValidationException,
    ],
    pagination: {
        inputToken: "NextToken",
        outputToken: "NextToken",
        pageSize: "MaxResults",
    },
}));
/**
 * Returns a list of your Timestream databases. Service quotas apply. See
 * code sample for
 * details.
 */
export const listDatabases = /*@__PURE__*/ /*#__PURE__*/ API.makePaginated(() => ({
    input: ListDatabasesRequest,
    output: ListDatabasesResponse,
    errors: [
        AccessDeniedException,
        InternalServerException,
        InvalidEndpointException,
        ThrottlingException,
        ValidationException,
    ],
    pagination: {
        inputToken: "NextToken",
        outputToken: "NextToken",
        pageSize: "MaxResults",
    },
}));
/**
 * Provides a list of tables, along with the name, status, and retention properties of each
 * table. See code sample
 * for details.
 */
export const listTables = /*@__PURE__*/ /*#__PURE__*/ API.makePaginated(() => ({
    input: ListTablesRequest,
    output: ListTablesResponse,
    errors: [
        AccessDeniedException,
        InternalServerException,
        InvalidEndpointException,
        ResourceNotFoundException,
        ThrottlingException,
        ValidationException,
    ],
    pagination: {
        inputToken: "NextToken",
        outputToken: "NextToken",
        pageSize: "MaxResults",
    },
}));
/**
 * Lists all tags on a Timestream resource.
 */
export const listTagsForResource = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: ListTagsForResourceRequest,
    output: ListTagsForResourceResponse,
    errors: [
        InvalidEndpointException,
        ResourceNotFoundException,
        ThrottlingException,
        ValidationException,
    ],
}));
/**
 *
 */
export const resumeBatchLoadTask = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: ResumeBatchLoadTaskRequest,
    output: ResumeBatchLoadTaskResponse,
    errors: [
        AccessDeniedException,
        InternalServerException,
        InvalidEndpointException,
        ResourceNotFoundException,
        ThrottlingException,
        ValidationException,
    ],
}));
/**
 * Associates a set of tags with a Timestream resource. You can then activate
 * these user-defined tags so that they appear on the Billing and Cost Management console for
 * cost allocation tracking.
 */
export const tagResource = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: TagResourceRequest,
    output: TagResourceResponse,
    errors: [
        InvalidEndpointException,
        ResourceNotFoundException,
        ServiceQuotaExceededException,
        ThrottlingException,
        ValidationException,
    ],
}));
/**
 * Removes the association of tags from a Timestream resource.
 */
export const untagResource = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: UntagResourceRequest,
    output: UntagResourceResponse,
    errors: [
        InvalidEndpointException,
        ResourceNotFoundException,
        ServiceQuotaExceededException,
        ThrottlingException,
        ValidationException,
    ],
}));
/**
 * Modifies the KMS key for an existing database. While updating the
 * database, you must specify the database name and the identifier of the new KMS key to be used (`KmsKeyId`). If there are any concurrent
 * `UpdateDatabase` requests, first writer wins.
 *
 * See code sample
 * for details.
 */
export const updateDatabase = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: UpdateDatabaseRequest,
    output: UpdateDatabaseResponse,
    errors: [
        AccessDeniedException,
        InternalServerException,
        InvalidEndpointException,
        ResourceNotFoundException,
        ServiceQuotaExceededException,
        ThrottlingException,
        ValidationException,
    ],
}));
/**
 * Modifies the retention duration of the memory store and magnetic store for your Timestream table. Note that the change in retention duration takes effect immediately.
 * For example, if the retention period of the memory store was initially set to 2 hours and
 * then changed to 24 hours, the memory store will be capable of holding 24 hours of data, but
 * will be populated with 24 hours of data 22 hours after this change was made. Timestream does not retrieve data from the magnetic store to populate the memory store.
 *
 * See code
 * sample for details.
 */
export const updateTable = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: UpdateTableRequest,
    output: UpdateTableResponse,
    errors: [
        AccessDeniedException,
        InternalServerException,
        InvalidEndpointException,
        ResourceNotFoundException,
        ThrottlingException,
        ValidationException,
    ],
}));
/**
 * Enables you to write your time-series data into Timestream. You can specify a
 * single data point or a batch of data points to be inserted into the system. Timestream offers you a flexible schema that auto detects the column names and data
 * types for your Timestream tables based on the dimension names and data types of
 * the data points you specify when invoking writes into the database.
 *
 * Timestream supports eventual consistency read semantics. This means that when
 * you query data immediately after writing a batch of data into Timestream, the
 * query results might not reflect the results of a recently completed write operation. The
 * results may also include some stale data. If you repeat the query request after a short
 * time, the results should return the latest data. Service quotas apply.
 *
 * See code sample for
 * details.
 *
 * **Upserts**
 *
 * You can use the `Version` parameter in a `WriteRecords` request to
 * update data points. Timestream tracks a version number with each record.
 * `Version` defaults to `1` when it's not specified for the record
 * in the request. Timestream updates an existing record’s measure value along with
 * its `Version` when it receives a write request with a higher
 * `Version` number for that record. When it receives an update request where
 * the measure value is the same as that of the existing record, Timestream still
 * updates `Version`, if it is greater than the existing value of
 * `Version`. You can update a data point as many times as desired, as long as
 * the value of `Version` continuously increases.
 *
 * For example, suppose you write a new record without indicating `Version` in
 * the request. Timestream stores this record, and set `Version` to
 * `1`. Now, suppose you try to update this record with a
 * `WriteRecords` request of the same record with a different measure value but,
 * like before, do not provide `Version`. In this case, Timestream will
 * reject this update with a `RejectedRecordsException` since the updated record’s
 * version is not greater than the existing value of Version.
 *
 * However, if you were to resend the update request with `Version` set to
 * `2`, Timestream would then succeed in updating the record’s value,
 * and the `Version` would be set to `2`. Next, suppose you sent a
 * `WriteRecords` request with this same record and an identical measure value,
 * but with `Version` set to `3`. In this case, Timestream
 * would only update `Version` to `3`. Any further updates would need to
 * send a version number greater than `3`, or the update requests would receive a
 * `RejectedRecordsException`.
 */
export const writeRecords = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: WriteRecordsRequest,
    output: WriteRecordsResponse,
    errors: [
        AccessDeniedException,
        InternalServerException,
        InvalidEndpointException,
        RejectedRecordsException,
        ResourceNotFoundException,
        ThrottlingException,
        ValidationException,
    ],
}));
//# sourceMappingURL=timestream-write.js.map