Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Deprecate legacy API #390

Merged
merged 11 commits into from
Oct 16, 2023
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

### Deprecated

- Deprecated legacy API /opensearchapi/api.indices.put_template.go ([#151](https://github.com/opensearch-project/opensearch-go/issues/151))
tannerjones4075 marked this conversation as resolved.
Show resolved Hide resolved

### Removed

- Removes info call before performing every request ([#219](https://github.com/opensearch-project/opensearch-go/pull/219))
Expand Down
31 changes: 15 additions & 16 deletions opensearchapi/api.indices.put_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
"time"
)

// Deprecated: uses a nonexistent legacy REST API (/_template) correct REST API is /_index_template use newIndicesPutSettingsFunc instead
tannerjones4075 marked this conversation as resolved.
Show resolved Hide resolved
func newIndicesPutTemplateFunc(t Transport) IndicesPutTemplate {
return func(name string, body io.Reader, o ...func(*IndicesPutTemplateRequest)) (*Response, error) {
var r = IndicesPutTemplateRequest{Name: name, Body: body}
Expand All @@ -48,12 +49,11 @@ func newIndicesPutTemplateFunc(t Transport) IndicesPutTemplate {
// ----- API Definition -------------------------------------------------------

// IndicesPutTemplate creates or updates an index template.
//
//
// Deprecated: uses a nonexistent legacy REST API (/_template) correct REST API is /_index_template use IndicesPutSettings instead
type IndicesPutTemplate func(name string, body io.Reader, o ...func(*IndicesPutTemplateRequest)) (*Response, error)

// IndicesPutTemplateRequest configures the Indices Put Template API request.
//
// Deprecated: uses a nonexistent legacy REST API (/_template) correct REST API is /_index_template use IndicesPutSettingsRequest instead
type IndicesPutTemplateRequest struct {
Body io.Reader

Expand All @@ -75,7 +75,7 @@ type IndicesPutTemplateRequest struct {
}

// Do executes the request and returns response or error.
//
// Deprecated: uses a nonexistent legacy REST API (/_template) correct REST API is /_index_template use IndicesPutSettingsRequest instead
func (r IndicesPutTemplateRequest) Do(ctx context.Context, transport Transport) (*Response, error) {
var (
method string
Expand Down Expand Up @@ -173,81 +173,80 @@ func (r IndicesPutTemplateRequest) Do(ctx context.Context, transport Transport)
}

// WithContext sets the request context.
//
// Deprecated: uses a nonexistent legacy REST API (/_template) correct REST API is /_index_template use IndicesPutSettings instead
func (f IndicesPutTemplate) WithContext(v context.Context) func(*IndicesPutTemplateRequest) {
return func(r *IndicesPutTemplateRequest) {
r.ctx = v
}
}

// WithCreate - whether the index template should only be added if new or can also replace an existing one.
//
// Deprecated: uses a nonexistent legacy REST API (/_template) correct REST API is /_index_template use IndicesPutSettings instead
func (f IndicesPutTemplate) WithCreate(v bool) func(*IndicesPutTemplateRequest) {
return func(r *IndicesPutTemplateRequest) {
r.Create = &v
}
}

// WithMasterTimeout - explicit operation timeout for connection to cluster-manager node.
//
// Deprecated: To promote inclusive language, use WithClusterManagerTimeout instead.
//
// Deprecated: uses a nonexistent legacy REST API (/_template) correct REST API is /_index_template use IndicesPutSettings instead
func (f IndicesPutTemplate) WithMasterTimeout(v time.Duration) func(*IndicesPutTemplateRequest) {
return func(r *IndicesPutTemplateRequest) {
r.MasterTimeout = v
}
}

// WithClusterManagerTimeout - explicit operation timeout for connection to cluster-manager node.
//
// Deprecated: uses a nonexistent legacy REST API (/_template) correct REST API is /_index_template use IndicesPutSettings instead
func (f IndicesPutTemplate) WithClusterManagerTimeout(v time.Duration) func(*IndicesPutTemplateRequest) {
return func(r *IndicesPutTemplateRequest) {
r.ClusterManagerTimeout = v
}
}

// WithOrder - the order for this template when merging multiple matching ones (higher numbers are merged later, overriding the lower numbers).
//
// Deprecated: uses a nonexistent legacy REST API (/_template) correct REST API is /_index_template use IndicesPutSettings instead
func (f IndicesPutTemplate) WithOrder(v int) func(*IndicesPutTemplateRequest) {
return func(r *IndicesPutTemplateRequest) {
r.Order = &v
}
}

// WithPretty makes the response body pretty-printed.
//
// Deprecated: uses a nonexistent legacy REST API (/_template) correct REST API is /_index_template use IndicesPutSettings instead
func (f IndicesPutTemplate) WithPretty() func(*IndicesPutTemplateRequest) {
return func(r *IndicesPutTemplateRequest) {
r.Pretty = true
}
}

// WithHuman makes statistical values human-readable.
//
// Deprecated: uses a nonexistent legacy REST API (/_template) correct REST API is /_index_template use IndicesPutSettings instead
func (f IndicesPutTemplate) WithHuman() func(*IndicesPutTemplateRequest) {
return func(r *IndicesPutTemplateRequest) {
r.Human = true
}
}

// WithErrorTrace includes the stack trace for errors in the response body.
//
// Deprecated: uses a nonexistent legacy REST API (/_template) correct REST API is /_index_template use IndicesPutSettings instead
func (f IndicesPutTemplate) WithErrorTrace() func(*IndicesPutTemplateRequest) {
return func(r *IndicesPutTemplateRequest) {
r.ErrorTrace = true
}
}

// WithFilterPath filters the properties of the response body.
//
// Deprecated: uses a nonexistent legacy REST API (/_template) correct REST API is /_index_template use IndicesPutSettings instead
func (f IndicesPutTemplate) WithFilterPath(v ...string) func(*IndicesPutTemplateRequest) {
return func(r *IndicesPutTemplateRequest) {
r.FilterPath = v
}
}

// WithHeader adds the headers to the HTTP request.
//
// Deprecated: uses a nonexistent legacy REST API (/_template) correct REST API is /_index_template use IndicesPutSettings instead
func (f IndicesPutTemplate) WithHeader(h map[string]string) func(*IndicesPutTemplateRequest) {
return func(r *IndicesPutTemplateRequest) {
if r.Header == nil {
Expand All @@ -260,7 +259,7 @@ func (f IndicesPutTemplate) WithHeader(h map[string]string) func(*IndicesPutTemp
}

// WithOpaqueID adds the X-Opaque-Id header to the HTTP request.
//
// Deprecated: uses a nonexistent legacy REST API (/_template) correct REST API is /_index_template use IndicesPutSettings instead
func (f IndicesPutTemplate) WithOpaqueID(s string) func(*IndicesPutTemplateRequest) {
return func(r *IndicesPutTemplateRequest) {
if r.Header == nil {
Expand Down