2021-10-28 14:48:46 +00:00
|
|
|
package internal
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io"
|
|
|
|
|
2022-12-23 17:35:35 +00:00
|
|
|
"github.com/TrueCloudLab/frostfs-sdk-go/bearer"
|
|
|
|
"github.com/TrueCloudLab/frostfs-sdk-go/client"
|
|
|
|
cid "github.com/TrueCloudLab/frostfs-sdk-go/container/id"
|
|
|
|
oid "github.com/TrueCloudLab/frostfs-sdk-go/object/id"
|
|
|
|
"github.com/TrueCloudLab/frostfs-sdk-go/session"
|
2021-10-28 14:48:46 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// here are small structures with public setters to share between parameter structures
|
|
|
|
|
|
|
|
type commonPrm struct {
|
2022-01-13 15:01:50 +00:00
|
|
|
cli *client.Client
|
2021-10-28 14:48:46 +00:00
|
|
|
}
|
|
|
|
|
2023-02-03 16:29:25 +00:00
|
|
|
// SetClient sets the base client for FrostFS API communication.
|
2022-01-13 15:01:50 +00:00
|
|
|
func (x *commonPrm) SetClient(cli *client.Client) {
|
2021-10-28 14:48:46 +00:00
|
|
|
x.cli = cli
|
|
|
|
}
|
|
|
|
|
|
|
|
type containerIDPrm struct {
|
2022-05-31 17:00:41 +00:00
|
|
|
cnrID cid.ID
|
2021-10-28 14:48:46 +00:00
|
|
|
}
|
|
|
|
|
2022-04-21 11:28:05 +00:00
|
|
|
// SetContainerID sets the container identifier.
|
2022-05-31 17:00:41 +00:00
|
|
|
func (x *containerIDPrm) SetContainerID(id cid.ID) {
|
2021-10-28 14:48:46 +00:00
|
|
|
x.cnrID = id
|
|
|
|
}
|
|
|
|
|
|
|
|
type bearerTokenPrm struct {
|
2022-05-12 07:22:02 +00:00
|
|
|
bearerToken *bearer.Token
|
2021-10-28 14:48:46 +00:00
|
|
|
}
|
|
|
|
|
2022-04-21 11:28:05 +00:00
|
|
|
// SetBearerToken sets the bearer token to be attached to the request.
|
2022-05-12 07:22:02 +00:00
|
|
|
func (x *bearerTokenPrm) SetBearerToken(tok *bearer.Token) {
|
2021-10-28 14:48:46 +00:00
|
|
|
x.bearerToken = tok
|
|
|
|
}
|
|
|
|
|
|
|
|
type objectAddressPrm struct {
|
2022-05-31 17:00:41 +00:00
|
|
|
objAddr oid.Address
|
2021-10-28 14:48:46 +00:00
|
|
|
}
|
|
|
|
|
2022-05-31 17:00:41 +00:00
|
|
|
func (x *objectAddressPrm) SetAddress(addr oid.Address) {
|
2021-10-28 14:48:46 +00:00
|
|
|
x.objAddr = addr
|
|
|
|
}
|
|
|
|
|
|
|
|
type rawPrm struct {
|
|
|
|
raw bool
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetRawFlag sets flag of raw request.
|
|
|
|
func (x *rawPrm) SetRawFlag(raw bool) {
|
|
|
|
x.raw = raw
|
|
|
|
}
|
|
|
|
|
|
|
|
type payloadWriterPrm struct {
|
|
|
|
wrt io.Writer
|
|
|
|
}
|
|
|
|
|
2022-04-21 11:28:05 +00:00
|
|
|
// SetPayloadWriter sets the writer of the object payload.
|
2021-10-28 14:48:46 +00:00
|
|
|
func (x *payloadWriterPrm) SetPayloadWriter(wrt io.Writer) {
|
|
|
|
x.wrt = wrt
|
|
|
|
}
|
|
|
|
|
|
|
|
type commonObjectPrm struct {
|
|
|
|
commonPrm
|
|
|
|
bearerTokenPrm
|
|
|
|
|
2022-05-18 15:20:08 +00:00
|
|
|
sessionToken *session.Object
|
|
|
|
|
2022-02-25 09:20:49 +00:00
|
|
|
local bool
|
2022-03-03 12:30:20 +00:00
|
|
|
|
2022-05-18 15:20:08 +00:00
|
|
|
xHeaders []string
|
2021-10-28 14:48:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// SetTTL sets request TTL value.
|
|
|
|
func (x *commonObjectPrm) SetTTL(ttl uint32) {
|
2022-02-25 09:20:49 +00:00
|
|
|
x.local = ttl < 2
|
2021-10-28 14:48:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// SetXHeaders sets request X-Headers.
|
2022-05-18 15:20:08 +00:00
|
|
|
func (x *commonObjectPrm) SetXHeaders(hs []string) {
|
2022-03-03 12:30:20 +00:00
|
|
|
x.xHeaders = hs
|
|
|
|
}
|
|
|
|
|
2022-05-18 15:20:08 +00:00
|
|
|
// SetSessionToken sets the token of the session within which the request should be sent.
|
|
|
|
func (x *commonObjectPrm) SetSessionToken(tok *session.Object) {
|
|
|
|
x.sessionToken = tok
|
2021-10-28 14:48:46 +00:00
|
|
|
}
|