Package: arn

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

Type Summary collapse

Interface Summary collapse

Function Summary collapse

Function Details

func GetARNField(input interface{}) (*string, bool)

GetARNField would be called during middleware execution to retrieve a member value that is an ARN in need of processing.



15
16
17
18
19
20
21
// File 'service/internal/s3shared/arn/arn_member.go', line 15

func GetARNField(input interface{}) (*string, bool) { v, ok := input.(arnable) if !ok { return nil, false } return v.GetARNMember() }

func IsARN(s string) bool

IsARN returns whether the given string is an ARN



71
72
73
// File 'service/internal/s3shared/arn/arn.go', line 71

func IsARN(s string) bool { return arn.IsARN(s) }

func ParseAccessPointResource(a arn.ARN, resParts []string) (AccessPointARN, error)

ParseAccessPointResource attempts to parse the ARN’s resource as an AccessPoint resource.

Supported Access point resource format: - Access point format: arn:service/internal/s3shared/arnpartition:s3:service/internal/s3shared/arnregion:service/internal/s3shared/arnaccountId:accesspoint/service/internal/s3shared/arnaccesspointName - example: arn:aws:s3:us-west-2:012345678901:accesspoint/myaccesspoint



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// File 'service/internal/s3shared/arn/accesspoint_arn.go', line 25

func ParseAccessPointResource(a arn.ARN, resParts []string) (AccessPointARN, error) { if isFIPS(a.Region) { return AccessPointARN{}, InvalidARNError{ARN: a, Reason: "FIPS region not allowed in ARN"} } if len(a.AccountID) == 0 { return AccessPointARN{}, InvalidARNError{ARN: a, Reason: "account-id not set"} } if len(resParts) == 0 { return AccessPointARN{}, InvalidARNError{ARN: a, Reason: "resource-id not set"} } if len(resParts) > 1 { return AccessPointARN{}, InvalidARNError{ARN: a, Reason: "sub resource not supported"} } resID := resParts[0] if len(strings.TrimSpace(resID)) == 0 { return AccessPointARN{}, InvalidARNError{ARN: a, Reason: "resource-id not set"} } return AccessPointARN{ ARN: a, AccessPointName: resID, }, nil }

func ParseOutpostARNResource(a arn.ARN, resParts []string) (OutpostARN, error)

ParseOutpostARNResource will parse a provided ARNs resource using the appropriate ARN format and return a specific OutpostARN type

Currently supported outpost ARN formats: * Outpost AccessPoint ARN format: - ARN format: arn:service/internal/s3shared/arnpartition:s3-outposts:service/internal/s3shared/arnregion:service/internal/s3shared/arnaccountId:outpost/service/internal/s3shared/arnoutpostId/accesspoint/service/internal/s3shared/arnaccesspointName - example: arn:aws:s3-outposts:us-west-2:012345678901:outpost/op-1234567890123456/accesspoint/myaccesspoint

  • Outpost Bucket ARN format:

  • ARN format: arn:service/internal/s3shared/arnpartition:s3-outposts:service/internal/s3shared/arnregion:service/internal/s3shared/arnaccountId:outpost/service/internal/s3shared/arnoutpostId/bucket/service/internal/s3shared/arnbucketName

  • example: arn:aws:s3-outposts:us-west-2:012345678901:outpost/op-1234567890123456/bucket/mybucket

Other outpost ARN formats may be supported and added in the future.



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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
76
77
78
79
80
// File 'service/internal/s3shared/arn/outpost_arn.go', line 27

func ParseOutpostARNResource(a arn.ARN, resParts []string) (OutpostARN, error) { if len(a.Region) == 0 { return nil, InvalidARNError{ARN: a, Reason: "region not set"} } if isFIPS(a.Region) { return nil, InvalidARNError{ARN: a, Reason: "FIPS region not allowed in ARN"} } if len(a.AccountID) == 0 { return nil, InvalidARNError{ARN: a, Reason: "account-id not set"} } // verify if outpost id is present and valid if len(resParts) == 0 || len(strings.TrimSpace(resParts[0])) == 0 { return nil, InvalidARNError{ARN: a, Reason: "outpost resource-id not set"} } // verify possible resource type exists if len(resParts) < 3 { return nil, InvalidARNError{ ARN: a, Reason: "incomplete outpost resource type. Expected bucket or access-point resource to be present", } } // Since we know this is a OutpostARN fetch outpostID outpostID := strings.TrimSpace(resParts[0]) switch resParts[1] { case "accesspoint": accesspointARN, err := ParseAccessPointResource(a, resParts[2:]) if err != nil { return OutpostAccessPointARN{}, err } return OutpostAccessPointARN{ AccessPointARN: accesspointARN, OutpostID: outpostID, }, nil case "bucket": bucketName, err := parseBucketResource(a, resParts[2:]) if err != nil { return nil, err } return OutpostBucketARN{ ARN: a, BucketName: bucketName, OutpostID: outpostID, }, nil default: return nil, InvalidARNError{ARN: a, Reason: "unknown resource set for outpost ARN"} } }

func ParseResource(a arn.ARN, resParser ResourceParser) (resARN Resource, err error)

ParseResource parses an AWS ARN into a typed resource for the S3 API.



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// File 'service/internal/s3shared/arn/arn.go', line 36

func ParseResource(a arn.ARN, resParser ResourceParser) (resARN Resource, err error) { if len(a.Partition) == 0 { return nil, InvalidARNError{ARN: a, Reason: "partition not set"} } if !isSupportedServiceARN(a.Service) { return nil, InvalidARNError{ARN: a, Reason: "service is not supported"} } if len(a.Resource) == 0 { return nil, InvalidARNError{ARN: a, Reason: "resource not set"} } return resParser(a) }

func SetARNField(input interface{}, v string) error

SetARNField would called during middleware exeuction to set a member value that required ARN processing.



25
26
27
28
29
30
31
// File 'service/internal/s3shared/arn/arn_member.go', line 25

func SetARNField(input interface{}, v string) error { params, ok := input.(arnable) if !ok { return fmt.Errorf("Params does not contain arn field member") } return params.SetARNMember(v) }

func SplitResource(v string) []string

SplitResource splits the resource components by the ARN resource delimiters.



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// File 'service/internal/s3shared/arn/arn.go', line 53

func SplitResource(v string) []string { var parts []string var offset int for offset <= len(v) { idx := strings.IndexAny(v[offset:], "/:") if idx < 0 { parts = append(parts, v[offset:]) break } parts = append(parts, v[offset:idx+offset]) offset += idx + 1 } return parts }