package client import ( "context" "fmt" apeSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/ape" apemanagerV2 "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/apemanager" rpcapi "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/rpc" "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/rpc/client" sessionV2 "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/session" "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/signature" apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status" ) // PrmAPEManagerRemoveChain groups parameters of APEManagerRemoveChain operation. type PrmAPEManagerRemoveChain struct { XHeaders []string ChainTarget apeSDK.ChainTarget ChainID apeSDK.ChainID } func (prm *PrmAPEManagerRemoveChain) buildRequest(c *Client) (*apemanagerV2.RemoveChainRequest, error) { if len(prm.XHeaders)%2 != 0 { return nil, errorInvalidXHeaders } req := new(apemanagerV2.RemoveChainRequest) reqBody := new(apemanagerV2.RemoveChainRequestBody) reqBody.SetTarget(prm.ChainTarget.ToV2()) reqBody.SetChainID(prm.ChainID) req.SetBody(reqBody) var meta sessionV2.RequestMetaHeader writeXHeadersToMeta(prm.XHeaders, &meta) c.prepareRequest(req, &meta) return req, nil } type ResAPEManagerRemoveChain struct { statusRes } // APEManagerRemoveChain removes Chain with ChainID defined for ChainTarget. func (c *Client) APEManagerRemoveChain(ctx context.Context, prm PrmAPEManagerRemoveChain) (*ResAPEManagerRemoveChain, error) { req, err := prm.buildRequest(c) if err != nil { return nil, err } if err := signature.SignServiceMessage(&c.prm.Key, req); err != nil { return nil, fmt.Errorf("sign request: %w", err) } resp, err := rpcapi.RemoveChain(&c.c, req, client.WithContext(ctx)) if err != nil { return nil, err } var res ResAPEManagerRemoveChain res.st, err = c.processResponse(resp) if err != nil || !apistatus.IsSuccessful(res.st) { return &res, err } return &res, nil }