[#197] sdk: Rename getters of Version type

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2020-11-16 11:08:47 +03:00 committed by Alex Vanin
parent f886d75560
commit 2bcbd48972
7 changed files with 30 additions and 30 deletions

View file

@ -25,7 +25,7 @@ func (c Client) GetSelfBalance(ctx context.Context, opts ...CallOption) (*accoun
func (c Client) GetBalance(ctx context.Context, owner *owner.ID, opts ...CallOption) (*accounting.Decimal, error) { func (c Client) GetBalance(ctx context.Context, owner *owner.ID, opts ...CallOption) (*accounting.Decimal, error) {
// check remote node version // check remote node version
switch c.remoteNode.Version.GetMajor() { switch c.remoteNode.Version.Major() {
case 2: case 2:
return c.getBalanceV2(ctx, owner, opts...) return c.getBalanceV2(ctx, owner, opts...)
default: default:

View file

@ -27,7 +27,7 @@ func (c delContainerSignWrapper) SignedDataSize() int {
} }
func (c Client) PutContainer(ctx context.Context, cnr *container.Container, opts ...CallOption) (*container.ID, error) { func (c Client) PutContainer(ctx context.Context, cnr *container.Container, opts ...CallOption) (*container.ID, error) {
switch c.remoteNode.Version.GetMajor() { switch c.remoteNode.Version.Major() {
case 2: case 2:
return c.putContainerV2(ctx, cnr, opts...) return c.putContainerV2(ctx, cnr, opts...)
default: default:
@ -36,7 +36,7 @@ func (c Client) PutContainer(ctx context.Context, cnr *container.Container, opts
} }
func (c Client) GetContainer(ctx context.Context, id *container.ID, opts ...CallOption) (*container.Container, error) { func (c Client) GetContainer(ctx context.Context, id *container.ID, opts ...CallOption) (*container.Container, error) {
switch c.remoteNode.Version.GetMajor() { switch c.remoteNode.Version.Major() {
case 2: case 2:
return c.getContainerV2(ctx, id, opts...) return c.getContainerV2(ctx, id, opts...)
default: default:
@ -45,7 +45,7 @@ func (c Client) GetContainer(ctx context.Context, id *container.ID, opts ...Call
} }
func (c Client) ListContainers(ctx context.Context, owner *owner.ID, opts ...CallOption) ([]*container.ID, error) { func (c Client) ListContainers(ctx context.Context, owner *owner.ID, opts ...CallOption) ([]*container.ID, error) {
switch c.remoteNode.Version.GetMajor() { switch c.remoteNode.Version.Major() {
case 2: case 2:
return c.listContainerV2(ctx, owner, opts...) return c.listContainerV2(ctx, owner, opts...)
default: default:
@ -66,7 +66,7 @@ func (c Client) ListSelfContainers(ctx context.Context, opts ...CallOption) ([]*
} }
func (c Client) DeleteContainer(ctx context.Context, id *container.ID, opts ...CallOption) error { func (c Client) DeleteContainer(ctx context.Context, id *container.ID, opts ...CallOption) error {
switch c.remoteNode.Version.GetMajor() { switch c.remoteNode.Version.Major() {
case 2: case 2:
return c.delContainerV2(ctx, id, opts...) return c.delContainerV2(ctx, id, opts...)
default: default:
@ -75,7 +75,7 @@ func (c Client) DeleteContainer(ctx context.Context, id *container.ID, opts ...C
} }
func (c Client) GetEACL(ctx context.Context, id *container.ID, opts ...CallOption) (*eacl.Table, error) { func (c Client) GetEACL(ctx context.Context, id *container.ID, opts ...CallOption) (*eacl.Table, error) {
switch c.remoteNode.Version.GetMajor() { switch c.remoteNode.Version.Major() {
case 2: case 2:
return c.getEACLV2(ctx, id, opts...) return c.getEACLV2(ctx, id, opts...)
default: default:
@ -84,7 +84,7 @@ func (c Client) GetEACL(ctx context.Context, id *container.ID, opts ...CallOptio
} }
func (c Client) SetEACL(ctx context.Context, eacl *eacl.Table, opts ...CallOption) error { func (c Client) SetEACL(ctx context.Context, eacl *eacl.Table, opts ...CallOption) error {
switch c.remoteNode.Version.GetMajor() { switch c.remoteNode.Version.Major() {
case 2: case 2:
return c.setEACLV2(ctx, eacl, opts...) return c.setEACLV2(ctx, eacl, opts...)
default: default:

View file

@ -14,7 +14,7 @@ import (
// in client constructor via address or open connection. This can be used as a // in client constructor via address or open connection. This can be used as a
// health check to see if node is alive and responses to requests. // health check to see if node is alive and responses to requests.
func (c Client) EndpointInfo(ctx context.Context, opts ...CallOption) (*netmap.NodeInfo, error) { func (c Client) EndpointInfo(ctx context.Context, opts ...CallOption) (*netmap.NodeInfo, error) {
switch c.remoteNode.Version.GetMajor() { switch c.remoteNode.Version.Major() {
case 2: case 2:
resp, err := c.endpointInfoV2(ctx, opts...) resp, err := c.endpointInfoV2(ctx, opts...)
if err != nil { if err != nil {
@ -29,7 +29,7 @@ func (c Client) EndpointInfo(ctx context.Context, opts ...CallOption) (*netmap.N
// Epoch returns the epoch number from the local state of the remote host. // Epoch returns the epoch number from the local state of the remote host.
func (c Client) Epoch(ctx context.Context, opts ...CallOption) (uint64, error) { func (c Client) Epoch(ctx context.Context, opts ...CallOption) (uint64, error) {
switch c.remoteNode.Version.GetMajor() { switch c.remoteNode.Version.Major() {
case 2: case 2:
resp, err := c.endpointInfoV2(ctx, opts...) resp, err := c.endpointInfoV2(ctx, opts...)
if err != nil { if err != nil {

View file

@ -144,7 +144,7 @@ func (p *PutObjectParams) WithPayloadReader(v io.Reader) *PutObjectParams {
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.GetMajor() { switch c.remoteNode.Version.Major() {
case 2: case 2:
return c.putObjectV2(ctx, p, opts...) return c.putObjectV2(ctx, p, opts...)
default: default:
@ -264,7 +264,7 @@ func (p *DeleteObjectParams) WithAddress(v *object.Address) *DeleteObjectParams
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.GetMajor() { switch c.remoteNode.Version.Major() {
case 2: case 2:
return c.deleteObjectV2(ctx, p, opts...) return c.deleteObjectV2(ctx, p, opts...)
default: default:
@ -344,7 +344,7 @@ func (p *GetObjectParams) WithPayloadWriter(w io.Writer) *GetObjectParams {
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.GetMajor() { switch c.remoteNode.Version.Major() {
case 2: case 2:
return c.getObjectV2(ctx, p, opts...) return c.getObjectV2(ctx, p, opts...)
default: default:
@ -477,7 +477,7 @@ func (p *ObjectHeaderParams) WithMainFields() *ObjectHeaderParams {
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.GetMajor() { switch c.remoteNode.Version.Major() {
case 2: case 2:
return c.getObjectHeaderV2(ctx, p, opts...) return c.getObjectHeaderV2(ctx, p, opts...)
default: default:
@ -610,7 +610,7 @@ func (p *RangeDataParams) WithDataWriter(v io.Writer) *RangeDataParams {
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.GetMajor() { switch c.remoteNode.Version.Major() {
case 2: case 2:
return c.objectPayloadRangeV2(ctx, p, opts...) return c.objectPayloadRangeV2(ctx, p, opts...)
default: default:
@ -752,7 +752,7 @@ func (c *Client) ObjectPayloadRangeTZ(ctx context.Context, p *RangeChecksumParam
func (c *Client) objectPayloadRangeHash(ctx context.Context, p *RangeChecksumParams, opts ...CallOption) (interface{}, error) { func (c *Client) objectPayloadRangeHash(ctx context.Context, p *RangeChecksumParams, opts ...CallOption) (interface{}, error) {
// check remote node version // check remote node version
switch c.remoteNode.Version.GetMajor() { switch c.remoteNode.Version.Major() {
case 2: case 2:
return c.objectPayloadRangeHashV2(ctx, p, opts...) return c.objectPayloadRangeHashV2(ctx, p, opts...)
default: default:
@ -884,7 +884,7 @@ func (p *SearchObjectParams) WithSearchFilters(v object.SearchFilters) *SearchOb
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.GetMajor() { switch c.remoteNode.Version.Major() {
case 2: case 2:
return c.searchObjectV2(ctx, p, opts...) return c.searchObjectV2(ctx, p, opts...)
default: default:

View file

@ -12,7 +12,7 @@ import (
) )
func (c Client) CreateSession(ctx context.Context, expiration uint64, opts ...CallOption) (*token.SessionToken, error) { func (c Client) CreateSession(ctx context.Context, expiration uint64, opts ...CallOption) (*token.SessionToken, error) {
switch c.remoteNode.Version.GetMajor() { switch c.remoteNode.Version.Major() {
case 2: case 2:
return c.createSessionV2(ctx, expiration, opts...) return c.createSessionV2(ctx, expiration, opts...)
default: default:

View file

@ -34,8 +34,8 @@ func SDKVersion() *Version {
return v return v
} }
// GetMajor returns major number of the revision. // Major returns major number of the revision.
func (v *Version) GetMajor() uint32 { func (v *Version) Major() uint32 {
return (*refs.Version)(v). return (*refs.Version)(v).
GetMajor() GetMajor()
} }
@ -46,8 +46,8 @@ func (v *Version) SetMajor(val uint32) {
SetMajor(val) SetMajor(val)
} }
// GetMinor returns minor number of the revision. // Minor returns minor number of the revision.
func (v *Version) GetMinor() uint32 { func (v *Version) Minor() uint32 {
return (*refs.Version)(v). return (*refs.Version)(v).
GetMinor() GetMinor()
} }
@ -64,22 +64,22 @@ func (v *Version) ToV2() *refs.Version {
} }
func (v *Version) String() string { func (v *Version) String() string {
return fmt.Sprintf("v%d.%d", v.GetMajor(), v.GetMinor()) return fmt.Sprintf("v%d.%d", v.Major(), v.Minor())
} }
// IsSupportedVersion returns error if v is not supported by current SDK. // IsSupportedVersion returns error if v is not supported by current SDK.
func IsSupportedVersion(v *Version) error { func IsSupportedVersion(v *Version) error {
switch mjr := v.GetMajor(); mjr { switch mjr := v.Major(); mjr {
case 2: case 2:
switch mnr := v.GetMinor(); mnr { switch mnr := v.Minor(); mnr {
case 0: case 0:
return nil return nil
} }
} }
return errors.Errorf("unsupported version %d.%d", return errors.Errorf("unsupported version %d.%d",
v.GetMajor(), v.Major(),
v.GetMinor(), v.Minor(),
) )
} }

View file

@ -14,8 +14,8 @@ func TestNewVersionFromV2(t *testing.T) {
v.SetMajor(mjr) v.SetMajor(mjr)
v.SetMinor(mnr) v.SetMinor(mnr)
require.Equal(t, mjr, v.GetMajor()) require.Equal(t, mjr, v.Major())
require.Equal(t, mnr, v.GetMinor()) require.Equal(t, mnr, v.Minor())
ver := v.ToV2() ver := v.ToV2()
@ -26,8 +26,8 @@ func TestNewVersionFromV2(t *testing.T) {
func TestSDKVersion(t *testing.T) { func TestSDKVersion(t *testing.T) {
v := SDKVersion() v := SDKVersion()
require.Equal(t, uint32(sdkMjr), v.GetMajor()) require.Equal(t, uint32(sdkMjr), v.Major())
require.Equal(t, uint32(sdkMnr), v.GetMinor()) require.Equal(t, uint32(sdkMnr), v.Minor())
} }
func TestIsSupportedVersion(t *testing.T) { func TestIsSupportedVersion(t *testing.T) {