hashicorp / vault-client-go

HashiCorp Vault Go Client Library generated from OpenAPI spec.
Mozilla Public License 2.0
84 stars 17 forks source link

Auth.AwsWriteAuthRole usage documentation incorrect #167

Closed MushiTheMoshi closed 1 year ago

MushiTheMoshi commented 1 year ago

Expected Behavior

I can read auth/aws/role/ROLE like vault read auth/aws/role/ROLE

Current Behavior

Types from the documentation are not matching

Failure Information

    role := "ROLE"
    request := schema.NewAwsWriteAuthRoleRequestWithDefaults()
    resp2, err := client.Auth.AwsWriteAuthRole(
        context.Background(),
        role,
        request,
        vault.WithToken(resp.Auth.ClientToken),
        vault.WithMountPath("aws"),
    )
    if err != nil {
        log.Fatal(err)
    }

Please include the version of Vault binary and the version of vault-client-go you're using. github.com/hashicorp/vault-client-go v0.3.0

Error:

cannot use request (variable of type *schema.AwsWriteAuthRoleRequest) as type schema.AwsWriteAuthRoleRequest in argument to client.Auth.AwsWriteAuthRole

Hope you can help me.

Regards, Julio

MushiTheMoshi commented 1 year ago

additionally I am reading this piece of doc: https://github.com/hashicorp/vault-client-go/blob/main/docs/AuthApi.md#awswriteauthrole

averche commented 1 year ago

Hi @MushiTheMoshi,

The generated docs are not quite correct here. Currently the request is passed by value. We are considering changing that in the future versions. The current syntax is:

resp2, err := client.Auth.AwsWriteAuthRole(
        context.Background(),
        role,
        *request,
        vault.WithToken(resp.Auth.ClientToken),
        vault.WithMountPath("aws"),
)

Alternatively:

resp2, err := client.Auth.AwsWriteAuthRole(
        context.Background(),
        role,
        AwsWriteRoleRequest{
              // populate request parameters
        },
        vault.WithToken(resp.Auth.ClientToken),
        vault.WithMountPath("aws"),
)
MushiTheMoshi commented 1 year ago

Hi there, that fixed the issue, though I just realize that the method I needed is client.Auth.AwsListAuthRoles which is having the same problem documentation is not having correct info, can you please share how should I use client.Auth.AwsListAuthRoles?

getting: cannot use ROLE (variable of type string) as type vault.RequestOption in argument to client.Auth.AwsListAuthRoles