Skip to content

Commit

Permalink
Add version and cause to Put Template API
Browse files Browse the repository at this point in the history
  • Loading branch information
olivere committed Apr 14, 2017
1 parent 2d8d0af commit 5f2bc47
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Alex [@akotlar](https://github.com/akotlar)
Alexandre Olivier [@aliphen](https://github.com/aliphen)
Alexey Sharov [@nizsheanez](https://github.com/nizsheanez)
AndreKR [@AndreKR](https://github.com/AndreKR)
Andrew Dunham [@andrew-d](https://github.com/andrew-d)
Andrew Gaul [@andrewgaul](https://github.com/andrewgaul)
Benjamin Fernandes [@LotharSee](https://github.com/LotharSee)
Benjamin Zarzycki [@kf6nux](https://github.com/kf6nux)
Expand Down
2 changes: 1 addition & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (

const (
// Version is the current version of Elastic.
Version = "5.0.33"
Version = "5.0.34"

// DefaultURL is the default endpoint of Elasticsearch on the local machine.
// It is used e.g. when initializing a new Client without a specific URL.
Expand Down
21 changes: 21 additions & 0 deletions indices_put_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ type IndicesPutTemplateService struct {
client *Client
pretty bool
name string
cause string
order interface{}
version *int
create *bool
timeout string
masterTimeout string
Expand All @@ -41,6 +43,13 @@ func (s *IndicesPutTemplateService) Name(name string) *IndicesPutTemplateService
return s
}

// Cause describes the cause for this index template creation. This is currently
// undocumented, but part of the Java source.
func (s *IndicesPutTemplateService) Cause(cause string) *IndicesPutTemplateService {
s.cause = cause
return s
}

// Timeout is an explicit operation timeout.
func (s *IndicesPutTemplateService) Timeout(timeout string) *IndicesPutTemplateService {
s.timeout = timeout
Expand All @@ -66,6 +75,12 @@ func (s *IndicesPutTemplateService) Order(order interface{}) *IndicesPutTemplate
return s
}

// Version sets the version number for this template.
func (s *IndicesPutTemplateService) Version(version int) *IndicesPutTemplateService {
s.version = &version
return s
}

// Create indicates whether the index template should only be added if
// new or can also replace an existing one.
func (s *IndicesPutTemplateService) Create(create bool) *IndicesPutTemplateService {
Expand Down Expand Up @@ -109,9 +124,15 @@ func (s *IndicesPutTemplateService) buildURL() (string, url.Values, error) {
if s.order != nil {
params.Set("order", fmt.Sprintf("%v", s.order))
}
if s.version != nil {
params.Set("version", fmt.Sprintf("%v", *s.version))
}
if s.create != nil {
params.Set("create", fmt.Sprintf("%v", *s.create))
}
if s.cause != "" {
params.Set("cause", s.cause)
}
if s.timeout != "" {
params.Set("timeout", s.timeout)
}
Expand Down

0 comments on commit 5f2bc47

Please sign in to comment.