Skip to content

Commit

Permalink
opensearchapi: split SnapshotGetResp into sub structs (#603)
Browse files Browse the repository at this point in the history
Signed-off-by: Jakob Hahn <jakob.hahn@hetzner.com>
  • Loading branch information
Jakob3xD authored Aug 26, 2024
1 parent 2a80891 commit 25d17e8
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 24 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Adds `Suggest` to `SearchResp` ([#602](https://github.com/opensearch-project/opensearch-go/pull/602))

### Changed
- Split SnapshotGetResp into sub structs ([#603](https://github.com/opensearch-project/opensearch-go/pull/603))

### Deprecated

Expand Down
54 changes: 30 additions & 24 deletions opensearchapi/api_snapshot-get.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,33 +40,39 @@ func (r SnapshotGetReq) GetRequest() (*http.Request, error) {

// SnapshotGetResp represents the returned struct of the index create response
type SnapshotGetResp struct {
Snapshots []struct {
Snapshot string `json:"snapshot"`
UUID string `json:"uuid"`
VersionID int `json:"version_id"`
Version string `json:"version"`
RemoteStoreIndexShallowCopy bool `json:"remote_store_index_shallow_copy"`
Indices []string `json:"indices"`
DataStreams []json.RawMessage `json:"data_streams"`
IncludeGlobalState bool `json:"include_global_state"`
Metadata map[string]string `json:"metadata"`
State string `json:"state"`
StartTime string `json:"start_time"`
StartTimeInMillis int64 `json:"start_time_in_millis"`
EndTime string `json:"end_time"`
EndTimeInMillis int64 `json:"end_time_in_millis"`
DurationInMillis int `json:"duration_in_millis"`
Failures []json.RawMessage `json:"failures"`
Shards struct {
Total int `json:"total"`
Failed int `json:"failed"`
Successful int `json:"successful"`
} `json:"shards"`
} `json:"snapshots"`
response *opensearch.Response
Snapshots []SnapshotGet `json:"snapshots"`
response *opensearch.Response
}

// Inspect returns the Inspect type containing the raw *opensearch.Reponse
func (r SnapshotGetResp) Inspect() Inspect {
return Inspect{Response: r.response}
}

// SnapshotGet is a sub type of SnapshotGetResp represeting a single snapshot
type SnapshotGet struct {
Snapshot string `json:"snapshot"`
UUID string `json:"uuid"`
VersionID int `json:"version_id"`
Version string `json:"version"`
RemoteStoreIndexShallowCopy bool `json:"remote_store_index_shallow_copy"`
Indices []string `json:"indices"`
DataStreams []json.RawMessage `json:"data_streams"`
IncludeGlobalState bool `json:"include_global_state"`
Metadata map[string]string `json:"metadata"`
State string `json:"state"`
StartTime string `json:"start_time"`
StartTimeInMillis int64 `json:"start_time_in_millis"`
EndTime string `json:"end_time"`
EndTimeInMillis int64 `json:"end_time_in_millis"`
DurationInMillis int `json:"duration_in_millis"`
Failures []json.RawMessage `json:"failures"`
Shards SnapshotGetShards `json:"shards"`
}

// SnapshotGetShards is a sub type of SnapshotGet containing shard numbers
type SnapshotGetShards struct {
Total int `json:"total"`
Failed int `json:"failed"`
Successful int `json:"successful"`
}

0 comments on commit 25d17e8

Please sign in to comment.