package arn

import (
	

	
)

// OutpostARN interface that should be satisfied by outpost ARNs
type OutpostARN interface {
	Resource
	GetOutpostID() string
}

// 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:{partition}:s3-outposts:{region}:{accountId}:outpost/{outpostId}/accesspoint/{accesspointName}
//   - example: arn:aws:s3-outposts:us-west-2:012345678901:outpost/op-1234567890123456/accesspoint/myaccesspoint
//
// * Outpost Bucket ARN format:
//   - ARN format: arn:{partition}:s3-outposts:{region}:{accountId}:outpost/{outpostId}/bucket/{bucketName}
//   - 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.
func ( arn.ARN,  []string) (OutpostARN, error) {
	if len(.Region) == 0 {
		return nil, InvalidARNError{ARN: , Reason: "region not set"}
	}

	if isFIPS(.Region) {
		return nil, InvalidARNError{ARN: , Reason: "FIPS region not allowed in ARN"}
	}

	if len(.AccountID) == 0 {
		return nil, InvalidARNError{ARN: , Reason: "account-id not set"}
	}

	// verify if outpost id is present and valid
	if len() == 0 || len(strings.TrimSpace([0])) == 0 {
		return nil, InvalidARNError{ARN: , Reason: "outpost resource-id not set"}
	}

	// verify possible resource type exists
	if len() < 3 {
		return nil, InvalidARNError{
			ARN: , Reason: "incomplete outpost resource type. Expected bucket or access-point resource to be present",
		}
	}

	// Since we know this is a OutpostARN fetch outpostID
	 := strings.TrimSpace([0])

	switch [1] {
	case "accesspoint":
		,  := ParseAccessPointResource(, [2:])
		if  != nil {
			return OutpostAccessPointARN{}, 
		}
		return OutpostAccessPointARN{
			AccessPointARN: ,
			OutpostID:      ,
		}, nil

	case "bucket":
		,  := parseBucketResource(, [2:])
		if  != nil {
			return nil, 
		}
		return OutpostBucketARN{
			ARN:        ,
			BucketName: ,
			OutpostID:  ,
		}, nil

	default:
		return nil, InvalidARNError{ARN: , Reason: "unknown resource set for outpost ARN"}
	}
}

// OutpostAccessPointARN represents outpost access point ARN.
type OutpostAccessPointARN struct {
	AccessPointARN
	OutpostID string
}

// GetOutpostID returns the outpost id of outpost access point arn
func ( OutpostAccessPointARN) () string {
	return .OutpostID
}

// OutpostBucketARN represents the outpost bucket ARN.
type OutpostBucketARN struct {
	arn.ARN
	BucketName string
	OutpostID  string
}

// GetOutpostID returns the outpost id of outpost bucket arn
func ( OutpostBucketARN) () string {
	return .OutpostID
}

// GetARN retrives the base ARN from outpost bucket ARN resource
func ( OutpostBucketARN) () arn.ARN {
	return .ARN
}

// parseBucketResource attempts to parse the ARN's bucket resource and retrieve the
// bucket resource id.
//
// parseBucketResource only parses the bucket resource id.
func ( arn.ARN,  []string) ( string,  error) {
	if len() == 0 {
		return , InvalidARNError{ARN: , Reason: "bucket resource-id not set"}
	}
	if len() > 1 {
		return , InvalidARNError{ARN: , Reason: "sub resource not supported"}
	}

	 = strings.TrimSpace([0])
	if len() == 0 {
		return , InvalidARNError{ARN: , Reason: "bucket resource-id not set"}
	}
	return , 
}