Skip to content

Commit

Permalink
Deprecate legacy API (opensearch-project#390)
Browse files Browse the repository at this point in the history
* deprecated legacy REST API /_template

Signed-off-by: Tanner Jones <alltechguyblog@gmail.com>

* deprecated legacy REST API /_template

Signed-off-by: Tanner Jones <alltechguyblog@gmail.com>

* removed deprecated header at the top of the doc

Signed-off-by: Tanner Jones <alltechguyblog@gmail.com>

* added deprecated notes to the CHANGELOG.md

Signed-off-by: Tanner Jones <alltechguyblog@gmail.com>

* Corrected deprecation statement

Signed-off-by: Tanner Jones <alltechguyblog@gmail.com>

* Update CHANGELOG.md

Co-authored-by: Jakob <jakob.hahn@hetzner.com>
Signed-off-by: Tanner Jones <78619684+tannerjones4075@users.noreply.github.com>

* Updated deprecated message on api.indices.put_template.go

Signed-off-by: Tanner Jones <alltechguyblog@gmail.com>

* Added deprecated message on api.indices.exists_template.go

Signed-off-by: Tanner Jones <alltechguyblog@gmail.com>

* Added deprecated message on api.indices.delete_template.go

Signed-off-by: Tanner Jones <alltechguyblog@gmail.com>

* Added deprecated message on api.indices.get_template.go

Signed-off-by: Tanner Jones <alltechguyblog@gmail.com>

* Updated deprecated message on api.indices.exists_template.go and added back in IndicesExistsTemplate that was delete by mistake

Signed-off-by: Tanner Jones <alltechguyblog@gmail.com>

---------

Signed-off-by: Tanner Jones <alltechguyblog@gmail.com>
Signed-off-by: Tanner Jones <78619684+tannerjones4075@users.noreply.github.com>
Co-authored-by: Jakob <jakob.hahn@hetzner.com>
  • Loading branch information
2 people authored and VachaShah committed Oct 19, 2023
1 parent 8e92598 commit bbd8aae
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 44 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

### Deprecated

- Deprecate legacy API /_template ([#151](https://github.com/opensearch-project/opensearch-go/issues/151))

### Removed

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

// Deprecated: uses legacy API (/_template), correct API is /_index_template, use newIndicesDeleteIndexTemplateFunc instead
func newIndicesDeleteTemplateFunc(t Transport) IndicesDeleteTemplate {
return func(name string, o ...func(*IndicesDeleteTemplateRequest)) (*Response, error) {
var r = IndicesDeleteTemplateRequest{Name: name}
Expand All @@ -47,11 +48,12 @@ func newIndicesDeleteTemplateFunc(t Transport) IndicesDeleteTemplate {

// IndicesDeleteTemplate deletes an index template.
//
//
// Deprecated: uses legacy API (/_template), correct API is /_index_template, use IndicesDeleteIndexTemplate instead
type IndicesDeleteTemplate func(name string, o ...func(*IndicesDeleteTemplateRequest)) (*Response, error)

// IndicesDeleteTemplateRequest configures the Indices Delete Template API request.
//
// Deprecated: uses legacy API (/_template), correct API is /_index_template, use IndicesDeleteIndexTemplateRequest instead
type IndicesDeleteTemplateRequest struct {
Name string

Expand All @@ -71,6 +73,7 @@ type IndicesDeleteTemplateRequest struct {

// Do executes the request and returns response or error.
//
// Deprecated: uses legacy API (/_template), correct API is /_index_template, use IndicesDeleteIndexTemplateRequest instead
func (r IndicesDeleteTemplateRequest) Do(ctx context.Context, transport Transport) (*Response, error) {
var (
method string
Expand Down Expand Up @@ -161,6 +164,7 @@ func (r IndicesDeleteTemplateRequest) Do(ctx context.Context, transport Transpor

// WithContext sets the request context.
//
// Deprecated: uses legacy API (/_template), correct API is /_index_template, use IndicesDeleteIndexTemplate instead
func (f IndicesDeleteTemplate) WithContext(v context.Context) func(*IndicesDeleteTemplateRequest) {
return func(r *IndicesDeleteTemplateRequest) {
r.ctx = v
Expand All @@ -171,6 +175,7 @@ func (f IndicesDeleteTemplate) WithContext(v context.Context) func(*IndicesDelet
//
// Deprecated: To promote inclusive language, use WithClusterManagerTimeout instead.
//
// Deprecated: uses legacy API (/_template), correct API is /_index_template, use IndicesDeleteIndexTemplate instead
func (f IndicesDeleteTemplate) WithMasterTimeout(v time.Duration) func(*IndicesDeleteTemplateRequest) {
return func(r *IndicesDeleteTemplateRequest) {
r.MasterTimeout = v
Expand All @@ -179,6 +184,7 @@ func (f IndicesDeleteTemplate) WithMasterTimeout(v time.Duration) func(*IndicesD

// WithClusterManagerTimeout - explicit operation timeout for connection to cluster-manager node.
//
// Deprecated: uses legacy API (/_template), correct API is /_index_template, use IndicesDeleteIndexTemplate instead
func (f IndicesDeleteTemplate) WithClusterManagerTimeout(v time.Duration) func(*IndicesDeleteTemplateRequest) {
return func(r *IndicesDeleteTemplateRequest) {
r.ClusterManagerTimeout = v
Expand All @@ -187,6 +193,7 @@ func (f IndicesDeleteTemplate) WithClusterManagerTimeout(v time.Duration) func(*

// WithTimeout - explicit operation timeout.
//
// Deprecated: uses legacy API (/_template), correct API is /_index_template, use IndicesDeleteIndexTemplate instead
func (f IndicesDeleteTemplate) WithTimeout(v time.Duration) func(*IndicesDeleteTemplateRequest) {
return func(r *IndicesDeleteTemplateRequest) {
r.Timeout = v
Expand All @@ -195,6 +202,7 @@ func (f IndicesDeleteTemplate) WithTimeout(v time.Duration) func(*IndicesDeleteT

// WithPretty makes the response body pretty-printed.
//
// Deprecated: uses legacy API (/_template), correct API is /_index_template, use IndicesDeleteIndexTemplate instead
func (f IndicesDeleteTemplate) WithPretty() func(*IndicesDeleteTemplateRequest) {
return func(r *IndicesDeleteTemplateRequest) {
r.Pretty = true
Expand All @@ -203,6 +211,7 @@ func (f IndicesDeleteTemplate) WithPretty() func(*IndicesDeleteTemplateRequest)

// WithHuman makes statistical values human-readable.
//
// Deprecated: uses legacy API (/_template), correct API is /_index_template, use IndicesDeleteIndexTemplate instead
func (f IndicesDeleteTemplate) WithHuman() func(*IndicesDeleteTemplateRequest) {
return func(r *IndicesDeleteTemplateRequest) {
r.Human = true
Expand All @@ -211,6 +220,7 @@ func (f IndicesDeleteTemplate) WithHuman() func(*IndicesDeleteTemplateRequest) {

// WithErrorTrace includes the stack trace for errors in the response body.
//
// Deprecated: uses legacy API (/_template), correct API is /_index_template, use IndicesDeleteIndexTemplate instead
func (f IndicesDeleteTemplate) WithErrorTrace() func(*IndicesDeleteTemplateRequest) {
return func(r *IndicesDeleteTemplateRequest) {
r.ErrorTrace = true
Expand All @@ -219,6 +229,7 @@ func (f IndicesDeleteTemplate) WithErrorTrace() func(*IndicesDeleteTemplateReque

// WithFilterPath filters the properties of the response body.
//
// Deprecated: uses legacy API (/_template), correct API is /_index_template, use IndicesDeleteIndexTemplate instead
func (f IndicesDeleteTemplate) WithFilterPath(v ...string) func(*IndicesDeleteTemplateRequest) {
return func(r *IndicesDeleteTemplateRequest) {
r.FilterPath = v
Expand All @@ -227,6 +238,7 @@ func (f IndicesDeleteTemplate) WithFilterPath(v ...string) func(*IndicesDeleteTe

// WithHeader adds the headers to the HTTP request.
//
// Deprecated: uses legacy API (/_template), correct API is /_index_template, use IndicesDeleteIndexTemplate instead
func (f IndicesDeleteTemplate) WithHeader(h map[string]string) func(*IndicesDeleteTemplateRequest) {
return func(r *IndicesDeleteTemplateRequest) {
if r.Header == nil {
Expand All @@ -240,6 +252,7 @@ func (f IndicesDeleteTemplate) WithHeader(h map[string]string) func(*IndicesDele

// WithOpaqueID adds the X-Opaque-Id header to the HTTP request.
//
// Deprecated: uses legacy API (/_template), correct API is /_index_template, use IndicesDeleteIndexTemplate instead
func (f IndicesDeleteTemplate) WithOpaqueID(s string) func(*IndicesDeleteTemplateRequest) {
return func(r *IndicesDeleteTemplateRequest) {
if r.Header == nil {
Expand Down
29 changes: 15 additions & 14 deletions opensearchapi/api.indices.exists_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
"time"
)

// Deprecated: uses legacy API (/_template), correct API is /_index_template, use newIndicesExistsIndexTemplateFunc instead
func newIndicesExistsTemplateFunc(t Transport) IndicesExistsTemplate {
return func(name []string, o ...func(*IndicesExistsTemplateRequest)) (*Response, error) {
var r = IndicesExistsTemplateRequest{Name: name}
Expand All @@ -47,12 +48,11 @@ func newIndicesExistsTemplateFunc(t Transport) IndicesExistsTemplate {
// ----- API Definition -------------------------------------------------------

// IndicesExistsTemplate returns information about whether a particular index template exists.
//
//
// Deprecated: uses legacy API (/_template), correct API is /_index_template, use IndicesExistsIndexTemplate instead
type IndicesExistsTemplate func(name []string, o ...func(*IndicesExistsTemplateRequest)) (*Response, error)

// Deprecated: uses legacy API (/_template), correct API is /_index_template, use IndicesExistsIndexTemplateRequest instead
// IndicesExistsTemplateRequest configures the Indices Exists Template API request.
//
type IndicesExistsTemplateRequest struct {
Name []string

Expand All @@ -73,6 +73,7 @@ type IndicesExistsTemplateRequest struct {

// Do executes the request and returns response or error.
//
// Deprecated: uses legacy API (/_template), correct API is /_index_template, use IndicesExistsIndexTemplateRequest instead
func (r IndicesExistsTemplateRequest) Do(ctx context.Context, transport Transport) (*Response, error) {
var (
method string
Expand Down Expand Up @@ -166,23 +167,23 @@ func (r IndicesExistsTemplateRequest) Do(ctx context.Context, transport Transpor
}

// WithContext sets the request context.
//
// Deprecated: uses legacy API (/_template), correct API is /_index_template, use IndicesExistsIndexTemplate instead
func (f IndicesExistsTemplate) WithContext(v context.Context) func(*IndicesExistsTemplateRequest) {
return func(r *IndicesExistsTemplateRequest) {
r.ctx = v
}
}

// WithFlatSettings - return settings in flat format (default: false).
//
// Deprecated: uses legacy API (/_template), correct API is /_index_template, use IndicesExistsIndexTemplate instead
func (f IndicesExistsTemplate) WithFlatSettings(v bool) func(*IndicesExistsTemplateRequest) {
return func(r *IndicesExistsTemplateRequest) {
r.FlatSettings = &v
}
}

// WithLocal - return local information, do not retrieve the state from cluster-manager node (default: false).
//
// Deprecated: uses legacy API (/_template), correct API is /_index_template, use IndicesExistsIndexTemplate instead
func (f IndicesExistsTemplate) WithLocal(v bool) func(*IndicesExistsTemplateRequest) {
return func(r *IndicesExistsTemplateRequest) {
r.Local = &v
Expand All @@ -192,55 +193,55 @@ func (f IndicesExistsTemplate) WithLocal(v bool) func(*IndicesExistsTemplateRequ
// WithMasterTimeout - explicit operation timeout for connection to cluster-manager node.
//
// Deprecated: To promote inclusive language, use WithClusterManagerTimeout instead.
//
// Deprecated: uses legacy API (/_template), correct API is /_index_template, use IndicesExistsIndexTemplate instead
func (f IndicesExistsTemplate) WithMasterTimeout(v time.Duration) func(*IndicesExistsTemplateRequest) {
return func(r *IndicesExistsTemplateRequest) {
r.MasterTimeout = v
}
}

// WithClusterManagerTimeout - explicit operation timeout for connection to cluster-manager node.
//
// Deprecated: uses legacy API (/_template), correct API is /_index_template, use IndicesExistsIndexTemplate instead
func (f IndicesExistsTemplate) WithClusterManagerTimeout(v time.Duration) func(*IndicesExistsTemplateRequest) {
return func(r *IndicesExistsTemplateRequest) {
r.ClusterManagerTimeout = v
}
}

// WithPretty makes the response body pretty-printed.
//
// Deprecated: uses legacy API (/_template), correct API is /_index_template, use IndicesExistsIndexTemplate instead
func (f IndicesExistsTemplate) WithPretty() func(*IndicesExistsTemplateRequest) {
return func(r *IndicesExistsTemplateRequest) {
r.Pretty = true
}
}

// WithHuman makes statistical values human-readable.
//
// Deprecated: uses legacy API (/_template), correct API is /_index_template, use IndicesExistsIndexTemplate instead
func (f IndicesExistsTemplate) WithHuman() func(*IndicesExistsTemplateRequest) {
return func(r *IndicesExistsTemplateRequest) {
r.Human = true
}
}

// WithErrorTrace includes the stack trace for errors in the response body.
//
// Deprecated: uses legacy API (/_template), correct API is /_index_template, use IndicesExistsIndexTemplate instead
func (f IndicesExistsTemplate) WithErrorTrace() func(*IndicesExistsTemplateRequest) {
return func(r *IndicesExistsTemplateRequest) {
r.ErrorTrace = true
}
}

// WithFilterPath filters the properties of the response body.
//
// Deprecated: uses legacy API (/_template), correct API is /_index_template, use IndicesExistsIndexTemplate instead
func (f IndicesExistsTemplate) WithFilterPath(v ...string) func(*IndicesExistsTemplateRequest) {
return func(r *IndicesExistsTemplateRequest) {
r.FilterPath = v
}
}

// WithHeader adds the headers to the HTTP request.
//
// Deprecated: uses legacy API (/_template), correct API is /_index_template, use IndicesExistsIndexTemplate instead
func (f IndicesExistsTemplate) WithHeader(h map[string]string) func(*IndicesExistsTemplateRequest) {
return func(r *IndicesExistsTemplateRequest) {
if r.Header == nil {
Expand All @@ -253,7 +254,7 @@ func (f IndicesExistsTemplate) WithHeader(h map[string]string) func(*IndicesExis
}

// WithOpaqueID adds the X-Opaque-Id header to the HTTP request.
//
// Deprecated: uses legacy API (/_template), correct API is /_index_template, use IndicesExistsIndexTemplate instead
func (f IndicesExistsTemplate) WithOpaqueID(s string) func(*IndicesExistsTemplateRequest) {
return func(r *IndicesExistsTemplateRequest) {
if r.Header == nil {
Expand Down
30 changes: 17 additions & 13 deletions opensearchapi/api.indices.get_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ import (
"time"
)

// Deprecated: uses legacy API (/_template), correct API is /_index_template, use newIndicesGetIndexTemplateFunc instead

func newIndicesGetTemplateFunc(t Transport) IndicesGetTemplate {
return func(o ...func(*IndicesGetTemplateRequest)) (*Response, error) {
var r = IndicesGetTemplateRequest{}
Expand All @@ -48,11 +50,12 @@ func newIndicesGetTemplateFunc(t Transport) IndicesGetTemplate {

// IndicesGetTemplate returns an index template.
//
//
// Deprecated: uses legacy API (/_template), correct API is /_index_template, use IndicesGetIndexTemplate instead
type IndicesGetTemplate func(o ...func(*IndicesGetTemplateRequest)) (*Response, error)

// IndicesGetTemplateRequest configures the Indices Get Template API request.
//
// Deprecated: uses legacy API (/_template), correct API is /_index_template, use IndicesGetIndexTemplateRequest instead
type IndicesGetTemplateRequest struct {
Name []string

Expand All @@ -73,6 +76,7 @@ type IndicesGetTemplateRequest struct {

// Do executes the request and returns response or error.
//
// Deprecated: uses legacy API (/_template), correct API is /_index_template, use IndicesGetIndexTemplateRequest instead
func (r IndicesGetTemplateRequest) Do(ctx context.Context, transport Transport) (*Response, error) {
var (
method string
Expand Down Expand Up @@ -168,31 +172,31 @@ func (r IndicesGetTemplateRequest) Do(ctx context.Context, transport Transport)
}

// WithContext sets the request context.
//
// Deprecated: uses legacy API (/_template), correct API is /_index_template, use IndicesGetIndexTemplate instead
func (f IndicesGetTemplate) WithContext(v context.Context) func(*IndicesGetTemplateRequest) {
return func(r *IndicesGetTemplateRequest) {
r.ctx = v
}
}

// WithName - the comma separated names of the index templates.
//
// Deprecated: uses legacy API (/_template), correct API is /_index_template, use IndicesGetIndexTemplate instead
func (f IndicesGetTemplate) WithName(v ...string) func(*IndicesGetTemplateRequest) {
return func(r *IndicesGetTemplateRequest) {
r.Name = v
}
}

// WithFlatSettings - return settings in flat format (default: false).
//
// Deprecated: uses legacy API (/_template), correct API is /_index_template, use IndicesGetIndexTemplate instead
func (f IndicesGetTemplate) WithFlatSettings(v bool) func(*IndicesGetTemplateRequest) {
return func(r *IndicesGetTemplateRequest) {
r.FlatSettings = &v
}
}

// WithLocal - return local information, do not retrieve the state from cluster-manager node (default: false).
//
// Deprecated: uses legacy API (/_template), correct API is /_index_template, use IndicesGetIndexTemplate instead
func (f IndicesGetTemplate) WithLocal(v bool) func(*IndicesGetTemplateRequest) {
return func(r *IndicesGetTemplateRequest) {
r.Local = &v
Expand All @@ -202,55 +206,55 @@ func (f IndicesGetTemplate) WithLocal(v bool) func(*IndicesGetTemplateRequest) {
// WithMasterTimeout - explicit operation timeout for connection to cluster-manager node.
//
// Deprecated: To promote inclusive language, use WithClusterManagerTimeout instead.
//
// Deprecated: uses legacy API (/_template), correct API is /_index_template, use IndicesGetIndexTemplate instead
func (f IndicesGetTemplate) WithMasterTimeout(v time.Duration) func(*IndicesGetTemplateRequest) {
return func(r *IndicesGetTemplateRequest) {
r.MasterTimeout = v
}
}

// WithClusterManagerTimeout - explicit operation timeout for connection to cluster-manager node.
//
// Deprecated: uses legacy API (/_template), correct API is /_index_template, use IndicesGetIndexTemplate instead
func (f IndicesGetTemplate) WithClusterManagerTimeout(v time.Duration) func(*IndicesGetTemplateRequest) {
return func(r *IndicesGetTemplateRequest) {
r.ClusterManagerTimeout = v
}
}

// WithPretty makes the response body pretty-printed.
//
// Deprecated: uses legacy API (/_template), correct API is /_index_template, use IndicesGetIndexTemplate instead
func (f IndicesGetTemplate) WithPretty() func(*IndicesGetTemplateRequest) {
return func(r *IndicesGetTemplateRequest) {
r.Pretty = true
}
}

// WithHuman makes statistical values human-readable.
//
// Deprecated: uses legacy API (/_template), correct API is /_index_template, use IndicesGetIndexTemplate instead
func (f IndicesGetTemplate) WithHuman() func(*IndicesGetTemplateRequest) {
return func(r *IndicesGetTemplateRequest) {
r.Human = true
}
}

// WithErrorTrace includes the stack trace for errors in the response body.
//
// Deprecated: uses legacy API (/_template), correct API is /_index_template, use IndicesGetIndexTemplate instead
func (f IndicesGetTemplate) WithErrorTrace() func(*IndicesGetTemplateRequest) {
return func(r *IndicesGetTemplateRequest) {
r.ErrorTrace = true
}
}

// WithFilterPath filters the properties of the response body.
//
// Deprecated: uses legacy API (/_template), correct API is /_index_template, use IndicesGetIndexTemplate instead
func (f IndicesGetTemplate) WithFilterPath(v ...string) func(*IndicesGetTemplateRequest) {
return func(r *IndicesGetTemplateRequest) {
r.FilterPath = v
}
}

// WithHeader adds the headers to the HTTP request.
//
// Deprecated: uses legacy API (/_template), correct API is /_index_template, use IndicesGetIndexTemplate instead
func (f IndicesGetTemplate) WithHeader(h map[string]string) func(*IndicesGetTemplateRequest) {
return func(r *IndicesGetTemplateRequest) {
if r.Header == nil {
Expand All @@ -263,7 +267,7 @@ func (f IndicesGetTemplate) WithHeader(h map[string]string) func(*IndicesGetTemp
}

// WithOpaqueID adds the X-Opaque-Id header to the HTTP request.
//
// Deprecated: uses legacy API (/_template), correct API is /_index_template, use IndicesGetIndexTemplate instead
func (f IndicesGetTemplate) WithOpaqueID(s string) func(*IndicesGetTemplateRequest) {
return func(r *IndicesGetTemplateRequest) {
if r.Header == nil {
Expand Down
Loading

0 comments on commit bbd8aae

Please sign in to comment.