Initial QSfera import

This commit is contained in:
Курнат Андрей
2026-06-07 10:20:04 +03:00
commit 2315f25754
16485 changed files with 4826827 additions and 0 deletions
@@ -0,0 +1,78 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
// Modifications Copyright OpenSearch Contributors. See
// GitHub history for details.
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package opensearchapi
import (
"strings"
"time"
)
// AliasesParams represents possible parameters for the AliasesReq
type AliasesParams struct {
MasterTimeout time.Duration
ClusterManagerTimeout time.Duration
Timeout time.Duration
Pretty bool
Human bool
ErrorTrace bool
FilterPath []string
}
func (r AliasesParams) get() map[string]string {
params := make(map[string]string)
if r.MasterTimeout != 0 {
params["master_timeout"] = formatDuration(r.MasterTimeout)
}
if r.ClusterManagerTimeout != 0 {
params["cluster_manager_timeout"] = formatDuration(r.ClusterManagerTimeout)
}
if r.Timeout != 0 {
params["timeout"] = formatDuration(r.Timeout)
}
if r.Pretty {
params["pretty"] = "true"
}
if r.Human {
params["human"] = "true"
}
if r.ErrorTrace {
params["error_trace"] = "true"
}
if len(r.FilterPath) > 0 {
params["filter_path"] = strings.Join(r.FilterPath, ",")
}
return params
}
@@ -0,0 +1,58 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
package opensearchapi
import (
"context"
"io"
"net/http"
"github.com/opensearch-project/opensearch-go/v4"
)
// Aliases executes an /_aliases request with the required AliasesReq
func (c Client) Aliases(ctx context.Context, req AliasesReq) (*AliasesResp, error) {
var (
data AliasesResp
err error
)
if data.response, err = c.do(ctx, req, &data); err != nil {
return &data, err
}
return &data, nil
}
// AliasesReq represents possible options for the / request
type AliasesReq struct {
Body io.Reader
Header http.Header
Params AliasesParams
}
// GetRequest returns the *http.Request that gets executed by the client
func (r AliasesReq) GetRequest() (*http.Request, error) {
return opensearch.BuildRequest(
"POST",
"/_aliases",
r.Body,
r.Params.get(),
r.Header,
)
}
// AliasesResp represents the returned struct of the / response
type AliasesResp struct {
Acknowledged bool `json:"acknowledged"`
response *opensearch.Response
}
// Inspect returns the Inspect type containing the raw *opensearch.Response
func (r AliasesResp) Inspect() Inspect {
return Inspect{Response: r.response}
}
@@ -0,0 +1,118 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
// Modifications Copyright OpenSearch Contributors. See
// GitHub history for details.
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package opensearchapi
import (
"strconv"
"strings"
"time"
)
// BulkParams represents possible parameters for the BulkReq
type BulkParams struct {
Pipeline string
Refresh string
RequireAlias *bool
Routing string
Source any
SourceExcludes []string
SourceIncludes []string
Timeout time.Duration
WaitForActiveShards string
Pretty bool
Human bool
ErrorTrace bool
FilterPath []string
}
func (r BulkParams) get() map[string]string {
params := make(map[string]string)
if r.Pipeline != "" {
params["pipeline"] = r.Pipeline
}
if r.Refresh != "" {
params["refresh"] = r.Refresh
}
if r.RequireAlias != nil {
params["require_alias"] = strconv.FormatBool(*r.RequireAlias)
}
if r.Routing != "" {
params["routing"] = r.Routing
}
switch source := r.Source.(type) {
case bool:
params["_source"] = strconv.FormatBool(source)
case string:
if source != "" {
params["_source"] = source
}
case []string:
if len(source) > 0 {
params["_source"] = strings.Join(source, ",")
}
}
if len(r.SourceExcludes) > 0 {
params["_source_excludes"] = strings.Join(r.SourceExcludes, ",")
}
if len(r.SourceIncludes) > 0 {
params["_source_includes"] = strings.Join(r.SourceIncludes, ",")
}
if r.Timeout != 0 {
params["timeout"] = formatDuration(r.Timeout)
}
if r.WaitForActiveShards != "" {
params["wait_for_active_shards"] = r.WaitForActiveShards
}
if r.Pretty {
params["pretty"] = "true"
}
if r.Human {
params["human"] = "true"
}
if r.ErrorTrace {
params["error_trace"] = "true"
}
if len(r.FilterPath) > 0 {
params["filter_path"] = strings.Join(r.FilterPath, ",")
}
return params
}
@@ -0,0 +1,109 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
package opensearchapi
import (
"context"
"io"
"net/http"
"strings"
"github.com/opensearch-project/opensearch-go/v4"
)
// Bulk executes a /_bulk request with the needed BulkReq
func (c Client) Bulk(ctx context.Context, req BulkReq) (*BulkResp, error) {
var (
data BulkResp
err error
)
if data.response, err = c.do(ctx, req, &data); err != nil {
return &data, err
}
return &data, nil
}
// BulkReq represents possible options for the /_bulk request
type BulkReq struct {
Index string
Body io.Reader
Header http.Header
Params BulkParams
}
// GetRequest returns the *http.Request that gets executed by the client
func (r BulkReq) GetRequest() (*http.Request, error) {
var path strings.Builder
//nolint:gomnd // 7 is the max number of static chars
path.Grow(7 + len(r.Index))
if len(r.Index) > 0 {
path.WriteString("/")
path.WriteString(r.Index)
}
path.WriteString("/_bulk")
return opensearch.BuildRequest(
"POST",
path.String(),
r.Body,
r.Params.get(),
r.Header,
)
}
// BulkResp represents the returned struct of the /_bulk response
type BulkResp struct {
Took int `json:"took"`
Errors bool `json:"errors"`
Items []map[string]BulkRespItem `json:"items"`
response *opensearch.Response
}
// BulkRespItem represents an item of the BulkResp
type BulkRespItem struct {
Index string `json:"_index"`
ID string `json:"_id"`
Version int `json:"_version"`
Type string `json:"_type"` // Deprecated field
Result string `json:"result"`
Shards struct {
Total int `json:"total"`
Successful int `json:"successful"`
Failed int `json:"failed"`
} `json:"_shards"`
SeqNo int `json:"_seq_no"`
PrimaryTerm int `json:"_primary_term"`
Status int `json:"status"`
Error *struct {
Type string `json:"type"`
Reason string `json:"reason"`
Cause struct {
Type string `json:"type"`
Reason string `json:"reason"`
ScriptStack *[]string `json:"script_stack,omitempty"`
Script *string `json:"script,omitempty"`
Lang *string `json:"lang,omitempty"`
Position *struct {
Offset int `json:"offset"`
Start int `json:"start"`
End int `json:"end"`
} `json:"position,omitempty"`
Cause *struct {
Type string `json:"type"`
Reason *string `json:"reason"`
} `json:"caused_by"`
} `json:"caused_by,omitempty"`
} `json:"error,omitempty"`
}
// Inspect returns the Inspect type containing the raw *opensearch.Response
func (r BulkResp) Inspect() Inspect {
return Inspect{Response: r.response}
}
@@ -0,0 +1,90 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
// Modifications Copyright OpenSearch Contributors. See
// GitHub history for details.
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package opensearchapi
import (
"strconv"
"strings"
)
// CatAliasesParams represents possible parameters for the CatAliasesReq
type CatAliasesParams struct {
ExpandWildcards string
H []string
Local *bool
Sort []string
V *bool
Pretty bool
Human bool
ErrorTrace bool
FilterPath []string
}
func (r CatAliasesParams) get() map[string]string {
params := make(map[string]string)
if r.ExpandWildcards != "" {
params["expand_wildcards"] = r.ExpandWildcards
}
if len(r.H) > 0 {
params["h"] = strings.Join(r.H, ",")
}
if r.Local != nil {
params["local"] = strconv.FormatBool(*r.Local)
}
if len(r.Sort) > 0 {
params["s"] = strings.Join(r.Sort, ",")
}
if r.V != nil {
params["v"] = strconv.FormatBool(*r.V)
}
if r.Pretty {
params["pretty"] = "true"
}
if r.Human {
params["human"] = "true"
}
if r.ErrorTrace {
params["error_trace"] = "true"
}
if len(r.FilterPath) > 0 {
params["filter_path"] = strings.Join(r.FilterPath, ",")
}
params["format"] = "json"
return params
}
@@ -0,0 +1,63 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
package opensearchapi
import (
"net/http"
"strings"
"github.com/opensearch-project/opensearch-go/v4"
)
// CatAliasesReq represent possible options for the /_cat/aliases request
type CatAliasesReq struct {
Aliases []string
Header http.Header
Params CatAliasesParams
}
// GetRequest returns the *http.Request that gets executed by the client
func (r CatAliasesReq) GetRequest() (*http.Request, error) {
aliases := strings.Join(r.Aliases, ",")
var path strings.Builder
path.Grow(len("/_cat/aliases/") + len(aliases))
path.WriteString("/_cat/aliases")
if len(r.Aliases) > 0 {
path.WriteString("/")
path.WriteString(aliases)
}
return opensearch.BuildRequest(
"GET",
path.String(),
nil,
r.Params.get(),
r.Header,
)
}
// CatAliasesResp represents the returned struct of the /_cat/aliases response
type CatAliasesResp struct {
Aliases []CatAliasResp
response *opensearch.Response
}
// CatAliasResp represents one index of the CatAliasesResp
type CatAliasResp struct {
Alias string `json:"alias"`
Index string `json:"index"`
Filter string `json:"filter"`
RoutingIndex string `json:"routing.index"`
RoutingSearch string `json:"routing.search"`
IsWriteIndex string `json:"is_write_index"`
}
// Inspect returns the Inspect type containing the raw *opensearch.Response
func (r CatAliasesResp) Inspect() Inspect {
return Inspect{
Response: r.response,
}
}
@@ -0,0 +1,106 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
// Modifications Copyright OpenSearch Contributors. See
// GitHub history for details.
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package opensearchapi
import (
"strconv"
"strings"
"time"
)
// CatAllocationParams represents possible parameters for the CatAllocationReq
type CatAllocationParams struct {
Bytes string
ExpandWildcards string
H []string
Local *bool
MasterTimeout time.Duration
ClusterManagerTimeout time.Duration
Sort []string
V *bool
Pretty bool
Human bool
ErrorTrace bool
FilterPath []string
}
func (r CatAllocationParams) get() map[string]string {
params := make(map[string]string)
if r.Bytes != "" {
params["bytes"] = r.Bytes
}
if r.ExpandWildcards != "" {
params["expand_wildcards"] = r.ExpandWildcards
}
if len(r.H) > 0 {
params["h"] = strings.Join(r.H, ",")
}
if r.Local != nil {
params["local"] = strconv.FormatBool(*r.Local)
}
if r.MasterTimeout != 0 {
params["master_timeout"] = formatDuration(r.MasterTimeout)
}
if r.ClusterManagerTimeout != 0 {
params["cluster_manager_timeout"] = formatDuration(r.ClusterManagerTimeout)
}
if len(r.Sort) > 0 {
params["s"] = strings.Join(r.Sort, ",")
}
if r.V != nil {
params["v"] = strconv.FormatBool(*r.V)
}
if r.Pretty {
params["pretty"] = "true"
}
if r.Human {
params["human"] = "true"
}
if r.ErrorTrace {
params["error_trace"] = "true"
}
if len(r.FilterPath) > 0 {
params["filter_path"] = strings.Join(r.FilterPath, ",")
}
params["format"] = "json"
return params
}
@@ -0,0 +1,67 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
package opensearchapi
import (
"net/http"
"strings"
"github.com/opensearch-project/opensearch-go/v4"
)
// CatAllocationReq represent possible options for the /_cat/allocation request
type CatAllocationReq struct {
NodeIDs []string
Header http.Header
Params CatAllocationParams
}
// GetRequest returns the *http.Request that gets executed by the client
func (r CatAllocationReq) GetRequest() (*http.Request, error) {
nodes := strings.Join(r.NodeIDs, ",")
var path strings.Builder
path.Grow(len("/_cat/allocation/") + len(nodes))
path.WriteString("/_cat/allocation")
if len(r.NodeIDs) > 0 {
path.WriteString("/")
path.WriteString(nodes)
}
return opensearch.BuildRequest(
"GET",
path.String(),
nil,
r.Params.get(),
r.Header,
)
}
// CatAllocationsResp represents the returned struct of the /_cat/allocation response
type CatAllocationsResp struct {
Allocations []CatAllocationResp
response *opensearch.Response
}
// CatAllocationResp represents one index of the CatAllocationResp
type CatAllocationResp struct {
Shards int `json:"shards,string"`
// Pointer of string as the api can returns null for those fileds with Node set to "UNASSIGNED"
DiskIndices *string `json:"disk.indices"`
DiskUsed *string `json:"disk.used"`
DiskAvail *string `json:"disk.avail"`
DiskTotal *string `json:"disk.total"`
DiskPercent *int `json:"disk.percent,string"`
Host *string `json:"host"`
IP *string `json:"ip"`
Node string `json:"node"`
}
// Inspect returns the Inspect type containing the raw *opensearch.Response
func (r CatAllocationsResp) Inspect() Inspect {
return Inspect{
Response: r.response,
}
}
@@ -0,0 +1,96 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
// Modifications Copyright OpenSearch Contributors. See
// GitHub history for details.
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package opensearchapi
import (
"strconv"
"strings"
"time"
)
// CatClusterManagerParams represents possible parameters for the CatClusterManagerReq
type CatClusterManagerParams struct {
H []string
Local *bool
MasterTimeout time.Duration
ClusterManagerTimeout time.Duration
Sort []string
V *bool
Pretty bool
Human bool
ErrorTrace bool
FilterPath []string
}
func (r CatClusterManagerParams) get() map[string]string {
params := make(map[string]string)
if len(r.H) > 0 {
params["h"] = strings.Join(r.H, ",")
}
if r.Local != nil {
params["local"] = strconv.FormatBool(*r.Local)
}
if r.MasterTimeout != 0 {
params["master_timeout"] = formatDuration(r.MasterTimeout)
}
if r.ClusterManagerTimeout != 0 {
params["cluster_manager_timeout"] = formatDuration(r.ClusterManagerTimeout)
}
if len(r.Sort) > 0 {
params["s"] = strings.Join(r.Sort, ",")
}
if r.V != nil {
params["v"] = strconv.FormatBool(*r.V)
}
if r.Pretty {
params["pretty"] = "true"
}
if r.Human {
params["human"] = "true"
}
if r.ErrorTrace {
params["error_trace"] = "true"
}
if len(r.FilterPath) > 0 {
params["filter_path"] = strings.Join(r.FilterPath, ",")
}
params["format"] = "json"
return params
}
@@ -0,0 +1,51 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
package opensearchapi
import (
"net/http"
"github.com/opensearch-project/opensearch-go/v4"
)
// CatClusterManagerReq represent possible options for the /_cat/cluster_manager request
type CatClusterManagerReq struct {
Header http.Header
Params CatClusterManagerParams
}
// GetRequest returns the *http.Request that gets executed by the client
func (r CatClusterManagerReq) GetRequest() (*http.Request, error) {
return opensearch.BuildRequest(
"GET",
"/_cat/cluster_manager",
nil,
r.Params.get(),
r.Header,
)
}
// CatClusterManagersResp represents the returned struct of the /_cat/cluster_manager response
type CatClusterManagersResp struct {
ClusterManagers []CatClusterManagerResp
response *opensearch.Response
}
// CatClusterManagerResp represents one index of the CatClusterManagerResp
type CatClusterManagerResp struct {
ID string `json:"id"`
Host string `json:"host"`
IP string `json:"ip"`
Node string `json:"node"`
}
// Inspect returns the Inspect type containing the raw *opensearch.Response
func (r CatClusterManagersResp) Inspect() Inspect {
return Inspect{
Response: r.response,
}
}
@@ -0,0 +1,80 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
// Modifications Copyright OpenSearch Contributors. See
// GitHub history for details.
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package opensearchapi
import (
"strconv"
"strings"
)
// CatCountParams represents possible parameters for the CatCountReq
type CatCountParams struct {
H []string
Sort []string
V *bool
Pretty bool
Human bool
ErrorTrace bool
FilterPath []string
}
func (r CatCountParams) get() map[string]string {
params := make(map[string]string)
if len(r.H) > 0 {
params["h"] = strings.Join(r.H, ",")
}
if len(r.Sort) > 0 {
params["s"] = strings.Join(r.Sort, ",")
}
if r.V != nil {
params["v"] = strconv.FormatBool(*r.V)
}
if r.Pretty {
params["pretty"] = "true"
}
if r.Human {
params["human"] = "true"
}
if r.ErrorTrace {
params["error_trace"] = "true"
}
if len(r.FilterPath) > 0 {
params["filter_path"] = strings.Join(r.FilterPath, ",")
}
params["format"] = "json"
return params
}
@@ -0,0 +1,60 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
package opensearchapi
import (
"net/http"
"strings"
"github.com/opensearch-project/opensearch-go/v4"
)
// CatCountReq represent possible options for the /_cat/count request
type CatCountReq struct {
Indices []string
Header http.Header
Params CatCountParams
}
// GetRequest returns the *http.Request that gets executed by the client
func (r CatCountReq) GetRequest() (*http.Request, error) {
indices := strings.Join(r.Indices, ",")
var path strings.Builder
path.Grow(len("/_cat/count/") + len(indices))
path.WriteString("/_cat/count")
if len(r.Indices) > 0 {
path.WriteString("/")
path.WriteString(indices)
}
return opensearch.BuildRequest(
"GET",
path.String(),
nil,
r.Params.get(),
r.Header,
)
}
// CatCountsResp represents the returned struct of the /_cat/count response
type CatCountsResp struct {
Counts []CatCountResp
response *opensearch.Response
}
// CatCountResp represents one index of the CatCountResp
type CatCountResp struct {
Epoch int `json:"epoch,string"`
Timestamp string `json:"timestamp"`
Count int `json:"count,string"`
}
// Inspect returns the Inspect type containing the raw *opensearch.Response
func (r CatCountsResp) Inspect() Inspect {
return Inspect{
Response: r.response,
}
}
@@ -0,0 +1,85 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
// Modifications Copyright OpenSearch Contributors. See
// GitHub history for details.
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package opensearchapi
import (
"strconv"
"strings"
)
// CatFieldDataParams represents possible parameters for the CatFieldDataReq
type CatFieldDataParams struct {
Bytes string
H []string
Sort []string
V *bool
Pretty bool
Human bool
ErrorTrace bool
FilterPath []string
}
func (r CatFieldDataParams) get() map[string]string {
params := make(map[string]string)
if r.Bytes != "" {
params["bytes"] = r.Bytes
}
if len(r.H) > 0 {
params["h"] = strings.Join(r.H, ",")
}
if len(r.Sort) > 0 {
params["s"] = strings.Join(r.Sort, ",")
}
if r.V != nil {
params["v"] = strconv.FormatBool(*r.V)
}
if r.Pretty {
params["pretty"] = "true"
}
if r.Human {
params["human"] = "true"
}
if r.ErrorTrace {
params["error_trace"] = "true"
}
if len(r.FilterPath) > 0 {
params["filter_path"] = strings.Join(r.FilterPath, ",")
}
params["format"] = "json"
return params
}
@@ -0,0 +1,63 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
package opensearchapi
import (
"net/http"
"strings"
"github.com/opensearch-project/opensearch-go/v4"
)
// CatFieldDataReq represent possible options for the /_cat/fielddata request
type CatFieldDataReq struct {
FieldData []string
Header http.Header
Params CatFieldDataParams
}
// GetRequest returns the *http.Request that gets executed by the client
func (r CatFieldDataReq) GetRequest() (*http.Request, error) {
fielddata := strings.Join(r.FieldData, ",")
var path strings.Builder
path.Grow(len("/_cat/fielddata/") + len(fielddata))
path.WriteString("/_cat/fielddata")
if len(r.FieldData) > 0 {
path.WriteString("/")
path.WriteString(fielddata)
}
return opensearch.BuildRequest(
"GET",
path.String(),
nil,
r.Params.get(),
r.Header,
)
}
// CatFieldDataResp represents the returned struct of the /_cat/fielddata response
type CatFieldDataResp struct {
FieldData []CatFieldDataItemResp
response *opensearch.Response
}
// CatFieldDataItemResp represents one index of the CatFieldDataResp
type CatFieldDataItemResp struct {
ID string `json:"id"`
Host string `json:"host"`
IP string `json:"ip"`
Node string `json:"node"`
Field string `json:"field"`
Size string `json:"size"`
}
// Inspect returns the Inspect type containing the raw *opensearch.Response
func (r CatFieldDataResp) Inspect() Inspect {
return Inspect{
Response: r.response,
}
}
@@ -0,0 +1,90 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
// Modifications Copyright OpenSearch Contributors. See
// GitHub history for details.
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package opensearchapi
import (
"strconv"
"strings"
)
// CatHealthParams represents possible parameters for the CatHealthReq
type CatHealthParams struct {
H []string
Sort []string
Time string
TS *bool
V *bool
Pretty bool
Human bool
ErrorTrace bool
FilterPath []string
}
func (r CatHealthParams) get() map[string]string {
params := make(map[string]string)
if len(r.H) > 0 {
params["h"] = strings.Join(r.H, ",")
}
if len(r.Sort) > 0 {
params["s"] = strings.Join(r.Sort, ",")
}
if r.Time != "" {
params["time"] = r.Time
}
if r.TS != nil {
params["ts"] = strconv.FormatBool(*r.TS)
}
if r.V != nil {
params["v"] = strconv.FormatBool(*r.V)
}
if r.Pretty {
params["pretty"] = "true"
}
if r.Human {
params["human"] = "true"
}
if r.ErrorTrace {
params["error_trace"] = "true"
}
if len(r.FilterPath) > 0 {
params["filter_path"] = strings.Join(r.FilterPath, ",")
}
params["format"] = "json"
return params
}
@@ -0,0 +1,63 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
package opensearchapi
import (
"net/http"
"github.com/opensearch-project/opensearch-go/v4"
)
// CatHealthReq represent possible options for the /_cat/health request
type CatHealthReq struct {
Header http.Header
Params CatHealthParams
}
// GetRequest returns the *http.Request that gets executed by the client
func (r CatHealthReq) GetRequest() (*http.Request, error) {
return opensearch.BuildRequest(
"GET",
"/_cat/health",
nil,
r.Params.get(),
r.Header,
)
}
// CatHealthResp represents the returned struct of the /_cat/health response
type CatHealthResp struct {
Health []CatHealthItemResp
response *opensearch.Response
}
// CatHealthItemResp represents one index of the CatHealthResp
type CatHealthItemResp struct {
Epoch int `json:"epoch,string"`
Timestamp string `json:"timestamp"`
Cluster string `json:"cluster"`
Status string `json:"status"`
NodeTotal int `json:"node.total,string"`
NodeData int `json:"node.data,string"`
DiscoveredMaster bool `json:"discovered_master,string"`
DiscoveredClusterManager bool `json:"discovered_cluster_manager,string"`
Shards int `json:"shards,string"`
Primary int `json:"pri,string"`
Relocating int `json:"relo,string"`
Initializing int `json:"init,string"`
Unassigned int `json:"unassign,string"`
PendingTasks int `json:"pending_tasks,string"`
MaxTaskWaitTime string `json:"max_task_wait_time"`
ActiveShardsPercent string `json:"active_shards_percent"`
}
// Inspect returns the Inspect type containing the raw *opensearch.Response
func (r CatHealthResp) Inspect() Inspect {
return Inspect{
Response: r.response,
}
}
@@ -0,0 +1,126 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
// Modifications Copyright OpenSearch Contributors. See
// GitHub history for details.
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package opensearchapi
import (
"strconv"
"strings"
"time"
)
// CatIndicesParams represents possible parameters for the CatIndicesReq
type CatIndicesParams struct {
Bytes string
ExpandWildcards string
H []string
Health string
IncludeUnloadedSegments *bool
Local *bool
MasterTimeout time.Duration
ClusterManagerTimeout time.Duration
Primary *bool
Sort []string
Time string
V *bool
Pretty bool
Human bool
ErrorTrace bool
FilterPath []string
}
func (r CatIndicesParams) get() map[string]string {
params := make(map[string]string)
if r.Bytes != "" {
params["bytes"] = r.Bytes
}
if r.ExpandWildcards != "" {
params["expand_wildcards"] = r.ExpandWildcards
}
if len(r.H) > 0 {
params["h"] = strings.Join(r.H, ",")
}
if r.Health != "" {
params["health"] = r.Health
}
if r.IncludeUnloadedSegments != nil {
params["include_unloaded_segments"] = strconv.FormatBool(*r.IncludeUnloadedSegments)
}
if r.Local != nil {
params["local"] = strconv.FormatBool(*r.Local)
}
if r.MasterTimeout != 0 {
params["master_timeout"] = formatDuration(r.MasterTimeout)
}
if r.ClusterManagerTimeout != 0 {
params["cluster_manager_timeout"] = formatDuration(r.ClusterManagerTimeout)
}
if r.Primary != nil {
params["pri"] = strconv.FormatBool(*r.Primary)
}
if len(r.Sort) > 0 {
params["s"] = strings.Join(r.Sort, ",")
}
if r.Time != "" {
params["time"] = r.Time
}
if r.V != nil {
params["v"] = strconv.FormatBool(*r.V)
}
if r.Pretty {
params["pretty"] = "true"
}
if r.Human {
params["human"] = "true"
}
if r.ErrorTrace {
params["error_trace"] = "true"
}
if len(r.FilterPath) > 0 {
params["filter_path"] = strings.Join(r.FilterPath, ",")
}
params["format"] = "json"
return params
}
@@ -0,0 +1,203 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
package opensearchapi
import (
"net/http"
"strings"
"github.com/opensearch-project/opensearch-go/v4"
)
// CatIndicesReq represent possible options for the /_cat/indices request
type CatIndicesReq struct {
Indices []string
Header http.Header
Params CatIndicesParams
}
// GetRequest returns the *http.Request that gets executed by the client
func (r CatIndicesReq) GetRequest() (*http.Request, error) {
indices := strings.Join(r.Indices, ",")
var path strings.Builder
path.Grow(len("/_cat/indices/") + len(indices))
path.WriteString("/_cat/indices")
if len(r.Indices) > 0 {
path.WriteString("/")
path.WriteString(indices)
}
return opensearch.BuildRequest(
"GET",
path.String(),
nil,
r.Params.get(),
r.Header,
)
}
// CatIndicesResp represents the returned struct of the /_cat/indices response
type CatIndicesResp struct {
Indices []CatIndexResp
response *opensearch.Response
}
// CatIndexResp represents one index of the CatIndicesResp
type CatIndexResp struct {
Health string `json:"health"`
Status string `json:"status"`
Index string `json:"index"`
UUID string `json:"uuid"`
Primary *int `json:"pri,string"`
Replica *int `json:"rep,string"`
DocsCount *int `json:"docs.count,string"`
DocDeleted *int `json:"docs.deleted,string"`
CreationDate int `json:"creation.date,string"`
CreationDateString string `json:"creation.date.string"`
// Pointer as newly created indices can return null
StoreSize *string `json:"store.size"`
PrimaryStoreSize *string `json:"pri.store.size"`
CompletionSize *string `json:"completion.size"`
PrimaryCompletionSize *string `json:"pri.completion.size"`
FieldDataMemorySize *string `json:"fielddata.memory_size"`
PrimaryFieldDataMemorySize *string `json:"pri.fielddata.memory_size"`
FieldDataEvictions *int `json:"fielddata.evictions,string"`
PrimaryFieldDataEvictions *int `json:"pri.fielddata.evictions,string"`
QueryCacheMemorySize *string `json:"query_cache.memory_size"`
PrimaryQueryCacheMemorySize *string `json:"pri.query_cache.memory_size"`
QueryCacheEvictions *int `json:"query_cache.evictions,string"`
PrimaryQueryCacheEvictions *int `json:"pri.query_cache.evictions,string"`
RequestCacheMemorySize *string `json:"request_cache.memory_size"`
PrimaryRequestCacheMemorySize *string `json:"pri.request_cache.memory_size"`
RequestCacheEvictions *int `json:"request_cache.evictions,string"`
PrimaryRequestCacheEvictions *int `json:"pri.request_cache.evictions,string"`
RequestCacheHitCount *int `json:"request_cache.hit_count,string"`
PrimaryRequestCacheHitCount *int `json:"pri.request_cache.hit_count,string"`
RequestCacheMissCount *int `json:"request_cache.miss_count,string"`
PrimaryRequestCacheMissCount *int `json:"pri.request_cache.miss_count,string"`
FlushTotal *int `json:"flush.total,string"`
PrimaryFlushTotal *int `json:"pri.flush.total,string"`
FlushTime *string `json:"flush.total_time"`
PrimaryFlushTime *string `json:"pri.flush.total_time"`
GetCurrent *int `json:"get.current,string"`
PrimaryGetCurrent *int `json:"pri.get.current,string"`
GetTime *string `json:"get.time"`
PrimaryGetTime *string `json:"pri.get.time"`
GetTotal *int `json:"get.total,string"`
PrimaryGetTotal *int `json:"pri.get.total,string"`
GetExistsTime *string `json:"get.exists_time"`
PrimaryGetExistsTime *string `json:"pri.get.exists_time"`
GetExistsTotal *int `json:"get.exists_total,string"`
PrimaryGetExistsTotal *int `json:"pri.get.exists_total,string"`
GetMissingTime *string `json:"get.missing_time"`
PrimaryGetMissingTime *string `json:"pri.get.missing_time"`
GetMissingTotal *int `json:"get.missing_total,string"`
PrimaryGetMissingTotal *int `json:"pri.get.missing_total,string"`
IndexingDeleteCurrent *int `json:"indexing.delete_current,string"`
PrimaryIndexingDeleteCurrent *int `json:"pri.indexing.delete_current,string"`
IndexingDeleteTime *string `json:"indexing.delete_time"`
PrimaryIndexingDeleteTime *string `json:"pri.indexing.delete_time"`
IndexingDeleteTotal *int `json:"indexing.delete_total,string"`
PrimaryIndexingDeleteTotal *int `json:"pri.indexing.delete_total,string"`
IndexingIndexCurrent *int `json:"indexing.index_current,string"`
PrimaryIndexingIndexCurrent *int `json:"pri.indexing.index_current,string"`
IndexingIndexTime *string `json:"indexing.index_time"`
PrimaryIndexingIndexTime *string `json:"pri.indexing.index_time"`
IndexingIndexTotal *int `json:"indexing.index_total,string"`
PrimaryIndexingIndexTotal *int `json:"pri.indexing.index_total,string"`
IndexingIndexFailed *int `json:"indexing.index_failed,string"`
PrimaryIndexingIndexFailed *int `json:"pri.indexing.index_failed,string"`
MergesCurrent *int `json:"merges.current,string"`
PrimaryMergesCurrent *int `json:"pri.merges.current,string"`
MergesCurrentDocs *int `json:"merges.current_docs,string"`
PrimaryMergesCurrentDocs *int `json:"pri.merges.current_docs,string"`
MergesCurrentSize *string `json:"merges.current_size"`
PrimaryMergesCurrentSize *string `json:"pri.merges.current_size"`
MergesTotal *int `json:"merges.total,string"`
PrimaryMergesTotal *int `json:"pri.merges.total,string"`
MergesTotalDocs *int `json:"merges.total_docs,string"`
PrimaryMergesTotalDocs *int `json:"pri.merges.total_docs,string"`
MergesTotalSize *string `json:"merges.total_size"`
PrimaryMergesTotalSize *string `json:"pri.merges.total_size"`
MergesTotalTime *string `json:"merges.total_time"`
PrimaryMergesTotalTime *string `json:"pri.merges.total_time"`
RefreshTotal *int `json:"refresh.total,string"`
PrimaryRefreshTotal *int `json:"pri.refresh.total,string"`
RefreshTime *string `json:"refresh.time"`
PrimaryRefreshTime *string `json:"pri.refresh.time"`
RefreshExternalTotal *int `json:"refresh.external_total,string"`
PrimaryRefreshExternalTotal *int `json:"pri.refresh.external_total,string"`
RefreshExternalTime *string `json:"refresh.external_time"`
PrimaryRefreshExternalTime *string `json:"pri.refresh.external_time"`
RefreshListeners *int `json:"refresh.listeners,string"`
PrimaryRefreshListeners *int `json:"pri.refresh.listeners,string"`
SearchFetchCurrent *int `json:"search.fetch_current,string"`
PrimarySearchFetchCurrent *int `json:"pri.search.fetch_current,string"`
SearchFetchTime *string `json:"search.fetch_time"`
PrimarySearchFetchTime *string `json:"pri.search.fetch_time"`
SearchFetchTotal *int `json:"search.fetch_total,string"`
PrimarySearchFetchTotal *int `json:"pri.search.fetch_total,string"`
SearchOpenContexts *int `json:"search.open_contexts,string"`
PrimarySearchOpenContexts *int `json:"pri.search.open_contexts,string"`
SearchQueryCurrent *int `json:"search.query_current,string"`
PrimarySearchQueryCurrent *int `json:"pri.search.query_current,string"`
SearchQueryTime *string `json:"search.query_time"`
PrimarySearchQueryTime *string `json:"pri.search.query_time"`
SearchQueryTotal *int `json:"search.query_total,string"`
PrimarySearchQueryTotal *int `json:"pri.search.query_total,string"`
SearchConcurrentQueryCurrent *int `json:"search.concurrent_query_current,string"`
PrimarySearchConcurrentQueryCurrent *int `json:"pri.search.concurrent_query_current,string"`
SearchConcurrentQueryTime *string `json:"search.concurrent_query_time"`
PrimarySearchConcurrentQueryTime *string `json:"pri.search.concurrent_query_time"`
SearchConcurrentQueryTotal *int `json:"search.concurrent_query_total,string"`
PrimarySearchConcurrentQueryTotal *int `json:"pri.search.concurrent_query_total,string"`
SearchConcurrentAvgSliceCount *string `json:"search.concurrent_avg_slice_count"`
PrimarySearchConcurrentAvgSliceCount *string `json:"pri.search.concurrent_avg_slice_count"`
SearchScrollCurrent *int `json:"search.scroll_current,string"`
PrimarySearchScrollCurrent *int `json:"pri.search.scroll_current,string"`
SearchScrollTime *string `json:"search.scroll_time"`
PrimarySearchScrollTime *string `json:"pri.search.scroll_time"`
SearchScrollTotal *int `json:"search.scroll_total,string"`
PrimarySearchScrollTotal *int `json:"pri.search.scroll_total,string"`
SearchPointInTimeCurrent *string `json:"search.point_in_time_current"`
PrimarySearchPointInTimeCurrent *string `json:"pri.search.point_in_time_current"`
SearchPointInTimeTime *string `json:"search.point_in_time_time"`
PrimarySearchPointInTimeTime *string `json:"pri.search.point_in_time_time"`
SearchPointInTimeTotal *int `json:"search.point_in_time_total,string"`
PrimarySearchPointInTimeTotal *int `json:"pri.search.point_in_time_total,string"`
SegmentsCount *int `json:"segments.count,string"`
PrimarySegmentsCount *int `json:"pri.segments.count,string"`
SegmentsMemory *string `json:"segments.memory"`
PrimarySegmentsMemory *string `json:"pri.segments.memory"`
SegmentsIndexWriteMemory *string `json:"segments.index_writer_memory"`
PrimarySegmentsIndexWriteMemory *string `json:"pri.segments.index_writer_memory"`
SegmentsVersionMapMemory *string `json:"segments.version_map_memory"`
PrimarySegmentsVersionMapMemory *string `json:"pri.segments.version_map_memory"`
SegmentsFixedBitsetMemory *string `json:"segments.fixed_bitset_memory"`
PrimarySegmentsFixedBitsetMemory *string `json:"pri.segments.fixed_bitset_memory"`
WarmerCurrent *int `json:"warmer.current,string"`
PrimaryWarmerCurrent *int `json:"pri.warmer.current,string"`
WarmerTotal *int `json:"warmer.total,string"`
PrimaryWarmerTotal *int `json:"pri.warmer.total,string"`
WarmerTotalTime *string `json:"warmer.total_time"`
PrimaryWarmerTotalTime *string `json:"pri.warmer.total_time"`
SuggestCurrent *int `json:"suggest.current,string"`
PrimarySuggestCurrent *int `json:"pri.suggest.current,string"`
SuggestTime *string `json:"suggest.time"`
PrimarySuggestTime *string `json:"pri.suggest.time"`
SuggestTotal *int `json:"suggest.total,string"`
PrimarySuggestTotal *int `json:"pri.suggest.total,string"`
MemoryTotal string `json:"memory.total"`
PrimaryMemoryTotal string `json:"pri.memory.total"`
SearchThrottled bool `json:"search.throttled,string"`
}
// Inspect returns the Inspect type containing the raw *opensearch.Response
func (r CatIndicesResp) Inspect() Inspect {
return Inspect{
Response: r.response,
}
}
@@ -0,0 +1,96 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
// Modifications Copyright OpenSearch Contributors. See
// GitHub history for details.
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package opensearchapi
import (
"strconv"
"strings"
"time"
)
// CatMasterParams represents possible parameters for the CatMasterReq
type CatMasterParams struct {
H []string
Local *bool
MasterTimeout time.Duration
ClusterManagerTimeout time.Duration
Sort []string
V *bool
Pretty bool
Human bool
ErrorTrace bool
FilterPath []string
}
func (r CatMasterParams) get() map[string]string {
params := make(map[string]string)
if len(r.H) > 0 {
params["h"] = strings.Join(r.H, ",")
}
if r.Local != nil {
params["local"] = strconv.FormatBool(*r.Local)
}
if r.MasterTimeout != 0 {
params["master_timeout"] = formatDuration(r.MasterTimeout)
}
if r.ClusterManagerTimeout != 0 {
params["cluster_manager_timeout"] = formatDuration(r.ClusterManagerTimeout)
}
if len(r.Sort) > 0 {
params["s"] = strings.Join(r.Sort, ",")
}
if r.V != nil {
params["v"] = strconv.FormatBool(*r.V)
}
if r.Pretty {
params["pretty"] = "true"
}
if r.Human {
params["human"] = "true"
}
if r.ErrorTrace {
params["error_trace"] = "true"
}
if len(r.FilterPath) > 0 {
params["filter_path"] = strings.Join(r.FilterPath, ",")
}
params["format"] = "json"
return params
}
@@ -0,0 +1,51 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
package opensearchapi
import (
"net/http"
"github.com/opensearch-project/opensearch-go/v4"
)
// CatMasterReq represent possible options for the /_cat/master request
type CatMasterReq struct {
Header http.Header
Params CatMasterParams
}
// GetRequest returns the *http.Request that gets executed by the client
func (r CatMasterReq) GetRequest() (*http.Request, error) {
return opensearch.BuildRequest(
"GET",
"/_cat/master",
nil,
r.Params.get(),
r.Header,
)
}
// CatMasterResp represents the returned struct of the /_cat/master response
type CatMasterResp struct {
Master []CatMasterItemResp
response *opensearch.Response
}
// CatMasterItemResp represents one index of the CatMasterResp
type CatMasterItemResp struct {
ID string `json:"id"`
Host string `json:"host"`
IP string `json:"ip"`
Node string `json:"node"`
}
// Inspect returns the Inspect type containing the raw *opensearch.Response
func (r CatMasterResp) Inspect() Inspect {
return Inspect{
Response: r.response,
}
}
@@ -0,0 +1,96 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
// Modifications Copyright OpenSearch Contributors. See
// GitHub history for details.
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package opensearchapi
import (
"strconv"
"strings"
"time"
)
// CatNodeAttrsParams represents possible parameters for the CatNodeAttrsReq
type CatNodeAttrsParams struct {
H []string
Local *bool
MasterTimeout time.Duration
ClusterManagerTimeout time.Duration
Sort []string
V *bool
Pretty bool
Human bool
ErrorTrace bool
FilterPath []string
}
func (r CatNodeAttrsParams) get() map[string]string {
params := make(map[string]string)
if len(r.H) > 0 {
params["h"] = strings.Join(r.H, ",")
}
if r.Local != nil {
params["local"] = strconv.FormatBool(*r.Local)
}
if r.MasterTimeout != 0 {
params["master_timeout"] = formatDuration(r.MasterTimeout)
}
if r.ClusterManagerTimeout != 0 {
params["cluster_manager_timeout"] = formatDuration(r.ClusterManagerTimeout)
}
if len(r.Sort) > 0 {
params["s"] = strings.Join(r.Sort, ",")
}
if r.V != nil {
params["v"] = strconv.FormatBool(*r.V)
}
if r.Pretty {
params["pretty"] = "true"
}
if r.Human {
params["human"] = "true"
}
if r.ErrorTrace {
params["error_trace"] = "true"
}
if len(r.FilterPath) > 0 {
params["filter_path"] = strings.Join(r.FilterPath, ",")
}
params["format"] = "json"
return params
}
@@ -0,0 +1,55 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
package opensearchapi
import (
"net/http"
"github.com/opensearch-project/opensearch-go/v4"
)
// CatNodeAttrsReq represent possible options for the /_cat/nodeattrs request
type CatNodeAttrsReq struct {
Header http.Header
Params CatNodeAttrsParams
}
// GetRequest returns the *http.Request that gets executed by the client
func (r CatNodeAttrsReq) GetRequest() (*http.Request, error) {
return opensearch.BuildRequest(
"GET",
"/_cat/nodeattrs",
nil,
r.Params.get(),
r.Header,
)
}
// CatNodeAttrsResp represents the returned struct of the /_cat/nodeattrs response
type CatNodeAttrsResp struct {
NodeAttrs []CatNodeAttrsItemResp
response *opensearch.Response
}
// CatNodeAttrsItemResp represents one index of the CatNodeAttrsResp
type CatNodeAttrsItemResp struct {
Node string `json:"node"`
ID string `json:"id"`
PID *int `json:"pid,string"`
Host string `json:"host"`
IP string `json:"ip"`
Port int `json:"port,string"`
Attr string `json:"attr"`
Value string `json:"value"`
}
// Inspect returns the Inspect type containing the raw *opensearch.Response
func (r CatNodeAttrsResp) Inspect() Inspect {
return Inspect{
Response: r.response,
}
}
@@ -0,0 +1,116 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
// Modifications Copyright OpenSearch Contributors. See
// GitHub history for details.
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package opensearchapi
import (
"strconv"
"strings"
"time"
)
// CatNodesParams represents possible parameters for the CatNodesReq
type CatNodesParams struct {
Bytes string
FullID *bool
H []string
IncludeUnloadedSegments *bool
Local *bool
MasterTimeout time.Duration
ClusterManagerTimeout time.Duration
Sort []string
Time string
V *bool
Pretty bool
Human bool
ErrorTrace bool
FilterPath []string
}
func (r CatNodesParams) get() map[string]string {
params := make(map[string]string)
if r.Bytes != "" {
params["bytes"] = r.Bytes
}
if r.FullID != nil {
params["full_id"] = strconv.FormatBool(*r.FullID)
}
if len(r.H) > 0 {
params["h"] = strings.Join(r.H, ",")
}
if r.IncludeUnloadedSegments != nil {
params["include_unloaded_segments"] = strconv.FormatBool(*r.IncludeUnloadedSegments)
}
if r.Local != nil {
params["local"] = strconv.FormatBool(*r.Local)
}
if r.MasterTimeout != 0 {
params["master_timeout"] = formatDuration(r.MasterTimeout)
}
if r.ClusterManagerTimeout != 0 {
params["cluster_manager_timeout"] = formatDuration(r.ClusterManagerTimeout)
}
if len(r.Sort) > 0 {
params["s"] = strings.Join(r.Sort, ",")
}
if r.Time != "" {
params["time"] = r.Time
}
if r.V != nil {
params["v"] = strconv.FormatBool(*r.V)
}
if r.Pretty {
params["pretty"] = "true"
}
if r.Human {
params["human"] = "true"
}
if r.ErrorTrace {
params["error_trace"] = "true"
}
if len(r.FilterPath) > 0 {
params["filter_path"] = strings.Join(r.FilterPath, ",")
}
params["format"] = "json"
return params
}
@@ -0,0 +1,146 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
package opensearchapi
import (
"net/http"
"github.com/opensearch-project/opensearch-go/v4"
)
// CatNodesReq represent possible options for the /_cat/nodes request
type CatNodesReq struct {
Header http.Header
Params CatNodesParams
}
// GetRequest returns the *http.Request that gets executed by the client
func (r CatNodesReq) GetRequest() (*http.Request, error) {
return opensearch.BuildRequest(
"GET",
"/_cat/nodes",
nil,
r.Params.get(),
r.Header,
)
}
// CatNodesResp represents the returned struct of the /_cat/nodes response
type CatNodesResp struct {
Nodes []CatNodesItemResp
response *opensearch.Response
}
// CatNodesItemResp represents one index of the CatNodesResp
type CatNodesItemResp struct {
ID string `json:"id"`
PID *string `json:"pid"`
IP string `json:"ip"`
Port int `json:"port,string"`
HTTPAddress string `json:"http_address"`
Version string `json:"version"`
Type *string `json:"type"`
Build *string `json:"build"`
JDK *string `json:"jdk"`
DiskTotal *string `json:"disk.total"`
DiskUsed *string `json:"disk.used"`
DiskAvail *string `json:"disk.avail"`
DiskUsedPercent *string `json:"disk.used_percent"`
HeapCurrent *string `json:"heap.current"`
HeapPercent *int `json:"heap.percent,string"`
HeapMax *string `json:"heap.max"`
RAMCurrent *string `json:"ram.current"`
RAMPercent *int `json:"ram.percent,string"`
RAMMax *string `json:"ram.max"`
FileDescCurrent *int `json:"file_desc.current,string"`
FileDescPercent *int `json:"file_desc.percent,string"`
FileDescMax *int `json:"file_desc.max,string"`
CPU *int `json:"cpu,string"`
Load1M *string `json:"load_1m"`
Load5M *string `json:"load_5m"`
Load15M *string `json:"load_15m"`
Uptime *string `json:"uptime"`
Role string `json:"node.role"`
Roles string `json:"node.roles"`
Master string `json:"master"`
ClusterManager string `json:"cluster_manager"`
Name string `json:"name"`
CompletionSize *string `json:"completion.size"`
FieldDataMemorySize *string `json:"fielddata.memory_size"`
FileldDataEvictions *int `json:"fielddata.evictions,string"`
QueryCacheMemorySize *string `json:"query_cache.memory_size"`
QueryCacheEvictions *int `json:"query_cache.evictions,string"`
QueryCacheHitCount *int `json:"query_cache.hit_count,string"`
QueryCacheMissCount *int `json:"query_cache.miss_count,string"`
RequestCacheMemorySize *string `json:"request_cache.memory_size"`
RequestCacheEvictions *int `json:"request_cache.evictions,string"`
RequestCacheHitCount *int `json:"request_cache.hit_count,string"`
RequestCacheMissCount *int `json:"request_cache.miss_count,string"`
FlushTotal *int `json:"flush.total,string"`
FlushTotalTime *string `json:"flush.total_time"`
GetCurrent *int `json:"get.current,string"`
GetTime *string `json:"get.time"`
GetTotal *int `json:"get.total,string"`
GetExistsTime *string `json:"get.exists_time"`
GetExistsTotal *int `json:"get.exists_total,string"`
GetMissingTime *string `json:"get.missing_time"`
GetMissingTotal *int `json:"get.missing_total,string"`
IndexingDeleteCurrent *int `json:"indexing.delete_current,string"`
IndexingDeleteTime *string `json:"indexing.delete_time"`
IndexingDeleteTotal *int `json:"indexing.delete_total,string"`
IndexingIndexCurrent *int `json:"indexing.index_current,string"`
IndexingIndexTime *string `json:"indexing.index_time"`
IndexingIndexTotal *int `json:"indexing.index_total,string"`
IndexingIndexFailed *int `json:"indexing.index_failed,string"`
MergesCurrent *int `json:"merges.current,string"`
MergesCurrentDoc *int `json:"merges.current_docs,string"`
MergesCurrentSize *string `json:"merges.current_size"`
MergesTotal *int `json:"merges.total,string"`
MergesTotalDocs *int `json:"merges.total_docs,string"`
MergesTotalSize *string `json:"merges.total_size"`
MergesTotalTime *string `json:"merges.total_time"`
RefreshTotal *int `json:"refresh.total,string"`
RefreshTime *string `json:"refresh.time"`
RefreshExternalTotal *int `json:"refresh.external_total,string"`
RefreshExternalTime *string `json:"refresh.external_time"`
RefreshListeners *int `json:"refresh.listeners,string"`
ScriptCompilations *int `json:"script.compilations,string"`
ScriptCacheEvictions *int `json:"script.cache_evictions,string"`
ScriptCompilationLimitTriggered *int `json:"script.compilation_limit_triggered,string"`
SearchFetchCurrent *int `json:"search.fetch_current,string"`
SearchFetchTime *string `json:"search.fetch_time"`
SearchFetchTotal *int `json:"search.fetch_total,string"`
SearchOpenContexts *int `json:"search.open_contexts,string"`
SearchQueryCurrent *int `json:"search.query_current,string"`
SearchQueryTime *string `json:"search.query_time"`
SearchQueryTotal *int `json:"search.query_total,string"`
SearchConcurrentQueryCurrent *int `json:"search.concurrent_query_current,string"`
SearchConcurrentQueryTime *string `json:"search.concurrent_query_time"`
SearchConcurrentQueryTotal *int `json:"search.concurrent_query_total,string"`
SearchConcurrentAvgSliceCount *string `json:"search.concurrent_avg_slice_count"`
SearchScrollCurrent *int `json:"search.scroll_current,string"`
SearchScrollTime *string `json:"search.scroll_time"`
SearchScrollTotal *int `json:"search.scroll_total,string"`
SearchPointInTimeCurrent *int `json:"search.point_in_time_current,string"`
SearchPointInTimeTime *string `json:"search.point_in_time_time"`
SearchPointInTimeTotal *int `json:"search.point_in_time_total,string"`
SegmentsCount *int `json:"segments.count,string"`
SegmentsMemory *string `json:"segments.memory"`
SegmentsIndexWriteMemory *string `json:"segments.index_writer_memory"`
SegmentsVersionMapMemory *string `json:"segments.version_map_memory"`
SegmentsFixedBitsetMemory *string `json:"segments.fixed_bitset_memory"`
SuggestCurrent *int `json:"suggest.current,string"`
SuggestTime *string `json:"suggest.time"`
SuggestTotal *int `json:"suggest.total,string"`
}
// Inspect returns the Inspect type containing the raw *opensearch.Response
func (r CatNodesResp) Inspect() Inspect {
return Inspect{
Response: r.response,
}
}
@@ -0,0 +1,101 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
// Modifications Copyright OpenSearch Contributors. See
// GitHub history for details.
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package opensearchapi
import (
"strconv"
"strings"
"time"
)
// CatPendingTasksParams represents possible parameters for the CatPendingTasksReq
type CatPendingTasksParams struct {
H []string
Local *bool
MasterTimeout time.Duration
ClusterManagerTimeout time.Duration
Sort []string
Time string
V *bool
Pretty bool
Human bool
ErrorTrace bool
FilterPath []string
}
func (r CatPendingTasksParams) get() map[string]string {
params := make(map[string]string)
if len(r.H) > 0 {
params["h"] = strings.Join(r.H, ",")
}
if r.Local != nil {
params["local"] = strconv.FormatBool(*r.Local)
}
if r.MasterTimeout != 0 {
params["master_timeout"] = formatDuration(r.MasterTimeout)
}
if r.ClusterManagerTimeout != 0 {
params["cluster_manager_timeout"] = formatDuration(r.ClusterManagerTimeout)
}
if len(r.Sort) > 0 {
params["s"] = strings.Join(r.Sort, ",")
}
if r.Time != "" {
params["time"] = r.Time
}
if r.V != nil {
params["v"] = strconv.FormatBool(*r.V)
}
if r.Pretty {
params["pretty"] = "true"
}
if r.Human {
params["human"] = "true"
}
if r.ErrorTrace {
params["error_trace"] = "true"
}
if len(r.FilterPath) > 0 {
params["filter_path"] = strings.Join(r.FilterPath, ",")
}
params["format"] = "json"
return params
}
@@ -0,0 +1,51 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
package opensearchapi
import (
"net/http"
"github.com/opensearch-project/opensearch-go/v4"
)
// CatPendingTasksReq represent possible options for the /_cat/pending_tasks request
type CatPendingTasksReq struct {
Header http.Header
Params CatPendingTasksParams
}
// GetRequest returns the *http.Request that gets executed by the client
func (r CatPendingTasksReq) GetRequest() (*http.Request, error) {
return opensearch.BuildRequest(
"GET",
"/_cat/pending_tasks",
nil,
r.Params.get(),
r.Header,
)
}
// CatPendingTasksResp represents the returned struct of the /_cat/pending_tasks response
type CatPendingTasksResp struct {
PendingTasks []CatPendingTaskResp
response *opensearch.Response
}
// CatPendingTaskResp represents one index of the CatPendingTasksResp
type CatPendingTaskResp struct {
InsertOrder string `json:"insertOrder"`
TimeInQueue string `json:"timeInQueue"`
Priority string `json:"priority"`
Source string `json:"source"`
}
// Inspect returns the Inspect type containing the raw *opensearch.Response
func (r CatPendingTasksResp) Inspect() Inspect {
return Inspect{
Response: r.response,
}
}
@@ -0,0 +1,96 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
// Modifications Copyright OpenSearch Contributors. See
// GitHub history for details.
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package opensearchapi
import (
"strconv"
"strings"
"time"
)
// CatPluginsParams represents possible parameters for the CatPluginsReq
type CatPluginsParams struct {
H []string
Local *bool
MasterTimeout time.Duration
ClusterManagerTimeout time.Duration
Sort []string
V *bool
Pretty bool
Human bool
ErrorTrace bool
FilterPath []string
}
func (r CatPluginsParams) get() map[string]string {
params := make(map[string]string)
if len(r.H) > 0 {
params["h"] = strings.Join(r.H, ",")
}
if r.Local != nil {
params["local"] = strconv.FormatBool(*r.Local)
}
if r.MasterTimeout != 0 {
params["master_timeout"] = formatDuration(r.MasterTimeout)
}
if r.ClusterManagerTimeout != 0 {
params["cluster_manager_timeout"] = formatDuration(r.ClusterManagerTimeout)
}
if len(r.Sort) > 0 {
params["s"] = strings.Join(r.Sort, ",")
}
if r.V != nil {
params["v"] = strconv.FormatBool(*r.V)
}
if r.Pretty {
params["pretty"] = "true"
}
if r.Human {
params["human"] = "true"
}
if r.ErrorTrace {
params["error_trace"] = "true"
}
if len(r.FilterPath) > 0 {
params["filter_path"] = strings.Join(r.FilterPath, ",")
}
params["format"] = "json"
return params
}
@@ -0,0 +1,52 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
package opensearchapi
import (
"net/http"
"github.com/opensearch-project/opensearch-go/v4"
)
// CatPluginsReq represent possible options for the /_cat/plugins request
type CatPluginsReq struct {
Header http.Header
Params CatPluginsParams
}
// GetRequest returns the *http.Request that gets executed by the client
func (r CatPluginsReq) GetRequest() (*http.Request, error) {
return opensearch.BuildRequest(
"GET",
"/_cat/plugins",
nil,
r.Params.get(),
r.Header,
)
}
// CatPluginsResp represents the returned struct of the /_cat/plugins response
type CatPluginsResp struct {
Plugins []CatPluginResp
response *opensearch.Response
}
// CatPluginResp represents one index of the CatPluginsResp
type CatPluginResp struct {
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Component string `json:"component,omitempty"`
Version string `json:"version,omitempty"`
Description string `json:"description,omitempty"`
}
// Inspect returns the Inspect type containing the raw *opensearch.Response
func (r CatPluginsResp) Inspect() Inspect {
return Inspect{
Response: r.response,
}
}
@@ -0,0 +1,100 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
// Modifications Copyright OpenSearch Contributors. See
// GitHub history for details.
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package opensearchapi
import (
"strconv"
"strings"
)
// CatRecoveryParams represents possible parameters for the CatRecoveryReq
type CatRecoveryParams struct {
ActiveOnly *bool
Bytes string
Detailed *bool
H []string
Sort []string
Time string
V *bool
Pretty bool
Human bool
ErrorTrace bool
FilterPath []string
}
func (r CatRecoveryParams) get() map[string]string {
params := make(map[string]string)
if r.ActiveOnly != nil {
params["active_only"] = strconv.FormatBool(*r.ActiveOnly)
}
if r.Bytes != "" {
params["bytes"] = r.Bytes
}
if r.Detailed != nil {
params["detailed"] = strconv.FormatBool(*r.Detailed)
}
if len(r.H) > 0 {
params["h"] = strings.Join(r.H, ",")
}
if len(r.Sort) > 0 {
params["s"] = strings.Join(r.Sort, ",")
}
if r.Time != "" {
params["time"] = r.Time
}
if r.V != nil {
params["v"] = strconv.FormatBool(*r.V)
}
if r.Pretty {
params["pretty"] = "true"
}
if r.Human {
params["human"] = "true"
}
if r.ErrorTrace {
params["error_trace"] = "true"
}
if len(r.FilterPath) > 0 {
params["filter_path"] = strings.Join(r.FilterPath, ",")
}
params["format"] = "json"
return params
}
@@ -0,0 +1,83 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
package opensearchapi
import (
"net/http"
"strings"
"github.com/opensearch-project/opensearch-go/v4"
)
// CatRecoveryReq represent possible options for the /_cat/recovery request
type CatRecoveryReq struct {
Indices []string
Header http.Header
Params CatRecoveryParams
}
// GetRequest returns the *http.Request that gets executed by the client
func (r CatRecoveryReq) GetRequest() (*http.Request, error) {
indices := strings.Join(r.Indices, ",")
var path strings.Builder
path.Grow(len("/_cat/recovery/") + len(indices))
path.WriteString("/_cat/recovery")
if len(r.Indices) > 0 {
path.WriteString("/")
path.WriteString(indices)
}
return opensearch.BuildRequest(
"GET",
path.String(),
nil,
r.Params.get(),
r.Header,
)
}
// CatRecoveryResp represents the returned struct of the /_cat/recovery response
type CatRecoveryResp struct {
Recovery []CatRecoveryItemResp
response *opensearch.Response
}
// CatRecoveryItemResp represents one index of the CatRecoveryResp
type CatRecoveryItemResp struct {
Index string `json:"index"`
Shard int `json:"shard,string"`
StartTime string `json:"start_time"`
StartTimeMillis int `json:"start_time_millis,string"`
StopTime string `json:"stop_time"`
StopTimeMillis int `json:"stop_time_millis,string"`
Time string `json:"time"`
Type string `json:"type"`
Stage string `json:"stage"`
SourceHost string `json:"source_host"`
SourceNode string `json:"source_node"`
TargetHost string `json:"target_host"`
TargetNode string `json:"target_node"`
Repository string `json:"repository"`
Snapshot string `json:"snapshot"`
Files int `json:"files,string"`
FilesRecovered int `json:"files_recovered,string"`
FilesPercent string `json:"files_percent"`
FilesTotal int `json:"files_total,string"`
Bytes string `json:"bytes"`
BytesRecovered string `json:"bytes_recovered"`
BytesPercent string `json:"bytes_percent"`
BytesTotal string `json:"bytes_total"`
TranslogOps int `json:"translog_ops,string"`
TranslogOpsRecovered int `json:"translog_ops_recovered,string"`
TranslogOpsPercent string `json:"translog_ops_percent"`
}
// Inspect returns the Inspect type containing the raw *opensearch.Response
func (r CatRecoveryResp) Inspect() Inspect {
return Inspect{
Response: r.response,
}
}
@@ -0,0 +1,96 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
// Modifications Copyright OpenSearch Contributors. See
// GitHub history for details.
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package opensearchapi
import (
"strconv"
"strings"
"time"
)
// CatRepositoriesParams represents possible parameters for the CatRepositoriesReq
type CatRepositoriesParams struct {
H []string
Local *bool
MasterTimeout time.Duration
ClusterManagerTimeout time.Duration
Sort []string
V *bool
Pretty bool
Human bool
ErrorTrace bool
FilterPath []string
}
func (r CatRepositoriesParams) get() map[string]string {
params := make(map[string]string)
if len(r.H) > 0 {
params["h"] = strings.Join(r.H, ",")
}
if r.Local != nil {
params["local"] = strconv.FormatBool(*r.Local)
}
if r.MasterTimeout != 0 {
params["master_timeout"] = formatDuration(r.MasterTimeout)
}
if r.ClusterManagerTimeout != 0 {
params["cluster_manager_timeout"] = formatDuration(r.ClusterManagerTimeout)
}
if len(r.Sort) > 0 {
params["s"] = strings.Join(r.Sort, ",")
}
if r.V != nil {
params["v"] = strconv.FormatBool(*r.V)
}
if r.Pretty {
params["pretty"] = "true"
}
if r.Human {
params["human"] = "true"
}
if r.ErrorTrace {
params["error_trace"] = "true"
}
if len(r.FilterPath) > 0 {
params["filter_path"] = strings.Join(r.FilterPath, ",")
}
params["format"] = "json"
return params
}
@@ -0,0 +1,49 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
package opensearchapi
import (
"net/http"
"github.com/opensearch-project/opensearch-go/v4"
)
// CatRepositoriesReq represent possible options for the /_cat/repositories request
type CatRepositoriesReq struct {
Header http.Header
Params CatRepositoriesParams
}
// GetRequest returns the *http.Request that gets executed by the client
func (r CatRepositoriesReq) GetRequest() (*http.Request, error) {
return opensearch.BuildRequest(
"GET",
"/_cat/repositories",
nil,
r.Params.get(),
r.Header,
)
}
// CatRepositoriesResp represents the returned struct of the /_cat/repositories response
type CatRepositoriesResp struct {
Repositories []CatRepositorieResp
response *opensearch.Response
}
// CatRepositorieResp represents one index of the CatRepositoriesResp
type CatRepositorieResp struct {
ID string `json:"id"`
Type string `json:"type"`
}
// Inspect returns the Inspect type containing the raw *opensearch.Response
func (r CatRepositoriesResp) Inspect() Inspect {
return Inspect{
Response: r.response,
}
}
@@ -0,0 +1,101 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
// Modifications Copyright OpenSearch Contributors. See
// GitHub history for details.
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package opensearchapi
import (
"strconv"
"strings"
"time"
)
// CatSegmentsParams represents possible parameters for the CatSegmentsReq
type CatSegmentsParams struct {
Bytes string
H []string
Local *bool
MasterTimeout time.Duration
ClusterManagerTimeout time.Duration
Sort []string
V *bool
Pretty bool
Human bool
ErrorTrace bool
FilterPath []string
}
func (r CatSegmentsParams) get() map[string]string {
params := make(map[string]string)
if r.Bytes != "" {
params["bytes"] = r.Bytes
}
if len(r.H) > 0 {
params["h"] = strings.Join(r.H, ",")
}
if r.Local != nil {
params["local"] = strconv.FormatBool(*r.Local)
}
if r.MasterTimeout != 0 {
params["master_timeout"] = formatDuration(r.MasterTimeout)
}
if r.ClusterManagerTimeout != 0 {
params["cluster_manager_timeout"] = formatDuration(r.ClusterManagerTimeout)
}
if len(r.Sort) > 0 {
params["s"] = strings.Join(r.Sort, ",")
}
if r.V != nil {
params["v"] = strconv.FormatBool(*r.V)
}
if r.Pretty {
params["pretty"] = "true"
}
if r.Human {
params["human"] = "true"
}
if r.ErrorTrace {
params["error_trace"] = "true"
}
if len(r.FilterPath) > 0 {
params["filter_path"] = strings.Join(r.FilterPath, ",")
}
params["format"] = "json"
return params
}
@@ -0,0 +1,72 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
package opensearchapi
import (
"net/http"
"strings"
"github.com/opensearch-project/opensearch-go/v4"
)
// CatSegmentsReq represent possible options for the /_cat/segments request
type CatSegmentsReq struct {
Indices []string
Header http.Header
Params CatSegmentsParams
}
// GetRequest returns the *http.Request that gets executed by the client
func (r CatSegmentsReq) GetRequest() (*http.Request, error) {
indices := strings.Join(r.Indices, ",")
var path strings.Builder
path.Grow(len("/_cat/segments/") + len(indices))
path.WriteString("/_cat/segments")
if len(r.Indices) > 0 {
path.WriteString("/")
path.WriteString(indices)
}
return opensearch.BuildRequest(
"GET",
path.String(),
nil,
r.Params.get(),
r.Header,
)
}
// CatSegmentsResp represents the returned struct of the /_cat/segments response
type CatSegmentsResp struct {
Segments []CatSegmentResp
response *opensearch.Response
}
// CatSegmentResp represents one index of the CatSegmentsResp
type CatSegmentResp struct {
Index string `json:"index"`
Shard int `json:"shard,string"`
Prirep string `json:"prirep"`
IP string `json:"ip"`
ID string `json:"id"`
Segment string `json:"segment"`
Generation int `json:"generation,string"`
DocsCount int `json:"docs.count,string"`
DocsDeleted int `json:"docs.deleted,string"`
Size string `json:"size"`
SizeMemory string `json:"size.memory"`
Committed bool `json:"committed,string"`
Searchable bool `json:"searchable,string"`
Version string `json:"version"`
Compound bool `json:"compound,string"`
}
// Inspect returns the Inspect type containing the raw *opensearch.Response
func (r CatSegmentsResp) Inspect() Inspect {
return Inspect{
Response: r.response,
}
}
@@ -0,0 +1,106 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
// Modifications Copyright OpenSearch Contributors. See
// GitHub history for details.
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package opensearchapi
import (
"strconv"
"strings"
"time"
)
// CatShardsParams represents possible parameters for the CatShardsReq
type CatShardsParams struct {
Bytes string
H []string
Local *bool
MasterTimeout time.Duration
ClusterManagerTimeout time.Duration
Sort []string
Time string
V *bool
Pretty bool
Human bool
ErrorTrace bool
FilterPath []string
}
func (r CatShardsParams) get() map[string]string {
params := make(map[string]string)
if r.Bytes != "" {
params["bytes"] = r.Bytes
}
if len(r.H) > 0 {
params["h"] = strings.Join(r.H, ",")
}
if r.Local != nil {
params["local"] = strconv.FormatBool(*r.Local)
}
if r.MasterTimeout != 0 {
params["master_timeout"] = formatDuration(r.MasterTimeout)
}
if r.ClusterManagerTimeout != 0 {
params["cluster_manager_timeout"] = formatDuration(r.ClusterManagerTimeout)
}
if len(r.Sort) > 0 {
params["s"] = strings.Join(r.Sort, ",")
}
if r.Time != "" {
params["time"] = r.Time
}
if r.V != nil {
params["v"] = strconv.FormatBool(*r.V)
}
if r.Pretty {
params["pretty"] = "true"
}
if r.Human {
params["human"] = "true"
}
if r.ErrorTrace {
params["error_trace"] = "true"
}
if len(r.FilterPath) > 0 {
params["filter_path"] = strings.Join(r.FilterPath, ",")
}
params["format"] = "json"
return params
}
@@ -0,0 +1,137 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
package opensearchapi
import (
"net/http"
"strings"
"github.com/opensearch-project/opensearch-go/v4"
)
// CatShardsReq represent possible options for the /_cat/shards request
type CatShardsReq struct {
Indices []string
Header http.Header
Params CatShardsParams
}
// GetRequest returns the *http.Request that gets executed by the client
func (r CatShardsReq) GetRequest() (*http.Request, error) {
indices := strings.Join(r.Indices, ",")
var path strings.Builder
path.Grow(len("/_cat/shards/") + len(indices))
path.WriteString("/_cat/shards")
if len(r.Indices) > 0 {
path.WriteString("/")
path.WriteString(indices)
}
return opensearch.BuildRequest(
"GET",
path.String(),
nil,
r.Params.get(),
r.Header,
)
}
// CatShardsResp represents the returned struct of the /_cat/shards response
type CatShardsResp struct {
Shards []CatShardResp
response *opensearch.Response
}
// CatShardResp represents one index of the CatShardsResp
type CatShardResp struct {
Index string `json:"index"`
Shard int `json:"shard,string"`
Prirep string `json:"prirep"`
State string `json:"state"`
Docs *string `json:"docs"`
Store *string `json:"store"`
IP *string `json:"ip"`
ID *string `json:"id"`
Node *string `json:"node"`
SyncID *string `json:"sync_id"`
UnassignedReason *string `json:"unassigned.reason"`
UnassignedAt *string `json:"unassigned.at"`
UnassignedFor *string `json:"unassigned.for"`
UnassignedDetails *string `json:"unassigned.details"`
RecoverysourceType *string `json:"recoverysource.type"`
CompletionSize *string `json:"completion.size"`
FielddataMemorySize *string `json:"fielddata.memory_size"`
FielddataEvictions *int `json:"fielddata.evictions,string"`
QueryCacheMemorySize *string `json:"query_cache.memory_size"`
QueryCacheEvictions *int `json:"query_cache.evictions,string"`
FlushTotal *int `json:"flush.total,string"`
FlushTotalTime *string `json:"flush.total_time"`
GetCurrent *int `json:"get.current,string"`
GetTime *string `json:"get.time"`
GetTotal *int `json:"get.total,string"`
GetExistsTime *string `json:"get.exists_time"`
GetExistsTotal *int `json:"get.exists_total,string"`
GetMissingTime *string `json:"get.missing_time"`
GetMissingTotal *int `json:"get.missing_total,string"`
IndexingDeleteCurrent *int `json:"indexing.delete_current,string"`
IndexingDeleteTime *string `json:"indexing.delete_time"`
IndexingDeleteTotal *string `json:"indexing.delete_total"`
IndexingIndexCurrent *int `json:"indexing.index_current,string"`
IndexingIndexTime *string `json:"indexing.index_time"`
IndexingIndexTotal *int `json:"indexing.index_total,string"`
IndexingIndexFailed *int `json:"indexing.index_failed,string"`
MergesCurrent *int `json:"merges.current,string"`
MergesCurrentDocs *int `json:"merges.current_docs,string"`
MergesCurrentSize *string `json:"merges.current_size"`
MergesTotal *int `json:"merges.total,string"`
MergesTotalDocs *int `json:"merges.total_docs,string"`
MergesTotalSize *string `json:"merges.total_size"`
MergesTotalTime *string `json:"merges.total_time"`
RefreshTotal *int `json:"refresh.total,string"`
RefreshTime *string `json:"refresh.time"`
RefreshExternalTotal *int `json:"refresh.external_total,string"`
RefreshExternalTime *string `json:"refresh.external_time"`
RefreshListeners *int `json:"refresh.listeners,string"`
SearchFetchCurrent *int `json:"search.fetch_current,string"`
SearchFetchTime *string `json:"search.fetch_time"`
SearchFetchTotal *int `json:"search.fetch_total,string"`
SearchOpenContexts *int `json:"search.open_contexts,string"`
SearchQueryCurrent *int `json:"search.query_current,string"`
SearchQueryTime *string `json:"search.query_time"`
SearchQueryTotal *int `json:"search.query_total,string"`
SearchConcurrentQueryCurrent *int `json:"search.concurrent_query_current,string"`
SearchConcurrentQueryTime *string `json:"search.concurrent_query_time"`
SearchConcurrentQueryTotal *int `json:"search.concurrent_query_total,string"`
SearchConcurrentAvgSliceCount *string `json:"search.concurrent_avg_slice_count"`
SearchScrollCurrent *int `json:"search.scroll_current,string"`
SearchScrollTime *string `json:"search.scroll_time"`
SearchScrollTotal *int `json:"search.scroll_total,string"`
SearchPointInTimeCurrent *int `json:"search.point_in_time_current,string"`
SearchPointInTimeTime *string `json:"search.point_in_time_time"`
SearchPointInTimeTotal *int `json:"search.point_in_time_total,string"`
SearchIdleReactivateCountTotal *int `json:"search.search_idle_reactivate_count_total,string"`
SegmentsCount *int `json:"segments.count,string"`
SegmentsMemory *string `json:"segments.memory"`
SegmentsIndexWriterMemory *string `json:"segments.index_writer_memory"`
SegmentsVersionMapMemory *string `json:"segments.version_map_memory"`
SegmentsFixedBitsetMemory *string `json:"segments.fixed_bitset_memory"`
SeqNoMax *int `json:"seq_no.max,string"`
SeqNoLocalCheckpoint *int `json:"seq_no.local_checkpoint,string"`
SeqNoGlobalCheckpoint *int `json:"seq_no.global_checkpoint,string"`
WarmerCurrent *int `json:"warmer.current,string"`
WarmerTotal *int `json:"warmer.total,string"`
WarmerTotalTime *string `json:"warmer.total_time"`
PathData *string `json:"path.data"`
PathState *string `json:"path.state"`
DocsDeleted *int `json:"docs.deleted,string"`
}
// Inspect returns the Inspect type containing the raw *opensearch.Response
func (r CatShardsResp) Inspect() Inspect {
return Inspect{
Response: r.response,
}
}
@@ -0,0 +1,101 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
// Modifications Copyright OpenSearch Contributors. See
// GitHub history for details.
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package opensearchapi
import (
"strconv"
"strings"
"time"
)
// CatSnapshotsParams represents possible parameters for the CatSnapshotsReq
type CatSnapshotsParams struct {
H []string
Local *bool
MasterTimeout time.Duration
ClusterManagerTimeout time.Duration
Sort []string
Time string
V *bool
Pretty bool
Human bool
ErrorTrace bool
FilterPath []string
}
func (r CatSnapshotsParams) get() map[string]string {
params := make(map[string]string)
if len(r.H) > 0 {
params["h"] = strings.Join(r.H, ",")
}
if r.Local != nil {
params["local"] = strconv.FormatBool(*r.Local)
}
if r.MasterTimeout != 0 {
params["master_timeout"] = formatDuration(r.MasterTimeout)
}
if r.ClusterManagerTimeout != 0 {
params["cluster_manager_timeout"] = formatDuration(r.ClusterManagerTimeout)
}
if len(r.Sort) > 0 {
params["s"] = strings.Join(r.Sort, ",")
}
if r.Time != "" {
params["time"] = r.Time
}
if r.V != nil {
params["v"] = strconv.FormatBool(*r.V)
}
if r.Pretty {
params["pretty"] = "true"
}
if r.Human {
params["human"] = "true"
}
if r.ErrorTrace {
params["error_trace"] = "true"
}
if len(r.FilterPath) > 0 {
params["filter_path"] = strings.Join(r.FilterPath, ",")
}
params["format"] = "json"
return params
}
@@ -0,0 +1,61 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
package opensearchapi
import (
"fmt"
"net/http"
"github.com/opensearch-project/opensearch-go/v4"
)
// CatSnapshotsReq represent possible options for the /_cat/snapshots request
type CatSnapshotsReq struct {
Repository string
Header http.Header
Params CatSnapshotsParams
}
// GetRequest returns the *http.Request that gets executed by the client
func (r CatSnapshotsReq) GetRequest() (*http.Request, error) {
return opensearch.BuildRequest(
"GET",
fmt.Sprintf("%s%s", "/_cat/snapshots/", r.Repository),
nil,
r.Params.get(),
r.Header,
)
}
// CatSnapshotsResp represents the returned struct of the /_cat/snapshots response
type CatSnapshotsResp struct {
Snapshots []CatSnapshotResp
response *opensearch.Response
}
// CatSnapshotResp represents one index of the CatSnapshotsResp
type CatSnapshotResp struct {
ID string `json:"id"`
Status string `json:"status"`
StartEpoch int `json:"start_epoch,string"`
StartTime string `json:"start_time"`
EndEpoch int `json:"end_epoch,string"`
EndTime string `json:"end_time"`
Duration string `json:"duration"`
Indices int `json:"indices,string"`
SuccessfulShards int `json:"successful_shards,string"`
FailedShards int `json:"failed_shards,string"`
TotalShards int `json:"total_shards,string"`
Reason string `json:"reason"`
}
// Inspect returns the Inspect type containing the raw *opensearch.Response
func (r CatSnapshotsResp) Inspect() Inspect {
return Inspect{
Response: r.response,
}
}
@@ -0,0 +1,110 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
// Modifications Copyright OpenSearch Contributors. See
// GitHub history for details.
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package opensearchapi
import (
"strconv"
"strings"
)
// CatTasksParams represents possible parameters for the CatTasksReq
type CatTasksParams struct {
Actions []string
Detailed *bool
H []string
Nodes []string
ParentTaskID string
Local *bool
Sort []string
Time string
V *bool
Pretty bool
Human bool
ErrorTrace bool
FilterPath []string
}
func (r CatTasksParams) get() map[string]string {
params := make(map[string]string)
if len(r.Actions) > 0 {
params["actions"] = strings.Join(r.Actions, ",")
}
if r.Detailed != nil {
params["detailed"] = strconv.FormatBool(*r.Detailed)
}
if len(r.H) > 0 {
params["h"] = strings.Join(r.H, ",")
}
if len(r.Nodes) > 0 {
params["nodes"] = strings.Join(r.Nodes, ",")
}
if r.ParentTaskID != "" {
params["parent_task_id"] = r.ParentTaskID
}
if r.Local != nil {
params["local"] = strconv.FormatBool(*r.Local)
}
if len(r.Sort) > 0 {
params["s"] = strings.Join(r.Sort, ",")
}
if r.Time != "" {
params["time"] = r.Time
}
if r.V != nil {
params["v"] = strconv.FormatBool(*r.V)
}
if r.Pretty {
params["pretty"] = "true"
}
if r.Human {
params["human"] = "true"
}
if r.ErrorTrace {
params["error_trace"] = "true"
}
if len(r.FilterPath) > 0 {
params["filter_path"] = strings.Join(r.FilterPath, ",")
}
params["format"] = "json"
return params
}
@@ -0,0 +1,62 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
package opensearchapi
import (
"net/http"
"github.com/opensearch-project/opensearch-go/v4"
)
// CatTasksReq represent possible options for the /_cat/tasks request
type CatTasksReq struct {
Header http.Header
Params CatTasksParams
}
// GetRequest returns the *http.Request that gets executed by the client
func (r CatTasksReq) GetRequest() (*http.Request, error) {
return opensearch.BuildRequest(
"GET",
"/_cat/tasks",
nil,
r.Params.get(),
r.Header,
)
}
// CatTasksResp represents the returned struct of the /_cat/tasks response
type CatTasksResp struct {
Tasks []CatTaskResp
response *opensearch.Response
}
// CatTaskResp represents one index of the CatTasksResp
type CatTaskResp struct {
ID string `json:"id"`
Action string `json:"action"`
TaskID string `json:"task_id"`
ParentTaskID string `json:"parent_task_id"`
Type string `json:"type"`
StartTime int `json:"start_time,string"`
Timestamp string `json:"timestamp"`
RunningTimeNs int `json:"running_time_ns,string"`
RunningTime string `json:"running_time"`
NodeID string `json:"node_id"`
IP string `json:"ip"`
Port int `json:"port,string"`
Node string `json:"node"`
Version string `json:"version"`
XOpaqueID string `json:"x_opaque_id"`
}
// Inspect returns the Inspect type containing the raw *opensearch.Response
func (r CatTasksResp) Inspect() Inspect {
return Inspect{
Response: r.response,
}
}
@@ -0,0 +1,96 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
// Modifications Copyright OpenSearch Contributors. See
// GitHub history for details.
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package opensearchapi
import (
"strconv"
"strings"
"time"
)
// CatTemplatesParams represents possible parameters for the CatTemplatesReq
type CatTemplatesParams struct {
H []string
Local *bool
MasterTimeout time.Duration
ClusterManagerTimeout time.Duration
Sort []string
V *bool
Pretty bool
Human bool
ErrorTrace bool
FilterPath []string
}
func (r CatTemplatesParams) get() map[string]string {
params := make(map[string]string)
if len(r.H) > 0 {
params["h"] = strings.Join(r.H, ",")
}
if r.Local != nil {
params["local"] = strconv.FormatBool(*r.Local)
}
if r.MasterTimeout != 0 {
params["master_timeout"] = formatDuration(r.MasterTimeout)
}
if r.ClusterManagerTimeout != 0 {
params["cluster_manager_timeout"] = formatDuration(r.ClusterManagerTimeout)
}
if len(r.Sort) > 0 {
params["s"] = strings.Join(r.Sort, ",")
}
if r.V != nil {
params["v"] = strconv.FormatBool(*r.V)
}
if r.Pretty {
params["pretty"] = "true"
}
if r.Human {
params["human"] = "true"
}
if r.ErrorTrace {
params["error_trace"] = "true"
}
if len(r.FilterPath) > 0 {
params["filter_path"] = strings.Join(r.FilterPath, ",")
}
params["format"] = "json"
return params
}
@@ -0,0 +1,62 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
package opensearchapi
import (
"net/http"
"strings"
"github.com/opensearch-project/opensearch-go/v4"
)
// CatTemplatesReq represent possible options for the /_cat/templates request
type CatTemplatesReq struct {
Templates []string
Header http.Header
Params CatTemplatesParams
}
// GetRequest returns the *http.Request that gets executed by the client
func (r CatTemplatesReq) GetRequest() (*http.Request, error) {
templates := strings.Join(r.Templates, ",")
var path strings.Builder
path.Grow(len("/_cat/templates/") + len(templates))
path.WriteString("/_cat/templates")
if len(r.Templates) > 0 {
path.WriteString("/")
path.WriteString(templates)
}
return opensearch.BuildRequest(
"GET",
path.String(),
nil,
r.Params.get(),
r.Header,
)
}
// CatTemplatesResp represents the returned struct of the /_cat/templates response
type CatTemplatesResp struct {
Templates []CatTemplateResp
response *opensearch.Response
}
// CatTemplateResp represents one index of the CatTemplatesResp
type CatTemplateResp struct {
Name string `json:"name"`
IndexPatterns string `json:"index_patterns"`
Order int `json:"order,string"`
Version *string `json:"version"`
ComposedOf string `json:"composed_of"`
}
// Inspect returns the Inspect type containing the raw *opensearch.Response
func (r CatTemplatesResp) Inspect() Inspect {
return Inspect{
Response: r.response,
}
}
@@ -0,0 +1,96 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
// Modifications Copyright OpenSearch Contributors. See
// GitHub history for details.
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package opensearchapi
import (
"strconv"
"strings"
"time"
)
// CatThreadPoolParams represents possible parameters for the CatThreadPoolReq
type CatThreadPoolParams struct {
H []string
Local *bool
MasterTimeout time.Duration
ClusterManagerTimeout time.Duration
Sort []string
V *bool
Pretty bool
Human bool
ErrorTrace bool
FilterPath []string
}
func (r CatThreadPoolParams) get() map[string]string {
params := make(map[string]string)
if len(r.H) > 0 {
params["h"] = strings.Join(r.H, ",")
}
if r.Local != nil {
params["local"] = strconv.FormatBool(*r.Local)
}
if r.MasterTimeout != 0 {
params["master_timeout"] = formatDuration(r.MasterTimeout)
}
if r.ClusterManagerTimeout != 0 {
params["cluster_manager_timeout"] = formatDuration(r.ClusterManagerTimeout)
}
if len(r.Sort) > 0 {
params["s"] = strings.Join(r.Sort, ",")
}
if r.V != nil {
params["v"] = strconv.FormatBool(*r.V)
}
if r.Pretty {
params["pretty"] = "true"
}
if r.Human {
params["human"] = "true"
}
if r.ErrorTrace {
params["error_trace"] = "true"
}
if len(r.FilterPath) > 0 {
params["filter_path"] = strings.Join(r.FilterPath, ",")
}
params["format"] = "json"
return params
}
@@ -0,0 +1,78 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
package opensearchapi
import (
"net/http"
"strings"
"github.com/opensearch-project/opensearch-go/v4"
)
// CatThreadPoolReq represent possible options for the /_cat/thread_pool request
type CatThreadPoolReq struct {
Pools []string
Header http.Header
Params CatThreadPoolParams
}
// GetRequest returns the *http.Request that gets executed by the client
func (r CatThreadPoolReq) GetRequest() (*http.Request, error) {
pools := strings.Join(r.Pools, ",")
var path strings.Builder
path.Grow(len("/_cat/thread_pool/") + len(pools))
path.WriteString("/_cat/thread_pool")
if len(r.Pools) > 0 {
path.WriteString("/")
path.WriteString(pools)
}
return opensearch.BuildRequest(
"GET",
path.String(),
nil,
r.Params.get(),
r.Header,
)
}
// CatThreadPoolResp represents the returned struct of the /_cat/thread_pool response
type CatThreadPoolResp struct {
ThreadPool []CatThreadPoolItemResp
response *opensearch.Response
}
// CatThreadPoolItemResp represents one index of the CatThreadPoolResp
type CatThreadPoolItemResp struct {
NodeName string `json:"node_name"`
NodeID string `json:"node_id"`
EphemeralNodeID string `json:"ephemeral_node_id"`
PID int `json:"pid,string"`
Host string `json:"host"`
IP string `json:"ip"`
Port int `json:"port,string"`
Name string `json:"name"`
Type string `json:"type"`
Active int `json:"active,string"`
PoolSize int `json:"pool_size,string"`
Queue int `json:"queue,string"`
QueueSize int `json:"queue_size,string"`
Rejected int `json:"rejected,string"`
Largest int `json:"largest,string"`
Completed int `json:"completed,string"`
Core *int `json:"core,string"`
Max *int `json:"max,string"`
Size *int `json:"size,string"`
KeepAlive *string `json:"keep_alive"`
TotalWaitTime string `json:"total_wait_time"`
}
// Inspect returns the Inspect type containing the raw *opensearch.Response
func (r CatThreadPoolResp) Inspect() Inspect {
return Inspect{
Response: r.response,
}
}
@@ -0,0 +1,351 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
package opensearchapi
import (
"context"
)
type catClient struct {
apiClient *Client
}
// Aliases executes a /_cat/aliases request with the optional CatAliasesReq
func (c catClient) Aliases(ctx context.Context, req *CatAliasesReq) (*CatAliasesResp, error) {
if req == nil {
req = &CatAliasesReq{}
}
var (
data CatAliasesResp
err error
)
if data.response, err = c.apiClient.do(ctx, req, &data.Aliases); err != nil {
return &data, err
}
return &data, nil
}
// Allocation executes a /_cat/allocation request with the optional CatAllocationReq
func (c catClient) Allocation(ctx context.Context, req *CatAllocationReq) (*CatAllocationsResp, error) {
if req == nil {
req = &CatAllocationReq{}
}
var (
data CatAllocationsResp
err error
)
if data.response, err = c.apiClient.do(ctx, req, &data.Allocations); err != nil {
return &data, err
}
return &data, nil
}
// ClusterManager executes a /_cat/cluster_manager request with the optional CatClusterManagerReq
func (c catClient) ClusterManager(ctx context.Context, req *CatClusterManagerReq) (*CatClusterManagersResp, error) {
if req == nil {
req = &CatClusterManagerReq{}
}
var (
data CatClusterManagersResp
err error
)
if data.response, err = c.apiClient.do(ctx, req, &data.ClusterManagers); err != nil {
return &data, err
}
return &data, nil
}
// Count executes a /_cat/count request with the optional CatCountReq
func (c catClient) Count(ctx context.Context, req *CatCountReq) (*CatCountsResp, error) {
if req == nil {
req = &CatCountReq{}
}
var (
data CatCountsResp
err error
)
if data.response, err = c.apiClient.do(ctx, req, &data.Counts); err != nil {
return &data, err
}
return &data, nil
}
// FieldData executes a /_cat/fielddata request with the optional CatFieldDataReq
func (c catClient) FieldData(ctx context.Context, req *CatFieldDataReq) (*CatFieldDataResp, error) {
if req == nil {
req = &CatFieldDataReq{}
}
var (
data CatFieldDataResp
err error
)
if data.response, err = c.apiClient.do(ctx, req, &data.FieldData); err != nil {
return &data, err
}
return &data, nil
}
// Health executes a /_cat/health request with the optional CatHealthReq
func (c catClient) Health(ctx context.Context, req *CatHealthReq) (*CatHealthResp, error) {
if req == nil {
req = &CatHealthReq{}
}
var (
data CatHealthResp
err error
)
if data.response, err = c.apiClient.do(ctx, req, &data.Health); err != nil {
return &data, err
}
return &data, nil
}
// Indices executes a /_cat/indices request with the optional CatIndicesReq
func (c catClient) Indices(ctx context.Context, req *CatIndicesReq) (*CatIndicesResp, error) {
if req == nil {
req = &CatIndicesReq{}
}
var (
data CatIndicesResp
err error
)
if data.response, err = c.apiClient.do(ctx, req, &data.Indices); err != nil {
return &data, err
}
return &data, nil
}
// Master executes a /_cat/master request with the optional CatMasterReq
func (c catClient) Master(ctx context.Context, req *CatMasterReq) (*CatMasterResp, error) {
if req == nil {
req = &CatMasterReq{}
}
var (
data CatMasterResp
err error
)
if data.response, err = c.apiClient.do(ctx, req, &data.Master); err != nil {
return &data, err
}
return &data, nil
}
// NodeAttrs executes a /_cat/nodeattrs request with the optional CatNodeAttrsReq
func (c catClient) NodeAttrs(ctx context.Context, req *CatNodeAttrsReq) (*CatNodeAttrsResp, error) {
if req == nil {
req = &CatNodeAttrsReq{}
}
var (
data CatNodeAttrsResp
err error
)
if data.response, err = c.apiClient.do(ctx, req, &data.NodeAttrs); err != nil {
return &data, err
}
return &data, nil
}
// Nodes executes a /_cat/nodes request with the optional CatNodesReq
func (c catClient) Nodes(ctx context.Context, req *CatNodesReq) (*CatNodesResp, error) {
if req == nil {
req = &CatNodesReq{}
}
var (
data CatNodesResp
err error
)
if data.response, err = c.apiClient.do(ctx, req, &data.Nodes); err != nil {
return &data, err
}
return &data, nil
}
// PendingTasks executes a /_cat/pending_tasks request with the optional CatPendingTasksReq
func (c catClient) PendingTasks(ctx context.Context, req *CatPendingTasksReq) (*CatPendingTasksResp, error) {
if req == nil {
req = &CatPendingTasksReq{}
}
var (
data CatPendingTasksResp
err error
)
if data.response, err = c.apiClient.do(ctx, req, &data.PendingTasks); err != nil {
return &data, err
}
return &data, nil
}
// Plugins executes a /_cat/plugins request with the optional CatPluginsReq
func (c catClient) Plugins(ctx context.Context, req *CatPluginsReq) (*CatPluginsResp, error) {
if req == nil {
req = &CatPluginsReq{}
}
var (
data CatPluginsResp
err error
)
if data.response, err = c.apiClient.do(ctx, req, &data.Plugins); err != nil {
return &data, err
}
return &data, nil
}
// Recovery executes a /_cat/recovery request with the optional CatRecoveryReq
func (c catClient) Recovery(ctx context.Context, req *CatRecoveryReq) (*CatRecoveryResp, error) {
if req == nil {
req = &CatRecoveryReq{}
}
var (
data CatRecoveryResp
err error
)
if data.response, err = c.apiClient.do(ctx, req, &data.Recovery); err != nil {
return &data, err
}
return &data, nil
}
// Repositories executes a /_cat/repositories request with the optional CatRepositoriesReq
func (c catClient) Repositories(ctx context.Context, req *CatRepositoriesReq) (*CatRepositoriesResp, error) {
if req == nil {
req = &CatRepositoriesReq{}
}
var (
data CatRepositoriesResp
err error
)
if data.response, err = c.apiClient.do(ctx, req, &data.Repositories); err != nil {
return &data, err
}
return &data, nil
}
// Segments executes a /_cat/segments request with the optional CatSegmentsReq
func (c catClient) Segments(ctx context.Context, req *CatSegmentsReq) (*CatSegmentsResp, error) {
if req == nil {
req = &CatSegmentsReq{}
}
var (
data CatSegmentsResp
err error
)
if data.response, err = c.apiClient.do(ctx, req, &data.Segments); err != nil {
return &data, err
}
return &data, nil
}
// Shards executes a /_cat/shards request with the optional CatShardsReq
func (c catClient) Shards(ctx context.Context, req *CatShardsReq) (*CatShardsResp, error) {
if req == nil {
req = &CatShardsReq{}
}
var (
data CatShardsResp
err error
)
if data.response, err = c.apiClient.do(ctx, req, &data.Shards); err != nil {
return &data, err
}
return &data, nil
}
// Snapshots executes a /_cat/snapshots request with the required CatSnapshotsReq
func (c catClient) Snapshots(ctx context.Context, req CatSnapshotsReq) (*CatSnapshotsResp, error) {
var (
data CatSnapshotsResp
err error
)
if data.response, err = c.apiClient.do(ctx, req, &data.Snapshots); err != nil {
return &data, err
}
return &data, nil
}
// Tasks executes a /_cat/tasks request with the optional CatTasksReq
func (c catClient) Tasks(ctx context.Context, req *CatTasksReq) (*CatTasksResp, error) {
if req == nil {
req = &CatTasksReq{}
}
var (
data CatTasksResp
err error
)
if data.response, err = c.apiClient.do(ctx, req, &data.Tasks); err != nil {
return &data, err
}
return &data, nil
}
// Templates executes a /_cat/templates request with the optional CatTemplatesReq
func (c catClient) Templates(ctx context.Context, req *CatTemplatesReq) (*CatTemplatesResp, error) {
if req == nil {
req = &CatTemplatesReq{}
}
var (
data CatTemplatesResp
err error
)
if data.response, err = c.apiClient.do(ctx, req, &data.Templates); err != nil {
return &data, err
}
return &data, nil
}
// ThreadPool executes a /_cat/thread_pool request with the optional CatThreadPoolReq
func (c catClient) ThreadPool(ctx context.Context, req *CatThreadPoolReq) (*CatThreadPoolResp, error) {
if req == nil {
req = &CatThreadPoolReq{}
}
var (
data CatThreadPoolResp
err error
)
if data.response, err = c.apiClient.do(ctx, req, &data.ThreadPool); err != nil {
return &data, err
}
return &data, nil
}
@@ -0,0 +1,73 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
// Modifications Copyright OpenSearch Contributors. See
// GitHub history for details.
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package opensearchapi
import (
"strconv"
"strings"
)
// ClusterAllocationExplainParams represents possible parameters for the ClusterAllocationExplainReq
type ClusterAllocationExplainParams struct {
IncludeDiskInfo *bool
IncludeYesDecisions *bool
Pretty bool
Human bool
ErrorTrace bool
FilterPath []string
}
func (r ClusterAllocationExplainParams) get() map[string]string {
params := make(map[string]string)
if r.IncludeDiskInfo != nil {
params["include_disk_info"] = strconv.FormatBool(*r.IncludeDiskInfo)
}
if r.IncludeYesDecisions != nil {
params["include_yes_decisions"] = strconv.FormatBool(*r.IncludeYesDecisions)
}
if r.Pretty {
params["pretty"] = "true"
}
if r.Human {
params["human"] = "true"
}
if r.ErrorTrace {
params["error_trace"] = "true"
}
if len(r.FilterPath) > 0 {
params["filter_path"] = strings.Join(r.FilterPath, ",")
}
return params
}
@@ -0,0 +1,112 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
package opensearchapi
import (
"bytes"
"encoding/json"
"io"
"net/http"
"github.com/opensearch-project/opensearch-go/v4"
)
// ClusterAllocationExplainReq represents possible options for the /_nodes request
type ClusterAllocationExplainReq struct {
Body *ClusterAllocationExplainBody
Header http.Header
Params ClusterAllocationExplainParams
}
// GetRequest returns the *http.Request that gets executed by the client
func (r ClusterAllocationExplainReq) GetRequest() (*http.Request, error) {
var reader io.Reader
if r.Body != nil {
body, err := json.Marshal(r.Body)
if err != nil {
return nil, err
}
reader = bytes.NewReader(body)
}
return opensearch.BuildRequest(
"GET",
"/_cluster/allocation/explain",
reader,
r.Params.get(),
r.Header,
)
}
// ClusterAllocationExplainBody represents the optional Body for the ClusterAllocationExplainReq
type ClusterAllocationExplainBody struct {
Index string `json:"index"`
Shard int `json:"shard"`
Primary bool `json:"primary"`
}
// ClusterAllocationExplainResp represents the returned struct of the /_nodes response
type ClusterAllocationExplainResp struct {
Index string `json:"index"`
Shard int `json:"shard"`
Primary bool `json:"primary"`
CurrentState string `json:"current_state"`
CurrentNode ClusterAllocationCurrentNode `json:"current_node"`
UnassignedInfo struct {
Reason string `json:"reason"`
At string `json:"at"`
LastAllocationStatus string `json:"last_allocation_status"`
} `json:"unassigned_info"`
CanAllocate string `json:"can_allocate"`
CanRemainOnCurrentNode string `json:"can_remain_on_current_node"`
CanRebalanceCluster string `json:"can_rebalance_cluster"`
CanRebalanceToOtherNode string `json:"can_rebalance_to_other_node"`
RebalanceExplanation string `json:"rebalance_explanation"`
AllocateExplanation string `json:"allocate_explanation"`
NodeAllocationDecisions []ClusterAllocationNodeDecisions `json:"node_allocation_decisions"`
CanRebalanceClusterDecisions []ClusterAllocationExplainDeciders `json:"can_rebalance_cluster_decisions"`
response *opensearch.Response
}
// Inspect returns the Inspect type containing the raw *opensearch.Response
func (r ClusterAllocationExplainResp) Inspect() Inspect {
return Inspect{Response: r.response}
}
// ClusterAllocationCurrentNode is a sub type of ClusterAllocationExplainResp containing information of the node the shard is on
type ClusterAllocationCurrentNode struct {
NodeID string `json:"id"`
NodeName string `json:"name"`
TransportAddress string `json:"transport_address"`
NodeAttributes struct {
ShardIndexingPressureEnabled string `json:"shard_indexing_pressure_enabled"`
} `json:"attributes"`
WeightRanking int `json:"weight_ranking"`
}
// ClusterAllocationNodeDecisions is a sub type of ClusterAllocationExplainResp containing information of a node allocation decission
type ClusterAllocationNodeDecisions struct {
NodeID string `json:"node_id"`
NodeName string `json:"node_name"`
TransportAddress string `json:"transport_address"`
NodeAttributes struct {
ShardIndexingPressureEnabled string `json:"shard_indexing_pressure_enabled"`
} `json:"node_attributes"`
NodeDecision string `json:"node_decision"`
WeightRanking int `json:"weight_ranking"`
Deciders []ClusterAllocationExplainDeciders `json:"deciders"`
}
// ClusterAllocationExplainDeciders is a sub type of ClusterAllocationExplainResp and
// ClusterAllocationNodeDecisions containing inforamtion about Deciders decissions
type ClusterAllocationExplainDeciders struct {
Decider string `json:"decider"`
Decision string `json:"decision"`
Explanation string `json:"explanation"`
}
@@ -0,0 +1,119 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
// Modifications Copyright OpenSearch Contributors. See
// GitHub history for details.
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package opensearchapi
import "strings"
// ClusterPutDecommissionParams represents possible parameters for the ClusterPutDecommissionReq
type ClusterPutDecommissionParams struct {
Pretty bool
Human bool
ErrorTrace bool
FilterPath []string
}
func (r ClusterPutDecommissionParams) get() map[string]string {
params := make(map[string]string)
if r.Pretty {
params["pretty"] = "true"
}
if r.Human {
params["human"] = "true"
}
if r.ErrorTrace {
params["error_trace"] = "true"
}
if len(r.FilterPath) > 0 {
params["filter_path"] = strings.Join(r.FilterPath, ",")
}
return params
}
// ClusterGetDecommissionParams represents possible parameters for the ClusterGetDecommissionReq
type ClusterGetDecommissionParams struct {
Pretty bool
Human bool
ErrorTrace bool
FilterPath []string
}
func (r ClusterGetDecommissionParams) get() map[string]string {
params := make(map[string]string)
if r.Pretty {
params["pretty"] = "true"
}
if r.Human {
params["human"] = "true"
}
if r.ErrorTrace {
params["error_trace"] = "true"
}
if len(r.FilterPath) > 0 {
params["filter_path"] = strings.Join(r.FilterPath, ",")
}
return params
}
// ClusterDeleteDecommissionParams represents possible parameters for the ClusterDeleteDecommissionReq
type ClusterDeleteDecommissionParams struct {
Pretty bool
Human bool
ErrorTrace bool
FilterPath []string
}
func (r ClusterDeleteDecommissionParams) get() map[string]string {
params := make(map[string]string)
if r.Pretty {
params["pretty"] = "true"
}
if r.Human {
params["human"] = "true"
}
if r.ErrorTrace {
params["error_trace"] = "true"
}
if len(r.FilterPath) > 0 {
params["filter_path"] = strings.Join(r.FilterPath, ",")
}
return params
}
@@ -0,0 +1,116 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
package opensearchapi
import (
"net/http"
"strings"
"github.com/opensearch-project/opensearch-go/v4"
)
// ClusterPutDecommissionReq represents possible options for the /_cluster/decommission/awareness request
type ClusterPutDecommissionReq struct {
AwarenessAttrName string
AwarenessAttrValue string
Header http.Header
Params ClusterPutDecommissionParams
}
// GetRequest returns the *http.Request that gets executed by the client
func (r ClusterPutDecommissionReq) GetRequest() (*http.Request, error) {
var path strings.Builder
path.Grow(34 + len(r.AwarenessAttrName) + len(r.AwarenessAttrValue))
path.WriteString("/_cluster/decommission/awareness/")
path.WriteString(r.AwarenessAttrName)
path.WriteString("/")
path.WriteString(r.AwarenessAttrValue)
return opensearch.BuildRequest(
"PUT",
path.String(),
nil,
r.Params.get(),
r.Header,
)
}
// ClusterPutDecommissionResp represents the returned struct of the /_cluster/decommission/awareness response
type ClusterPutDecommissionResp struct {
Acknowledged bool `json:"acknowledged"`
response *opensearch.Response
}
// Inspect returns the Inspect type containing the raw *opensearch.Response
func (r ClusterPutDecommissionResp) Inspect() Inspect {
return Inspect{Response: r.response}
}
// ClusterDeleteDecommissionReq represents possible options for the /_cluster/decommission/awareness request
type ClusterDeleteDecommissionReq struct {
Header http.Header
Params ClusterDeleteDecommissionParams
}
// GetRequest returns the *http.Request that gets executed by the client
func (r ClusterDeleteDecommissionReq) GetRequest() (*http.Request, error) {
return opensearch.BuildRequest(
"DELETE",
"/_cluster/decommission/awareness",
nil,
r.Params.get(),
r.Header,
)
}
// ClusterDeleteDecommissionResp represents the returned struct of the /_cluster/decommission/awareness response
type ClusterDeleteDecommissionResp struct {
Acknowledged bool `json:"acknowledged"`
response *opensearch.Response
}
// Inspect returns the Inspect type containing the raw *opensearch.Response
func (r ClusterDeleteDecommissionResp) Inspect() Inspect {
return Inspect{Response: r.response}
}
// ClusterGetDecommissionReq represents possible options for the /_cluster/decommission/awareness request
type ClusterGetDecommissionReq struct {
AwarenessAttrName string
Header http.Header
Params ClusterGetDecommissionParams
}
// GetRequest returns the *http.Request that gets executed by the client
func (r ClusterGetDecommissionReq) GetRequest() (*http.Request, error) {
var path strings.Builder
path.Grow(41 + len(r.AwarenessAttrName))
path.WriteString("/_cluster/decommission/awareness/")
path.WriteString(r.AwarenessAttrName)
path.WriteString("/_status")
return opensearch.BuildRequest(
"GET",
path.String(),
nil,
r.Params.get(),
r.Header,
)
}
// ClusterGetDecommissionResp represents the returned struct of the /_cluster/decommission/awareness response
type ClusterGetDecommissionResp struct {
Values map[string]string
response *opensearch.Response
}
// Inspect returns the Inspect type containing the raw *opensearch.Response
func (r ClusterGetDecommissionResp) Inspect() Inspect {
return Inspect{Response: r.response}
}
@@ -0,0 +1,124 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
// Modifications Copyright OpenSearch Contributors. See
// GitHub history for details.
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package opensearchapi
import (
"strconv"
"strings"
"time"
)
// ClusterHealthParams represents possible parameters for the ClusterHealthReq
type ClusterHealthParams struct {
ExpandWildcards string
Level string
Local *bool
MasterTimeout time.Duration
ClusterManagerTimeout time.Duration
Timeout time.Duration
WaitForActiveShards string
WaitForEvents string
WaitForNoInitializingShards *bool
WaitForNoRelocatingShards *bool
WaitForNodes string
WaitForStatus string
Pretty bool
Human bool
ErrorTrace bool
FilterPath []string
}
func (r ClusterHealthParams) get() map[string]string {
params := make(map[string]string)
if r.ExpandWildcards != "" {
params["expand_wildcards"] = r.ExpandWildcards
}
if r.Level != "" {
params["level"] = r.Level
}
if r.Local != nil {
params["local"] = strconv.FormatBool(*r.Local)
}
if r.MasterTimeout != 0 {
params["master_timeout"] = formatDuration(r.MasterTimeout)
}
if r.ClusterManagerTimeout != 0 {
params["cluster_manager_timeout"] = formatDuration(r.ClusterManagerTimeout)
}
if r.Timeout != 0 {
params["timeout"] = formatDuration(r.Timeout)
}
if r.WaitForActiveShards != "" {
params["wait_for_active_shards"] = r.WaitForActiveShards
}
if r.WaitForEvents != "" {
params["wait_for_events"] = r.WaitForEvents
}
if r.WaitForNoInitializingShards != nil {
params["wait_for_no_initializing_shards"] = strconv.FormatBool(*r.WaitForNoInitializingShards)
}
if r.WaitForNoRelocatingShards != nil {
params["wait_for_no_relocating_shards"] = strconv.FormatBool(*r.WaitForNoRelocatingShards)
}
if r.WaitForNodes != "" {
params["wait_for_nodes"] = r.WaitForNodes
}
if r.WaitForStatus != "" {
params["wait_for_status"] = r.WaitForStatus
}
if r.Pretty {
params["pretty"] = "true"
}
if r.Human {
params["human"] = "true"
}
if r.ErrorTrace {
params["error_trace"] = "true"
}
if len(r.FilterPath) > 0 {
params["filter_path"] = strings.Join(r.FilterPath, ",")
}
return params
}
@@ -0,0 +1,69 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
package opensearchapi
import (
"net/http"
"strings"
"github.com/opensearch-project/opensearch-go/v4"
)
// ClusterHealthReq represents possible options for the /_cluster/health request
type ClusterHealthReq struct {
Indices []string
Header http.Header
Params ClusterHealthParams
}
// GetRequest returns the *http.Request that gets executed by the client
func (r ClusterHealthReq) GetRequest() (*http.Request, error) {
indices := strings.Join(r.Indices, ",")
var path strings.Builder
path.Grow(17 + len(indices))
path.WriteString("/_cluster/health")
if len(indices) > 0 {
path.WriteString("/")
path.WriteString(indices)
}
return opensearch.BuildRequest(
"GET",
path.String(),
nil,
r.Params.get(),
r.Header,
)
}
// ClusterHealthResp represents the returned struct of the ClusterHealthReq response
type ClusterHealthResp struct {
ClusterName string `json:"cluster_name"`
Status string `json:"status"`
TimedOut bool `json:"timed_out"`
NumberOfNodes int `json:"number_of_nodes"`
NumberOfDataNodes int `json:"number_of_data_nodes"`
DiscoveredMaster bool `json:"discovered_master"`
DiscoveredClusterManager bool `json:"discovered_cluster_manager"`
ActivePrimaryShards int `json:"active_primary_shards"`
ActiveShards int `json:"active_shards"`
RelocatingShards int `json:"relocating_shards"`
InitializingShards int `json:"initializing_shards"`
UnassignedShards int `json:"unassigned_shards"`
DelayedUnassignedShards int `json:"delayed_unassigned_shards"`
NumberOfPendingTasks int `json:"number_of_pending_tasks"`
NumberOfInFlightFetch int `json:"number_of_in_flight_fetch"`
TaskMaxWaitingInQueueMillis int `json:"task_max_waiting_in_queue_millis"`
ActiveShardsPercentAsNumber float64 `json:"active_shards_percent_as_number"`
response *opensearch.Response
}
// Inspect returns the Inspect type containing the raw *opensearch.Response
func (r ClusterHealthResp) Inspect() Inspect {
return Inspect{Response: r.response}
}
@@ -0,0 +1,78 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
// Modifications Copyright OpenSearch Contributors. See
// GitHub history for details.
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package opensearchapi
import (
"strconv"
"strings"
"time"
)
// ClusterPendingTasksParams represents possible parameters for the ClusterPendingTasksReq
type ClusterPendingTasksParams struct {
Local *bool
MasterTimeout time.Duration
ClusterManagerTimeout time.Duration
Pretty bool
Human bool
ErrorTrace bool
FilterPath []string
}
func (r ClusterPendingTasksParams) get() map[string]string {
params := make(map[string]string)
if r.Local != nil {
params["local"] = strconv.FormatBool(*r.Local)
}
if r.MasterTimeout != 0 {
params["master_timeout"] = formatDuration(r.MasterTimeout)
}
if r.ClusterManagerTimeout != 0 {
params["cluster_manager_timeout"] = formatDuration(r.ClusterManagerTimeout)
}
if r.Pretty {
params["pretty"] = "true"
}
if r.Human {
params["human"] = "true"
}
if r.ErrorTrace {
params["error_trace"] = "true"
}
if len(r.FilterPath) > 0 {
params["filter_path"] = strings.Join(r.FilterPath, ",")
}
return params
}
@@ -0,0 +1,51 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
package opensearchapi
import (
"net/http"
"github.com/opensearch-project/opensearch-go/v4"
)
// ClusterPendingTasksReq represents possible options for the /_cluster/pending_tasks request
type ClusterPendingTasksReq struct {
Header http.Header
Params ClusterPendingTasksParams
}
// GetRequest returns the *http.Request that gets executed by the client
func (r ClusterPendingTasksReq) GetRequest() (*http.Request, error) {
return opensearch.BuildRequest(
"GET",
"/_cluster/pending_tasks",
nil,
r.Params.get(),
r.Header,
)
}
// ClusterPendingTasksResp represents the returned struct of the ClusterPendingTasksReq response
type ClusterPendingTasksResp struct {
Tasks []ClusterPendingTasksItem `json:"tasks"`
response *opensearch.Response
}
// Inspect returns the Inspect type containing the raw *opensearch.Response
func (r ClusterPendingTasksResp) Inspect() Inspect {
return Inspect{Response: r.response}
}
// ClusterPendingTasksItem is a sub type if ClusterPendingTasksResp containing information about a task
type ClusterPendingTasksItem struct {
InsertOrder int `json:"insert_order"`
Priority string `json:"priority"`
Source string `json:"source"`
TimeInQueueMillis int `json:"time_in_queue_millis"`
TimeInQueue string `json:"time_in_queue"`
Executing bool `json:"executing"`
}
@@ -0,0 +1,59 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
// Modifications Copyright OpenSearch Contributors. See
// GitHub history for details.
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package opensearchapi
import "strings"
// ClusterRemoteInfoParams represents possible parameters for the ClusterRemoteInfoReq
type ClusterRemoteInfoParams struct {
Pretty bool
Human bool
ErrorTrace bool
FilterPath []string
}
func (r ClusterRemoteInfoParams) get() map[string]string {
params := make(map[string]string)
if r.Pretty {
params["pretty"] = "true"
}
if r.Human {
params["human"] = "true"
}
if r.ErrorTrace {
params["error_trace"] = "true"
}
if len(r.FilterPath) > 0 {
params["filter_path"] = strings.Join(r.FilterPath, ",")
}
return params
}
@@ -0,0 +1,52 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
package opensearchapi
import (
"net/http"
"github.com/opensearch-project/opensearch-go/v4"
)
// ClusterRemoteInfoReq represents possible options for the /_remote/info request
type ClusterRemoteInfoReq struct {
Header http.Header
Params ClusterRemoteInfoParams
}
// GetRequest returns the *http.Request that gets executed by the client
func (r ClusterRemoteInfoReq) GetRequest() (*http.Request, error) {
return opensearch.BuildRequest(
"GET",
"/_remote/info",
nil,
r.Params.get(),
r.Header,
)
}
// ClusterRemoteInfoResp represents the returned struct of the ClusterRemoteInfoReq response
type ClusterRemoteInfoResp struct {
Clusters map[string]ClusterRemoteInfoDetails
response *opensearch.Response
}
// Inspect returns the Inspect type containing the raw *opensearch.Response
func (r ClusterRemoteInfoResp) Inspect() Inspect {
return Inspect{Response: r.response}
}
// ClusterRemoteInfoDetails is a sub type of ClusterRemoteInfoResp contains information about a remote connection
type ClusterRemoteInfoDetails struct {
Connected bool `json:"connected"`
Mode string `json:"mode"`
Seeds []string `json:"seeds"`
NumNodesConnected int `json:"num_nodes_connected"`
MaxConnectionsPerCluster int `json:"max_connections_per_cluster"`
InitialConnectTimeout string `json:"initial_connect_timeout"`
SkipUnavailable bool `json:"skip_unavailable"`
}
@@ -0,0 +1,99 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
// Modifications Copyright OpenSearch Contributors. See
// GitHub history for details.
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package opensearchapi
import (
"strconv"
"strings"
"time"
)
// ClusterRerouteParams represents possible parameters for the ClusterRerouteReq
type ClusterRerouteParams struct {
DryRun *bool
Explain *bool
MasterTimeout time.Duration
ClusterManagerTimeout time.Duration
Metric []string
RetryFailed *bool
Timeout time.Duration
Pretty bool
Human bool
ErrorTrace bool
FilterPath []string
}
func (r ClusterRerouteParams) get() map[string]string {
params := make(map[string]string)
if r.DryRun != nil {
params["dry_run"] = strconv.FormatBool(*r.DryRun)
}
if r.Explain != nil {
params["explain"] = strconv.FormatBool(*r.Explain)
}
if r.MasterTimeout != 0 {
params["master_timeout"] = formatDuration(r.MasterTimeout)
}
if r.ClusterManagerTimeout != 0 {
params["cluster_manager_timeout"] = formatDuration(r.ClusterManagerTimeout)
}
if len(r.Metric) > 0 {
params["metric"] = strings.Join(r.Metric, ",")
}
if r.RetryFailed != nil {
params["retry_failed"] = strconv.FormatBool(*r.RetryFailed)
}
if r.Timeout != 0 {
params["timeout"] = formatDuration(r.Timeout)
}
if r.Pretty {
params["pretty"] = "true"
}
if r.Human {
params["human"] = "true"
}
if r.ErrorTrace {
params["error_trace"] = "true"
}
if len(r.FilterPath) > 0 {
params["filter_path"] = strings.Join(r.FilterPath, ",")
}
return params
}
@@ -0,0 +1,75 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
package opensearchapi
import (
"encoding/json"
"io"
"net/http"
"github.com/opensearch-project/opensearch-go/v4"
)
// ClusterRerouteReq represents possible options for the /_cluster/reroute request
type ClusterRerouteReq struct {
Body io.Reader
Header http.Header
Params ClusterRerouteParams
}
// GetRequest returns the *http.Request that gets executed by the client
func (r ClusterRerouteReq) GetRequest() (*http.Request, error) {
return opensearch.BuildRequest(
"POST",
"/_cluster/reroute",
r.Body,
r.Params.get(),
r.Header,
)
}
// ClusterRerouteResp represents the returned struct of the ClusterRerouteReq response
type ClusterRerouteResp struct {
Acknowledged bool `json:"acknowledged"`
State ClusterRerouteState `json:"state"`
response *opensearch.Response
}
// Inspect returns the Inspect type containing the raw *opensearch.Response
func (r ClusterRerouteResp) Inspect() Inspect {
return Inspect{Response: r.response}
}
// ClusterRerouteState is a sub type of ClusterRerouteResp containing information about the cluster and cluster routing
type ClusterRerouteState struct {
ClusterUUID string `json:"cluster_uuid"`
Version int `json:"version"`
StateUUID string `json:"state_uuid"`
MasterNode string `json:"master_node"`
ClusterManagerNode string `json:"cluster_manager_node"`
Blocks json.RawMessage `json:"blocks"`
Nodes map[string]ClusterStateNodes `json:"nodes"`
RoutingTable struct {
Indices map[string]struct {
Shards map[string][]ClusterStateRoutingIndex `json:"shards"`
} `json:"indices"`
} `json:"routing_table"`
RoutingNodes ClusterStateRoutingNodes `json:"routing_nodes"`
RepositoryCleanup struct {
RepositoryCleanup []json.RawMessage `json:"repository_cleanup"`
} `json:"repository_cleanup"`
SnapshotDeletions struct {
SnapshotDeletions []json.RawMessage `json:"snapshot_deletions"`
} `json:"snapshot_deletions"`
Snapshots struct {
Snapshots []json.RawMessage `json:"snapshots"`
} `json:"snapshots"`
Restore struct {
Snapshots []json.RawMessage `json:"snapshots"`
} `json:"restore"`
}
@@ -0,0 +1,140 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
// Modifications Copyright OpenSearch Contributors. See
// GitHub history for details.
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package opensearchapi
import (
"strconv"
"strings"
"time"
)
// ClusterGetSettingsParams represents possible parameters for the ClusterGetSettingsReq
type ClusterGetSettingsParams struct {
FlatSettings *bool
IncludeDefaults *bool
MasterTimeout time.Duration
ClusterManagerTimeout time.Duration
Timeout time.Duration
Pretty bool
Human bool
ErrorTrace bool
FilterPath []string
}
func (r ClusterGetSettingsParams) get() map[string]string {
params := make(map[string]string)
if r.FlatSettings != nil {
params["flat_settings"] = strconv.FormatBool(*r.FlatSettings)
}
if r.IncludeDefaults != nil {
params["include_defaults"] = strconv.FormatBool(*r.IncludeDefaults)
}
if r.MasterTimeout != 0 {
params["master_timeout"] = formatDuration(r.MasterTimeout)
}
if r.ClusterManagerTimeout != 0 {
params["cluster_manager_timeout"] = formatDuration(r.ClusterManagerTimeout)
}
if r.Timeout != 0 {
params["timeout"] = formatDuration(r.Timeout)
}
if r.Pretty {
params["pretty"] = "true"
}
if r.Human {
params["human"] = "true"
}
if r.ErrorTrace {
params["error_trace"] = "true"
}
if len(r.FilterPath) > 0 {
params["filter_path"] = strings.Join(r.FilterPath, ",")
}
return params
}
// ClusterPutSettingsParams represents possible parameters for the ClusterGetSettingsReq
type ClusterPutSettingsParams struct {
FlatSettings *bool
MasterTimeout time.Duration
ClusterManagerTimeout time.Duration
Timeout time.Duration
Pretty bool
Human bool
ErrorTrace bool
FilterPath []string
}
func (r ClusterPutSettingsParams) get() map[string]string {
params := make(map[string]string)
if r.FlatSettings != nil {
params["flat_settings"] = strconv.FormatBool(*r.FlatSettings)
}
if r.MasterTimeout != 0 {
params["master_timeout"] = formatDuration(r.MasterTimeout)
}
if r.ClusterManagerTimeout != 0 {
params["cluster_manager_timeout"] = formatDuration(r.ClusterManagerTimeout)
}
if r.Timeout != 0 {
params["timeout"] = formatDuration(r.Timeout)
}
if r.Pretty {
params["pretty"] = "true"
}
if r.Human {
params["human"] = "true"
}
if r.ErrorTrace {
params["error_trace"] = "true"
}
if len(r.FilterPath) > 0 {
params["filter_path"] = strings.Join(r.FilterPath, ",")
}
return params
}
@@ -0,0 +1,76 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
package opensearchapi
import (
"encoding/json"
"io"
"net/http"
"github.com/opensearch-project/opensearch-go/v4"
)
// ClusterGetSettingsReq represents possible options for the /_cluster/settings request
type ClusterGetSettingsReq struct {
Header http.Header
Params ClusterGetSettingsParams
}
// GetRequest returns the *http.Request that gets executed by the client
func (r ClusterGetSettingsReq) GetRequest() (*http.Request, error) {
return opensearch.BuildRequest(
"GET",
"/_cluster/settings",
nil,
r.Params.get(),
r.Header,
)
}
// ClusterGetSettingsResp represents the returned struct of the ClusterGetSettingsReq response
type ClusterGetSettingsResp struct {
Persistent json.RawMessage `json:"persistent"`
Transient json.RawMessage `json:"transient"`
Defaults json.RawMessage `json:"defaults"`
response *opensearch.Response
}
// Inspect returns the Inspect type containing the raw *opensearch.Response
func (r ClusterGetSettingsResp) Inspect() Inspect {
return Inspect{Response: r.response}
}
// ClusterPutSettingsReq represents possible options for the /_cluster/settings request
type ClusterPutSettingsReq struct {
Body io.Reader
Header http.Header
Params ClusterPutSettingsParams
}
// GetRequest returns the *http.Request that gets executed by the client
func (r ClusterPutSettingsReq) GetRequest() (*http.Request, error) {
return opensearch.BuildRequest(
"PUT",
"/_cluster/settings",
r.Body,
r.Params.get(),
r.Header,
)
}
// ClusterPutSettingsResp represents the returned struct of the /_cluster/settings response
type ClusterPutSettingsResp struct {
Acknowledged bool `json:"acknowledged"`
Persistent json.RawMessage `json:"persistent"`
Transient json.RawMessage `json:"transient"`
response *opensearch.Response
}
// Inspect returns the Inspect type containing the raw *opensearch.Response
func (r ClusterPutSettingsResp) Inspect() Inspect {
return Inspect{Response: r.response}
}
@@ -0,0 +1,109 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
// Modifications Copyright OpenSearch Contributors. See
// GitHub history for details.
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package opensearchapi
import (
"strconv"
"strings"
"time"
)
// ClusterStateParams represents possible parameters for the ClusterStateReq
type ClusterStateParams struct {
AllowNoIndices *bool
ExpandWildcards string
FlatSettings *bool
IgnoreUnavailable *bool
Local *bool
MasterTimeout time.Duration
ClusterManagerTimeout time.Duration
WaitForMetadataVersion *int
WaitForTimeout time.Duration
Pretty bool
Human bool
ErrorTrace bool
FilterPath []string
}
func (r ClusterStateParams) get() map[string]string {
params := make(map[string]string)
if r.AllowNoIndices != nil {
params["allow_no_indices"] = strconv.FormatBool(*r.AllowNoIndices)
}
if r.ExpandWildcards != "" {
params["expand_wildcards"] = r.ExpandWildcards
}
if r.FlatSettings != nil {
params["flat_settings"] = strconv.FormatBool(*r.FlatSettings)
}
if r.IgnoreUnavailable != nil {
params["ignore_unavailable"] = strconv.FormatBool(*r.IgnoreUnavailable)
}
if r.Local != nil {
params["local"] = strconv.FormatBool(*r.Local)
}
if r.MasterTimeout != 0 {
params["master_timeout"] = formatDuration(r.MasterTimeout)
}
if r.ClusterManagerTimeout != 0 {
params["cluster_manager_timeout"] = formatDuration(r.ClusterManagerTimeout)
}
if r.WaitForMetadataVersion != nil {
params["wait_for_metadata_version"] = strconv.FormatInt(int64(*r.WaitForMetadataVersion), 10)
}
if r.WaitForTimeout != 0 {
params["wait_for_timeout"] = formatDuration(r.WaitForTimeout)
}
if r.Pretty {
params["pretty"] = "true"
}
if r.Human {
params["human"] = "true"
}
if r.ErrorTrace {
params["error_trace"] = "true"
}
if len(r.FilterPath) > 0 {
params["filter_path"] = strings.Join(r.FilterPath, ",")
}
return params
}
@@ -0,0 +1,222 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
package opensearchapi
import (
"encoding/json"
"net/http"
"strings"
"github.com/opensearch-project/opensearch-go/v4"
)
// ClusterStateReq represents possible options for the /_cluster/state request
type ClusterStateReq struct {
Metrics []string
Indices []string
Header http.Header
Params ClusterStateParams
}
// GetRequest returns the *http.Request that gets executed by the client
func (r ClusterStateReq) GetRequest() (*http.Request, error) {
indices := strings.Join(r.Indices, ",")
metrics := strings.Join(r.Metrics, ",")
var path strings.Builder
path.Grow(17 + len(indices) + len(metrics))
path.WriteString("/_cluster/state")
if len(metrics) > 0 {
path.WriteString("/")
path.WriteString(metrics)
if len(indices) > 0 {
path.WriteString("/")
path.WriteString(indices)
}
}
return opensearch.BuildRequest(
"GET",
path.String(),
nil,
r.Params.get(),
r.Header,
)
}
// ClusterStateResp represents the returned struct of the ClusterStateReq response
type ClusterStateResp struct {
ClusterName string `json:"cluster_name"`
ClusterUUID string `json:"cluster_uuid"`
Version int `json:"version"`
StateUUID string `json:"state_uuid"`
MasterNode string `json:"master_node"`
ClusterManagerNode string `json:"cluster_manager_node"`
Blocks struct {
Indices map[string]map[string]ClusterStateBlocksIndex `json:"indices"`
} `json:"blocks"`
Nodes map[string]ClusterStateNodes `json:"nodes"`
Metadata ClusterStateMetaData `json:"metadata"`
response *opensearch.Response
RoutingTable struct {
Indices map[string]struct {
Shards map[string][]ClusterStateRoutingIndex `json:"shards"`
} `json:"indices"`
} `json:"routing_table"`
RoutingNodes ClusterStateRoutingNodes `json:"routing_nodes"`
Snapshots struct {
Snapshots []json.RawMessage `json:"snapshots"`
} `json:"snapshots"`
SnapshotDeletions struct {
SnapshotDeletions []json.RawMessage `json:"snapshot_deletions"`
} `json:"snapshot_deletions"`
RepositoryCleanup struct {
RepositoryCleanup []json.RawMessage `json:"repository_cleanup"`
} `json:"repository_cleanup"`
Restore struct {
Snapshots []json.RawMessage `json:"snapshots"`
} `json:"restore"`
}
// Inspect returns the Inspect type containing the raw *opensearch.Response
func (r ClusterStateResp) Inspect() Inspect {
return Inspect{Response: r.response}
}
// ClusterStateBlocksIndex is a sub type of ClusterStateResp
type ClusterStateBlocksIndex struct {
Description string `json:"description"`
Retryable bool `json:"retryable"`
Levels []string `json:"levels"`
}
// ClusterStateNodes is a sub type of ClusterStateResp
type ClusterStateNodes struct {
Name string `json:"name"`
EphemeralID string `json:"ephemeral_id"`
TransportAddress string `json:"transport_address"`
Attributes map[string]string `json:"attributes"`
}
// ClusterStateMetaData is a sub type if ClusterStateResp containing metadata of the cluster
type ClusterStateMetaData struct {
ClusterUUID string `json:"cluster_uuid"`
ClusterUUIDCommitted bool `json:"cluster_uuid_committed"`
ClusterCoordination struct {
Term int `json:"term"`
LastCommittedConfig []string `json:"last_committed_config"`
LastAcceptedConfig []string `json:"last_accepted_config"`
VotingConfigExclusions []struct {
NodeID string `json:"node_id"`
NodeName string `json:"node_name"`
} `json:"voting_config_exclusions"`
} `json:"cluster_coordination"`
Templates map[string]json.RawMessage `json:"templates"`
Indices map[string]ClusterStateMetaDataIndex `json:"indices"`
IndexGraveyard struct {
Tombstones []struct {
Index struct {
IndexName string `json:"index_name"`
IndexUUID string `json:"index_uuid"`
} `json:"index"`
DeleteDateInMillis int `json:"delete_date_in_millis"`
} `json:"tombstones"`
} `json:"index-graveyard"`
Repositories map[string]struct {
Type string `json:"type"`
Settings map[string]string `json:"settings"`
Generation int `json:"generation"`
PendingGeneration int `json:"pending_generation"`
} `json:"repositories"`
ComponentTemplate struct {
ComponentTemplate map[string]json.RawMessage `json:"component_template"`
} `json:"component_template"`
IndexTemplate struct {
IndexTemplate map[string]json.RawMessage `json:"index_template"`
} `json:"index_template"`
StoredScripts map[string]struct {
Lang string `json:"lang"`
Source string `json:"source"`
} `json:"stored_scripts"`
Ingest struct {
Pipeline []struct {
ID string `json:"id"`
Config struct {
Description string `json:"description"`
Processors json.RawMessage `json:"processors"`
} `json:"config"`
} `json:"pipeline"`
} `json:"ingest"`
DataStream struct {
DataStream map[string]ClusterStateMetaDataStream `json:"data_stream"`
} `json:"data_stream"`
}
// ClusterStateMetaDataIndex is a sub type of ClusterStateMetaData containing information about an index
type ClusterStateMetaDataIndex struct {
Version int `json:"version"`
MappingVersion int `json:"mapping_version"`
SettingsVersion int `json:"settings_version"`
AliasesVersion int `json:"aliases_version"`
RoutingNumShards int `json:"routing_num_shards"`
State string `json:"state"`
Settings json.RawMessage `json:"settings"`
Mappings json.RawMessage `json:"mappings"`
Aliases []string `json:"aliases"`
PrimaryTerms map[string]int `json:"primary_terms"`
InSyncAllocations map[string][]string `json:"in_sync_allocations"`
RolloverInfo map[string]struct {
MetConditions map[string]string `json:"met_conditions"`
Time int `json:"time"`
} `json:"rollover_info"`
System bool `json:"system"`
}
// ClusterStateMetaDataStream is a sub type of ClusterStateMetaData containing information about a data stream
type ClusterStateMetaDataStream struct {
Name string `json:"name"`
TimestampField struct {
Name string `json:"name"`
} `json:"timestamp_field"`
Indices []struct {
IndexName string `json:"index_name"`
IndexUUID string `json:"index_uuid"`
} `json:"indices"`
Generation int `json:"generation"`
}
// ClusterStateRoutingIndex is a sub type of ClusterStateResp and ClusterStateRoutingNodes containing information about shard routing
type ClusterStateRoutingIndex struct {
State string `json:"state"`
Primary bool `json:"primary"`
SearchOnly bool `json:"searchOnly"`
Node *string `json:"node"`
RelocatingNode *string `json:"relocating_node"`
Shard int `json:"shard"`
Index string `json:"index"`
ExpectedShardSizeInBytes int `json:"expected_shard_size_in_bytes"`
AllocationID *struct {
ID string `json:"id"`
} `json:"allocation_id,omitempty"`
RecoverySource *struct {
Type string `json:"type"`
} `json:"recovery_source,omitempty"`
UnassignedInfo *struct {
Reason string `json:"reason"`
At string `json:"at"`
Delayed bool `json:"delayed"`
AllocationStatus string `json:"allocation_status"`
Details string `json:"details"`
} `json:"unassigned_info,omitempty"`
}
// ClusterStateRoutingNodes is a sub type of ClusterStateResp containing information about shard assigned to nodes
type ClusterStateRoutingNodes struct {
Unassigned []ClusterStateRoutingIndex `json:"unassigned"`
Nodes map[string][]ClusterStateRoutingIndex `json:"nodes"`
}
@@ -0,0 +1,68 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
// Modifications Copyright OpenSearch Contributors. See
// GitHub history for details.
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package opensearchapi
import (
"strings"
"time"
)
// ClusterStatsParams represents possible parameters for the ClusterStatsReq
type ClusterStatsParams struct {
Timeout time.Duration
Pretty bool
Human bool
ErrorTrace bool
FilterPath []string
}
func (r ClusterStatsParams) get() map[string]string {
params := make(map[string]string)
if r.Timeout != 0 {
params["timeout"] = formatDuration(r.Timeout)
}
if r.Pretty {
params["pretty"] = "true"
}
if r.Human {
params["human"] = "true"
}
if r.ErrorTrace {
params["error_trace"] = "true"
}
if len(r.FilterPath) > 0 {
params["filter_path"] = strings.Join(r.FilterPath, ",")
}
return params
}
@@ -0,0 +1,277 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
package opensearchapi
import (
"encoding/json"
"net/http"
"strings"
"github.com/opensearch-project/opensearch-go/v4"
)
// ClusterStatsReq represents possible options for the /_cluster/stats request
type ClusterStatsReq struct {
NodeFilters []string
Header http.Header
Params ClusterStatsParams
}
// GetRequest returns the *http.Request that gets executed by the client
func (r ClusterStatsReq) GetRequest() (*http.Request, error) {
filters := strings.Join(r.NodeFilters, ",")
var path strings.Builder
path.Grow(22 + len(filters))
path.WriteString("/_cluster/stats")
if len(filters) > 0 {
path.WriteString("/nodes/")
path.WriteString(filters)
}
return opensearch.BuildRequest(
"GET",
path.String(),
nil,
r.Params.get(),
r.Header,
)
}
// ClusterStatsResp represents the returned struct of the ClusterStatsReq response
type ClusterStatsResp struct {
NodesInfo struct {
Total int `json:"total"`
Successful int `json:"successful"`
Failed int `json:"failed"`
Failures []FailuresCause `json:"failures"`
} `json:"_nodes"`
ClusterName string `json:"cluster_name"`
ClusterUUID string `json:"cluster_uuid"`
Timestamp int64 `json:"timestamp"`
Status string `json:"status"`
Indices ClusterStatsIndices `json:"indices"`
Nodes ClusterStatsNodes `json:"nodes"`
response *opensearch.Response
}
// Inspect returns the Inspect type containing the raw *opensearch.Response
func (r ClusterStatsResp) Inspect() Inspect {
return Inspect{Response: r.response}
}
// ClusterStatsIndices is a sub type of ClusterStatsResp containing cluster information about indices
type ClusterStatsIndices struct {
Count int `json:"count"`
Shards struct {
Total int `json:"total"`
Primaries int `json:"primaries"`
Replication float64 `json:"replication"`
Index struct {
Shards struct {
Min float64 `json:"min"`
Max float64 `json:"max"`
Avg float64 `json:"avg"`
} `json:"shards"`
Primaries struct {
Min float64 `json:"min"`
Max float64 `json:"max"`
Avg float64 `json:"avg"`
} `json:"primaries"`
Replication struct {
Min float64 `json:"min"`
Max float64 `json:"max"`
Avg float64 `json:"avg"`
} `json:"replication"`
} `json:"index"`
} `json:"shards"`
Docs struct {
Count int64 `json:"count"`
Deleted int `json:"deleted"`
} `json:"docs"`
Store struct {
SizeInBytes int64 `json:"size_in_bytes"`
ReservedInBytes int `json:"reserved_in_bytes"`
} `json:"store"`
Fielddata struct {
MemorySizeInBytes int `json:"memory_size_in_bytes"`
Evictions int `json:"evictions"`
} `json:"fielddata"`
QueryCache struct {
MemorySizeInBytes int `json:"memory_size_in_bytes"`
TotalCount int `json:"total_count"`
HitCount int `json:"hit_count"`
MissCount int `json:"miss_count"`
CacheSize int `json:"cache_size"`
CacheCount int `json:"cache_count"`
Evictions int `json:"evictions"`
} `json:"query_cache"`
Completion struct {
SizeInBytes int `json:"size_in_bytes"`
} `json:"completion"`
Segments struct {
Count int `json:"count"`
MemoryInBytes int `json:"memory_in_bytes"`
TermsMemoryInBytes int `json:"terms_memory_in_bytes"`
StoredFieldsMemoryInBytes int `json:"stored_fields_memory_in_bytes"`
TermVectorsMemoryInBytes int `json:"term_vectors_memory_in_bytes"`
NormsMemoryInBytes int `json:"norms_memory_in_bytes"`
PointsMemoryInBytes int `json:"points_memory_in_bytes"`
DocValuesMemoryInBytes int `json:"doc_values_memory_in_bytes"`
IndexWriterMemoryInBytes int `json:"index_writer_memory_in_bytes"`
VersionMapMemoryInBytes int `json:"version_map_memory_in_bytes"`
FixedBitSetMemoryInBytes int64 `json:"fixed_bit_set_memory_in_bytes"`
MaxUnsafeAutoIDTimestamp int64 `json:"max_unsafe_auto_id_timestamp"`
RemoteStore struct {
Upload struct {
TotalUploadSize struct {
StartedBytes int `json:"started_bytes"`
SucceededBytes int `json:"succeeded_bytes"`
FailedBytes int `json:"failed_bytes"`
} `json:"total_upload_size"`
RefreshSizeLag struct {
TotalBytes int `json:"total_bytes"`
MaxBytes int `json:"max_bytes"`
} `json:"refresh_size_lag"`
MaxRefreshTimeLagInMillis int `json:"max_refresh_time_lag_in_millis"`
TotalTimeSpentInMillis int `json:"total_time_spent_in_millis"`
Pressure struct {
TotalRejections int `json:"total_rejections"`
} `json:"pressure"`
} `json:"upload"`
Download struct {
TotalDownloadSize struct {
StartedBytes int `json:"started_bytes"`
SucceededBytes int `json:"succeeded_bytes"`
FailedBytes int `json:"failed_bytes"`
} `json:"total_download_size"`
TotalTimeSpentInMillis int `json:"total_time_spent_in_millis"`
} `json:"download"`
} `json:"remote_store"`
SegmentReplication struct {
// Type is json.RawMessage due to difference in opensearch versions from string to int
MaxBytesBehind json.RawMessage `json:"max_bytes_behind"`
TotalBytesBehind json.RawMessage `json:"total_bytes_behind"`
MaxReplicationLag json.RawMessage `json:"max_replication_lag"`
} `json:"segment_replication"`
FileSizes json.RawMessage `json:"file_sizes"`
} `json:"segments"`
Mappings struct {
FieldTypes []struct {
Name string `json:"name"`
Count int `json:"count"`
IndexCount int `json:"index_count"`
} `json:"field_types"`
} `json:"mappings"`
Analysis struct {
CharFilterTypes []json.RawMessage `json:"char_filter_types"`
TokenizerTypes []json.RawMessage `json:"tokenizer_types"`
FilterTypes []json.RawMessage `json:"filter_types"`
AnalyzerTypes []json.RawMessage `json:"analyzer_types"`
BuiltInCharFilters []json.RawMessage `json:"built_in_char_filters"`
BuiltInTokenizers []json.RawMessage `json:"built_in_tokenizers"`
BuiltInFilters []json.RawMessage `json:"built_in_filters"`
BuiltInAnalyzers []json.RawMessage `json:"built_in_analyzers"`
} `json:"analysis"`
RepositoryCleanup struct {
RepositoryCleanup []json.RawMessage `json:"repository_cleanup"`
} `json:"repository_cleanup"`
}
// ClusterStatsNodes is a sub type of ClusterStatsResp containing information about node stats
type ClusterStatsNodes struct {
Count struct {
Total int `json:"total"`
ClusterManager int `json:"cluster_manager"`
CoordinatingOnly int `json:"coordinating_only"`
Data int `json:"data"`
Ingest int `json:"ingest"`
Master int `json:"master"`
RemoteClusterClient int `json:"remote_cluster_client"`
Search int `json:"search"`
Warm int `json:"warm"`
} `json:"count"`
Versions []string `json:"versions"`
Os struct {
AvailableProcessors int `json:"available_processors"`
AllocatedProcessors int `json:"allocated_processors"`
Names []struct {
Name string `json:"name"`
Count int `json:"count"`
} `json:"names"`
PrettyNames []struct {
PrettyName string `json:"pretty_name"`
Count int `json:"count"`
} `json:"pretty_names"`
Mem struct {
TotalInBytes int64 `json:"total_in_bytes"`
FreeInBytes int64 `json:"free_in_bytes"`
UsedInBytes int64 `json:"used_in_bytes"`
FreePercent int `json:"free_percent"`
UsedPercent int `json:"used_percent"`
} `json:"mem"`
} `json:"os"`
Process struct {
CPU struct {
Percent int `json:"percent"`
} `json:"cpu"`
OpenFileDescriptors struct {
Min int `json:"min"`
Max int `json:"max"`
Avg int `json:"avg"`
} `json:"open_file_descriptors"`
} `json:"process"`
Jvm struct {
MaxUptimeInMillis int64 `json:"max_uptime_in_millis"`
Versions []struct {
Version string `json:"version"`
VMName string `json:"vm_name"`
VMVersion string `json:"vm_version"`
VMVendor string `json:"vm_vendor"`
BundledJdk bool `json:"bundled_jdk"`
UsingBundledJdk bool `json:"using_bundled_jdk"`
Count int `json:"count"`
} `json:"versions"`
Mem struct {
HeapUsedInBytes int64 `json:"heap_used_in_bytes"`
HeapMaxInBytes int64 `json:"heap_max_in_bytes"`
} `json:"mem"`
Threads int `json:"threads"`
} `json:"jvm"`
Fs struct {
TotalInBytes int64 `json:"total_in_bytes"`
FreeInBytes int64 `json:"free_in_bytes"`
AvailableInBytes int64 `json:"available_in_bytes"`
CacheReservedInBytes int `json:"cache_reserved_in_bytes"`
} `json:"fs"`
Plugins []struct {
Name string `json:"name"`
Version string `json:"version"`
OpensearchVersion string `json:"opensearch_version"`
JavaVersion string `json:"java_version"`
Description string `json:"description"`
Classname string `json:"classname"`
CustomFoldername *string `json:"custom_foldername"`
ExtendedPlugins []string `json:"extended_plugins"`
OptionalExtendedPlugins []string `json:"optional_extended_plugins"`
HasNativeController bool `json:"has_native_controller"`
} `json:"plugins"`
NetworkTypes struct {
TransportTypes map[string]int `json:"transport_types"`
HTTPTypes map[string]int `json:"http_types"`
} `json:"network_types"`
DiscoveryTypes map[string]int `json:"discovery_types"`
PackagingTypes []struct {
Type string `json:"type"`
Count int `json:"count"`
} `json:"packaging_types"`
Ingest struct {
NumberOfPipelines int `json:"number_of_pipelines"`
ProcessorStats json.RawMessage `json:"processor_stats"`
} `json:"ingest"`
}
@@ -0,0 +1,115 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
// Modifications Copyright OpenSearch Contributors. See
// GitHub history for details.
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package opensearchapi
import (
"strconv"
"strings"
"time"
)
// ClusterPostVotingConfigExclusionsParams represents possible parameters for the ClusterVotingConfigExclusionsReq
type ClusterPostVotingConfigExclusionsParams struct {
NodeIds string
NodeNames string
Timeout time.Duration
Pretty bool
Human bool
ErrorTrace bool
FilterPath []string
}
func (r ClusterPostVotingConfigExclusionsParams) get() map[string]string {
params := make(map[string]string)
if r.NodeIds != "" {
params["node_ids"] = r.NodeIds
}
if r.NodeNames != "" {
params["node_names"] = r.NodeNames
}
if r.Timeout != 0 {
params["timeout"] = formatDuration(r.Timeout)
}
if r.Pretty {
params["pretty"] = "true"
}
if r.Human {
params["human"] = "true"
}
if r.ErrorTrace {
params["error_trace"] = "true"
}
if len(r.FilterPath) > 0 {
params["filter_path"] = strings.Join(r.FilterPath, ",")
}
return params
}
// ClusterDeleteVotingConfigExclusionsParams represents possible parameters for the ClusterVotingConfigExclusionsReq
type ClusterDeleteVotingConfigExclusionsParams struct {
WaitForRemoval *bool
Pretty bool
Human bool
ErrorTrace bool
FilterPath []string
}
func (r ClusterDeleteVotingConfigExclusionsParams) get() map[string]string {
params := make(map[string]string)
if r.WaitForRemoval != nil {
params["wait_for_removal"] = strconv.FormatBool(*r.WaitForRemoval)
}
if r.Pretty {
params["pretty"] = "true"
}
if r.Human {
params["human"] = "true"
}
if r.ErrorTrace {
params["error_trace"] = "true"
}
if len(r.FilterPath) > 0 {
params["filter_path"] = strings.Join(r.FilterPath, ",")
}
return params
}
@@ -0,0 +1,47 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
package opensearchapi
import (
"net/http"
"github.com/opensearch-project/opensearch-go/v4"
)
// ClusterPostVotingConfigExclusionsReq represents possible options for the /_cluster/voting_config_exclusions request
type ClusterPostVotingConfigExclusionsReq struct {
Header http.Header
Params ClusterPostVotingConfigExclusionsParams
}
// GetRequest returns the *http.Request that gets executed by the client
func (r ClusterPostVotingConfigExclusionsReq) GetRequest() (*http.Request, error) {
return opensearch.BuildRequest(
"POST",
"/_cluster/voting_config_exclusions",
nil,
r.Params.get(),
r.Header,
)
}
// ClusterDeleteVotingConfigExclusionsReq represents possible options for the /_cluster/voting_config_exclusions request
type ClusterDeleteVotingConfigExclusionsReq struct {
Header http.Header
Params ClusterDeleteVotingConfigExclusionsParams
}
// GetRequest returns the *http.Request that gets executed by the client
func (r ClusterDeleteVotingConfigExclusionsReq) GetRequest() (*http.Request, error) {
return opensearch.BuildRequest(
"DELETE",
"/_cluster/voting_config_exclusions",
nil,
r.Params.get(),
r.Header,
)
}
@@ -0,0 +1,241 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
package opensearchapi
import (
"context"
"github.com/opensearch-project/opensearch-go/v4"
)
type clusterClient struct {
apiClient *Client
}
// AllocationExplain executes a /_cluster/allocation/explain request with the optional ClusterAllocationExplainReq
func (c clusterClient) AllocationExplain(ctx context.Context, req *ClusterAllocationExplainReq) (*ClusterAllocationExplainResp, error) {
if req == nil {
req = &ClusterAllocationExplainReq{}
}
var (
data ClusterAllocationExplainResp
err error
)
if data.response, err = c.apiClient.do(ctx, req, &data); err != nil {
return &data, err
}
return &data, nil
}
// Health executes a /_cluster/health request with the optional ClusterHealthReq
func (c clusterClient) Health(ctx context.Context, req *ClusterHealthReq) (*ClusterHealthResp, error) {
if req == nil {
req = &ClusterHealthReq{}
}
var (
data ClusterHealthResp
err error
)
if data.response, err = c.apiClient.do(ctx, req, &data); err != nil {
return &data, err
}
return &data, nil
}
// PendingTasks executes a /_cluster/pending_tasks request with the optional ClusterPendingTasksReq
func (c clusterClient) PendingTasks(ctx context.Context, req *ClusterPendingTasksReq) (*ClusterPendingTasksResp, error) {
if req == nil {
req = &ClusterPendingTasksReq{}
}
var (
data ClusterPendingTasksResp
err error
)
if data.response, err = c.apiClient.do(ctx, req, &data); err != nil {
return &data, err
}
return &data, nil
}
// GetSettings executes a /_cluster/settings request with the optional ClusterGetSettingsReq
func (c clusterClient) GetSettings(ctx context.Context, req *ClusterGetSettingsReq) (*ClusterGetSettingsResp, error) {
if req == nil {
req = &ClusterGetSettingsReq{}
}
var (
data ClusterGetSettingsResp
err error
)
if data.response, err = c.apiClient.do(ctx, req, &data); err != nil {
return &data, err
}
return &data, nil
}
// PutSettings executes a /_cluster/settings request with the required ClusterPutSettingsReq
func (c clusterClient) PutSettings(ctx context.Context, req ClusterPutSettingsReq) (*ClusterPutSettingsResp, error) {
var (
data ClusterPutSettingsResp
err error
)
if data.response, err = c.apiClient.do(ctx, req, &data); err != nil {
return &data, err
}
return &data, nil
}
// State executes a /_cluster/state request with the optional ClusterStateReq
func (c clusterClient) State(ctx context.Context, req *ClusterStateReq) (*ClusterStateResp, error) {
if req == nil {
req = &ClusterStateReq{}
}
var (
data ClusterStateResp
err error
)
if data.response, err = c.apiClient.do(ctx, req, &data); err != nil {
return &data, err
}
return &data, nil
}
// Stats executes a /_cluster/stats request with the optional ClusterStatsReq
func (c clusterClient) Stats(ctx context.Context, req *ClusterStatsReq) (*ClusterStatsResp, error) {
if req == nil {
req = &ClusterStatsReq{}
}
var (
data ClusterStatsResp
err error
)
if data.response, err = c.apiClient.do(ctx, req, &data); err != nil {
return &data, err
}
return &data, nil
}
// Reroute executes a /_cluster/reroute request with the required ClusterRerouteReq
func (c clusterClient) Reroute(ctx context.Context, req ClusterRerouteReq) (*ClusterRerouteResp, error) {
var (
data ClusterRerouteResp
err error
)
if data.response, err = c.apiClient.do(ctx, req, &data); err != nil {
return &data, err
}
return &data, nil
}
// PostVotingConfigExclusions executes a /_cluster/voting_config_exclusions request with the optional ClusterPostVotingConfigExclusionsReq
func (c clusterClient) PostVotingConfigExclusions(
ctx context.Context,
req ClusterPostVotingConfigExclusionsReq,
) (*opensearch.Response, error) {
var (
resp *opensearch.Response
err error
)
if resp, err = c.apiClient.do(ctx, req, nil); err != nil {
return resp, err
}
return resp, nil
}
// DeleteVotingConfigExclusions executes a /_cluster/voting_config_exclusions request
// with the optional ClusterDeleteVotingConfigExclusionsReq
func (c clusterClient) DeleteVotingConfigExclusions(
ctx context.Context,
req ClusterDeleteVotingConfigExclusionsReq,
) (*opensearch.Response, error) {
var (
resp *opensearch.Response
err error
)
if resp, err = c.apiClient.do(ctx, req, nil); err != nil {
return resp, err
}
return resp, nil
}
// PutDecommission executes a /_cluster/decommission/awareness request with the optional ClusterPutDecommissionReq
func (c clusterClient) PutDecommission(ctx context.Context, req ClusterPutDecommissionReq) (*ClusterPutDecommissionResp, error) {
var (
data ClusterPutDecommissionResp
err error
)
if data.response, err = c.apiClient.do(ctx, req, &data); err != nil {
return &data, err
}
return &data, nil
}
// DeleteDecommission executes a /_cluster/decommission/awareness request with the optional ClusterDeleteDecommissionReq
func (c clusterClient) DeleteDecommission(
ctx context.Context,
req *ClusterDeleteDecommissionReq,
) (*ClusterDeleteDecommissionResp, error) {
if req == nil {
req = &ClusterDeleteDecommissionReq{}
}
var (
data ClusterDeleteDecommissionResp
err error
)
if data.response, err = c.apiClient.do(ctx, req, &data); err != nil {
return &data, err
}
return &data, nil
}
// GetDecommission executes a /_cluster/decommission/awareness request with the optional ClusterGetDecommissionReq
func (c clusterClient) GetDecommission(ctx context.Context, req ClusterGetDecommissionReq) (*ClusterGetDecommissionResp, error) {
var (
data ClusterGetDecommissionResp
err error
)
if data.response, err = c.apiClient.do(ctx, req, &data.Values); err != nil {
return &data, err
}
return &data, nil
}
// RemoteInfo executes a /_remote/info request with the optional ClusterRemoteInfoReq
func (c clusterClient) RemoteInfo(ctx context.Context, req *ClusterRemoteInfoReq) (*ClusterRemoteInfoResp, error) {
if req == nil {
req = &ClusterRemoteInfoReq{}
}
var (
data ClusterRemoteInfoResp
err error
)
if data.response, err = c.apiClient.do(ctx, req, &data.Clusters); err != nil {
return &data, err
}
return &data, nil
}
@@ -0,0 +1,84 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
// Modifications Copyright OpenSearch Contributors. See
// GitHub history for details.
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package opensearchapi
import (
"strconv"
"strings"
"time"
)
// ComponentTemplateCreateParams represents possible parameters for the ComponentTemplateCreateReq
type ComponentTemplateCreateParams struct {
Create *bool
MasterTimeout time.Duration
ClusterManagerTimeout time.Duration
Timeout time.Duration
Pretty bool
Human bool
ErrorTrace bool
FilterPath []string
}
func (r ComponentTemplateCreateParams) get() map[string]string {
params := make(map[string]string)
if r.Create != nil {
params["create"] = strconv.FormatBool(*r.Create)
}
if r.MasterTimeout != 0 {
params["master_timeout"] = formatDuration(r.MasterTimeout)
}
if r.ClusterManagerTimeout != 0 {
params["cluster_manager_timeout"] = formatDuration(r.ClusterManagerTimeout)
}
if r.Timeout != 0 {
params["timeout"] = formatDuration(r.Timeout)
}
if r.Pretty {
params["pretty"] = "true"
}
if r.Human {
params["human"] = "true"
}
if r.ErrorTrace {
params["error_trace"] = "true"
}
if len(r.FilterPath) > 0 {
params["filter_path"] = strings.Join(r.FilterPath, ",")
}
return params
}
@@ -0,0 +1,47 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
package opensearchapi
import (
"fmt"
"io"
"net/http"
"github.com/opensearch-project/opensearch-go/v4"
)
// ComponentTemplateCreateReq represents possible options for the _component_template create request
type ComponentTemplateCreateReq struct {
ComponentTemplate string
Body io.Reader
Header http.Header
Params ComponentTemplateCreateParams
}
// GetRequest returns the *http.Request that gets executed by the client
func (r ComponentTemplateCreateReq) GetRequest() (*http.Request, error) {
return opensearch.BuildRequest(
"PUT",
fmt.Sprintf("/_component_template/%s", r.ComponentTemplate),
r.Body,
r.Params.get(),
r.Header,
)
}
// ComponentTemplateCreateResp represents the returned struct of the index create response
type ComponentTemplateCreateResp struct {
Acknowledged bool `json:"acknowledged"`
response *opensearch.Response
}
// Inspect returns the Inspect type containing the raw *opensearch.Response
func (r ComponentTemplateCreateResp) Inspect() Inspect {
return Inspect{Response: r.response}
}
@@ -0,0 +1,78 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
// Modifications Copyright OpenSearch Contributors. See
// GitHub history for details.
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package opensearchapi
import (
"strings"
"time"
)
// ComponentTemplateDeleteParams represents possible parameters for the ComponentTemplateDeleteReq
type ComponentTemplateDeleteParams struct {
MasterTimeout time.Duration
ClusterManagerTimeout time.Duration
Timeout time.Duration
Pretty bool
Human bool
ErrorTrace bool
FilterPath []string
}
func (r ComponentTemplateDeleteParams) get() map[string]string {
params := make(map[string]string)
if r.MasterTimeout != 0 {
params["master_timeout"] = formatDuration(r.MasterTimeout)
}
if r.ClusterManagerTimeout != 0 {
params["cluster_manager_timeout"] = formatDuration(r.ClusterManagerTimeout)
}
if r.Timeout != 0 {
params["timeout"] = formatDuration(r.Timeout)
}
if r.Pretty {
params["pretty"] = "true"
}
if r.Human {
params["human"] = "true"
}
if r.ErrorTrace {
params["error_trace"] = "true"
}
if len(r.FilterPath) > 0 {
params["filter_path"] = strings.Join(r.FilterPath, ",")
}
return params
}
@@ -0,0 +1,44 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
package opensearchapi
import (
"fmt"
"net/http"
"github.com/opensearch-project/opensearch-go/v4"
)
// ComponentTemplateDeleteReq represents possible options for the _component_template delete request
type ComponentTemplateDeleteReq struct {
ComponentTemplate string
Header http.Header
Params ComponentTemplateDeleteParams
}
// GetRequest returns the *http.Request that gets executed by the client
func (r ComponentTemplateDeleteReq) GetRequest() (*http.Request, error) {
return opensearch.BuildRequest(
"DELETE",
fmt.Sprintf("/_component_template/%s", r.ComponentTemplate),
nil,
r.Params.get(),
r.Header,
)
}
// ComponentTemplateDeleteResp represents the returned struct of the _component_template delete response
type ComponentTemplateDeleteResp struct {
Acknowledged bool `json:"acknowledged"`
response *opensearch.Response
}
// Inspect returns the Inspect type containing the raw *opensearch.Response
func (r ComponentTemplateDeleteResp) Inspect() Inspect {
return Inspect{Response: r.response}
}
@@ -0,0 +1,79 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
// Modifications Copyright OpenSearch Contributors. See
// GitHub history for details.
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package opensearchapi
import (
"strconv"
"strings"
"time"
)
// ComponentTemplateExistsParams represents possible parameters for the ComponentTemplateExistsReq
type ComponentTemplateExistsParams struct {
Local *bool
MasterTimeout time.Duration
ClusterManagerTimeout time.Duration
Pretty bool
Human bool
ErrorTrace bool
FilterPath []string
}
func (r ComponentTemplateExistsParams) get() map[string]string {
params := make(map[string]string)
if r.Local != nil {
params["local"] = strconv.FormatBool(*r.Local)
}
if r.MasterTimeout != 0 {
params["master_timeout"] = formatDuration(r.MasterTimeout)
}
if r.ClusterManagerTimeout != 0 {
params["cluster_manager_timeout"] = formatDuration(r.ClusterManagerTimeout)
}
if r.Pretty {
params["pretty"] = "true"
}
if r.Human {
params["human"] = "true"
}
if r.ErrorTrace {
params["error_trace"] = "true"
}
if len(r.FilterPath) > 0 {
params["filter_path"] = strings.Join(r.FilterPath, ",")
}
return params
}
@@ -0,0 +1,33 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
package opensearchapi
import (
"fmt"
"net/http"
"github.com/opensearch-project/opensearch-go/v4"
)
// ComponentTemplateExistsReq represents possible options for the _component_template exists request
type ComponentTemplateExistsReq struct {
ComponentTemplate string
Header http.Header
Params ComponentTemplateExistsParams
}
// GetRequest returns the *http.Request that gets executed by the client
func (r ComponentTemplateExistsReq) GetRequest() (*http.Request, error) {
return opensearch.BuildRequest(
"HEAD",
fmt.Sprintf("/_component_template/%s", r.ComponentTemplate),
nil,
r.Params.get(),
r.Header,
)
}
@@ -0,0 +1,79 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
// Modifications Copyright OpenSearch Contributors. See
// GitHub history for details.
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package opensearchapi
import (
"strconv"
"strings"
"time"
)
// ComponentTemplateGetParams represents possible parameters for the ComponentTemplateGetReq
type ComponentTemplateGetParams struct {
Local *bool
MasterTimeout time.Duration
ClusterManagerTimeout time.Duration
Pretty bool
Human bool
ErrorTrace bool
FilterPath []string
}
func (r ComponentTemplateGetParams) get() map[string]string {
params := make(map[string]string)
if r.Local != nil {
params["local"] = strconv.FormatBool(*r.Local)
}
if r.MasterTimeout != 0 {
params["master_timeout"] = formatDuration(r.MasterTimeout)
}
if r.ClusterManagerTimeout != 0 {
params["cluster_manager_timeout"] = formatDuration(r.ClusterManagerTimeout)
}
if r.Pretty {
params["pretty"] = "true"
}
if r.Human {
params["human"] = "true"
}
if r.ErrorTrace {
params["error_trace"] = "true"
}
if len(r.FilterPath) > 0 {
params["filter_path"] = strings.Join(r.FilterPath, ",")
}
return params
}
@@ -0,0 +1,65 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
package opensearchapi
import (
"encoding/json"
"net/http"
"strings"
"github.com/opensearch-project/opensearch-go/v4"
)
// ComponentTemplateGetReq represents possible options for the _component_template get request
type ComponentTemplateGetReq struct {
ComponentTemplate string
Header http.Header
Params ComponentTemplateGetParams
}
// GetRequest returns the *http.Request that gets executed by the client
func (r ComponentTemplateGetReq) GetRequest() (*http.Request, error) {
var path strings.Builder
path.Grow(len("/_component_template/") + len(r.ComponentTemplate))
path.WriteString("/_component_template")
if len(r.ComponentTemplate) > 0 {
path.WriteString("/")
path.WriteString(r.ComponentTemplate)
}
return opensearch.BuildRequest(
"GET",
path.String(),
nil,
r.Params.get(),
r.Header,
)
}
// ComponentTemplateGetResp represents the returned struct of the index create response
type ComponentTemplateGetResp struct {
ComponentTemplates []ComponentTemplateGetDetails `json:"component_templates"`
response *opensearch.Response
}
// Inspect returns the Inspect type containing the raw *opensearch.Response
func (r ComponentTemplateGetResp) Inspect() Inspect {
return Inspect{Response: r.response}
}
// ComponentTemplateGetDetails is a sub type of ComponentTemplateGetResp containing information about component template
type ComponentTemplateGetDetails struct {
Name string `json:"name"`
ComponentTemplate struct {
Template struct {
Mappings json.RawMessage `json:"mappings"`
Settings json.RawMessage `json:"settings"`
Aliases json.RawMessage `json:"aliases"`
} `json:"template"`
} `json:"component_template"`
}
@@ -0,0 +1,65 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
package opensearchapi
import (
"context"
"github.com/opensearch-project/opensearch-go/v4"
)
type componentTemplateClient struct {
apiClient *Client
}
// Create executes a creade componentTemplate request with the required ComponentTemplateCreateReq
func (c componentTemplateClient) Create(ctx context.Context, req ComponentTemplateCreateReq) (*ComponentTemplateCreateResp, error) {
var (
data ComponentTemplateCreateResp
err error
)
if data.response, err = c.apiClient.do(ctx, req, &data); err != nil {
return &data, err
}
return &data, nil
}
// Delete executes a delete componentTemplate request with the required ComponentTemplateDeleteReq
func (c componentTemplateClient) Delete(ctx context.Context, req ComponentTemplateDeleteReq) (*ComponentTemplateDeleteResp, error) {
var (
data ComponentTemplateDeleteResp
err error
)
if data.response, err = c.apiClient.do(ctx, req, &data); err != nil {
return &data, err
}
return &data, nil
}
// Get executes a get componentTemplate request with the optional ComponentTemplateGetReq
func (c componentTemplateClient) Get(ctx context.Context, req *ComponentTemplateGetReq) (*ComponentTemplateGetResp, error) {
if req == nil {
req = &ComponentTemplateGetReq{}
}
var (
data ComponentTemplateGetResp
err error
)
if data.response, err = c.apiClient.do(ctx, req, &data); err != nil {
return &data, err
}
return &data, nil
}
// Exists executes a exists componentTemplate request with the required ComponentTemplatExistsReq
func (c componentTemplateClient) Exists(ctx context.Context, req ComponentTemplateExistsReq) (*opensearch.Response, error) {
return c.apiClient.do(ctx, req, nil)
}
@@ -0,0 +1,84 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
// Modifications Copyright OpenSearch Contributors. See
// GitHub history for details.
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package opensearchapi
import (
"strconv"
"strings"
"time"
)
// DanglingDeleteParams represents possible parameters for the DanglingDeleteReq
type DanglingDeleteParams struct {
AcceptDataLoss *bool
MasterTimeout time.Duration
ClusterManagerTimeout time.Duration
Timeout time.Duration
Pretty bool
Human bool
ErrorTrace bool
FilterPath []string
}
func (r DanglingDeleteParams) get() map[string]string {
params := make(map[string]string)
if r.AcceptDataLoss != nil {
params["accept_data_loss"] = strconv.FormatBool(*r.AcceptDataLoss)
}
if r.MasterTimeout != 0 {
params["master_timeout"] = formatDuration(r.MasterTimeout)
}
if r.ClusterManagerTimeout != 0 {
params["cluster_manager_timeout"] = formatDuration(r.ClusterManagerTimeout)
}
if r.Timeout != 0 {
params["timeout"] = formatDuration(r.Timeout)
}
if r.Pretty {
params["pretty"] = "true"
}
if r.Human {
params["human"] = "true"
}
if r.ErrorTrace {
params["error_trace"] = "true"
}
if len(r.FilterPath) > 0 {
params["filter_path"] = strings.Join(r.FilterPath, ",")
}
return params
}
@@ -0,0 +1,44 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
package opensearchapi
import (
"fmt"
"net/http"
"github.com/opensearch-project/opensearch-go/v4"
)
// DanglingDeleteReq represents possible options for the delete dangling request
type DanglingDeleteReq struct {
IndexUUID string
Header http.Header
Params DanglingDeleteParams
}
// GetRequest returns the *http.Request that gets executed by the client
func (r DanglingDeleteReq) GetRequest() (*http.Request, error) {
return opensearch.BuildRequest(
"DELETE",
fmt.Sprintf("/_dangling/%s", r.IndexUUID),
nil,
r.Params.get(),
r.Header,
)
}
// DanglingDeleteResp represents the returned struct of the delete dangling response
type DanglingDeleteResp struct {
Acknowledged bool `json:"acknowledged"`
response *opensearch.Response
}
// Inspect returns the Inspect type containing the raw *opensearch.Response
func (r DanglingDeleteResp) Inspect() Inspect {
return Inspect{Response: r.response}
}
@@ -0,0 +1,59 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
// Modifications Copyright OpenSearch Contributors. See
// GitHub history for details.
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package opensearchapi
import "strings"
// DanglingGetParams represents possible parameters for the DanglingGetReq
type DanglingGetParams struct {
Pretty bool
Human bool
ErrorTrace bool
FilterPath []string
}
func (r DanglingGetParams) get() map[string]string {
params := make(map[string]string)
if r.Pretty {
params["pretty"] = "true"
}
if r.Human {
params["human"] = "true"
}
if r.ErrorTrace {
params["error_trace"] = "true"
}
if len(r.FilterPath) > 0 {
params["filter_path"] = strings.Join(r.FilterPath, ",")
}
return params
}
@@ -0,0 +1,61 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
package opensearchapi
import (
"net/http"
"github.com/opensearch-project/opensearch-go/v4"
)
// DanglingGetReq represents possible options for the dangling get request
type DanglingGetReq struct {
Header http.Header
Params DanglingGetParams
}
// GetRequest returns the *http.Request that gets executed by the client
func (r DanglingGetReq) GetRequest() (*http.Request, error) {
return opensearch.BuildRequest(
"GET",
"/_dangling",
nil,
r.Params.get(),
r.Header,
)
}
// DanglingGetResp represents the returned struct of the dangling get response
type DanglingGetResp struct {
Nodes struct {
Total int `json:"total"`
Successful int `json:"successful"`
Failed int `json:"failed"`
Failures []struct {
Type string `json:"type"`
Reason string `json:"reason"`
NodeID string `json:"node_id"`
CausedBy struct {
Type string `json:"type"`
Reason string `json:"reason"`
} `json:"caused_by"`
} `json:"failures"`
} `json:"_nodes"`
ClusterName string `json:"cluster_name"`
DanglingIndices []struct {
IndexName string `json:"index_name"`
IndexUUID string `json:"index_uuid"`
CreationDateMillis int64 `json:"creation_date_millis"`
NodeIds []string `json:"node_ids"`
} `json:"dangling_indices"`
response *opensearch.Response
}
// Inspect returns the Inspect type containing the raw *opensearch.Response
func (r DanglingGetResp) Inspect() Inspect {
return Inspect{Response: r.response}
}
@@ -0,0 +1,84 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
// Modifications Copyright OpenSearch Contributors. See
// GitHub history for details.
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package opensearchapi
import (
"strconv"
"strings"
"time"
)
// DanglingImportParams represents possible parameters for the DanglingImportReq
type DanglingImportParams struct {
AcceptDataLoss *bool
MasterTimeout time.Duration
ClusterManagerTimeout time.Duration
Timeout time.Duration
Pretty bool
Human bool
ErrorTrace bool
FilterPath []string
}
func (r DanglingImportParams) get() map[string]string {
params := make(map[string]string)
if r.AcceptDataLoss != nil {
params["accept_data_loss"] = strconv.FormatBool(*r.AcceptDataLoss)
}
if r.MasterTimeout != 0 {
params["master_timeout"] = formatDuration(r.MasterTimeout)
}
if r.ClusterManagerTimeout != 0 {
params["cluster_manager_timeout"] = formatDuration(r.ClusterManagerTimeout)
}
if r.Timeout != 0 {
params["timeout"] = formatDuration(r.Timeout)
}
if r.Pretty {
params["pretty"] = "true"
}
if r.Human {
params["human"] = "true"
}
if r.ErrorTrace {
params["error_trace"] = "true"
}
if len(r.FilterPath) > 0 {
params["filter_path"] = strings.Join(r.FilterPath, ",")
}
return params
}
@@ -0,0 +1,44 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
package opensearchapi
import (
"fmt"
"net/http"
"github.com/opensearch-project/opensearch-go/v4"
)
// DanglingImportReq represents possible options for the dangling import request
type DanglingImportReq struct {
IndexUUID string
Header http.Header
Params DanglingImportParams
}
// GetRequest returns the *http.Request that gets executed by the client
func (r DanglingImportReq) GetRequest() (*http.Request, error) {
return opensearch.BuildRequest(
"POST",
fmt.Sprintf("/_dangling/%s", r.IndexUUID),
nil,
r.Params.get(),
r.Header,
)
}
// DanglingImportResp represents the returned struct of thedangling import response
type DanglingImportResp struct {
Acknowledged bool `json:"acknowledged"`
response *opensearch.Response
}
// Inspect returns the Inspect type containing the raw *opensearch.Response
func (r DanglingImportResp) Inspect() Inspect {
return Inspect{Response: r.response}
}
@@ -0,0 +1,58 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
package opensearchapi
import (
"context"
)
type danglingClient struct {
apiClient *Client
}
// Delete executes a delete dangling request with the required DanglingDeleteReq
func (c danglingClient) Delete(ctx context.Context, req DanglingDeleteReq) (*DanglingDeleteResp, error) {
var (
data DanglingDeleteResp
err error
)
if data.response, err = c.apiClient.do(ctx, req, &data); err != nil {
return &data, err
}
return &data, nil
}
// Import executes an import dangling request with the required DanglingImportReq
func (c danglingClient) Import(ctx context.Context, req DanglingImportReq) (*DanglingImportResp, error) {
var (
data DanglingImportResp
err error
)
if data.response, err = c.apiClient.do(ctx, req, &data); err != nil {
return &data, err
}
return &data, nil
}
// Get executes a /_dangling request with the optional DanglingGetReq
func (c danglingClient) Get(ctx context.Context, req *DanglingGetReq) (*DanglingGetResp, error) {
if req == nil {
req = &DanglingGetReq{}
}
var (
data DanglingGetResp
err error
)
if data.response, err = c.apiClient.do(ctx, req, &data); err != nil {
return &data, err
}
return &data, nil
}
@@ -0,0 +1,59 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
// Modifications Copyright OpenSearch Contributors. See
// GitHub history for details.
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package opensearchapi
import "strings"
// DataStreamCreateParams represents possible parameters for the DataStreamCreateReq
type DataStreamCreateParams struct {
Pretty bool
Human bool
ErrorTrace bool
FilterPath []string
}
func (r DataStreamCreateParams) get() map[string]string {
params := make(map[string]string)
if r.Pretty {
params["pretty"] = "true"
}
if r.Human {
params["human"] = "true"
}
if r.ErrorTrace {
params["error_trace"] = "true"
}
if len(r.FilterPath) > 0 {
params["filter_path"] = strings.Join(r.FilterPath, ",")
}
return params
}
@@ -0,0 +1,44 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
package opensearchapi
import (
"fmt"
"net/http"
"github.com/opensearch-project/opensearch-go/v4"
)
// DataStreamCreateReq represents possible options for the _data_stream create request
type DataStreamCreateReq struct {
DataStream string
Header http.Header
Params DataStreamCreateParams
}
// GetRequest returns the *http.Request that gets executed by the client
func (r DataStreamCreateReq) GetRequest() (*http.Request, error) {
return opensearch.BuildRequest(
"PUT",
fmt.Sprintf("/_data_stream/%s", r.DataStream),
nil,
r.Params.get(),
r.Header,
)
}
// DataStreamCreateResp represents the returned struct of the _data_stream create response
type DataStreamCreateResp struct {
Acknowledged bool `json:"acknowledged"`
response *opensearch.Response
}
// Inspect returns the Inspect type containing the raw *opensearch.Response
func (r DataStreamCreateResp) Inspect() Inspect {
return Inspect{Response: r.response}
}
@@ -0,0 +1,73 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
// Modifications Copyright OpenSearch Contributors. See
// GitHub history for details.
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package opensearchapi
import (
"strings"
"time"
)
// DataStreamDeleteParams represents possible parameters for the DataStreamDeleteReq
type DataStreamDeleteParams struct {
ClusterManagerTimeout time.Duration
Timeout time.Duration
Pretty bool
Human bool
ErrorTrace bool
FilterPath []string
}
func (r DataStreamDeleteParams) get() map[string]string {
params := make(map[string]string)
if r.ClusterManagerTimeout != 0 {
params["cluster_manager_timeout"] = formatDuration(r.ClusterManagerTimeout)
}
if r.Timeout != 0 {
params["timeout"] = formatDuration(r.Timeout)
}
if r.Pretty {
params["pretty"] = "true"
}
if r.Human {
params["human"] = "true"
}
if r.ErrorTrace {
params["error_trace"] = "true"
}
if len(r.FilterPath) > 0 {
params["filter_path"] = strings.Join(r.FilterPath, ",")
}
return params
}
@@ -0,0 +1,44 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
package opensearchapi
import (
"fmt"
"net/http"
"github.com/opensearch-project/opensearch-go/v4"
)
// DataStreamDeleteReq represents possible options for the index _data_stream delete request
type DataStreamDeleteReq struct {
DataStream string
Header http.Header
Params DataStreamDeleteParams
}
// GetRequest returns the *http.Request that gets executed by the client
func (r DataStreamDeleteReq) GetRequest() (*http.Request, error) {
return opensearch.BuildRequest(
"DELETE",
fmt.Sprintf("/_data_stream/%s", r.DataStream),
nil,
r.Params.get(),
r.Header,
)
}
// DataStreamDeleteResp represents the returned struct of the _data_stream delete response
type DataStreamDeleteResp struct {
Acknowledged bool `json:"acknowledged"`
response *opensearch.Response
}
// Inspect returns the Inspect type containing the raw *opensearch.Response
func (r DataStreamDeleteResp) Inspect() Inspect {
return Inspect{Response: r.response}
}
@@ -0,0 +1,68 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
// Modifications Copyright OpenSearch Contributors. See
// GitHub history for details.
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package opensearchapi
import (
"strings"
"time"
)
// DataStreamGetParams represents possible parameters for the DataStreamGetReq
type DataStreamGetParams struct {
ClusterManagerTimeout time.Duration
Pretty bool
Human bool
ErrorTrace bool
FilterPath []string
}
func (r DataStreamGetParams) get() map[string]string {
params := make(map[string]string)
if r.ClusterManagerTimeout != 0 {
params["cluster_manager_timeout"] = formatDuration(r.ClusterManagerTimeout)
}
if r.Pretty {
params["pretty"] = "true"
}
if r.Human {
params["human"] = "true"
}
if r.ErrorTrace {
params["error_trace"] = "true"
}
if len(r.FilterPath) > 0 {
params["filter_path"] = strings.Join(r.FilterPath, ",")
}
return params
}
@@ -0,0 +1,72 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
package opensearchapi
import (
"net/http"
"strings"
"github.com/opensearch-project/opensearch-go/v4"
)
// DataStreamGetReq represents possible options for the _data_stream get request
type DataStreamGetReq struct {
DataStreams []string
Header http.Header
Params DataStreamGetParams
}
// GetRequest returns the *http.Request that gets executed by the client
func (r DataStreamGetReq) GetRequest() (*http.Request, error) {
dataStreams := strings.Join(r.DataStreams, ",")
var path strings.Builder
path.Grow(len("/_data_stream/") + len(dataStreams))
path.WriteString("/_data_stream")
if len(r.DataStreams) > 0 {
path.WriteString("/")
path.WriteString(dataStreams)
}
return opensearch.BuildRequest(
"GET",
path.String(),
nil,
r.Params.get(),
r.Header,
)
}
// DataStreamGetResp represents the returned struct of the _data_stream get response
type DataStreamGetResp struct {
DataStreams []DataStreamGetDetails `json:"data_streams"`
response *opensearch.Response
}
// Inspect returns the Inspect type containing the raw *opensearch.Response
func (r DataStreamGetResp) Inspect() Inspect {
return Inspect{Response: r.response}
}
// DataStreamGetDetails is a sub type if DataStreamGetResp containing information about a data stream
type DataStreamGetDetails struct {
Name string `json:"name"`
TimestampField struct {
Name string `json:"name"`
} `json:"timestamp_field"`
Indices []DataStreamIndices `json:"indices"`
Generation int `json:"generation"`
Status string `json:"status"`
Template string `json:"template"`
}
// DataStreamIndices is a sub type of DataStreamGetDetails containing information about an index
type DataStreamIndices struct {
Name string `json:"index_name"`
UUID string `json:"index_uuid"`
}
@@ -0,0 +1,68 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
// Modifications Copyright OpenSearch Contributors. See
// GitHub history for details.
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package opensearchapi
import (
"strings"
"time"
)
// DataStreamStatsParams represents possible parameters for the DataStreamCreateReq
type DataStreamStatsParams struct {
ClusterManagerTimeout time.Duration
Pretty bool
Human bool
ErrorTrace bool
FilterPath []string
}
func (r DataStreamStatsParams) get() map[string]string {
params := make(map[string]string)
if r.ClusterManagerTimeout != 0 {
params["cluster_manager_timeout"] = formatDuration(r.ClusterManagerTimeout)
}
if r.Pretty {
params["pretty"] = "true"
}
if r.Human {
params["human"] = "true"
}
if r.ErrorTrace {
params["error_trace"] = "true"
}
if len(r.FilterPath) > 0 {
params["filter_path"] = strings.Join(r.FilterPath, ",")
}
return params
}
@@ -0,0 +1,77 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
package opensearchapi
import (
"net/http"
"strings"
"github.com/opensearch-project/opensearch-go/v4"
)
// DataStreamStatsReq represents possible options for the _data_stream stats request
type DataStreamStatsReq struct {
DataStreams []string
Header http.Header
Params DataStreamStatsParams
}
// GetRequest returns the *http.Request that gets executed by the client
func (r DataStreamStatsReq) GetRequest() (*http.Request, error) {
dataStreams := strings.Join(r.DataStreams, ",")
var path strings.Builder
path.Grow(len("/_data_stream//_stats") + len(dataStreams))
path.WriteString("/_data_stream/")
if len(r.DataStreams) > 0 {
path.WriteString(dataStreams)
path.WriteString("/")
}
path.WriteString("_stats")
return opensearch.BuildRequest(
"GET",
path.String(),
nil,
r.Params.get(),
r.Header,
)
}
// DataStreamStatsResp represents the returned struct of the _data_stream stats response
type DataStreamStatsResp struct {
Shards struct {
Total int `json:"total"`
Successful int `json:"successful"`
Failed int `json:"failed"`
Failures []struct {
Shard int `json:"shard"`
Index string `json:"index"`
Status string `json:"status"`
Reason FailuresCause `json:"reason"`
} `json:"failures"`
} `json:"_shards"`
DataStreamCount int `json:"data_stream_count"`
BackingIndices int `json:"backing_indices"`
TotalStoreSizeBytes int64 `json:"total_store_size_bytes"`
DataStreams []DataStreamStatsDetails `json:"data_streams"`
response *opensearch.Response
}
// Inspect returns the Inspect type containing the raw *opensearch.Response
func (r DataStreamStatsResp) Inspect() Inspect {
return Inspect{Response: r.response}
}
// DataStreamStatsDetails is a sub type of DataStreamStatsResp containing information about a data stream
type DataStreamStatsDetails struct {
DataStream string `json:"data_stream"`
BackingIndices int `json:"backing_indices"`
StoreSizeBytes int64 `json:"store_size_bytes"`
MaximumTimestamp int64 `json:"maximum_timestamp"`
}
@@ -0,0 +1,75 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
package opensearchapi
import (
"context"
)
type dataStreamClient struct {
apiClient *Client
}
// Create executes a creade dataStream request with the required DataStreamCreateReq
func (c dataStreamClient) Create(ctx context.Context, req DataStreamCreateReq) (*DataStreamCreateResp, error) {
var (
data DataStreamCreateResp
err error
)
if data.response, err = c.apiClient.do(ctx, req, &data); err != nil {
return &data, err
}
return &data, nil
}
// Delete executes a delete dataStream request with the required DataStreamDeleteReq
func (c dataStreamClient) Delete(ctx context.Context, req DataStreamDeleteReq) (*DataStreamDeleteResp, error) {
var (
data DataStreamDeleteResp
err error
)
if data.response, err = c.apiClient.do(ctx, req, &data); err != nil {
return &data, err
}
return &data, nil
}
// Get executes a get dataStream request with the optional DataStreamGetReq
func (c dataStreamClient) Get(ctx context.Context, req *DataStreamGetReq) (*DataStreamGetResp, error) {
if req == nil {
req = &DataStreamGetReq{}
}
var (
data DataStreamGetResp
err error
)
if data.response, err = c.apiClient.do(ctx, req, &data); err != nil {
return &data, err
}
return &data, nil
}
// Stats executes a stats dataStream request with the optional DataStreamStatsReq
func (c dataStreamClient) Stats(ctx context.Context, req *DataStreamStatsReq) (*DataStreamStatsResp, error) {
if req == nil {
req = &DataStreamStatsReq{}
}
var (
data DataStreamStatsResp
err error
)
if data.response, err = c.apiClient.do(ctx, req, &data); err != nil {
return &data, err
}
return &data, nil
}
@@ -0,0 +1,99 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
// Modifications Copyright OpenSearch Contributors. See
// GitHub history for details.
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package opensearchapi
import (
"strconv"
"strings"
"time"
)
// DocumentCreateParams represents possible parameters for the DocumentCreateReq
type DocumentCreateParams struct {
Pipeline string
Refresh string
Routing string
Timeout time.Duration
Version *int
VersionType string
WaitForActiveShards string
Pretty bool
Human bool
ErrorTrace bool
FilterPath []string
}
func (r DocumentCreateParams) get() map[string]string {
params := make(map[string]string)
if r.Pipeline != "" {
params["pipeline"] = r.Pipeline
}
if r.Refresh != "" {
params["refresh"] = r.Refresh
}
if r.Routing != "" {
params["routing"] = r.Routing
}
if r.Timeout != 0 {
params["timeout"] = formatDuration(r.Timeout)
}
if r.Version != nil {
params["version"] = strconv.FormatInt(int64(*r.Version), 10)
}
if r.VersionType != "" {
params["version_type"] = r.VersionType
}
if r.WaitForActiveShards != "" {
params["wait_for_active_shards"] = r.WaitForActiveShards
}
if r.Pretty {
params["pretty"] = "true"
}
if r.Human {
params["human"] = "true"
}
if r.ErrorTrace {
params["error_trace"] = "true"
}
if len(r.FilterPath) > 0 {
params["filter_path"] = strings.Join(r.FilterPath, ",")
}
return params
}
@@ -0,0 +1,66 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
package opensearchapi
import (
"io"
"net/http"
"strings"
"github.com/opensearch-project/opensearch-go/v4"
)
// DocumentCreateReq represents possible options for the /<index>/_create request
type DocumentCreateReq struct {
Index string
DocumentID string
Body io.Reader
Header http.Header
Params DocumentCreateParams
}
// GetRequest returns the *http.Request that gets executed by the client
func (r DocumentCreateReq) GetRequest() (*http.Request, error) {
var path strings.Builder
path.Grow(10 + len(r.Index) + len(r.DocumentID))
path.WriteString("/")
path.WriteString(r.Index)
path.WriteString("/_create/")
path.WriteString(r.DocumentID)
return opensearch.BuildRequest(
"PUT",
path.String(),
r.Body,
r.Params.get(),
r.Header,
)
}
// DocumentCreateResp represents the returned struct of the /_doc response
type DocumentCreateResp struct {
Index string `json:"_index"`
ID string `json:"_id"`
Version int `json:"_version"`
Result string `json:"result"`
Type string `json:"_type"` // Deprecated field
ForcedRefresh bool `json:"forced_refresh"`
Shards struct {
Total int `json:"total"`
Successful int `json:"successful"`
Failed int `json:"failed"`
} `json:"_shards"`
SeqNo int `json:"_seq_no"`
PrimaryTerm int `json:"_primary_term"`
response *opensearch.Response
}
// Inspect returns the Inspect type containing the raw *opensearch.Response
func (r DocumentCreateResp) Inspect() Inspect {
return Inspect{Response: r.response}
}
@@ -0,0 +1,104 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
// Modifications Copyright OpenSearch Contributors. See
// GitHub history for details.
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package opensearchapi
import (
"strconv"
"strings"
"time"
)
// DocumentDeleteParams represents possible parameters for the DocumentDeleteReq
type DocumentDeleteParams struct {
IfPrimaryTerm *int
IfSeqNo *int
Refresh string
Routing string
Timeout time.Duration
Version *int
VersionType string
WaitForActiveShards string
Pretty bool
Human bool
ErrorTrace bool
FilterPath []string
}
func (r DocumentDeleteParams) get() map[string]string {
params := make(map[string]string)
if r.IfPrimaryTerm != nil {
params["if_primary_term"] = strconv.FormatInt(int64(*r.IfPrimaryTerm), 10)
}
if r.IfSeqNo != nil {
params["if_seq_no"] = strconv.FormatInt(int64(*r.IfSeqNo), 10)
}
if r.Refresh != "" {
params["refresh"] = r.Refresh
}
if r.Routing != "" {
params["routing"] = r.Routing
}
if r.Timeout != 0 {
params["timeout"] = formatDuration(r.Timeout)
}
if r.Version != nil {
params["version"] = strconv.FormatInt(int64(*r.Version), 10)
}
if r.VersionType != "" {
params["version_type"] = r.VersionType
}
if r.WaitForActiveShards != "" {
params["wait_for_active_shards"] = r.WaitForActiveShards
}
if r.Pretty {
params["pretty"] = "true"
}
if r.Human {
params["human"] = "true"
}
if r.ErrorTrace {
params["error_trace"] = "true"
}
if len(r.FilterPath) > 0 {
params["filter_path"] = strings.Join(r.FilterPath, ",")
}
return params
}
@@ -0,0 +1,62 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
package opensearchapi
import (
"net/http"
"strings"
"github.com/opensearch-project/opensearch-go/v4"
)
// DocumentDeleteReq represents possible options for the /<index>/_doc/<DocID> delete request
type DocumentDeleteReq struct {
Index string
DocumentID string
Header http.Header
Params DocumentDeleteParams
}
// GetRequest returns the *http.Request that gets executed by the client
func (r DocumentDeleteReq) GetRequest() (*http.Request, error) {
var path strings.Builder
path.Grow(7 + len(r.Index) + len(r.DocumentID))
path.WriteString("/")
path.WriteString(r.Index)
path.WriteString("/_doc/")
path.WriteString(r.DocumentID)
return opensearch.BuildRequest(
"DELETE",
path.String(),
nil,
r.Params.get(),
r.Header,
)
}
// DocumentDeleteResp represents the returned struct of the /<index>/_doc/<DocID> response
type DocumentDeleteResp struct {
Index string `json:"_index"`
ID string `json:"_id"`
Version int `json:"_version"`
Result string `json:"result"`
Type string `json:"_type"` // Deprecated field
Shards struct {
Total int `json:"total"`
Successful int `json:"successful"`
Failed int `json:"failed"`
} `json:"_shards"`
SeqNo int `json:"_seq_no"`
PrimaryTerm int `json:"_primary_term"`
response *opensearch.Response
}
// Inspect returns the Inspect type containing the raw *opensearch.Response
func (r DocumentDeleteResp) Inspect() Inspect {
return Inspect{Response: r.response}
}
@@ -0,0 +1,239 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
// Modifications Copyright OpenSearch Contributors. See
// GitHub history for details.
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package opensearchapi
import (
"fmt"
"strconv"
"strings"
"time"
)
// DocumentDeleteByQueryParams represents possible parameters for the DocumentDeleteByQueryReq
type DocumentDeleteByQueryParams struct {
AllowNoIndices *bool
Analyzer string
AnalyzeWildcard *bool
Conflicts string
DefaultOperator string
Df string
ExpandWildcards string
From *int
IgnoreUnavailable *bool
Lenient *bool
MaxDocs *int
Preference string
Query string
Refresh *bool
RequestCache *bool
RequestsPerSecond *int
Routing []string
Scroll time.Duration
ScrollSize *int
SearchTimeout time.Duration
SearchType string
Size *int
Slices interface{}
Sort []string
Source interface{}
SourceExcludes []string
SourceIncludes []string
Stats []string
TerminateAfter *int
Timeout time.Duration
Version *bool
WaitForActiveShards string
WaitForCompletion *bool
Pretty bool
Human bool
ErrorTrace bool
FilterPath []string
}
func (r DocumentDeleteByQueryParams) get() map[string]string {
params := make(map[string]string)
if r.AllowNoIndices != nil {
params["allow_no_indices"] = strconv.FormatBool(*r.AllowNoIndices)
}
if r.Analyzer != "" {
params["analyzer"] = r.Analyzer
}
if r.AnalyzeWildcard != nil {
params["analyze_wildcard"] = strconv.FormatBool(*r.AnalyzeWildcard)
}
if r.Conflicts != "" {
params["conflicts"] = r.Conflicts
}
if r.DefaultOperator != "" {
params["default_operator"] = r.DefaultOperator
}
if r.Df != "" {
params["df"] = r.Df
}
if r.ExpandWildcards != "" {
params["expand_wildcards"] = r.ExpandWildcards
}
if r.From != nil {
params["from"] = strconv.FormatInt(int64(*r.From), 10)
}
if r.IgnoreUnavailable != nil {
params["ignore_unavailable"] = strconv.FormatBool(*r.IgnoreUnavailable)
}
if r.Lenient != nil {
params["lenient"] = strconv.FormatBool(*r.Lenient)
}
if r.MaxDocs != nil {
params["max_docs"] = strconv.FormatInt(int64(*r.MaxDocs), 10)
}
if r.Preference != "" {
params["preference"] = r.Preference
}
if r.Query != "" {
params["q"] = r.Query
}
if r.Refresh != nil {
params["refresh"] = strconv.FormatBool(*r.Refresh)
}
if r.RequestCache != nil {
params["request_cache"] = strconv.FormatBool(*r.RequestCache)
}
if r.RequestsPerSecond != nil {
params["requests_per_second"] = strconv.FormatInt(int64(*r.RequestsPerSecond), 10)
}
if len(r.Routing) > 0 {
params["routing"] = strings.Join(r.Routing, ",")
}
if r.Scroll != 0 {
params["scroll"] = formatDuration(r.Scroll)
}
if r.ScrollSize != nil {
params["scroll_size"] = strconv.FormatInt(int64(*r.ScrollSize), 10)
}
if r.SearchTimeout != 0 {
params["search_timeout"] = formatDuration(r.SearchTimeout)
}
if r.SearchType != "" {
params["search_type"] = r.SearchType
}
if r.Size != nil {
params["size"] = strconv.FormatInt(int64(*r.Size), 10)
}
if r.Slices != nil {
params["slices"] = fmt.Sprintf("%v", r.Slices)
}
if len(r.Sort) > 0 {
params["sort"] = strings.Join(r.Sort, ",")
}
switch source := r.Source.(type) {
case bool:
params["_source"] = strconv.FormatBool(source)
case string:
if source != "" {
params["_source"] = source
}
case []string:
if len(source) > 0 {
params["_source"] = strings.Join(source, ",")
}
}
if len(r.SourceExcludes) > 0 {
params["_source_excludes"] = strings.Join(r.SourceExcludes, ",")
}
if len(r.SourceIncludes) > 0 {
params["_source_includes"] = strings.Join(r.SourceIncludes, ",")
}
if len(r.Stats) > 0 {
params["stats"] = strings.Join(r.Stats, ",")
}
if r.TerminateAfter != nil {
params["terminate_after"] = strconv.FormatInt(int64(*r.TerminateAfter), 10)
}
if r.Timeout != 0 {
params["timeout"] = formatDuration(r.Timeout)
}
if r.Version != nil {
params["version"] = strconv.FormatBool(*r.Version)
}
if r.WaitForActiveShards != "" {
params["wait_for_active_shards"] = r.WaitForActiveShards
}
if r.WaitForCompletion != nil {
params["wait_for_completion"] = strconv.FormatBool(*r.WaitForCompletion)
}
if r.Pretty {
params["pretty"] = "true"
}
if r.Human {
params["human"] = "true"
}
if r.ErrorTrace {
params["error_trace"] = "true"
}
if len(r.FilterPath) > 0 {
params["filter_path"] = strings.Join(r.FilterPath, ",")
}
return params
}
@@ -0,0 +1,64 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
package opensearchapi
import (
"encoding/json"
"fmt"
"io"
"net/http"
"strings"
"github.com/opensearch-project/opensearch-go/v4"
)
// DocumentDeleteByQueryReq represents possible options for the /<index>/_delete_by_query request
type DocumentDeleteByQueryReq struct {
Indices []string
Body io.Reader
Header http.Header
Params DocumentDeleteByQueryParams
}
// GetRequest returns the *http.Request that gets executed by the client
func (r DocumentDeleteByQueryReq) GetRequest() (*http.Request, error) {
return opensearch.BuildRequest(
"POST",
fmt.Sprintf("/%s/_delete_by_query", strings.Join(r.Indices, ",")),
r.Body,
r.Params.get(),
r.Header,
)
}
// DocumentDeleteByQueryResp represents the returned struct of the /<index>/_delete_by_query response
type DocumentDeleteByQueryResp struct {
Took int `json:"took"`
TimedOut bool `json:"timed_out"`
Total int `json:"total"`
Deleted int `json:"deleted"`
Batches int `json:"batches"`
VersionConflicts int `json:"version_conflicts"`
Noops int `json:"noops"`
Retries struct {
Bulk int `json:"bulk"`
Search int `json:"search"`
} `json:"retries"`
ThrottledMillis int `json:"throttled_millis"`
RequestsPerSecond float32 `json:"requests_per_second"`
ThrottledUntilMillis int `json:"throttled_until_millis"`
Failures []json.RawMessage `json:"failures"` // Unknow struct, open an issue with an example response so we can add it
Task string `json:"task,omitempty"` // Needed when wait_for_completion is set to false
response *opensearch.Response
}
// Inspect returns the Inspect type containing the raw *opensearch.Response
func (r DocumentDeleteByQueryResp) Inspect() Inspect {
return Inspect{Response: r.response}
}
@@ -0,0 +1,68 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
// Modifications Copyright OpenSearch Contributors. See
// GitHub history for details.
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package opensearchapi
import (
"strconv"
"strings"
)
// DocumentDeleteByQueryRethrottleParams represents possible parameters for the DocumentDeleteByQueryRethrottleReq
type DocumentDeleteByQueryRethrottleParams struct {
RequestsPerSecond *int
Pretty bool
Human bool
ErrorTrace bool
FilterPath []string
}
func (r DocumentDeleteByQueryRethrottleParams) get() map[string]string {
params := make(map[string]string)
if r.RequestsPerSecond != nil {
params["requests_per_second"] = strconv.FormatInt(int64(*r.RequestsPerSecond), 10)
}
if r.Pretty {
params["pretty"] = "true"
}
if r.Human {
params["human"] = "true"
}
if r.ErrorTrace {
params["error_trace"] = "true"
}
if len(r.FilterPath) > 0 {
params["filter_path"] = strings.Join(r.FilterPath, ",")
}
return params
}
@@ -0,0 +1,97 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
package opensearchapi
import (
"encoding/json"
"fmt"
"net/http"
"github.com/opensearch-project/opensearch-go/v4"
)
// DocumentDeleteByQueryRethrottleReq represents possible options for the /_delete_by_query/<index>/_rethrottle request
type DocumentDeleteByQueryRethrottleReq struct {
TaskID string
Header http.Header
Params DocumentDeleteByQueryRethrottleParams
}
// GetRequest returns the *http.Request that gets executed by the client
func (r DocumentDeleteByQueryRethrottleReq) GetRequest() (*http.Request, error) {
return opensearch.BuildRequest(
"POST",
fmt.Sprintf("/_delete_by_query/%s/_rethrottle", r.TaskID),
nil,
r.Params.get(),
r.Header,
)
}
// DocumentDeleteByQueryRethrottleResp represents the returned struct of the /_delete_by_query/<index>/_rethrottle response
type DocumentDeleteByQueryRethrottleResp struct {
Nodes map[string]struct {
Name string `json:"name"`
TransportAddress string `json:"transport_address"`
Host string `json:"host"`
IP string `json:"ip"`
Roles []string `json:"roles"`
Attributes map[string]string `json:"attributes"`
Tasks map[string]struct {
Node string `json:"node"`
ID int `json:"id"`
Type string `json:"type"`
Action string `json:"action"`
Status struct {
Total int `json:"total"`
Updated int `json:"updated"`
Created int `json:"created"`
Deleted int `json:"deleted"`
Batches int `json:"batches"`
VersionConflicts int `json:"version_conflicts"`
Noops int `json:"noops"`
Retries struct {
Bulk int `json:"bulk"`
Search int `json:"search"`
} `json:"retries"`
ThrottledMillis int `json:"throttled_millis"`
RequestsPerSecond float64 `json:"requests_per_second"`
ThrottledUntilMillis int `json:"throttled_until_millis"`
} `json:"status"`
Description string `json:"description"`
StartTimeInMillis int64 `json:"start_time_in_millis"`
RunningTimeInNanos int `json:"running_time_in_nanos"`
Cancellable bool `json:"cancellable"`
Cancelled bool `json:"cancelled"`
Headers json.RawMessage `json:"headers"`
ResourceStats struct {
Average DocumentDeleteByQueryRethrottleResourceInfo `json:"average"`
Max DocumentDeleteByQueryRethrottleResourceInfo `json:"max"`
Min DocumentDeleteByQueryRethrottleResourceInfo `json:"min"`
Total DocumentDeleteByQueryRethrottleResourceInfo `json:"total"`
ThreadInfo struct {
ActiveThreads int `json:"active_threads"`
ThreadExecutions int `json:"thread_executions"`
} `json:"thread_info"`
} `json:"resource_stats"`
} `json:"tasks"`
} `json:"nodes"`
NodeFailures []FailuresCause `json:"node_failures"`
response *opensearch.Response
}
// DocumentDeleteByQueryRethrottleResourceInfo is a sub type of DocumentDeleteByQueryRethrottleResp containing resource stats
type DocumentDeleteByQueryRethrottleResourceInfo struct {
CPUTimeInNanos int `json:"cpu_time_in_nanos"`
MemoryInBytes int `json:"memory_in_bytes"`
}
// Inspect returns the Inspect type containing the raw *opensearch.Response
func (r DocumentDeleteByQueryRethrottleResp) Inspect() Inspect {
return Inspect{Response: r.response}
}
@@ -0,0 +1,122 @@
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
// Modifications Copyright OpenSearch Contributors. See
// GitHub history for details.
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package opensearchapi
import (
"strconv"
"strings"
)
// DocumentExistsParams represents possible parameters for the DocumentExistsReq
type DocumentExistsParams struct {
Preference string
Realtime *bool
Refresh *bool
Routing string
Source interface{}
SourceExcludes []string
SourceIncludes []string
StoredFields []string
Version *int
VersionType string
Pretty bool
Human bool
ErrorTrace bool
FilterPath []string
}
func (r DocumentExistsParams) get() map[string]string {
params := make(map[string]string)
if r.Preference != "" {
params["preference"] = r.Preference
}
if r.Realtime != nil {
params["realtime"] = strconv.FormatBool(*r.Realtime)
}
if r.Refresh != nil {
params["refresh"] = strconv.FormatBool(*r.Refresh)
}
if r.Routing != "" {
params["routing"] = r.Routing
}
switch source := r.Source.(type) {
case bool:
params["_source"] = strconv.FormatBool(source)
case string:
if source != "" {
params["_source"] = source
}
case []string:
if len(source) > 0 {
params["_source"] = strings.Join(source, ",")
}
}
if len(r.SourceExcludes) > 0 {
params["_source_excludes"] = strings.Join(r.SourceExcludes, ",")
}
if len(r.SourceIncludes) > 0 {
params["_source_includes"] = strings.Join(r.SourceIncludes, ",")
}
if len(r.StoredFields) > 0 {
params["stored_fields"] = strings.Join(r.StoredFields, ",")
}
if r.Version != nil {
params["version"] = strconv.FormatInt(int64(*r.Version), 10)
}
if r.VersionType != "" {
params["version_type"] = r.VersionType
}
if r.Pretty {
params["pretty"] = "true"
}
if r.Human {
params["human"] = "true"
}
if r.ErrorTrace {
params["error_trace"] = "true"
}
if len(r.FilterPath) > 0 {
params["filter_path"] = strings.Join(r.FilterPath, ",")
}
return params
}

Some files were not shown because too many files have changed in this diff Show More