Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added struct SRAddOptions and SREditOptions #230

Merged
merged 3 commits into from
Oct 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 40 additions & 4 deletions cluster-commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,19 @@ type ReplicateAddStatus struct {
InitialSyncErrorMessage string `json:"initialSyncErrorMessage,omitempty"`
}

// SRAddOptions holds SR Add options
type SRAddOptions struct {
ReplicateILMExpiry bool
}

func (o *SRAddOptions) getURLValues() url.Values {
urlValues := make(url.Values)
urlValues.Set("replicateILMExpiry", strconv.FormatBool(o.ReplicateILMExpiry))
return urlValues
}

// SiteReplicationAdd - sends the SR add API call.
func (adm *AdminClient) SiteReplicationAdd(ctx context.Context, sites []PeerSite) (ReplicateAddStatus, error) {
func (adm *AdminClient) SiteReplicationAdd(ctx context.Context, sites []PeerSite, opts SRAddOptions) (ReplicateAddStatus, error) {
sitesBytes, err := json.Marshal(sites)
if err != nil {
return ReplicateAddStatus{}, nil
Expand All @@ -68,7 +79,7 @@ func (adm *AdminClient) SiteReplicationAdd(ctx context.Context, sites []PeerSite
return ReplicateAddStatus{}, err
}

q := make(url.Values)
q := opts.getURLValues()
q.Set("api-version", SiteReplAPIVersion)

reqData := requestData{
Expand Down Expand Up @@ -106,6 +117,7 @@ type SiteReplicationInfo struct {
Name string `json:"name,omitempty"`
Sites []PeerInfo `json:"sites,omitempty"`
ServiceAccountAccessKey string `json:"serviceAccountAccessKey,omitempty"`
ReplicateILMExpiry bool `json:"replicate-ilm-expiry"`
}

// SiteReplicationInfo - returns cluster replication information.
Expand Down Expand Up @@ -419,6 +431,7 @@ const (
SRBucketMetaTypeObjectLockConfig = "object-lock-config"
SRBucketMetaTypeSSEConfig = "sse-config"
SRBucketMetaTypeQuotaConfig = "quota-config"
SRBucketMetaLCConfig = "lc-config"
)

// SRBucketMeta - represents a bucket metadata change that will be copied to a peer.
Expand Down Expand Up @@ -446,8 +459,15 @@ type SRBucketMeta struct {
// Quota has a json representation use it as is.
Quota json.RawMessage `json:"quota,omitempty"`

// Since Expiry Lifecycle config does not have a json representation, we use its xml
// byte respresentation.
ExpiryLCConfig *string `json:"expLCConfig,omitempty"`

// UpdatedAt - timestamp of last update
UpdatedAt time.Time `json:"updatedAt,omitempty"`

// ExpiryUpdatedAt - timestamp of last update of expiry rule
ExpiryUpdatedAt time.Time `json:"expiryUpdatedAt,omitempty"`
}

// SRPeerReplicateBucketMeta - copies a bucket metadata change to a peer cluster.
Expand Down Expand Up @@ -504,6 +524,10 @@ type SRBucketInfo struct {
// quota config in json representation
QuotaConfig *string `json:"quotaConfig,omitempty"`

// Since Expiry Licfecycle config does not have a json representation, we use its xml
// byte representation
ExpiryLCConfig *string `json:"expLCConfig,omitempty"`

// time stamps of bucket metadata updates
PolicyUpdatedAt time.Time `json:"policyTimestamp,omitempty"`
TagConfigUpdatedAt time.Time `json:"tagTimestamp,omitempty"`
Expand All @@ -512,6 +536,7 @@ type SRBucketInfo struct {
VersioningConfigUpdatedAt time.Time `json:"versioningTimestamp,omitempty"`
ReplicationConfigUpdatedAt time.Time `json:"replicationConfigTimestamp,omitempty"`
QuotaConfigUpdatedAt time.Time `json:"quotaTimestamp,omitempty"`
ExpiryLCConfigUpdatedAt time.Time `json:"expLCTimestamp,omitempty"`
CreatedAt time.Time `json:"bucketTimestamp,omitempty"`
DeletedAt time.Time `json:"bucketDeletedTimestamp,omitempty"`
Location string `json:"location,omitempty"`
Expand Down Expand Up @@ -848,8 +873,19 @@ type ReplicateEditStatus struct {
ErrDetail string `json:"errorDetail,omitempty"`
}

// SREditOptions holds SR Edit options
type SREditOptions struct {
DisableILMExpiryReplication bool
}

func (o *SREditOptions) getURLValues() url.Values {
urlValues := make(url.Values)
urlValues.Set("disableILMExpiryReplication", strconv.FormatBool(o.DisableILMExpiryReplication))
return urlValues
}

// SiteReplicationEdit - sends the SR edit API call.
func (adm *AdminClient) SiteReplicationEdit(ctx context.Context, site PeerInfo) (ReplicateEditStatus, error) {
func (adm *AdminClient) SiteReplicationEdit(ctx context.Context, site PeerInfo, opts SREditOptions) (ReplicateEditStatus, error) {
sitesBytes, err := json.Marshal(site)
if err != nil {
return ReplicateEditStatus{}, nil
Expand All @@ -859,7 +895,7 @@ func (adm *AdminClient) SiteReplicationEdit(ctx context.Context, site PeerInfo)
return ReplicateEditStatus{}, err
}

q := make(url.Values)
q := opts.getURLValues()
q.Set("api-version", SiteReplAPIVersion)

reqData := requestData{
Expand Down
Loading