package client import ( "context" v2container "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/container" rpcapi "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc" "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc/client" "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container" ) // PrmAnnounceSpace groups parameters of ContainerAnnounceUsedSpace operation. type PrmAnnounceSpace struct { prmCommonMeta announcements []container.SizeEstimation } // SetValues sets values describing volume of space that is used for the container objects. // Required parameter. Must not be empty. // // Must not be mutated before the end of the operation. func (x *PrmAnnounceSpace) SetValues(vs []container.SizeEstimation) { x.announcements = vs } // ResAnnounceSpace groups resulting values of ContainerAnnounceUsedSpace operation. type ResAnnounceSpace struct { statusRes } // ContainerAnnounceUsedSpace sends request to announce volume of the space used for the container objects. // // Exactly one return value is non-nil. By default, server status is returned in res structure. // Any client's internal or transport errors are returned as `error`. // If PrmInit.ResolveFrostFSFailures has been called, unsuccessful // FrostFS status codes are returned as `error`, otherwise, are included // in the returned result structure. // // Operation is asynchronous and no guaranteed even in the absence of errors. // The required time is also not predictable. // // At this moment success can not be checked. // // Returns an error if parameters are set incorrectly (see PrmAnnounceSpace docs). // Context is required and must not be nil. It is used for network communication. // // Return statuses: // - global (see Client docs). func (c *Client) ContainerAnnounceUsedSpace(ctx context.Context, prm PrmAnnounceSpace) (*ResAnnounceSpace, error) { // check parameters switch { case ctx == nil: return nil, errorMissingContext case len(prm.announcements) == 0: return nil, errorMissingAnnouncements } // convert list of SDK announcement structures into FrostFS-API v2 list v2announce := make([]v2container.UsedSpaceAnnouncement, len(prm.announcements)) for i := range prm.announcements { prm.announcements[i].WriteToV2(&v2announce[i]) } // prepare body of the FrostFS-API v2 request and request itself reqBody := new(v2container.AnnounceUsedSpaceRequestBody) reqBody.SetAnnouncements(v2announce) // form request var req v2container.AnnounceUsedSpaceRequest req.SetBody(reqBody) // init call context var ( cc contextCall res ResAnnounceSpace ) c.initCallContext(&cc) cc.meta = prm.prmCommonMeta cc.req = &req cc.statusRes = &res cc.call = func() (responseV2, error) { return rpcapi.AnnounceUsedSpace(&c.c, &req, client.WithContext(ctx)) } // process call if !cc.processCall() { return nil, cc.err } return &res, nil }