From 9e5faaf8299339198ca4e3ec830f2962617613fa Mon Sep 17 00:00:00 2001 From: Airat Arifullin Date: Thu, 3 Aug 2023 11:42:54 +0300 Subject: [PATCH] [#121] client: Make PrmContainerDelete fields public Signed-off-by: Airat Arifullin a.arifullin@yadro.com --- client/container_delete.go | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/client/container_delete.go b/client/container_delete.go index 0059988d..70d5f40a 100644 --- a/client/container_delete.go +++ b/client/container_delete.go @@ -18,29 +18,33 @@ import ( // PrmContainerDelete groups parameters of ContainerDelete operation. type PrmContainerDelete struct { - prmCommonMeta + // FrostFS request X-Headers + XHeaders []string - idSet bool - id cid.ID + ContainerID *cid.ID - tokSet bool - tok session.Container + Session *session.Container } // SetContainer sets identifier of the FrostFS container to be removed. // Required parameter. +// +// Deprecated: Use PrmContainerDelete.Container instead. func (x *PrmContainerDelete) SetContainer(id cid.ID) { - x.id = id - x.idSet = true + x.ContainerID = &id } -func (x *PrmContainerDelete) buildRequest(c *Client) (*v2container.DeleteRequest, error) { - if !x.idSet { +func (prm *PrmContainerDelete) buildRequest(c *Client) (*v2container.DeleteRequest, error) { + if prm.ContainerID == nil { return nil, errorMissingContainer } + if len(prm.XHeaders)%2 != 0 { + return nil, errorInvalidXHeaders + } + var cidV2 refs.ContainerID - x.id.WriteToV2(&cidV2) + prm.ContainerID.WriteToV2(&cidV2) // Container contract expects signature of container ID value, // 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) var meta v2session.RequestMetaHeader - writeXHeadersToMeta(x.prmCommonMeta.xHeaders, &meta) + writeXHeadersToMeta(prm.XHeaders, &meta) - if x.tokSet { + if prm.Session != nil { var tokv2 v2session.Token - x.tok.WriteToV2(&tokv2) + prm.Session.WriteToV2(&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). // // Must be signed. +// +// Deprecated: Use PrmContainerDelete.Session instead. func (x *PrmContainerDelete) WithinSession(tok session.Container) { - x.tok = tok - x.tokSet = true + x.Session = &tok } // ResContainerDelete groups resulting values of ContainerDelete operation.