diff --git a/cluster-commands.go b/cluster-commands.go index 84bede4..e75f6e1 100644 --- a/cluster-commands.go +++ b/cluster-commands.go @@ -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 @@ -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{ @@ -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. @@ -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. @@ -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. @@ -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"` @@ -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"` @@ -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 @@ -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{