@aws-sdk/client-s3
Version:
AWS SDK for JavaScript S3 Client for Node.js, Browser and React Native
1,348 lines (1,328 loc) • 510 kB
text/typescript
import {
AbortMultipartUploadCommandInput,
AbortMultipartUploadCommandOutput,
} from "../commands/AbortMultipartUploadCommand";
import {
CompleteMultipartUploadCommandInput,
CompleteMultipartUploadCommandOutput,
} from "../commands/CompleteMultipartUploadCommand";
import { CopyObjectCommandInput, CopyObjectCommandOutput } from "../commands/CopyObjectCommand";
import { CreateBucketCommandInput, CreateBucketCommandOutput } from "../commands/CreateBucketCommand";
import {
CreateMultipartUploadCommandInput,
CreateMultipartUploadCommandOutput,
} from "../commands/CreateMultipartUploadCommand";
import {
DeleteBucketAnalyticsConfigurationCommandInput,
DeleteBucketAnalyticsConfigurationCommandOutput,
} from "../commands/DeleteBucketAnalyticsConfigurationCommand";
import { DeleteBucketCommandInput, DeleteBucketCommandOutput } from "../commands/DeleteBucketCommand";
import { DeleteBucketCorsCommandInput, DeleteBucketCorsCommandOutput } from "../commands/DeleteBucketCorsCommand";
import {
DeleteBucketEncryptionCommandInput,
DeleteBucketEncryptionCommandOutput,
} from "../commands/DeleteBucketEncryptionCommand";
import {
DeleteBucketIntelligentTieringConfigurationCommandInput,
DeleteBucketIntelligentTieringConfigurationCommandOutput,
} from "../commands/DeleteBucketIntelligentTieringConfigurationCommand";
import {
DeleteBucketInventoryConfigurationCommandInput,
DeleteBucketInventoryConfigurationCommandOutput,
} from "../commands/DeleteBucketInventoryConfigurationCommand";
import {
DeleteBucketLifecycleCommandInput,
DeleteBucketLifecycleCommandOutput,
} from "../commands/DeleteBucketLifecycleCommand";
import {
DeleteBucketMetricsConfigurationCommandInput,
DeleteBucketMetricsConfigurationCommandOutput,
} from "../commands/DeleteBucketMetricsConfigurationCommand";
import {
DeleteBucketOwnershipControlsCommandInput,
DeleteBucketOwnershipControlsCommandOutput,
} from "../commands/DeleteBucketOwnershipControlsCommand";
import { DeleteBucketPolicyCommandInput, DeleteBucketPolicyCommandOutput } from "../commands/DeleteBucketPolicyCommand";
import {
DeleteBucketReplicationCommandInput,
DeleteBucketReplicationCommandOutput,
} from "../commands/DeleteBucketReplicationCommand";
import {
DeleteBucketTaggingCommandInput,
DeleteBucketTaggingCommandOutput,
} from "../commands/DeleteBucketTaggingCommand";
import {
DeleteBucketWebsiteCommandInput,
DeleteBucketWebsiteCommandOutput,
} from "../commands/DeleteBucketWebsiteCommand";
import { DeleteObjectCommandInput, DeleteObjectCommandOutput } from "../commands/DeleteObjectCommand";
import {
DeleteObjectTaggingCommandInput,
DeleteObjectTaggingCommandOutput,
} from "../commands/DeleteObjectTaggingCommand";
import { DeleteObjectsCommandInput, DeleteObjectsCommandOutput } from "../commands/DeleteObjectsCommand";
import {
DeletePublicAccessBlockCommandInput,
DeletePublicAccessBlockCommandOutput,
} from "../commands/DeletePublicAccessBlockCommand";
import {
GetBucketAccelerateConfigurationCommandInput,
GetBucketAccelerateConfigurationCommandOutput,
} from "../commands/GetBucketAccelerateConfigurationCommand";
import { GetBucketAclCommandInput, GetBucketAclCommandOutput } from "../commands/GetBucketAclCommand";
import {
GetBucketAnalyticsConfigurationCommandInput,
GetBucketAnalyticsConfigurationCommandOutput,
} from "../commands/GetBucketAnalyticsConfigurationCommand";
import { GetBucketCorsCommandInput, GetBucketCorsCommandOutput } from "../commands/GetBucketCorsCommand";
import {
GetBucketEncryptionCommandInput,
GetBucketEncryptionCommandOutput,
} from "../commands/GetBucketEncryptionCommand";
import {
GetBucketIntelligentTieringConfigurationCommandInput,
GetBucketIntelligentTieringConfigurationCommandOutput,
} from "../commands/GetBucketIntelligentTieringConfigurationCommand";
import {
GetBucketInventoryConfigurationCommandInput,
GetBucketInventoryConfigurationCommandOutput,
} from "../commands/GetBucketInventoryConfigurationCommand";
import {
GetBucketLifecycleConfigurationCommandInput,
GetBucketLifecycleConfigurationCommandOutput,
} from "../commands/GetBucketLifecycleConfigurationCommand";
import { GetBucketLocationCommandInput, GetBucketLocationCommandOutput } from "../commands/GetBucketLocationCommand";
import { GetBucketLoggingCommandInput, GetBucketLoggingCommandOutput } from "../commands/GetBucketLoggingCommand";
import {
GetBucketMetricsConfigurationCommandInput,
GetBucketMetricsConfigurationCommandOutput,
} from "../commands/GetBucketMetricsConfigurationCommand";
import {
GetBucketNotificationConfigurationCommandInput,
GetBucketNotificationConfigurationCommandOutput,
} from "../commands/GetBucketNotificationConfigurationCommand";
import {
GetBucketOwnershipControlsCommandInput,
GetBucketOwnershipControlsCommandOutput,
} from "../commands/GetBucketOwnershipControlsCommand";
import { GetBucketPolicyCommandInput, GetBucketPolicyCommandOutput } from "../commands/GetBucketPolicyCommand";
import {
GetBucketPolicyStatusCommandInput,
GetBucketPolicyStatusCommandOutput,
} from "../commands/GetBucketPolicyStatusCommand";
import {
GetBucketReplicationCommandInput,
GetBucketReplicationCommandOutput,
} from "../commands/GetBucketReplicationCommand";
import {
GetBucketRequestPaymentCommandInput,
GetBucketRequestPaymentCommandOutput,
} from "../commands/GetBucketRequestPaymentCommand";
import { GetBucketTaggingCommandInput, GetBucketTaggingCommandOutput } from "../commands/GetBucketTaggingCommand";
import {
GetBucketVersioningCommandInput,
GetBucketVersioningCommandOutput,
} from "../commands/GetBucketVersioningCommand";
import { GetBucketWebsiteCommandInput, GetBucketWebsiteCommandOutput } from "../commands/GetBucketWebsiteCommand";
import { GetObjectAclCommandInput, GetObjectAclCommandOutput } from "../commands/GetObjectAclCommand";
import { GetObjectCommandInput, GetObjectCommandOutput } from "../commands/GetObjectCommand";
import { GetObjectLegalHoldCommandInput, GetObjectLegalHoldCommandOutput } from "../commands/GetObjectLegalHoldCommand";
import {
GetObjectLockConfigurationCommandInput,
GetObjectLockConfigurationCommandOutput,
} from "../commands/GetObjectLockConfigurationCommand";
import { GetObjectRetentionCommandInput, GetObjectRetentionCommandOutput } from "../commands/GetObjectRetentionCommand";
import { GetObjectTaggingCommandInput, GetObjectTaggingCommandOutput } from "../commands/GetObjectTaggingCommand";
import { GetObjectTorrentCommandInput, GetObjectTorrentCommandOutput } from "../commands/GetObjectTorrentCommand";
import {
GetPublicAccessBlockCommandInput,
GetPublicAccessBlockCommandOutput,
} from "../commands/GetPublicAccessBlockCommand";
import { HeadBucketCommandInput, HeadBucketCommandOutput } from "../commands/HeadBucketCommand";
import { HeadObjectCommandInput, HeadObjectCommandOutput } from "../commands/HeadObjectCommand";
import {
ListBucketAnalyticsConfigurationsCommandInput,
ListBucketAnalyticsConfigurationsCommandOutput,
} from "../commands/ListBucketAnalyticsConfigurationsCommand";
import {
ListBucketIntelligentTieringConfigurationsCommandInput,
ListBucketIntelligentTieringConfigurationsCommandOutput,
} from "../commands/ListBucketIntelligentTieringConfigurationsCommand";
import {
ListBucketInventoryConfigurationsCommandInput,
ListBucketInventoryConfigurationsCommandOutput,
} from "../commands/ListBucketInventoryConfigurationsCommand";
import {
ListBucketMetricsConfigurationsCommandInput,
ListBucketMetricsConfigurationsCommandOutput,
} from "../commands/ListBucketMetricsConfigurationsCommand";
import { ListBucketsCommandInput, ListBucketsCommandOutput } from "../commands/ListBucketsCommand";
import {
ListMultipartUploadsCommandInput,
ListMultipartUploadsCommandOutput,
} from "../commands/ListMultipartUploadsCommand";
import { ListObjectVersionsCommandInput, ListObjectVersionsCommandOutput } from "../commands/ListObjectVersionsCommand";
import { ListObjectsCommandInput, ListObjectsCommandOutput } from "../commands/ListObjectsCommand";
import { ListObjectsV2CommandInput, ListObjectsV2CommandOutput } from "../commands/ListObjectsV2Command";
import { ListPartsCommandInput, ListPartsCommandOutput } from "../commands/ListPartsCommand";
import {
PutBucketAccelerateConfigurationCommandInput,
PutBucketAccelerateConfigurationCommandOutput,
} from "../commands/PutBucketAccelerateConfigurationCommand";
import { PutBucketAclCommandInput, PutBucketAclCommandOutput } from "../commands/PutBucketAclCommand";
import {
PutBucketAnalyticsConfigurationCommandInput,
PutBucketAnalyticsConfigurationCommandOutput,
} from "../commands/PutBucketAnalyticsConfigurationCommand";
import { PutBucketCorsCommandInput, PutBucketCorsCommandOutput } from "../commands/PutBucketCorsCommand";
import {
PutBucketEncryptionCommandInput,
PutBucketEncryptionCommandOutput,
} from "../commands/PutBucketEncryptionCommand";
import {
PutBucketIntelligentTieringConfigurationCommandInput,
PutBucketIntelligentTieringConfigurationCommandOutput,
} from "../commands/PutBucketIntelligentTieringConfigurationCommand";
import {
PutBucketInventoryConfigurationCommandInput,
PutBucketInventoryConfigurationCommandOutput,
} from "../commands/PutBucketInventoryConfigurationCommand";
import {
PutBucketLifecycleConfigurationCommandInput,
PutBucketLifecycleConfigurationCommandOutput,
} from "../commands/PutBucketLifecycleConfigurationCommand";
import { PutBucketLoggingCommandInput, PutBucketLoggingCommandOutput } from "../commands/PutBucketLoggingCommand";
import {
PutBucketMetricsConfigurationCommandInput,
PutBucketMetricsConfigurationCommandOutput,
} from "../commands/PutBucketMetricsConfigurationCommand";
import {
PutBucketNotificationConfigurationCommandInput,
PutBucketNotificationConfigurationCommandOutput,
} from "../commands/PutBucketNotificationConfigurationCommand";
import {
PutBucketOwnershipControlsCommandInput,
PutBucketOwnershipControlsCommandOutput,
} from "../commands/PutBucketOwnershipControlsCommand";
import { PutBucketPolicyCommandInput, PutBucketPolicyCommandOutput } from "../commands/PutBucketPolicyCommand";
import {
PutBucketReplicationCommandInput,
PutBucketReplicationCommandOutput,
} from "../commands/PutBucketReplicationCommand";
import {
PutBucketRequestPaymentCommandInput,
PutBucketRequestPaymentCommandOutput,
} from "../commands/PutBucketRequestPaymentCommand";
import { PutBucketTaggingCommandInput, PutBucketTaggingCommandOutput } from "../commands/PutBucketTaggingCommand";
import {
PutBucketVersioningCommandInput,
PutBucketVersioningCommandOutput,
} from "../commands/PutBucketVersioningCommand";
import { PutBucketWebsiteCommandInput, PutBucketWebsiteCommandOutput } from "../commands/PutBucketWebsiteCommand";
import { PutObjectAclCommandInput, PutObjectAclCommandOutput } from "../commands/PutObjectAclCommand";
import { PutObjectCommandInput, PutObjectCommandOutput } from "../commands/PutObjectCommand";
import { PutObjectLegalHoldCommandInput, PutObjectLegalHoldCommandOutput } from "../commands/PutObjectLegalHoldCommand";
import {
PutObjectLockConfigurationCommandInput,
PutObjectLockConfigurationCommandOutput,
} from "../commands/PutObjectLockConfigurationCommand";
import { PutObjectRetentionCommandInput, PutObjectRetentionCommandOutput } from "../commands/PutObjectRetentionCommand";
import { PutObjectTaggingCommandInput, PutObjectTaggingCommandOutput } from "../commands/PutObjectTaggingCommand";
import {
PutPublicAccessBlockCommandInput,
PutPublicAccessBlockCommandOutput,
} from "../commands/PutPublicAccessBlockCommand";
import { RestoreObjectCommandInput, RestoreObjectCommandOutput } from "../commands/RestoreObjectCommand";
import {
SelectObjectContentCommandInput,
SelectObjectContentCommandOutput,
} from "../commands/SelectObjectContentCommand";
import { UploadPartCommandInput, UploadPartCommandOutput } from "../commands/UploadPartCommand";
import { UploadPartCopyCommandInput, UploadPartCopyCommandOutput } from "../commands/UploadPartCopyCommand";
import {
AbortIncompleteMultipartUpload,
AccelerateConfiguration,
AccessControlPolicy,
AccessControlTranslation,
AnalyticsAndOperator,
AnalyticsConfiguration,
AnalyticsExportDestination,
AnalyticsFilter,
AnalyticsS3BucketDestination,
Bucket,
BucketAlreadyExists,
BucketAlreadyOwnedByYou,
BucketLifecycleConfiguration,
BucketLoggingStatus,
CORSConfiguration,
CORSRule,
CommonPrefix,
CompletedMultipartUpload,
CompletedPart,
Condition,
CopyObjectResult,
CreateBucketConfiguration,
DefaultRetention,
Delete,
DeleteMarkerEntry,
DeleteMarkerReplication,
DeletedObject,
Destination,
Encryption,
EncryptionConfiguration,
ErrorDocument,
Event,
ExistingObjectReplication,
FilterRule,
GlacierJobParameters,
Grant,
Grantee,
IndexDocument,
Initiator,
IntelligentTieringAndOperator,
IntelligentTieringConfiguration,
IntelligentTieringFilter,
InvalidObjectState,
InventoryConfiguration,
InventoryDestination,
InventoryEncryption,
InventoryFilter,
InventoryOptionalField,
InventoryS3BucketDestination,
InventorySchedule,
LambdaFunctionConfiguration,
LifecycleExpiration,
LifecycleRule,
LifecycleRuleAndOperator,
LifecycleRuleFilter,
LoggingEnabled,
Metrics,
MetricsAndOperator,
MetricsConfiguration,
MetricsFilter,
MultipartUpload,
NoSuchBucket,
NoSuchKey,
NoSuchUpload,
NoncurrentVersionExpiration,
NoncurrentVersionTransition,
NotificationConfiguration,
NotificationConfigurationFilter,
ObjectAlreadyInActiveTierError,
ObjectIdentifier,
ObjectLockConfiguration,
ObjectLockLegalHold,
ObjectLockRetention,
ObjectLockRule,
ObjectNotInActiveTierError,
ObjectVersion,
Owner,
OwnershipControls,
OwnershipControlsRule,
Part,
PolicyStatus,
PublicAccessBlockConfiguration,
QueueConfiguration,
Redirect,
RedirectAllRequestsTo,
ReplicaModifications,
ReplicationConfiguration,
ReplicationRule,
ReplicationRuleAndOperator,
ReplicationRuleFilter,
ReplicationTime,
ReplicationTimeValue,
RequestPaymentConfiguration,
RoutingRule,
S3KeyFilter,
SSEKMS,
SSES3,
ServerSideEncryptionByDefault,
ServerSideEncryptionConfiguration,
ServerSideEncryptionRule,
SourceSelectionCriteria,
SseKmsEncryptedObjects,
StorageClassAnalysis,
StorageClassAnalysisDataExport,
Tag,
Tagging,
TargetGrant,
Tiering,
TopicConfiguration,
Transition,
VersioningConfiguration,
WebsiteConfiguration,
_Error,
_Object,
} from "../models/models_0";
import {
CSVInput,
CSVOutput,
ContinuationEvent,
CopyPartResult,
EndEvent,
InputSerialization,
JSONInput,
JSONOutput,
MetadataEntry,
OutputLocation,
OutputSerialization,
ParquetInput,
ProgressEvent,
RecordsEvent,
RequestProgress,
RestoreRequest,
S3Location,
ScanRange,
SelectObjectContentEventStream,
SelectParameters,
StatsEvent,
} from "../models/models_1";
import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@aws-sdk/protocol-http";
import {
SmithyException as __SmithyException,
dateToUtcString as __dateToUtcString,
extendedEncodeURIComponent as __extendedEncodeURIComponent,
getArrayIfSingleItem as __getArrayIfSingleItem,
getValueFromTextNode as __getValueFromTextNode,
} from "@aws-sdk/smithy-client";
import {
Endpoint as __Endpoint,
EventStreamSerdeContext as __EventStreamSerdeContext,
MetadataBearer as __MetadataBearer,
ResponseMetadata as __ResponseMetadata,
SerdeContext as __SerdeContext,
} from "@aws-sdk/types";
import { XmlNode as __XmlNode, XmlText as __XmlText } from "@aws-sdk/xml-builder";
import { parse as xmlParse } from "fast-xml-parser";
export const serializeAws_restXmlAbortMultipartUploadCommand = async (
input: AbortMultipartUploadCommandInput,
context: __SerdeContext
): Promise<__HttpRequest> => {
const headers: any = {
...(isSerializableHeaderValue(input.RequestPayer) && { "x-amz-request-payer": input.RequestPayer! }),
...(isSerializableHeaderValue(input.ExpectedBucketOwner) && {
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner!,
}),
};
let resolvedPath = "/{Bucket}/{Key+}";
if (input.Bucket !== undefined) {
const labelValue: string = input.Bucket;
if (labelValue.length <= 0) {
throw new Error("Empty value provided for input HTTP label: Bucket.");
}
resolvedPath = resolvedPath.replace("{Bucket}", __extendedEncodeURIComponent(labelValue));
} else {
throw new Error("No value provided for input HTTP label: Bucket.");
}
if (input.Key !== undefined) {
const labelValue: string = input.Key;
if (labelValue.length <= 0) {
throw new Error("Empty value provided for input HTTP label: Key.");
}
resolvedPath = resolvedPath.replace(
"{Key+}",
labelValue
.split("/")
.map((segment) => __extendedEncodeURIComponent(segment))
.join("/")
);
} else {
throw new Error("No value provided for input HTTP label: Key.");
}
const query: any = {
"x-id": "AbortMultipartUpload",
...(input.UploadId !== undefined && { uploadId: input.UploadId }),
};
let body: any;
const { hostname, protocol = "https", port } = await context.endpoint();
return new __HttpRequest({
protocol,
hostname,
port,
method: "DELETE",
headers,
path: resolvedPath,
query,
body,
});
};
export const serializeAws_restXmlCompleteMultipartUploadCommand = async (
input: CompleteMultipartUploadCommandInput,
context: __SerdeContext
): Promise<__HttpRequest> => {
const headers: any = {
"content-type": "application/xml",
...(isSerializableHeaderValue(input.RequestPayer) && { "x-amz-request-payer": input.RequestPayer! }),
...(isSerializableHeaderValue(input.ExpectedBucketOwner) && {
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner!,
}),
};
let resolvedPath = "/{Bucket}/{Key+}";
if (input.Bucket !== undefined) {
const labelValue: string = input.Bucket;
if (labelValue.length <= 0) {
throw new Error("Empty value provided for input HTTP label: Bucket.");
}
resolvedPath = resolvedPath.replace("{Bucket}", __extendedEncodeURIComponent(labelValue));
} else {
throw new Error("No value provided for input HTTP label: Bucket.");
}
if (input.Key !== undefined) {
const labelValue: string = input.Key;
if (labelValue.length <= 0) {
throw new Error("Empty value provided for input HTTP label: Key.");
}
resolvedPath = resolvedPath.replace(
"{Key+}",
labelValue
.split("/")
.map((segment) => __extendedEncodeURIComponent(segment))
.join("/")
);
} else {
throw new Error("No value provided for input HTTP label: Key.");
}
const query: any = {
...(input.UploadId !== undefined && { uploadId: input.UploadId }),
};
let body: any;
let contents: any;
if (input.MultipartUpload !== undefined) {
contents = serializeAws_restXmlCompletedMultipartUpload(input.MultipartUpload, context);
body = '<?xml version="1.0" encoding="UTF-8"?>';
contents.addAttribute("xmlns", "http://s3.amazonaws.com/doc/2006-03-01/");
body += contents.toString();
}
const { hostname, protocol = "https", port } = await context.endpoint();
return new __HttpRequest({
protocol,
hostname,
port,
method: "POST",
headers,
path: resolvedPath,
query,
body,
});
};
export const serializeAws_restXmlCopyObjectCommand = async (
input: CopyObjectCommandInput,
context: __SerdeContext
): Promise<__HttpRequest> => {
const headers: any = {
...(isSerializableHeaderValue(input.ACL) && { "x-amz-acl": input.ACL! }),
...(isSerializableHeaderValue(input.CacheControl) && { "cache-control": input.CacheControl! }),
...(isSerializableHeaderValue(input.ContentDisposition) && { "content-disposition": input.ContentDisposition! }),
...(isSerializableHeaderValue(input.ContentEncoding) && { "content-encoding": input.ContentEncoding! }),
...(isSerializableHeaderValue(input.ContentLanguage) && { "content-language": input.ContentLanguage! }),
...(isSerializableHeaderValue(input.ContentType) && { "content-type": input.ContentType! }),
...(isSerializableHeaderValue(input.CopySource) && { "x-amz-copy-source": input.CopySource! }),
...(isSerializableHeaderValue(input.CopySourceIfMatch) && {
"x-amz-copy-source-if-match": input.CopySourceIfMatch!,
}),
...(isSerializableHeaderValue(input.CopySourceIfModifiedSince) && {
"x-amz-copy-source-if-modified-since": __dateToUtcString(input.CopySourceIfModifiedSince!).toString(),
}),
...(isSerializableHeaderValue(input.CopySourceIfNoneMatch) && {
"x-amz-copy-source-if-none-match": input.CopySourceIfNoneMatch!,
}),
...(isSerializableHeaderValue(input.CopySourceIfUnmodifiedSince) && {
"x-amz-copy-source-if-unmodified-since": __dateToUtcString(input.CopySourceIfUnmodifiedSince!).toString(),
}),
...(isSerializableHeaderValue(input.Expires) && { expires: __dateToUtcString(input.Expires!).toString() }),
...(isSerializableHeaderValue(input.GrantFullControl) && { "x-amz-grant-full-control": input.GrantFullControl! }),
...(isSerializableHeaderValue(input.GrantRead) && { "x-amz-grant-read": input.GrantRead! }),
...(isSerializableHeaderValue(input.GrantReadACP) && { "x-amz-grant-read-acp": input.GrantReadACP! }),
...(isSerializableHeaderValue(input.GrantWriteACP) && { "x-amz-grant-write-acp": input.GrantWriteACP! }),
...(isSerializableHeaderValue(input.MetadataDirective) && { "x-amz-metadata-directive": input.MetadataDirective! }),
...(isSerializableHeaderValue(input.TaggingDirective) && { "x-amz-tagging-directive": input.TaggingDirective! }),
...(isSerializableHeaderValue(input.ServerSideEncryption) && {
"x-amz-server-side-encryption": input.ServerSideEncryption!,
}),
...(isSerializableHeaderValue(input.StorageClass) && { "x-amz-storage-class": input.StorageClass! }),
...(isSerializableHeaderValue(input.WebsiteRedirectLocation) && {
"x-amz-website-redirect-location": input.WebsiteRedirectLocation!,
}),
...(isSerializableHeaderValue(input.SSECustomerAlgorithm) && {
"x-amz-server-side-encryption-customer-algorithm": input.SSECustomerAlgorithm!,
}),
...(isSerializableHeaderValue(input.SSECustomerKey) && {
"x-amz-server-side-encryption-customer-key": input.SSECustomerKey!,
}),
...(isSerializableHeaderValue(input.SSECustomerKeyMD5) && {
"x-amz-server-side-encryption-customer-key-md5": input.SSECustomerKeyMD5!,
}),
...(isSerializableHeaderValue(input.SSEKMSKeyId) && {
"x-amz-server-side-encryption-aws-kms-key-id": input.SSEKMSKeyId!,
}),
...(isSerializableHeaderValue(input.SSEKMSEncryptionContext) && {
"x-amz-server-side-encryption-context": input.SSEKMSEncryptionContext!,
}),
...(isSerializableHeaderValue(input.BucketKeyEnabled) && {
"x-amz-server-side-encryption-bucket-key-enabled": input.BucketKeyEnabled!.toString(),
}),
...(isSerializableHeaderValue(input.CopySourceSSECustomerAlgorithm) && {
"x-amz-copy-source-server-side-encryption-customer-algorithm": input.CopySourceSSECustomerAlgorithm!,
}),
...(isSerializableHeaderValue(input.CopySourceSSECustomerKey) && {
"x-amz-copy-source-server-side-encryption-customer-key": input.CopySourceSSECustomerKey!,
}),
...(isSerializableHeaderValue(input.CopySourceSSECustomerKeyMD5) && {
"x-amz-copy-source-server-side-encryption-customer-key-md5": input.CopySourceSSECustomerKeyMD5!,
}),
...(isSerializableHeaderValue(input.RequestPayer) && { "x-amz-request-payer": input.RequestPayer! }),
...(isSerializableHeaderValue(input.Tagging) && { "x-amz-tagging": input.Tagging! }),
...(isSerializableHeaderValue(input.ObjectLockMode) && { "x-amz-object-lock-mode": input.ObjectLockMode! }),
...(isSerializableHeaderValue(input.ObjectLockRetainUntilDate) && {
"x-amz-object-lock-retain-until-date": (
input.ObjectLockRetainUntilDate!.toISOString().split(".")[0] + "Z"
).toString(),
}),
...(isSerializableHeaderValue(input.ObjectLockLegalHoldStatus) && {
"x-amz-object-lock-legal-hold": input.ObjectLockLegalHoldStatus!,
}),
...(isSerializableHeaderValue(input.ExpectedBucketOwner) && {
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner!,
}),
...(isSerializableHeaderValue(input.ExpectedSourceBucketOwner) && {
"x-amz-source-expected-bucket-owner": input.ExpectedSourceBucketOwner!,
}),
...(input.Metadata !== undefined &&
Object.keys(input.Metadata).reduce(
(acc: any, suffix: string) => ({
...acc,
[`x-amz-meta-${suffix.toLowerCase()}`]: input.Metadata![suffix],
}),
{}
)),
};
let resolvedPath = "/{Bucket}/{Key+}";
if (input.Bucket !== undefined) {
const labelValue: string = input.Bucket;
if (labelValue.length <= 0) {
throw new Error("Empty value provided for input HTTP label: Bucket.");
}
resolvedPath = resolvedPath.replace("{Bucket}", __extendedEncodeURIComponent(labelValue));
} else {
throw new Error("No value provided for input HTTP label: Bucket.");
}
if (input.Key !== undefined) {
const labelValue: string = input.Key;
if (labelValue.length <= 0) {
throw new Error("Empty value provided for input HTTP label: Key.");
}
resolvedPath = resolvedPath.replace(
"{Key+}",
labelValue
.split("/")
.map((segment) => __extendedEncodeURIComponent(segment))
.join("/")
);
} else {
throw new Error("No value provided for input HTTP label: Key.");
}
const query: any = {
"x-id": "CopyObject",
};
let body: any;
const { hostname, protocol = "https", port } = await context.endpoint();
return new __HttpRequest({
protocol,
hostname,
port,
method: "PUT",
headers,
path: resolvedPath,
query,
body,
});
};
export const serializeAws_restXmlCreateBucketCommand = async (
input: CreateBucketCommandInput,
context: __SerdeContext
): Promise<__HttpRequest> => {
const headers: any = {
"content-type": "application/xml",
...(isSerializableHeaderValue(input.ACL) && { "x-amz-acl": input.ACL! }),
...(isSerializableHeaderValue(input.GrantFullControl) && { "x-amz-grant-full-control": input.GrantFullControl! }),
...(isSerializableHeaderValue(input.GrantRead) && { "x-amz-grant-read": input.GrantRead! }),
...(isSerializableHeaderValue(input.GrantReadACP) && { "x-amz-grant-read-acp": input.GrantReadACP! }),
...(isSerializableHeaderValue(input.GrantWrite) && { "x-amz-grant-write": input.GrantWrite! }),
...(isSerializableHeaderValue(input.GrantWriteACP) && { "x-amz-grant-write-acp": input.GrantWriteACP! }),
...(isSerializableHeaderValue(input.ObjectLockEnabledForBucket) && {
"x-amz-bucket-object-lock-enabled": input.ObjectLockEnabledForBucket!.toString(),
}),
};
let resolvedPath = "/{Bucket}";
if (input.Bucket !== undefined) {
const labelValue: string = input.Bucket;
if (labelValue.length <= 0) {
throw new Error("Empty value provided for input HTTP label: Bucket.");
}
resolvedPath = resolvedPath.replace("{Bucket}", __extendedEncodeURIComponent(labelValue));
} else {
throw new Error("No value provided for input HTTP label: Bucket.");
}
let body: any;
let contents: any;
if (input.CreateBucketConfiguration !== undefined) {
contents = serializeAws_restXmlCreateBucketConfiguration(input.CreateBucketConfiguration, context);
body = '<?xml version="1.0" encoding="UTF-8"?>';
contents.addAttribute("xmlns", "http://s3.amazonaws.com/doc/2006-03-01/");
body += contents.toString();
}
const { hostname, protocol = "https", port } = await context.endpoint();
return new __HttpRequest({
protocol,
hostname,
port,
method: "PUT",
headers,
path: resolvedPath,
body,
});
};
export const serializeAws_restXmlCreateMultipartUploadCommand = async (
input: CreateMultipartUploadCommandInput,
context: __SerdeContext
): Promise<__HttpRequest> => {
const headers: any = {
...(isSerializableHeaderValue(input.ACL) && { "x-amz-acl": input.ACL! }),
...(isSerializableHeaderValue(input.CacheControl) && { "cache-control": input.CacheControl! }),
...(isSerializableHeaderValue(input.ContentDisposition) && { "content-disposition": input.ContentDisposition! }),
...(isSerializableHeaderValue(input.ContentEncoding) && { "content-encoding": input.ContentEncoding! }),
...(isSerializableHeaderValue(input.ContentLanguage) && { "content-language": input.ContentLanguage! }),
...(isSerializableHeaderValue(input.ContentType) && { "content-type": input.ContentType! }),
...(isSerializableHeaderValue(input.Expires) && { expires: __dateToUtcString(input.Expires!).toString() }),
...(isSerializableHeaderValue(input.GrantFullControl) && { "x-amz-grant-full-control": input.GrantFullControl! }),
...(isSerializableHeaderValue(input.GrantRead) && { "x-amz-grant-read": input.GrantRead! }),
...(isSerializableHeaderValue(input.GrantReadACP) && { "x-amz-grant-read-acp": input.GrantReadACP! }),
...(isSerializableHeaderValue(input.GrantWriteACP) && { "x-amz-grant-write-acp": input.GrantWriteACP! }),
...(isSerializableHeaderValue(input.ServerSideEncryption) && {
"x-amz-server-side-encryption": input.ServerSideEncryption!,
}),
...(isSerializableHeaderValue(input.StorageClass) && { "x-amz-storage-class": input.StorageClass! }),
...(isSerializableHeaderValue(input.WebsiteRedirectLocation) && {
"x-amz-website-redirect-location": input.WebsiteRedirectLocation!,
}),
...(isSerializableHeaderValue(input.SSECustomerAlgorithm) && {
"x-amz-server-side-encryption-customer-algorithm": input.SSECustomerAlgorithm!,
}),
...(isSerializableHeaderValue(input.SSECustomerKey) && {
"x-amz-server-side-encryption-customer-key": input.SSECustomerKey!,
}),
...(isSerializableHeaderValue(input.SSECustomerKeyMD5) && {
"x-amz-server-side-encryption-customer-key-md5": input.SSECustomerKeyMD5!,
}),
...(isSerializableHeaderValue(input.SSEKMSKeyId) && {
"x-amz-server-side-encryption-aws-kms-key-id": input.SSEKMSKeyId!,
}),
...(isSerializableHeaderValue(input.SSEKMSEncryptionContext) && {
"x-amz-server-side-encryption-context": input.SSEKMSEncryptionContext!,
}),
...(isSerializableHeaderValue(input.BucketKeyEnabled) && {
"x-amz-server-side-encryption-bucket-key-enabled": input.BucketKeyEnabled!.toString(),
}),
...(isSerializableHeaderValue(input.RequestPayer) && { "x-amz-request-payer": input.RequestPayer! }),
...(isSerializableHeaderValue(input.Tagging) && { "x-amz-tagging": input.Tagging! }),
...(isSerializableHeaderValue(input.ObjectLockMode) && { "x-amz-object-lock-mode": input.ObjectLockMode! }),
...(isSerializableHeaderValue(input.ObjectLockRetainUntilDate) && {
"x-amz-object-lock-retain-until-date": (
input.ObjectLockRetainUntilDate!.toISOString().split(".")[0] + "Z"
).toString(),
}),
...(isSerializableHeaderValue(input.ObjectLockLegalHoldStatus) && {
"x-amz-object-lock-legal-hold": input.ObjectLockLegalHoldStatus!,
}),
...(isSerializableHeaderValue(input.ExpectedBucketOwner) && {
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner!,
}),
...(input.Metadata !== undefined &&
Object.keys(input.Metadata).reduce(
(acc: any, suffix: string) => ({
...acc,
[`x-amz-meta-${suffix.toLowerCase()}`]: input.Metadata![suffix],
}),
{}
)),
};
let resolvedPath = "/{Bucket}/{Key+}";
if (input.Bucket !== undefined) {
const labelValue: string = input.Bucket;
if (labelValue.length <= 0) {
throw new Error("Empty value provided for input HTTP label: Bucket.");
}
resolvedPath = resolvedPath.replace("{Bucket}", __extendedEncodeURIComponent(labelValue));
} else {
throw new Error("No value provided for input HTTP label: Bucket.");
}
if (input.Key !== undefined) {
const labelValue: string = input.Key;
if (labelValue.length <= 0) {
throw new Error("Empty value provided for input HTTP label: Key.");
}
resolvedPath = resolvedPath.replace(
"{Key+}",
labelValue
.split("/")
.map((segment) => __extendedEncodeURIComponent(segment))
.join("/")
);
} else {
throw new Error("No value provided for input HTTP label: Key.");
}
const query: any = {
uploads: "",
};
let body: any;
const { hostname, protocol = "https", port } = await context.endpoint();
return new __HttpRequest({
protocol,
hostname,
port,
method: "POST",
headers,
path: resolvedPath,
query,
body,
});
};
export const serializeAws_restXmlDeleteBucketCommand = async (
input: DeleteBucketCommandInput,
context: __SerdeContext
): Promise<__HttpRequest> => {
const headers: any = {
...(isSerializableHeaderValue(input.ExpectedBucketOwner) && {
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner!,
}),
};
let resolvedPath = "/{Bucket}";
if (input.Bucket !== undefined) {
const labelValue: string = input.Bucket;
if (labelValue.length <= 0) {
throw new Error("Empty value provided for input HTTP label: Bucket.");
}
resolvedPath = resolvedPath.replace("{Bucket}", __extendedEncodeURIComponent(labelValue));
} else {
throw new Error("No value provided for input HTTP label: Bucket.");
}
let body: any;
const { hostname, protocol = "https", port } = await context.endpoint();
return new __HttpRequest({
protocol,
hostname,
port,
method: "DELETE",
headers,
path: resolvedPath,
body,
});
};
export const serializeAws_restXmlDeleteBucketAnalyticsConfigurationCommand = async (
input: DeleteBucketAnalyticsConfigurationCommandInput,
context: __SerdeContext
): Promise<__HttpRequest> => {
const headers: any = {
...(isSerializableHeaderValue(input.ExpectedBucketOwner) && {
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner!,
}),
};
let resolvedPath = "/{Bucket}";
if (input.Bucket !== undefined) {
const labelValue: string = input.Bucket;
if (labelValue.length <= 0) {
throw new Error("Empty value provided for input HTTP label: Bucket.");
}
resolvedPath = resolvedPath.replace("{Bucket}", __extendedEncodeURIComponent(labelValue));
} else {
throw new Error("No value provided for input HTTP label: Bucket.");
}
const query: any = {
analytics: "",
...(input.Id !== undefined && { id: input.Id }),
};
let body: any;
const { hostname, protocol = "https", port } = await context.endpoint();
return new __HttpRequest({
protocol,
hostname,
port,
method: "DELETE",
headers,
path: resolvedPath,
query,
body,
});
};
export const serializeAws_restXmlDeleteBucketCorsCommand = async (
input: DeleteBucketCorsCommandInput,
context: __SerdeContext
): Promise<__HttpRequest> => {
const headers: any = {
...(isSerializableHeaderValue(input.ExpectedBucketOwner) && {
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner!,
}),
};
let resolvedPath = "/{Bucket}";
if (input.Bucket !== undefined) {
const labelValue: string = input.Bucket;
if (labelValue.length <= 0) {
throw new Error("Empty value provided for input HTTP label: Bucket.");
}
resolvedPath = resolvedPath.replace("{Bucket}", __extendedEncodeURIComponent(labelValue));
} else {
throw new Error("No value provided for input HTTP label: Bucket.");
}
const query: any = {
cors: "",
};
let body: any;
const { hostname, protocol = "https", port } = await context.endpoint();
return new __HttpRequest({
protocol,
hostname,
port,
method: "DELETE",
headers,
path: resolvedPath,
query,
body,
});
};
export const serializeAws_restXmlDeleteBucketEncryptionCommand = async (
input: DeleteBucketEncryptionCommandInput,
context: __SerdeContext
): Promise<__HttpRequest> => {
const headers: any = {
...(isSerializableHeaderValue(input.ExpectedBucketOwner) && {
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner!,
}),
};
let resolvedPath = "/{Bucket}";
if (input.Bucket !== undefined) {
const labelValue: string = input.Bucket;
if (labelValue.length <= 0) {
throw new Error("Empty value provided for input HTTP label: Bucket.");
}
resolvedPath = resolvedPath.replace("{Bucket}", __extendedEncodeURIComponent(labelValue));
} else {
throw new Error("No value provided for input HTTP label: Bucket.");
}
const query: any = {
encryption: "",
};
let body: any;
const { hostname, protocol = "https", port } = await context.endpoint();
return new __HttpRequest({
protocol,
hostname,
port,
method: "DELETE",
headers,
path: resolvedPath,
query,
body,
});
};
export const serializeAws_restXmlDeleteBucketIntelligentTieringConfigurationCommand = async (
input: DeleteBucketIntelligentTieringConfigurationCommandInput,
context: __SerdeContext
): Promise<__HttpRequest> => {
const headers: any = {};
let resolvedPath = "/{Bucket}";
if (input.Bucket !== undefined) {
const labelValue: string = input.Bucket;
if (labelValue.length <= 0) {
throw new Error("Empty value provided for input HTTP label: Bucket.");
}
resolvedPath = resolvedPath.replace("{Bucket}", __extendedEncodeURIComponent(labelValue));
} else {
throw new Error("No value provided for input HTTP label: Bucket.");
}
const query: any = {
"intelligent-tiering": "",
...(input.Id !== undefined && { id: input.Id }),
};
let body: any;
const { hostname, protocol = "https", port } = await context.endpoint();
return new __HttpRequest({
protocol,
hostname,
port,
method: "DELETE",
headers,
path: resolvedPath,
query,
body,
});
};
export const serializeAws_restXmlDeleteBucketInventoryConfigurationCommand = async (
input: DeleteBucketInventoryConfigurationCommandInput,
context: __SerdeContext
): Promise<__HttpRequest> => {
const headers: any = {
...(isSerializableHeaderValue(input.ExpectedBucketOwner) && {
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner!,
}),
};
let resolvedPath = "/{Bucket}";
if (input.Bucket !== undefined) {
const labelValue: string = input.Bucket;
if (labelValue.length <= 0) {
throw new Error("Empty value provided for input HTTP label: Bucket.");
}
resolvedPath = resolvedPath.replace("{Bucket}", __extendedEncodeURIComponent(labelValue));
} else {
throw new Error("No value provided for input HTTP label: Bucket.");
}
const query: any = {
inventory: "",
...(input.Id !== undefined && { id: input.Id }),
};
let body: any;
const { hostname, protocol = "https", port } = await context.endpoint();
return new __HttpRequest({
protocol,
hostname,
port,
method: "DELETE",
headers,
path: resolvedPath,
query,
body,
});
};
export const serializeAws_restXmlDeleteBucketLifecycleCommand = async (
input: DeleteBucketLifecycleCommandInput,
context: __SerdeContext
): Promise<__HttpRequest> => {
const headers: any = {
...(isSerializableHeaderValue(input.ExpectedBucketOwner) && {
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner!,
}),
};
let resolvedPath = "/{Bucket}";
if (input.Bucket !== undefined) {
const labelValue: string = input.Bucket;
if (labelValue.length <= 0) {
throw new Error("Empty value provided for input HTTP label: Bucket.");
}
resolvedPath = resolvedPath.replace("{Bucket}", __extendedEncodeURIComponent(labelValue));
} else {
throw new Error("No value provided for input HTTP label: Bucket.");
}
const query: any = {
lifecycle: "",
};
let body: any;
const { hostname, protocol = "https", port } = await context.endpoint();
return new __HttpRequest({
protocol,
hostname,
port,
method: "DELETE",
headers,
path: resolvedPath,
query,
body,
});
};
export const serializeAws_restXmlDeleteBucketMetricsConfigurationCommand = async (
input: DeleteBucketMetricsConfigurationCommandInput,
context: __SerdeContext
): Promise<__HttpRequest> => {
const headers: any = {
...(isSerializableHeaderValue(input.ExpectedBucketOwner) && {
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner!,
}),
};
let resolvedPath = "/{Bucket}";
if (input.Bucket !== undefined) {
const labelValue: string = input.Bucket;
if (labelValue.length <= 0) {
throw new Error("Empty value provided for input HTTP label: Bucket.");
}
resolvedPath = resolvedPath.replace("{Bucket}", __extendedEncodeURIComponent(labelValue));
} else {
throw new Error("No value provided for input HTTP label: Bucket.");
}
const query: any = {
metrics: "",
...(input.Id !== undefined && { id: input.Id }),
};
let body: any;
const { hostname, protocol = "https", port } = await context.endpoint();
return new __HttpRequest({
protocol,
hostname,
port,
method: "DELETE",
headers,
path: resolvedPath,
query,
body,
});
};
export const serializeAws_restXmlDeleteBucketOwnershipControlsCommand = async (
input: DeleteBucketOwnershipControlsCommandInput,
context: __SerdeContext
): Promise<__HttpRequest> => {
const headers: any = {
...(isSerializableHeaderValue(input.ExpectedBucketOwner) && {
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner!,
}),
};
let resolvedPath = "/{Bucket}";
if (input.Bucket !== undefined) {
const labelValue: string = input.Bucket;
if (labelValue.length <= 0) {
throw new Error("Empty value provided for input HTTP label: Bucket.");
}
resolvedPath = resolvedPath.replace("{Bucket}", __extendedEncodeURIComponent(labelValue));
} else {
throw new Error("No value provided for input HTTP label: Bucket.");
}
const query: any = {
ownershipControls: "",
};
let body: any;
const { hostname, protocol = "https", port } = await context.endpoint();
return new __HttpRequest({
protocol,
hostname,
port,
method: "DELETE",
headers,
path: resolvedPath,
query,
body,
});
};
export const serializeAws_restXmlDeleteBucketPolicyCommand = async (
input: DeleteBucketPolicyCommandInput,
context: __SerdeContext
): Promise<__HttpRequest> => {
const headers: any = {
...(isSerializableHeaderValue(input.ExpectedBucketOwner) && {
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner!,
}),
};
let resolvedPath = "/{Bucket}";
if (input.Bucket !== undefined) {
const labelValue: string = input.Bucket;
if (labelValue.length <= 0) {
throw new Error("Empty value provided for input HTTP label: Bucket.");
}
resolvedPath = resolvedPath.replace("{Bucket}", __extendedEncodeURIComponent(labelValue));
} else {
throw new Error("No value provided for input HTTP label: Bucket.");
}
const query: any = {
policy: "",
};
let body: any;
const { hostname, protocol = "https", port } = await context.endpoint();
return new __HttpRequest({
protocol,
hostname,
port,
method: "DELETE",
headers,
path: resolvedPath,
query,
body,
});
};
export const serializeAws_restXmlDeleteBucketReplicationCommand = async (
input: DeleteBucketReplicationCommandInput,
context: __SerdeContext
): Promise<__HttpRequest> => {
const headers: any = {
...(isSerializableHeaderValue(input.ExpectedBucketOwner) && {
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner!,
}),
};
let resolvedPath = "/{Bucket}";
if (input.Bucket !== undefined) {
const labelValue: string = input.Bucket;
if (labelValue.length <= 0) {
throw new Error("Empty value provided for input HTTP label: Bucket.");
}
resolvedPath = resolvedPath.replace("{Bucket}", __extendedEncodeURIComponent(labelValue));
} else {
throw new Error("No value provided for input HTTP label: Bucket.");
}
const query: any = {
replication: "",
};
let body: any;
const { hostname, protocol = "https", port } = await context.endpoint();
return new __HttpRequest({
protocol,
hostname,
port,
method: "DELETE",
headers,
path: resolvedPath,
query,
body,
});
};
export const serializeAws_restXmlDeleteBucketTaggingCommand = async (
input: DeleteBucketTaggingCommandInput,
context: __SerdeContext
): Promise<__HttpRequest> => {
const headers: any = {
...(isSerializableHeaderValue(input.ExpectedBucketOwner) && {
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner!,
}),
};
let resolvedPath = "/{Bucket}";
if (input.Bucket !== undefined) {
const labelValue: string = input.Bucket;
if (labelValue.length <= 0) {
throw new Error("Empty value provided for input HTTP label: Bucket.");
}
resolvedPath = resolvedPath.replace("{Bucket}", __extendedEncodeURIComponent(labelValue));
} else {
throw new Error("No value provided for input HTTP label: Bucket.");
}
const query: any = {
tagging: "",
};
let body: any;
const { hostname, protocol = "https", port } = await context.endpoint();
return new __HttpRequest({
protocol,
hostname,
port,
method: "DELETE",
headers,
path: resolvedPath,
query,
body,
});
};
export const serializeAws_restXmlDeleteBucketWebsiteCommand = async (
input: DeleteBucketWebsiteCommandInput,
context: __SerdeContext
): Promise<__HttpRequest> => {
const headers: any = {
...(isSerializableHeaderValue(input.ExpectedBucketOwner) && {
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner!,
}),
};
let resolvedPath = "/{Bucket}";
if (input.Bucket !== undefined) {
const labelValue: string = input.Bucket;
if (labelValue.length <= 0) {
throw new Error("Empty value provided for input HTTP label: Bucket.");
}
resolvedPath = resolvedPath.replace("{Bucket}", __extendedEncodeURIComponent(labelValue));
} else {
throw new Error("No value provided for input HTTP label: Bucket.");
}
const query: any = {
website: "",
};
let body: any;
const { hostname, protocol = "https", port } = await context.endpoint();
return new __HttpRequest({
protocol,
hostname,
port,
method: "DELETE",
headers,
path: resolvedPath,
query,
body,
});
};
export const serializeAws_restXmlDeleteObjectCommand = async (
input: DeleteObjectCommandInput,
context: __SerdeContext
): Promise<__HttpRequest> => {
const headers: any = {
...(isSerializableHeaderValue(input.MFA) && { "x-amz-mfa": input.MFA! }),
...(isSerializableHeaderValue(input.RequestPayer) && { "x-amz-request-payer": input.RequestPayer! }),
...(isSerializableHeaderValue(input.BypassGovernanceRetention) && {
"x-amz-bypass-governance-retention": input.BypassGovernanceRetention!.toString(),
}),
...(isSerializableHeaderValue(input.ExpectedBucketOwner) && {
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner!,
}),
};
let resolvedPath = "/{Bucket}/{Key+}";
if (input.Bucket !== undefined) {
const labelValue: string = input.Bucket;
if (labelValue.length <= 0) {
throw new Error("Empty value provided for input HTTP label: Bucket.");
}
resolvedPath = resolvedPath.replace("{Bucket}", __extendedEncodeURIComponent(labelValue));
} else {
throw new Error("No value provided for input HTTP label: Bucket.");
}
if (input.Key !== undefined) {
const labelValue: string = input.Key;
if (labelValue.length <= 0) {
throw new Error("Empty value provided for input HTTP label: Key.");
}
resolvedPath = resolvedPath.replace(
"{Key+}",
labelValue
.split("/")
.map((segment) => __extendedEncodeURIComponent(segment))
.join("/")
);
} else {
throw new Error("No value provided for input HTTP label: Key.");
}
const query: any = {
"x-id": "DeleteObject",
...(input.VersionId !== undefined && { versionId: input.VersionId }),
};
let body: any;
const { hostname, protocol = "https", port } = await context.endpoint();
return new __HttpRequest({
protocol,
hostname,
port,
method: "DELETE",
headers,
path: resolvedPath,
query,
body,
});
};
export const serializeAws_restXmlDeleteObjectsCommand = async (
input: DeleteObjectsCommandInput,
context: __SerdeContext
): Promise<__HttpRequest> => {
const headers: any = {
"content-type": "application/xml",
...(isSerializableHeaderValue(input.MFA) && { "x-amz-mfa": input.MFA! }),
...(isSerializableHeaderValue(input.RequestPayer) && { "x-amz-request-payer": input.RequestPayer! }),
...(isSerializableHeaderValue(input.BypassGovernanceRetention) && {
"x-amz-bypass-governance-retention": input.BypassGovernanceRetention!.toString(),
}),
...(isSerializableHeaderValue(input.ExpectedBucketOwner) && {
"x-amz-expected-bucket-owner": input.ExpectedBucketOwner!,
}),
};
let resolvedPath = "/{Bucket}";
if (input.Bucket !== undefined) {
const labelValue: string = input.Bucket;
if (labelValue.length <= 0) {
throw new Error("Empty value provided for input HTTP label: Bucket.");
}
resolvedPath = resolvedPath.replace("{Bucket}", __extendedEncodeURIComponent(labelValue));
} else {
throw new Error("No value provided for input HTTP label: Bucket.");
}
const query: any = {
delete: "",
};
let body: any;
let contents: any;
if (input.Delete !== u