aws / aws-sdk-go-v2

AWS SDK for the Go programming language.
https://aws.github.io/aws-sdk-go-v2/docs/
Apache License 2.0
2.5k stars 602 forks source link

Add public constant values for Redshift Cluster - ClusterStatus #2645

Closed gogingersnap777 closed 1 month ago

gogingersnap777 commented 1 month ago

Describe the feature

Under service/redshift/types.go, for struct Cluster and member ClusterStatus. Add a constants and a array lookup for all the possible values, instead of just writing them in documentation.

Use Case

When writing a go program to check the status of Redshift clusters, I don't like that I need to hardcode the values that come back from the go sdk. I'd rather reference constants provided by the sdk.

Proposed Solution

I believe the solution should involve making these values constants. There may be more refactor, but I haven't looked too far. I wanted to get this issue up first.

Below is a proposal of changes to service/redshift/types/types.go

Note: The proposal only uses two possible values (available, and cancelling-resize), but their are others

// Enum values for ReservedNodeOfferingType
const (
    ClusterClusterStatusTypeAvailable    ClusterClusterStatusType = "available"
    ClusterClusterStatusTypeCancellingResize ClusterClusterStatusType = "cancelling-resize"
)

// Values returns all known values for ClusterClusterStatusType. Note that this
// can be expanded in the future, and so it is only as up to date as the client.
//
// The ordering of this slice is not guaranteed to be stable across updates.
func (ClusterClusterStatusType) Values() []ClusterClusterStatusType {
    return []ClusterClusterStatusType{
        "available",
        "cancelling-resize",
    }
}

Other Information

Reference to docs with ClusterStatus values - https://pkg.go.dev/github.com/aws/aws-sdk-go-v2/service/redshift@v1.44.3/types#Cluster

Acknowledgements

AWS Go SDK V2 Module Versions Used

module example

go 1.22.3

require ( github.com/aws/aws-sdk-go-v2/config v1.27.15 github.com/aws/aws-sdk-go-v2/service/redshift v1.44.3 )

require ( github.com/aws/aws-sdk-go-v2 v1.27.0 // indirect github.com/aws/aws-sdk-go-v2/credentials v1.17.15 // indirect github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.3 // indirect github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.7 // indirect github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.7 // indirect github.com/aws/aws-sdk-go-v2/internal/ini v1.8.0 // indirect github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.2 // indirect github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.9 // indirect github.com/aws/aws-sdk-go-v2/service/sso v1.20.8 // indirect github.com/aws/aws-sdk-go-v2/service/ssooidc v1.24.2 // indirect github.com/aws/aws-sdk-go-v2/service/sts v1.28.9 // indirect github.com/aws/smithy-go v1.20.2 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect )

Go version used

go version go1.22.3 darwin/amd64

RanVaknin commented 1 month ago

Hi @gogingersnap777 ,

Thanks for reaching out. Unfortunately the SDK team cannot change the data type for any of the APIs. All of the AWS SDKs are code-generated from the model of each AWS service. In this case, the Redshift API is modeled with ClusterStatus as a string rather than an enum, and while I agree that it makes sense to model this as an enum (similar to other status fields that are modeled as enum), a change to a more restrictive type would be considered a backwards incompatible / breaking change from an API perspective so we are unable to upstream your request.

Thanks again, Ran~

github-actions[bot] commented 1 month ago

This issue is now closed. Comments on closed issues are hard for our team to see. If you need more assistance, please open a new issue that references this one.