From b8a73e9401c9c11854e1dcfec09d11239f6200d5 Mon Sep 17 00:00:00 2001 From: cdoria Date: Fri, 4 Oct 2024 11:20:17 -0400 Subject: [PATCH] Get Specific Replication Pair --- inttests/replication_test.go | 28 ++++++++++++++++++++++++++++ replication.go | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/inttests/replication_test.go b/inttests/replication_test.go index d314361..524fd09 100644 --- a/inttests/replication_test.go +++ b/inttests/replication_test.go @@ -327,6 +327,34 @@ func TestQueryReplicationPairs(t *testing.T) { } } +// Query Specific Replication Pair +func TestQueryReplicationPair(t *testing.T) { + if C2 == nil { + t.Skip("no client connection to replication target system") + } + + pair, err := C.GetReplicationPair(rep.pair.ReplicaitonPair.ID) + assert.Nil(t, err) + assert.NotNil(t, pair) +} + +// Pause and Resume Replication Pair +func TestPauseAndResumeReplicationPair(t *testing.T) { + if C2 == nil { + t.Skip("no client connection to replication target system") + } + + // Pause + pairP, err := C.PausePairInitialCopy(rep.pair.ReplicaitonPair.ID) + assert.Nil(t, err) + assert.NotNil(t, pairP) + + // Resume + pairR, err := C.ResumePairInitialCopy(rep.pair.ReplicaitonPair.ID) + assert.Nil(t, err) + assert.NotNil(t, pairR) +} + // Query Replication Pair Statistics func TestQueryReplicationPairsStatistics(t *testing.T) { if C2 == nil { diff --git a/replication.go b/replication.go index 9f956d0..48cf947 100644 --- a/replication.go +++ b/replication.go @@ -212,6 +212,39 @@ func (c *Client) GetAllReplicationPairs() ([]*types.ReplicationPair, error) { return pairs, err } +// GetReplicationPair returns a specific replication pair on the system. +func (c *Client) GetReplicationPair(id string) (*types.ReplicationPair, error) { + defer TimeSpent("GetReplicationPair", time.Now()) + + path := "/api/instances/ReplicationPair::" + id + + var pair *types.ReplicationPair + err := c.getJSONWithRetry(http.MethodGet, path, nil, &pair) + return pair, err +} + +// PausePairInitialCopy pauses the initial copy of the replication pair. +func (c *Client) PausePairInitialCopy(id string) (*types.ReplicationPair, error) { + defer TimeSpent("PausePairInitialCopy", time.Now()) + + path := "/api/instances/ReplicationPair::" + id + "/action/pauseInitialCopy" + + var pair *types.ReplicationPair + err := c.getJSONWithRetry(http.MethodPost, path, nil, &pair) + return pair, err +} + +// ResumePairInitialCopy resumes the initial copy of the replication pair. +func (c *Client) ResumePairInitialCopy(id string) (*types.ReplicationPair, error) { + defer TimeSpent("ResumePairInitialCopy", time.Now()) + + path := "/api/instances/ReplicationPair::" + id + "/action/resumePairInitialCopy" + + var pair *types.ReplicationPair + err := c.getJSONWithRetry(http.MethodPost, path, nil, &pair) + return pair, err +} + // GetReplicationPairs returns a list of replication pairs associated to the rcg. func (rcg *ReplicationConsistencyGroup) GetReplicationPairs() ([]*types.ReplicationPair, error) { defer TimeSpent("GetReplicationPairs", time.Now())