-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Jakob Hahn <[email protected]>
- Loading branch information
Showing
10 changed files
with
773 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. | ||
// | ||
// Modifications Copyright OpenSearch Contributors. See | ||
// GitHub history for details. | ||
|
||
// Licensed 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 "time" | ||
|
||
// IngestCreateParams represents possible parameters for the IngestCreateReq | ||
type IngestCreateParams struct { | ||
MasterTimeout time.Duration | ||
ClusterManagerTimeout time.Duration | ||
Timeout time.Duration | ||
|
||
Pretty bool | ||
Human bool | ||
ErrorTrace bool | ||
} | ||
|
||
func (r IngestCreateParams) 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" | ||
} | ||
|
||
return params | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. | ||
// | ||
// Modifications Copyright OpenSearch Contributors. See | ||
// GitHub history for details. | ||
|
||
// Licensed 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" | ||
"io" | ||
"net/http" | ||
|
||
"github.com/opensearch-project/opensearch-go/v2" | ||
) | ||
|
||
// IngestCreateReq represents possible options for the index create request | ||
type IngestCreateReq struct { | ||
PipelineID string | ||
|
||
Body io.Reader | ||
|
||
Header http.Header | ||
Params IngestCreateParams | ||
} | ||
|
||
// GetRequest returns the *http.Request that gets executed by the client | ||
func (r IngestCreateReq) GetRequest() (*http.Request, error) { | ||
return opensearch.BuildRequest( | ||
"PUT", | ||
fmt.Sprintf("/_ingest/pipeline/%s", r.PipelineID), | ||
r.Body, | ||
r.Params.get(), | ||
r.Header, | ||
) | ||
} | ||
|
||
// IngestCreateResp represents the returned struct of the index create response | ||
type IngestCreateResp struct { | ||
Acknowledged bool `json:"acknowledged"` | ||
response *opensearch.Response | ||
} | ||
|
||
// Inspect returns the Inspect type containing the raw *opensearch.Reponse | ||
func (r IngestCreateResp) Inspect() Inspect { | ||
return Inspect{Response: r.response} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. | ||
// | ||
// Modifications Copyright OpenSearch Contributors. See | ||
// GitHub history for details. | ||
|
||
// Licensed 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 "time" | ||
|
||
// IngestDeleteParams represents possible parameters for the IngestDeleteReq | ||
type IngestDeleteParams struct { | ||
MasterTimeout time.Duration | ||
ClusterManagerTimeout time.Duration | ||
Timeout time.Duration | ||
|
||
Pretty bool | ||
Human bool | ||
ErrorTrace bool | ||
} | ||
|
||
func (r IngestDeleteParams) 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" | ||
} | ||
|
||
return params | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 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" | ||
"net/http" | ||
|
||
"github.com/opensearch-project/opensearch-go/v2" | ||
) | ||
|
||
// IngestDeleteReq represents possible options for the index create request | ||
type IngestDeleteReq struct { | ||
PipelineID string | ||
|
||
Header http.Header | ||
Params IngestDeleteParams | ||
} | ||
|
||
// GetRequest returns the *http.Request that gets executed by the client | ||
func (r IngestDeleteReq) GetRequest() (*http.Request, error) { | ||
return opensearch.BuildRequest( | ||
"DELETE", | ||
fmt.Sprintf("/_ingest/pipeline/%s", r.PipelineID), | ||
nil, | ||
r.Params.get(), | ||
r.Header, | ||
) | ||
} | ||
|
||
// IngestDeleteResp represents the returned struct of the index create response | ||
type IngestDeleteResp struct { | ||
Acknowledged bool `json:"acknowledged"` | ||
response *opensearch.Response | ||
} | ||
|
||
// Inspect returns the Inspect type containing the raw *opensearch.Reponse | ||
func (r IngestDeleteResp) Inspect() Inspect { | ||
return Inspect{Response: r.response} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 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" | ||
"time" | ||
) | ||
|
||
// IngestGetParams represents possible parameters for the IngestGetReq | ||
type IngestGetParams struct { | ||
MasterTimeout time.Duration | ||
ClusterManagerTimeout time.Duration | ||
Summary *bool | ||
|
||
Pretty bool | ||
Human bool | ||
ErrorTrace bool | ||
} | ||
|
||
func (r IngestGetParams) 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.Summary != nil { | ||
params["summary"] = strconv.FormatBool(*r.Summary) | ||
} | ||
|
||
if r.Pretty { | ||
params["pretty"] = "true" | ||
} | ||
|
||
if r.Human { | ||
params["human"] = "true" | ||
} | ||
|
||
if r.ErrorTrace { | ||
params["error_trace"] = "true" | ||
} | ||
|
||
return params | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. | ||
// | ||
// Modifications Copyright OpenSearch Contributors. See | ||
// GitHub history for details. | ||
|
||
// Licensed 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 ( | ||
"encoding/json" | ||
"fmt" | ||
"net/http" | ||
"strings" | ||
|
||
"github.com/opensearch-project/opensearch-go/v2" | ||
) | ||
|
||
// IngestGetReq represents possible options for the index create request | ||
type IngestGetReq struct { | ||
PipelineIDs []string | ||
|
||
Header http.Header | ||
Params IngestGetParams | ||
} | ||
|
||
// GetRequest returns the *http.Request that gets executed by the client | ||
func (r IngestGetReq) GetRequest() (*http.Request, error) { | ||
return opensearch.BuildRequest( | ||
"GET", | ||
fmt.Sprintf("/_ingest/pipeline/%s", strings.Join(r.PipelineIDs, ",")), | ||
nil, | ||
r.Params.get(), | ||
r.Header, | ||
) | ||
} | ||
|
||
// IngestGetResp represents the returned struct of the index create response | ||
type IngestGetResp struct { | ||
Pipelines map[string]struct { | ||
Description string `json:"description"` | ||
Processors []map[string]json.RawMessage `json:"processors"` | ||
} | ||
response *opensearch.Response | ||
} | ||
|
||
// Inspect returns the Inspect type containing the raw *opensearch.Reponse | ||
func (r IngestGetResp) Inspect() Inspect { | ||
return Inspect{Response: r.response} | ||
} |
Oops, something went wrong.