opensearch-go icon indicating copy to clipboard operation
opensearch-go copied to clipboard

[FEATURE] Make all response structs their own type

Open Jakob3xD opened this issue 7 months ago • 0 comments

Is your feature request related to a problem?

For example the SnapshotGetResp struct has a field named Snapshots which is an array of struct. I want to write a functions that uses this struct, but it can't be used as it is not its own type. So it can't be referenced in the function arguments. https://github.com/opensearch-project/opensearch-go/blob/main/opensearchapi/api_snapshot-get.go#L43

What solution would you like?

All structs inside Resp types should become their own type.

What alternatives have you considered?

Otherwise I need to redefine the struct on my end instead of using the lib.

Do you have any additional context?

resp, _ := client.Snapshot.Get(ctx, opensearchapi.SnapshotGetReq{xyz})
for _, snapshot := range resp.Snapshots {
    err := someFunction(snapshot)
    if err != nil {
        return err
    }
}

func someFunction(???) error {
    return nil
}

Jakob3xD avatar Jul 09 '24 08:07 Jakob3xD