[#777] client: Refactor PrmContainerList, PrmObjectSearch usage
Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
This commit is contained in:
parent
cae50ecb21
commit
74c91eeef5
5 changed files with 16 additions and 37 deletions
|
@ -689,24 +689,15 @@ func (x SearchObjectsRes) IDList() []oid.ID {
|
|||
//
|
||||
// Returns any error which prevented the operation from completing correctly in error return.
|
||||
func SearchObjects(ctx context.Context, prm SearchObjectsPrm) (*SearchObjectsRes, error) {
|
||||
var cliPrm client.PrmObjectSearch
|
||||
cliPrm.InContainer(prm.cnrID)
|
||||
cliPrm.SetFilters(prm.filters)
|
||||
|
||||
if prm.sessionToken != nil {
|
||||
cliPrm.WithinSession(*prm.sessionToken)
|
||||
cliPrm := client.PrmObjectSearch{
|
||||
XHeaders: prm.xHeaders,
|
||||
Local: prm.local,
|
||||
BearerToken: prm.bearerToken,
|
||||
Session: prm.sessionToken,
|
||||
ContainerID: &prm.cnrID,
|
||||
Filters: prm.filters,
|
||||
}
|
||||
|
||||
if prm.bearerToken != nil {
|
||||
cliPrm.WithBearerToken(*prm.bearerToken)
|
||||
}
|
||||
|
||||
if prm.local {
|
||||
cliPrm.MarkLocal()
|
||||
}
|
||||
|
||||
cliPrm.WithXHeaders(prm.xHeaders...)
|
||||
|
||||
rdr, err := prm.cli.ObjectSearchInit(ctx, cliPrm)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("init object search: %w", err)
|
||||
|
|
|
@ -47,7 +47,7 @@ var listContainersCmd = &cobra.Command{
|
|||
|
||||
var prm internalclient.ListContainersPrm
|
||||
prm.SetClient(cli)
|
||||
prm.SetAccount(idUser)
|
||||
prm.Account = &idUser
|
||||
|
||||
res, err := internalclient.ListContainers(cmd.Context(), prm)
|
||||
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
||||
|
|
2
go.mod
2
go.mod
|
@ -6,7 +6,7 @@ require (
|
|||
git.frostfs.info/TrueCloudLab/frostfs-api-go/v2 v2.16.1-0.20231031104748-498877e378fd
|
||||
git.frostfs.info/TrueCloudLab/frostfs-contract v0.18.1-0.20231102065436-9ed3845aa989
|
||||
git.frostfs.info/TrueCloudLab/frostfs-observability v0.0.0-20230531082742-c97d21411eb6
|
||||
git.frostfs.info/TrueCloudLab/frostfs-sdk-go v0.0.0-20231027075445-a02c0bfac885
|
||||
git.frostfs.info/TrueCloudLab/frostfs-sdk-go v0.0.0-20231101144515-6fbe1595cb3d
|
||||
git.frostfs.info/TrueCloudLab/hrw v1.2.1
|
||||
git.frostfs.info/TrueCloudLab/tzhash v1.8.0
|
||||
github.com/cheggaaa/pb v1.0.29
|
||||
|
|
BIN
go.sum
BIN
go.sum
Binary file not shown.
|
@ -474,12 +474,12 @@ type SearchObjectsPrm struct {
|
|||
//
|
||||
// Required parameter.
|
||||
func (x *SearchObjectsPrm) SetContainerID(id cid.ID) {
|
||||
x.cliPrm.InContainer(id)
|
||||
x.cliPrm.ContainerID = &id
|
||||
}
|
||||
|
||||
// SetFilters sets search filters.
|
||||
func (x *SearchObjectsPrm) SetFilters(fs objectSDK.SearchFilters) {
|
||||
x.cliPrm.SetFilters(fs)
|
||||
x.cliPrm.Filters = fs
|
||||
}
|
||||
|
||||
// SearchObjectsRes groups the resulting values of SearchObjects operation.
|
||||
|
@ -496,23 +496,11 @@ func (x SearchObjectsRes) IDList() []oid.ID {
|
|||
//
|
||||
// Returns any error which prevented the operation from completing correctly in error return.
|
||||
func SearchObjects(ctx context.Context, prm SearchObjectsPrm) (*SearchObjectsRes, error) {
|
||||
if prm.local {
|
||||
prm.cliPrm.MarkLocal()
|
||||
}
|
||||
|
||||
if prm.tokenSession != nil {
|
||||
prm.cliPrm.WithinSession(*prm.tokenSession)
|
||||
}
|
||||
|
||||
if prm.tokenBearer != nil {
|
||||
prm.cliPrm.WithBearerToken(*prm.tokenBearer)
|
||||
}
|
||||
|
||||
prm.cliPrm.WithXHeaders(prm.xHeaders...)
|
||||
|
||||
if prm.key != nil {
|
||||
prm.cliPrm.UseKey(*prm.key)
|
||||
}
|
||||
prm.cliPrm.Local = prm.local
|
||||
prm.cliPrm.Session = prm.tokenSession
|
||||
prm.cliPrm.BearerToken = prm.tokenBearer
|
||||
prm.cliPrm.XHeaders = prm.xHeaders
|
||||
prm.cliPrm.Key = prm.key
|
||||
|
||||
rdr, err := prm.cli.ObjectSearchInit(ctx, prm.cliPrm)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in a new issue