[#223] pkg/client: Add getters for object params

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
Alex Vanin 2020-12-03 16:36:57 +03:00 committed by Alex Vanin
parent 1fe0307711
commit 6db6b569e0

View file

@ -140,6 +140,14 @@ func (p *PutObjectParams) WithObject(v *object.Object) *PutObjectParams {
return p return p
} }
func (p *PutObjectParams) Object() *object.Object {
if p != nil {
return p.obj
}
return nil
}
func (p *PutObjectParams) WithPayloadReader(v io.Reader) *PutObjectParams { func (p *PutObjectParams) WithPayloadReader(v io.Reader) *PutObjectParams {
if p != nil { if p != nil {
p.r = v p.r = v
@ -148,6 +156,14 @@ func (p *PutObjectParams) WithPayloadReader(v io.Reader) *PutObjectParams {
return p return p
} }
func (p *PutObjectParams) PayloadReader() io.Reader {
if p != nil {
return p.r
}
return nil
}
func (c *Client) PutObject(ctx context.Context, p *PutObjectParams, opts ...CallOption) (*object.ID, error) { func (c *Client) PutObject(ctx context.Context, p *PutObjectParams, opts ...CallOption) (*object.ID, error) {
// check remote node version // check remote node version
switch c.remoteNode.Version.Major() { switch c.remoteNode.Version.Major() {
@ -269,6 +285,14 @@ func (p *DeleteObjectParams) WithAddress(v *object.Address) *DeleteObjectParams
return p return p
} }
func (p *DeleteObjectParams) Address() *object.Address {
if p != nil {
return p.addr
}
return nil
}
func (c *Client) DeleteObject(ctx context.Context, p *DeleteObjectParams, opts ...CallOption) error { func (c *Client) DeleteObject(ctx context.Context, p *DeleteObjectParams, opts ...CallOption) error {
// check remote node version // check remote node version
switch c.remoteNode.Version.Major() { switch c.remoteNode.Version.Major() {
@ -342,6 +366,14 @@ func (p *GetObjectParams) WithAddress(v *object.Address) *GetObjectParams {
return p return p
} }
func (p *GetObjectParams) Address() *object.Address {
if p != nil {
return p.addr
}
return nil
}
func (p *GetObjectParams) WithPayloadWriter(w io.Writer) *GetObjectParams { func (p *GetObjectParams) WithPayloadWriter(w io.Writer) *GetObjectParams {
if p != nil { if p != nil {
p.w = w p.w = w
@ -350,6 +382,14 @@ func (p *GetObjectParams) WithPayloadWriter(w io.Writer) *GetObjectParams {
return p return p
} }
func (p *GetObjectParams) PayloadWriter() io.Writer {
if p != nil {
return p.w
}
return nil
}
func (p *GetObjectParams) WithRawFlag(v bool) *GetObjectParams { func (p *GetObjectParams) WithRawFlag(v bool) *GetObjectParams {
if p != nil { if p != nil {
p.raw = v p.raw = v
@ -358,6 +398,14 @@ func (p *GetObjectParams) WithRawFlag(v bool) *GetObjectParams {
return p return p
} }
func (p *GetObjectParams) RawFlag() bool {
if p != nil {
return p.raw
}
return false
}
func (c *Client) GetObject(ctx context.Context, p *GetObjectParams, opts ...CallOption) (*object.Object, error) { func (c *Client) GetObject(ctx context.Context, p *GetObjectParams, opts ...CallOption) (*object.Object, error) {
// check remote node version // check remote node version
switch c.remoteNode.Version.Major() { switch c.remoteNode.Version.Major() {
@ -480,6 +528,14 @@ func (p *ObjectHeaderParams) WithAddress(v *object.Address) *ObjectHeaderParams
return p return p
} }
func (p *ObjectHeaderParams) Address() *object.Address {
if p != nil {
return p.addr
}
return nil
}
func (p *ObjectHeaderParams) WithAllFields() *ObjectHeaderParams { func (p *ObjectHeaderParams) WithAllFields() *ObjectHeaderParams {
if p != nil { if p != nil {
p.short = false p.short = false
@ -488,6 +544,16 @@ func (p *ObjectHeaderParams) WithAllFields() *ObjectHeaderParams {
return p return p
} }
// AllFields return true if parameter set to return all header fields, returns
// false if parameter set to return only main fields of header.
func (p *ObjectHeaderParams) AllFields() bool {
if p != nil {
return !p.short
}
return false
}
func (p *ObjectHeaderParams) WithMainFields() *ObjectHeaderParams { func (p *ObjectHeaderParams) WithMainFields() *ObjectHeaderParams {
if p != nil { if p != nil {
p.short = true p.short = true
@ -504,6 +570,14 @@ func (p *ObjectHeaderParams) WithRawFlag(v bool) *ObjectHeaderParams {
return p return p
} }
func (p *ObjectHeaderParams) RawFlag() bool {
if p != nil {
return p.raw
}
return false
}
func (c *Client) GetObjectHeader(ctx context.Context, p *ObjectHeaderParams, opts ...CallOption) (*object.Object, error) { func (c *Client) GetObjectHeader(ctx context.Context, p *ObjectHeaderParams, opts ...CallOption) (*object.Object, error) {
// check remote node version // check remote node version
switch c.remoteNode.Version.Major() { switch c.remoteNode.Version.Major() {
@ -639,6 +713,14 @@ func (p *RangeDataParams) WithAddress(v *object.Address) *RangeDataParams {
return p return p
} }
func (p *RangeDataParams) Address() *object.Address {
if p != nil {
return p.addr
}
return nil
}
func (p *RangeDataParams) WithRange(v *object.Range) *RangeDataParams { func (p *RangeDataParams) WithRange(v *object.Range) *RangeDataParams {
if p != nil { if p != nil {
p.r = v p.r = v
@ -647,6 +729,14 @@ func (p *RangeDataParams) WithRange(v *object.Range) *RangeDataParams {
return p return p
} }
func (p *RangeDataParams) Range() *object.Range {
if p != nil {
return p.r
}
return nil
}
func (p *RangeDataParams) WithDataWriter(v io.Writer) *RangeDataParams { func (p *RangeDataParams) WithDataWriter(v io.Writer) *RangeDataParams {
if p != nil { if p != nil {
p.w = v p.w = v
@ -655,6 +745,14 @@ func (p *RangeDataParams) WithDataWriter(v io.Writer) *RangeDataParams {
return p return p
} }
func (p *RangeDataParams) DataWriter() io.Writer {
if p != nil {
return p.w
}
return nil
}
func (c *Client) ObjectPayloadRangeData(ctx context.Context, p *RangeDataParams, opts ...CallOption) ([]byte, error) { func (c *Client) ObjectPayloadRangeData(ctx context.Context, p *RangeDataParams, opts ...CallOption) ([]byte, error) {
// check remote node version // check remote node version
switch c.remoteNode.Version.Major() { switch c.remoteNode.Version.Major() {
@ -756,6 +854,14 @@ func (p *RangeChecksumParams) WithAddress(v *object.Address) *RangeChecksumParam
return p return p
} }
func (p *RangeChecksumParams) Address() *object.Address {
if p != nil {
return p.addr
}
return nil
}
func (p *RangeChecksumParams) WithRangeList(rs ...*object.Range) *RangeChecksumParams { func (p *RangeChecksumParams) WithRangeList(rs ...*object.Range) *RangeChecksumParams {
if p != nil { if p != nil {
p.rs = rs p.rs = rs
@ -764,6 +870,14 @@ func (p *RangeChecksumParams) WithRangeList(rs ...*object.Range) *RangeChecksumP
return p return p
} }
func (p *RangeChecksumParams) RangeList() []*object.Range {
if p != nil {
return p.rs
}
return nil
}
func (p *RangeChecksumParams) WithSalt(v []byte) *RangeChecksumParams { func (p *RangeChecksumParams) WithSalt(v []byte) *RangeChecksumParams {
if p != nil { if p != nil {
p.salt = v p.salt = v
@ -772,6 +886,14 @@ func (p *RangeChecksumParams) WithSalt(v []byte) *RangeChecksumParams {
return p return p
} }
func (p *RangeChecksumParams) Salt() []byte {
if p != nil {
return p.salt
}
return nil
}
func (p *RangeChecksumParams) withChecksumType(t checksumType) *RangeChecksumParams { func (p *RangeChecksumParams) withChecksumType(t checksumType) *RangeChecksumParams {
if p != nil { if p != nil {
p.typ = t p.typ = t
@ -923,6 +1045,14 @@ func (p *SearchObjectParams) WithContainerID(v *container.ID) *SearchObjectParam
return p return p
} }
func (p *SearchObjectParams) ContainerID() *container.ID {
if p != nil {
return p.cid
}
return nil
}
func (p *SearchObjectParams) WithSearchFilters(v object.SearchFilters) *SearchObjectParams { func (p *SearchObjectParams) WithSearchFilters(v object.SearchFilters) *SearchObjectParams {
if p != nil { if p != nil {
p.filters = v p.filters = v
@ -931,6 +1061,14 @@ func (p *SearchObjectParams) WithSearchFilters(v object.SearchFilters) *SearchOb
return p return p
} }
func (p *SearchObjectParams) SearchFilters() object.SearchFilters {
if p != nil {
return p.filters
}
return nil
}
func (c *Client) SearchObject(ctx context.Context, p *SearchObjectParams, opts ...CallOption) ([]*object.ID, error) { func (c *Client) SearchObject(ctx context.Context, p *SearchObjectParams, opts ...CallOption) ([]*object.ID, error) {
// check remote node version // check remote node version
switch c.remoteNode.Version.Major() { switch c.remoteNode.Version.Major() {