package s3shared

import (
	
	

	awsarn 
	
)

// ResourceRequest represents an ARN resource and api request metadata
type ResourceRequest struct {
	Resource arn.Resource
	// RequestRegion is the region configured on the request config
	RequestRegion string

	// SigningRegion is the signing region resolved for the request
	SigningRegion string

	// PartitionID is the resolved partition id for the provided request region
	PartitionID string

	// UseARNRegion indicates if client should use the region provided in an ARN resource
	UseARNRegion bool

	// UseFIPS indicates if te client is configured for FIPS
	UseFIPS bool
}

// ARN returns the resource ARN
func ( ResourceRequest) () awsarn.ARN {
	return .Resource.GetARN()
}

// ResourceConfiguredForFIPS returns true if resource ARNs region is FIPS
//
// Deprecated: FIPS will not be present in the ARN region
func ( ResourceRequest) () bool {
	return IsFIPS(.ARN().Region)
}

// AllowCrossRegion returns a bool value to denote if S3UseARNRegion flag is set
func ( ResourceRequest) () bool {
	return .UseARNRegion
}

// IsCrossPartition returns true if request is configured for region of another partition, than
// the partition that resource ARN region resolves to. IsCrossPartition will not return an error,
// if request is not configured with a specific partition id. This might happen if customer provides
// custom endpoint url, but does not associate a partition id with it.
func ( ResourceRequest) () (bool, error) {
	 := .PartitionID
	if len() == 0 {
		return false, nil
	}

	 := .Resource.GetARN().Partition
	if len() == 0 {
		return false, fmt.Errorf("no partition id for provided ARN")
	}

	return !strings.EqualFold(, ), nil
}

// IsCrossRegion returns true if request signing region is not same as arn region
func ( ResourceRequest) () bool {
	 := .SigningRegion
	return !strings.EqualFold(, .Resource.GetARN().Region)
}

// IsFIPS returns true if region is a fips pseudo-region
//
// Deprecated: FIPS should be specified via EndpointOptions.
func ( string) bool {
	return strings.HasPrefix(, "fips-") ||
		strings.HasSuffix(, "-fips")
}