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

opensearchapi: split SnapshotGetResp into sub structs #603

Merged
merged 1 commit into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
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
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"`
}
Loading