[#121] client: Make PrmContainerDelete fields public

Signed-off-by: Airat Arifullin a.arifullin@yadro.com
This commit is contained in:
Airat Arifullin 2023-08-03 11:42:54 +03:00 committed by Evgenii Stratonikov
parent 3dc8129ed7
commit 9e5faaf829

View file

@ -18,29 +18,33 @@ import (
// PrmContainerDelete groups parameters of ContainerDelete operation. // PrmContainerDelete groups parameters of ContainerDelete operation.
type PrmContainerDelete struct { type PrmContainerDelete struct {
prmCommonMeta // FrostFS request X-Headers
XHeaders []string
idSet bool ContainerID *cid.ID
id cid.ID
tokSet bool Session *session.Container
tok session.Container
} }
// SetContainer sets identifier of the FrostFS container to be removed. // SetContainer sets identifier of the FrostFS container to be removed.
// Required parameter. // Required parameter.
//
// Deprecated: Use PrmContainerDelete.Container instead.
func (x *PrmContainerDelete) SetContainer(id cid.ID) { func (x *PrmContainerDelete) SetContainer(id cid.ID) {
x.id = id x.ContainerID = &id
x.idSet = true
} }
func (x *PrmContainerDelete) buildRequest(c *Client) (*v2container.DeleteRequest, error) { func (prm *PrmContainerDelete) buildRequest(c *Client) (*v2container.DeleteRequest, error) {
if !x.idSet { if prm.ContainerID == nil {
return nil, errorMissingContainer return nil, errorMissingContainer
} }
if len(prm.XHeaders)%2 != 0 {
return nil, errorInvalidXHeaders
}
var cidV2 refs.ContainerID var cidV2 refs.ContainerID
x.id.WriteToV2(&cidV2) prm.ContainerID.WriteToV2(&cidV2)
// Container contract expects signature of container ID value, // Container contract expects signature of container ID value,
// don't get confused with stable marshaled protobuf container.ID structure. // don't get confused with stable marshaled protobuf container.ID structure.
@ -61,11 +65,11 @@ func (x *PrmContainerDelete) buildRequest(c *Client) (*v2container.DeleteRequest
reqBody.SetSignature(&sigv2) reqBody.SetSignature(&sigv2)
var meta v2session.RequestMetaHeader var meta v2session.RequestMetaHeader
writeXHeadersToMeta(x.prmCommonMeta.xHeaders, &meta) writeXHeadersToMeta(prm.XHeaders, &meta)
if x.tokSet { if prm.Session != nil {
var tokv2 v2session.Token var tokv2 v2session.Token
x.tok.WriteToV2(&tokv2) prm.Session.WriteToV2(&tokv2)
meta.SetSessionToken(&tokv2) meta.SetSessionToken(&tokv2)
} }
@ -82,9 +86,10 @@ func (x *PrmContainerDelete) buildRequest(c *Client) (*v2container.DeleteRequest
// This may affect the execution of an operation (e.g. access control). // This may affect the execution of an operation (e.g. access control).
// //
// Must be signed. // Must be signed.
//
// Deprecated: Use PrmContainerDelete.Session instead.
func (x *PrmContainerDelete) WithinSession(tok session.Container) { func (x *PrmContainerDelete) WithinSession(tok session.Container) {
x.tok = tok x.Session = &tok
x.tokSet = true
} }
// ResContainerDelete groups resulting values of ContainerDelete operation. // ResContainerDelete groups resulting values of ContainerDelete operation.