Package: s3shared

import "../ibm-cos-sdk-go-v2/service/internal/s3shared"

Sub-Packages

arn, config

Type Summary collapse

Function Summary collapse

Type Details

EnableDualstack struct

EnableDualstack represents middleware struct for enabling dualstack support

Deprecated: See EndpointResolverOptions’ UseDualStackEndpoint support

Structure Fields:

UseDualstack bool

UseDualstack indicates if dualstack endpoint resolving is to be enabled

DefaultServiceID string

DefaultServiceID is the service id prefix used in endpoint resolving by default service-id is ‘s3’ and ‘s3-control’ for service s3, s3control.

ErrorComponents struct

ErrorComponents represents the error response fields that will be deserialized from an xml error response body

Structure Fields:

Code string
Message string
RequestID string
HostID string

ErrorResponseDeserializerOptions struct

ErrorResponseDeserializerOptions represents error response deserializer options for s3 and s3-control service

Structure Fields:

UseStatusCode bool

UseStatusCode denotes if status code should be used to retrieve error code, msg

StatusCode int

StatusCode is status code of error response

IsWrappedWithErrorTag bool

IsWrappedWithErrorTag represents if error response’s code, msg is wrapped within an additional <Error> tag

Function Details

func Add100Continue(stack *middleware.Stack, continueHeaderThresholdBytes int64) error

Add100Continue add middleware, which adds 100-continue header for s3 client HTTP PUT request larger than 2MB or with unknown size streaming bodies, during operation builder step



14
15
16
17
18
// File 'service/internal/s3shared/s3100continue.go', line 14

func Add100Continue(stack *middleware.Stack, continueHeaderThresholdBytes int64) error { return stack.Build.Add(&s3100Continue{ continueHeaderThresholdBytes: continueHeaderThresholdBytes, }, middleware.After) }

func AddMetadataRetrieverMiddleware(stack *middleware.Stack) error

AddMetadataRetrieverMiddleware adds request id, host id retriever middleware



14
15
16
17
18
// File 'service/internal/s3shared/metadata_retriever.go', line 14

func AddMetadataRetrieverMiddleware(stack *middleware.Stack) error { // add metadata retriever middleware before operation deserializers so that it can retrieve metadata such as // host id, request id from response header returned by operation deserializers return stack.Deserialize.Insert(&metadataRetriever{}, "OperationDeserializer", middleware.Before) }

func AddResponseErrorMiddleware(stack *middleware.Stack) error

AddResponseErrorMiddleware adds response error wrapper middleware



12
13
14
15
16
// File 'service/internal/s3shared/response_error_middleware.go', line 12

func AddResponseErrorMiddleware(stack *middleware.Stack) error { // add error wrapper middleware before request id retriever middleware so that it can wrap the error response // returned by operation deserializers return stack.Deserialize.Insert(&errorWrapper{}, metadataRetrieverID, middleware.Before) }

func GetARNResourceFromContext(ctx context.Context) (arn.ARN, bool)

GetARNResourceFromContext returns an ARN from context and a bool indicating presence of ARN on ctx.

Scoped to stack values. Use github.com/aws/smithy-go/middleware#ClearStackValues to clear all stack values.



69
70
71
72
// File 'service/internal/s3shared/arn_lookup.go', line 69

func GetARNResourceFromContext(ctx context.Context) (arn.ARN, bool) { v, ok := middleware.GetStackValue(ctx, arnResourceKey{}).(arn.ARN) return v, ok }

func GetErrorResponseComponents(r io.Reader, options ErrorResponseDeserializerOptions) (ErrorComponents, error)

GetErrorResponseComponents retrieves error components according to passed in options



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// File 'service/internal/s3shared/xml_utils.go', line 51

func GetErrorResponseComponents(r io.Reader, options ErrorResponseDeserializerOptions) (ErrorComponents, error) { var errComponents ErrorComponents var err error if options.IsWrappedWithErrorTag { errComponents, err = GetWrappedErrorResponseComponents(r) } else { errComponents, err = GetUnwrappedErrorResponseComponents(r) } if err != nil { return ErrorComponents{}, err } // If an error code or message is not retrieved, it is derived from the http status code // eg, for S3 service, we derive err code and message, if none is found if options.UseStatusCode && len(errComponents.Code) == 0 && len(errComponents.Message) == 0 { // derive code and message from status code statusText := http.StatusText(options.StatusCode) errComponents.Code = strings.Replace(statusText, " ", "", -1) errComponents.Message = statusText } return errComponents, nil }

func GetHostIDMetadata(metadata middleware.Metadata) (string, bool)

GetHostIDMetadata retrieves the host id from middleware metadata returns host id as string along with a boolean indicating presence of hostId on middleware metadata.



18
19
20
21
22
23
24
25
26
27
28
// File 'service/internal/s3shared/host_id.go', line 18

func GetHostIDMetadata(metadata middleware.Metadata) (string, bool) { if !metadata.Has(hostID{}) { return "", false } v, ok := metadata.Get(hostID{}).(string) if !ok { return "", true } return v, true }

func GetUnwrappedErrorResponseComponents(r io.Reader) (ErrorComponents, error)

GetUnwrappedErrorResponseComponents returns the error fields from an xml error response body



20
21
22
23
24
25
26
// File 'service/internal/s3shared/xml_utils.go', line 20

func GetUnwrappedErrorResponseComponents(r io.Reader) (ErrorComponents, error) { var errComponents ErrorComponents if err := xml.NewDecoder(r).Decode(&errComponents); err != nil && err != io.EOF { return ErrorComponents{}, fmt.Errorf("error while deserializing xml error response : %w", err) } return errComponents, nil }

func GetWrappedErrorResponseComponents(r io.Reader) (ErrorComponents, error)

GetWrappedErrorResponseComponents returns the error fields from an xml error response body in which error code, and message are wrapped by a <Error> tag



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// File 'service/internal/s3shared/xml_utils.go', line 30

func GetWrappedErrorResponseComponents(r io.Reader) (ErrorComponents, error) { var errComponents struct { Code string `xml:"Error>Code"` Message string `xml:"Error>Message"` RequestID string `xml:"RequestId"` HostID string `xml:"HostId"` } if err := xml.NewDecoder(r).Decode(&errComponents); err != nil && err != io.EOF { return ErrorComponents{}, fmt.Errorf("error while deserializing xml error response : %w", err) } return ErrorComponents{ Code: errComponents.Code, Message: errComponents.Message, RequestID: errComponents.RequestID, HostID: errComponents.HostID, }, nil }

func IsClonedInput(ctx context.Context) bool

IsClonedInput retrieves if context key for cloned input was set. If set, we can infer that the reuqest input was cloned previously.

Scoped to stack values. Use github.com/aws/smithy-go/middleware#ClearStackValues to clear all stack values.



24
25
26
27
// File 'service/internal/s3shared/metadata.go', line 24

func IsClonedInput(ctx context.Context) bool { v, _ := middleware.GetStackValue(ctx, clonedInputKey{}).(bool) return v }

func IsFIPS(region string) bool

IsFIPS returns true if region is a fips pseudo-region

Deprecated: FIPS should be specified via EndpointOptions.



73
74
75
76
// File 'service/internal/s3shared/resource_request.go', line 73

func IsFIPS(region string) bool { return strings.HasPrefix(region, "fips-") || strings.HasSuffix(region, "-fips") }

func NewClientConfiguredForAccelerateError(resource arn.Resource, clientPartitionID, clientRegion string, err error) ConfigurationError

NewClientConfiguredForAccelerateError denotes client config error for unsupported S3 accelerate



152
153
154
155
156
157
158
159
160
// File 'service/internal/s3shared/endpoint_error.go', line 152

func NewClientConfiguredForAccelerateError(resource arn.Resource, clientPartitionID, clientRegion string, err error) ConfigurationError { return ConfigurationError{ message: "client configured for S3 Accelerate but is not supported with resource ARN", origErr: err, resource: resource, clientPartitionID: clientPartitionID, clientRegion: clientRegion, } }

func NewClientConfiguredForCrossRegionFIPSError(resource arn.Resource, clientPartitionID, clientRegion string, err error) ConfigurationError

NewClientConfiguredForCrossRegionFIPSError denotes client config error for unsupported cross region FIPS request



163
164
165
166
167
168
169
170
171
// File 'service/internal/s3shared/endpoint_error.go', line 163

func NewClientConfiguredForCrossRegionFIPSError(resource arn.Resource, clientPartitionID, clientRegion string, err error) ConfigurationError { return ConfigurationError{ message: "client configured for FIPS with cross-region enabled but is supported with cross-region resource ARN", origErr: err, resource: resource, clientPartitionID: clientPartitionID, clientRegion: clientRegion, } }

func NewClientConfiguredForDualStackError(resource arn.Resource, clientPartitionID, clientRegion string, err error) ConfigurationError

NewClientConfiguredForDualStackError denotes client config error for unsupported S3 Dual-stack



174
175
176
177
178
179
180
181
182
// File 'service/internal/s3shared/endpoint_error.go', line 174

func NewClientConfiguredForDualStackError(resource arn.Resource, clientPartitionID, clientRegion string, err error) ConfigurationError { return ConfigurationError{ message: "client configured for S3 Dual-stack but is not supported with resource ARN", origErr: err, resource: resource, clientPartitionID: clientPartitionID, clientRegion: clientRegion, } }

func NewClientConfiguredForFIPSError(resource arn.Resource, clientPartitionID, clientRegion string, err error) ConfigurationError

NewClientConfiguredForFIPSError denotes client config error for unsupported cross region FIPS access



130
131
132
133
134
135
136
137
138
// File 'service/internal/s3shared/endpoint_error.go', line 130

func NewClientConfiguredForFIPSError(resource arn.Resource, clientPartitionID, clientRegion string, err error) ConfigurationError { return ConfigurationError{ message: "client configured for fips but cross-region resource ARN provided", origErr: err, resource: resource, clientPartitionID: clientPartitionID, clientRegion: clientRegion, } }

func NewClientPartitionMismatchError(resource arn.Resource, clientPartitionID, clientRegion string, err error) ConfigurationError

NewClientPartitionMismatchError stub



97
98
99
100
101
102
103
104
105
// File 'service/internal/s3shared/endpoint_error.go', line 97

func NewClientPartitionMismatchError(resource arn.Resource, clientPartitionID, clientRegion string, err error) ConfigurationError { return ConfigurationError{ message: "client partition does not match provided ARN partition", origErr: err, resource: resource, clientPartitionID: clientPartitionID, clientRegion: clientRegion, } }

func NewClientRegionMismatchError(resource arn.Resource, clientPartitionID, clientRegion string, err error) ConfigurationError

NewClientRegionMismatchError denotes cross region access error



108
109
110
111
112
113
114
115
116
// File 'service/internal/s3shared/endpoint_error.go', line 108

func NewClientRegionMismatchError(resource arn.Resource, clientPartitionID, clientRegion string, err error) ConfigurationError { return ConfigurationError{ message: "client region does not match provided ARN region", origErr: err, resource: resource, clientPartitionID: clientPartitionID, clientRegion: clientRegion, } }

func NewFailedToResolveEndpointError(resource arn.Resource, clientPartitionID, clientRegion string, err error) ConfigurationError

NewFailedToResolveEndpointError denotes endpoint resolving error



119
120
121
122
123
124
125
126
127
// File 'service/internal/s3shared/endpoint_error.go', line 119

func NewFailedToResolveEndpointError(resource arn.Resource, clientPartitionID, clientRegion string, err error) ConfigurationError { return ConfigurationError{ message: "endpoint resolver failed to find an endpoint for the provided ARN region", origErr: err, resource: resource, clientPartitionID: clientPartitionID, clientRegion: clientRegion, } }

func NewFIPSConfigurationError(resource arn.Resource, clientPartitionID, clientRegion string, err error) ConfigurationError

NewFIPSConfigurationError denotes a configuration error when a client or request is configured for FIPS



141
142
143
144
145
146
147
148
149
// File 'service/internal/s3shared/endpoint_error.go', line 141

func NewFIPSConfigurationError(resource arn.Resource, clientPartitionID, clientRegion string, err error) ConfigurationError { return ConfigurationError{ message: "use of ARN is not supported when client or request is configured for FIPS", origErr: err, resource: resource, clientPartitionID: clientPartitionID, clientRegion: clientRegion, } }

func NewInvalidARNError(resource arn.Resource, err error) InvalidARNError

NewInvalidARNError denotes invalid arn error



42
43
44
45
46
47
48
// File 'service/internal/s3shared/endpoint_error.go', line 42

func NewInvalidARNError(resource arn.Resource, err error) InvalidARNError { return InvalidARNError{ message: "invalid ARN", origErr: err, resource: resource, } }

func NewInvalidARNWithFIPSError(resource arn.Resource, err error) InvalidARNError

NewInvalidARNWithFIPSError ARN not supported for FIPS region

Deprecated: FIPS will not appear in the ARN region component.



62
63
64
65
66
67
68
// File 'service/internal/s3shared/endpoint_error.go', line 62

func NewInvalidARNWithFIPSError(resource arn.Resource, err error) InvalidARNError { return InvalidARNError{ message: "resource ARN not supported for FIPS region", resource: resource, origErr: err, } }

func NewInvalidARNWithUnsupportedPartitionError(resource arn.Resource, err error) InvalidARNError

NewInvalidARNWithUnsupportedPartitionError ARN not supported for the target partition



51
52
53
54
55
56
57
// File 'service/internal/s3shared/endpoint_error.go', line 51

func NewInvalidARNWithUnsupportedPartitionError(resource arn.Resource, err error) InvalidARNError { return InvalidARNError{ message: "resource ARN not supported for the target ARN partition", origErr: err, resource: resource, } }

func SetClonedInputKey(ctx context.Context, value bool) context.Context

SetClonedInputKey sets a key on context to denote input was cloned previously.

Scoped to stack values. Use github.com/aws/smithy-go/middleware#ClearStackValues to clear all stack values.



15
16
17
// File 'service/internal/s3shared/metadata.go', line 15

func SetClonedInputKey(ctx context.Context, value bool) context.Context { return middleware.WithStackValue(ctx, clonedInputKey{}, value) }

func SetHostIDMetadata(metadata *middleware.Metadata, id string)

SetHostIDMetadata sets the provided host id over middleware metadata



11
12
13
// File 'service/internal/s3shared/host_id.go', line 11

func SetHostIDMetadata(metadata *middleware.Metadata, id string) { metadata.Set(hostID{}, id) }