From f7b3fdce9e6f440ec0a05510f5cae972f53e7cc7 Mon Sep 17 00:00:00 2001 From: Vacha Shah Date: Mon, 22 May 2023 05:34:29 -0700 Subject: [PATCH] =?UTF-8?q?Revert=20"Draft:=20Add=20Err()=20function=20to?= =?UTF-8?q?=20Response=20for=20detailed=20errors=20(#2=E2=80=A6=20(#322)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Revert "Draft: Add Err() function to Response for detailed errors (#246)" This reverts commit 8d3cf4dd6e872f5c9fc50408ca74dc7c06e9b490. Signed-off-by: Vacha Shah * Fixing PIT APIs introduced in PR #253 since they use response.Err() Signed-off-by: Vacha Shah * Removing opensearchapi.Error usage from snapshot tests introduced in PR #237 Signed-off-by: Vacha Shah * Resolve Changelog conflicts Signed-off-by: Vacha Shah --------- Signed-off-by: Vacha Shah --- CHANGELOG.md | 1 - UPGRADING.md | 95 ------------------- USER_GUIDE.md | 84 +++++++--------- internal/build/go.sum | 28 +++--- opensearchapi/api.bulk.go | 2 +- opensearchapi/api.cat.aliases.go | 2 +- opensearchapi/api.cat.allocation.go | 2 +- opensearchapi/api.cat.cluster_manager.go | 2 +- opensearchapi/api.cat.count.go | 2 +- opensearchapi/api.cat.fielddata.go | 2 +- opensearchapi/api.cat.health.go | 2 +- opensearchapi/api.cat.help.go | 2 +- opensearchapi/api.cat.indices.go | 2 +- opensearchapi/api.cat.master.go | 2 +- opensearchapi/api.cat.nodeattrs.go | 2 +- opensearchapi/api.cat.nodes.go | 2 +- opensearchapi/api.cat.pending_tasks.go | 2 +- opensearchapi/api.cat.plugins.go | 2 +- opensearchapi/api.cat.recovery.go | 2 +- opensearchapi/api.cat.repositories.go | 2 +- opensearchapi/api.cat.segments.go | 2 +- opensearchapi/api.cat.shards.go | 2 +- opensearchapi/api.cat.snapshots.go | 2 +- opensearchapi/api.cat.tasks.go | 2 +- opensearchapi/api.cat.templates.go | 2 +- opensearchapi/api.cat.thread_pool.go | 2 +- opensearchapi/api.clear_scroll.go | 2 +- .../api.cluster.allocation_explain.go | 2 +- .../api.cluster.delete_component_template.go | 2 +- ...cluster.delete_voting_config_exclusions.go | 2 +- .../api.cluster.exists_component_template.go | 2 +- .../api.cluster.get_component_template.go | 2 +- opensearchapi/api.cluster.get_settings.go | 2 +- opensearchapi/api.cluster.health.go | 2 +- opensearchapi/api.cluster.pending_tasks.go | 2 +- ...i.cluster.post_voting_config_exclusions.go | 2 +- .../api.cluster.put_component_template.go | 2 +- opensearchapi/api.cluster.put_settings.go | 2 +- opensearchapi/api.cluster.remote_info.go | 2 +- opensearchapi/api.cluster.reroute.go | 2 +- opensearchapi/api.cluster.state.go | 2 +- opensearchapi/api.cluster.stats.go | 2 +- opensearchapi/api.count.go | 2 +- opensearchapi/api.create.go | 2 +- ....dangling_indices.delete_dangling_index.go | 2 +- ....dangling_indices.import_dangling_index.go | 2 +- ....dangling_indices.list_dangling_indices.go | 2 +- opensearchapi/api.delete.go | 2 +- opensearchapi/api.delete_by_query.go | 2 +- .../api.delete_by_query_rethrottle.go | 2 +- opensearchapi/api.delete_script.go | 2 +- opensearchapi/api.exists.go | 2 +- opensearchapi/api.exists_source.go | 2 +- opensearchapi/api.explain.go | 2 +- opensearchapi/api.field_caps.go | 2 +- opensearchapi/api.get.go | 2 +- opensearchapi/api.get_script.go | 2 +- opensearchapi/api.get_script_context.go | 2 +- opensearchapi/api.get_script_languages.go | 2 +- opensearchapi/api.get_source.go | 2 +- opensearchapi/api.index.go | 2 +- opensearchapi/api.indices.add_block.go | 2 +- opensearchapi/api.indices.analyze.go | 2 +- opensearchapi/api.indices.clear_cache.go | 2 +- opensearchapi/api.indices.clone.go | 2 +- opensearchapi/api.indices.close.go | 2 +- opensearchapi/api.indices.create.go | 2 +- opensearchapi/api.indices.delete.go | 2 +- opensearchapi/api.indices.delete_alias.go | 2 +- .../api.indices.delete_index_template.go | 2 +- opensearchapi/api.indices.delete_template.go | 2 +- opensearchapi/api.indices.disk_usage.go | 2 +- opensearchapi/api.indices.exists.go | 2 +- opensearchapi/api.indices.exists_alias.go | 2 +- .../api.indices.exists_index_template.go | 2 +- opensearchapi/api.indices.exists_template.go | 2 +- .../api.indices.field_usage_stats.go | 2 +- opensearchapi/api.indices.flush.go | 2 +- opensearchapi/api.indices.forcemerge.go | 2 +- opensearchapi/api.indices.get.go | 2 +- opensearchapi/api.indices.get_alias.go | 2 +- .../api.indices.get_field_mapping.go | 2 +- .../api.indices.get_index_template.go | 2 +- opensearchapi/api.indices.get_mapping.go | 2 +- opensearchapi/api.indices.get_settings.go | 2 +- opensearchapi/api.indices.get_template.go | 2 +- opensearchapi/api.indices.get_upgrade.go | 2 +- opensearchapi/api.indices.open.go | 2 +- opensearchapi/api.indices.put_alias.go | 2 +- .../api.indices.put_index_template.go | 2 +- opensearchapi/api.indices.put_mapping.go | 2 +- opensearchapi/api.indices.put_settings.go | 2 +- opensearchapi/api.indices.put_template.go | 2 +- opensearchapi/api.indices.recovery.go | 2 +- opensearchapi/api.indices.refresh.go | 2 +- opensearchapi/api.indices.resolve_index.go | 2 +- opensearchapi/api.indices.rollover.go | 2 +- opensearchapi/api.indices.segments.go | 2 +- opensearchapi/api.indices.shard_stores.go | 2 +- opensearchapi/api.indices.shrink.go | 2 +- .../api.indices.simulate_index_template.go | 2 +- .../api.indices.simulate_template.go | 2 +- opensearchapi/api.indices.split.go | 2 +- opensearchapi/api.indices.stats.go | 2 +- opensearchapi/api.indices.update_aliases.go | 2 +- opensearchapi/api.indices.upgrade.go | 2 +- opensearchapi/api.indices.validate_query.go | 2 +- opensearchapi/api.info.go | 2 +- opensearchapi/api.ingest.delete_pipeline.go | 2 +- opensearchapi/api.ingest.get_pipeline.go | 2 +- opensearchapi/api.ingest.processor_grok.go | 2 +- opensearchapi/api.ingest.put_pipeline.go | 2 +- opensearchapi/api.ingest.simulate.go | 2 +- opensearchapi/api.mget.go | 2 +- opensearchapi/api.msearch.go | 2 +- opensearchapi/api.msearch_template.go | 2 +- opensearchapi/api.mtermvectors.go | 2 +- opensearchapi/api.nodes.hot_threads.go | 2 +- opensearchapi/api.nodes.info.go | 2 +- .../api.nodes.reload_secure_settings.go | 2 +- opensearchapi/api.nodes.stats.go | 2 +- opensearchapi/api.nodes.usage.go | 2 +- opensearchapi/api.ping.go | 2 +- opensearchapi/api.pointintime.create.go | 4 - opensearchapi/api.pointintime.delete.go | 4 - opensearchapi/api.pointintime.get.go | 4 - opensearchapi/api.put_script.go | 2 +- opensearchapi/api.rank_eval.go | 2 +- opensearchapi/api.reindex.go | 2 +- opensearchapi/api.reindex_rethrottle.go | 2 +- opensearchapi/api.render_search_template.go | 2 +- opensearchapi/api.scripts_painless_execute.go | 2 +- opensearchapi/api.scroll.go | 2 +- opensearchapi/api.search.go | 2 +- opensearchapi/api.search_shards.go | 2 +- opensearchapi/api.search_template.go | 2 +- .../api.snapshot.cleanup_repository.go | 2 +- opensearchapi/api.snapshot.clone.go | 2 +- opensearchapi/api.snapshot.create.go | 2 +- .../api.snapshot.create_repository.go | 2 +- opensearchapi/api.snapshot.delete.go | 2 +- .../api.snapshot.delete_repository.go | 2 +- opensearchapi/api.snapshot.get.go | 2 +- opensearchapi/api.snapshot.get_repository.go | 2 +- opensearchapi/api.snapshot.restore.go | 2 +- opensearchapi/api.snapshot.status.go | 2 +- .../api.snapshot.verify_repository.go | 2 +- opensearchapi/api.tasks.cancel.go | 2 +- opensearchapi/api.tasks.get.go | 2 +- opensearchapi/api.tasks.list.go | 2 +- opensearchapi/api.terms_enum.go | 2 +- opensearchapi/api.termvectors.go | 2 +- opensearchapi/api.update.go | 2 +- opensearchapi/api.update_by_query.go | 2 +- .../api.update_by_query_rethrottle.go | 2 +- opensearchapi/opensearchapi.error.go | 53 ----------- opensearchapi/opensearchapi.response.go | 28 ++---- opensearchapi/opensearchapi_benchmark_test.go | 11 +-- .../opensearchapi_integration_test.go | 33 +++++-- .../opensearchapi_response_internal_test.go | 75 --------------- .../json_reader_integration_test.go | 9 +- 161 files changed, 236 insertions(+), 489 deletions(-) delete mode 100644 UPGRADING.md delete mode 100644 opensearchapi/opensearchapi.error.go diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a048330b..9c59174fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,6 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Added - Adds implementation of Data Streams API ([#257](https://github.com/opensearch-project/opensearch-go/pull/257)) -- Adds `Err()` function to Response for detailed errors ([#246](https://github.com/opensearch-project/opensearch-go/pull/246)) - Adds Point In Time API ([#253](https://github.com/opensearch-project/opensearch-go/pull/253)) - Adds InfoResp type ([#253](https://github.com/opensearch-project/opensearch-go/pull/253)) - Adds markdown linter ([#261](https://github.com/opensearch-project/opensearch-go/pull/261)) diff --git a/UPGRADING.md b/UPGRADING.md deleted file mode 100644 index d09583b4d..000000000 --- a/UPGRADING.md +++ /dev/null @@ -1,95 +0,0 @@ -- [Upgrading Opensearch GO Client](#upgrading-opensearch-go-client) - - [Upgraading to >= 3.0.0](#upgrading-to->=-3.0.0) - - [opensearchapi](#opensearchapi-snapshot-delete) - - [opensearchapi](#opensearchapi-error-handling) - -# Upgrading Opensearch GO Client - -## Upgrading to >= 3.0.0 - -### opensearchapi snapshot delete - -`SnapshotDeleteRequest` and `SnapshotDelete` changed the argument `Snapshot` type from `string` to `[]string`. - -Before 3.0.0: - -```go -// If you have a string containing your snapshot -stringSnapshotsToDelete := "snapshot-1,snapshot-2" -reqSnapshots := &opensearchapi.SnapshotDeleteRequest{ - Repository: repo, - Snapshot: stringSnapshotsToDelete, -} - -// If you have a slice of strings containing your snapshot -sliceSnapshotToDelete := []string{"snapshot-1","snapshot-2"} -reqSnapshots := &opensearchapi.SnapshotDeleteRequest{ - Repository: repo, - Snapshot: strings.Join(sliceSnapshotsToDelete, ","), -} -``` - -With 3.0.0: - -```go -// If you have a string containing your snapshots -stringSnapshotsToDelete := strings.Split("snapshot-1,snapshot-2", ",") -reqSnapshots := &opensearchapi.SnapshotDeleteRequest{ - Repository: repo, - Snapshot: stringSnapshotsToDelete, -} - -// If you have a slice of strings containing your snapshots -sliceSnapshotToDelete := []string{"snapshot-1", "snapshot-2"} -reqSnapshots := &opensearchapi.SnapshotDeleteRequest{ - Repository: repo, - Snapshot: sliceSnapshotsToDelete, -``` - -### opensearchapi error handling - -With opensearch-go >= 3.0.0 opensearchapi responses are now checked for errors. Checking for errors twice is no longer needed. - -Prior versions only returned an error if the request failed to execute. For example if the client can't reach the server or the TLS handshake failed. With opensearch-go >= 3.0.0 each opensearchapi requests will return an error if the response http status code is > 299. The error can be parsed into the new `opensearchapi.Error` type by using `errors.As` to match for exceptions and get a more detailed view. - -Before 3.0.0: - -```go -createIndex := opensearchapi.IndicesCreateRequest{ - Index: IndexName, - Body: mapping, -} - -ctx := context.Background() -createIndexResp, err := createIndex.Do(ctx, client) -if err != nil { - return err -} -if createIndexResp.IsError() { - fmt.Errorf("Opensearch returned an error. Status: %d", createIndexResp.StatusCode) -} -``` - -With 3.0.0: - -```go -createIndex := opensearchapi.IndicesCreateRequest{ - Index: IndexName, - Body: mapping, -} - -ctx := context.Background() -var opensearchError *opensearchapi.Error - -createIndexResponse, err := createIndex.Do(ctx, client) -// Load err into opensearchapi.Error to access the fields and tolerate if the index already exists -if err != nil { - if errors.As(err, &opensearchError) { - if opensearchError.Err.Type != "resource_already_exists_exception" { - return err - } - } else { - return err - } -} -``` diff --git a/USER_GUIDE.md b/USER_GUIDE.md index 616a60d50..471246b63 100644 --- a/USER_GUIDE.md +++ b/USER_GUIDE.md @@ -15,29 +15,20 @@ In the example below, we create a client, an index with non-default settings, in package main import ( + "os" "context" "crypto/tls" - "errors" "fmt" - "net/http" - "os" - "strings" - opensearch "github.com/opensearch-project/opensearch-go/v2" opensearchapi "github.com/opensearch-project/opensearch-go/v2/opensearchapi" opensearchutil "github.com/opensearch-project/opensearch-go/v2/opensearchutil" + "net/http" + "strings" ) const IndexName = "go-test-index1" func main() { - if err := example(); err != nil { - fmt.Println(fmt.Sprintf("Error: %s", err)) - os.Exit(1) - } -} - -func example() error { // Initialize the client with SSL/TLS enabled. client, err := opensearch.NewClient(opensearch.Config{ @@ -49,7 +40,8 @@ func example() error { Password: "admin", }) if err != nil { - return err + fmt.Println("cannot initialize", err) + os.Exit(1) } // Print OpenSearch version information on console. @@ -71,18 +63,10 @@ func example() error { Index: IndexName, Body: mapping, } - ctx := context.Background() - var opensearchError *opensearchapi.Error - createIndexResponse, err := createIndex.Do(ctx, client) - // Load err into opensearchapi.Error to access the fields and tolerate if the index already exists + createIndexResponse, err := createIndex.Do(context.Background(), client) if err != nil { - if errors.As(err, &opensearchError) { - if opensearchError.Err.Type != "resource_already_exists_exception" { - return err - } - } else { - return err - } + fmt.Println("failed to create index ", err) + os.Exit(1) } fmt.Println(createIndexResponse) @@ -103,9 +87,10 @@ func example() error { DocumentID: docId, Body: opensearchutil.NewJSONReader(&document), } - insertResponse, err := req.Do(ctx, client) + insertResponse, err := req.Do(context.Background(), client) if err != nil { - return err + fmt.Println("failed to insert document ", err) + os.Exit(1) } fmt.Println(insertResponse) @@ -124,21 +109,23 @@ func example() error { Body: content, } - searchResponse, err := search.Do(ctx, client) + searchResponse, err := search.Do(context.Background(), client) if err != nil { - return err + fmt.Println("failed to search document ", err) + os.Exit(1) } fmt.Println(searchResponse) // Delete the document. - deleteReq := opensearchapi.DeleteRequest{ + delete := opensearchapi.DeleteRequest{ Index: IndexName, DocumentID: docId, } - deleteResponse, err := deleteReq.Do(ctx, client) + deleteResponse, err := delete.Do(context.Background(), client) if err != nil { - return err + fmt.Println("failed to delete document ", err) + os.Exit(1) } fmt.Println("deleting document") fmt.Println(deleteResponse) @@ -148,26 +135,14 @@ func example() error { Index: []string{IndexName}, } - deleteIndexResponse, err := deleteIndex.Do(ctx, client) + deleteIndexResponse, err := deleteIndex.Do(context.Background(), client) if err != nil { - return err + fmt.Println("failed to delete index ", err) + os.Exit(1) } fmt.Println("deleting index", deleteIndexResponse) - - // Try to delete the index again which failes as it does not exist - // Load err into opensearchapi.Error to access the fields and tolerate if the index is missing - _, err = deleteIndex.Do(ctx, client) - if err != nil { - if errors.As(err, &opensearchError) { - if opensearchError.Err.Type != "index_not_found_exception" { - return err - } - } else { - return err - } - } - return nil } + ``` ## Amazon OpenSearch Service @@ -232,6 +207,17 @@ func main() { } defer resp.Body.Close() + if resp.IsError() { + log.Printf("ping response status: %q", resp.Status()) + + respBody, err := io.ReadAll(resp.Body) + if err != nil { + log.Fatalf("failed to read response body body: %v", err) + } + + log.Fatalf("ping resp body: %s", respBody) + } + log.Println("PING OK") } ``` @@ -301,7 +287,7 @@ func main() { Index: indexName, Body: mapping, } - createIndexResponse, err := createIndex.Do(ctx, client) + createIndexResponse, err := createIndex.Do(context.Background(), client) if err != nil { log.Fatalf("failed to create index: %v", err) } @@ -312,7 +298,7 @@ func main() { Index: []string{indexName}, } - deleteIndexResponse, err := deleteIndex.Do(ctx, client) + deleteIndexResponse, err := deleteIndex.Do(context.Background(), client) if err != nil { log.Fatalf("failed to delete index: %v", err) } diff --git a/internal/build/go.sum b/internal/build/go.sum index 6522dd92a..60d1ebf05 100644 --- a/internal/build/go.sum +++ b/internal/build/go.sum @@ -7,18 +7,18 @@ github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721/go.mod h1:QO9JBo github.com/alecthomas/kong v0.2.4/go.mod h1:kQOmtJgV+Lb4aj+I2LEn40cbtawdWJ9Y8QLq+lElKxE= github.com/alecthomas/repr v0.0.0-20180818092828-117648cd9897 h1:p9Sln00KOTlrYkxI1zYWl1QLnEqAqEARBEYa8FQnQcY= github.com/alecthomas/repr v0.0.0-20180818092828-117648cd9897/go.mod h1:xTS7Pm1pD1mvyM075QCDSRqH6qRLXylzS24ZTpRiSzQ= -github.com/aws/aws-sdk-go v1.44.205/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= -github.com/aws/aws-sdk-go-v2 v1.17.5/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= -github.com/aws/aws-sdk-go-v2/config v1.18.15/go.mod h1:vS0tddZqpE8cD9CyW0/kITHF5Bq2QasW9Y1DFHD//O0= -github.com/aws/aws-sdk-go-v2/credentials v1.13.15/go.mod h1:vRMLMD3/rXU+o6j2MW5YefrGMBmdTvkLLGqFwMLBHQc= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.23/go.mod h1:mOtmAg65GT1HIL/HT/PynwPbS+UG0BgCZ6vhkPqnxWo= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.29/go.mod h1:Dip3sIGv485+xerzVv24emnjX5Sg88utCL8fwGmCeWg= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.23/go.mod h1:mr6c4cHC+S/MMkrjtSlG4QA36kOznDep+0fga5L/fGQ= -github.com/aws/aws-sdk-go-v2/internal/ini v1.3.30/go.mod h1:vsbq62AOBwQ1LJ/GWKFxX8beUEYeRp/Agitrxee2/qM= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.23/go.mod h1:9uPh+Hrz2Vn6oMnQYiUi/zbh3ovbnQk19YKINkQny44= -github.com/aws/aws-sdk-go-v2/service/sso v1.12.4/go.mod h1:jtLIhd+V+lft6ktxpItycqHqiVXrPIRjWIsFIlzMriw= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.4/go.mod h1:zVwRrfdSmbRZWkUkWjOItY7SOalnFnq/Yg2LVPqDjwc= -github.com/aws/aws-sdk-go-v2/service/sts v1.18.5/go.mod h1:1mKZHLLpDMHTNSYPJ7qrcnCQdHCWsNQaT0xRvq2u80s= +github.com/aws/aws-sdk-go v1.44.263/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= +github.com/aws/aws-sdk-go-v2 v1.18.0/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= +github.com/aws/aws-sdk-go-v2/config v1.18.25/go.mod h1:dZnYpD5wTW/dQF0rRNLVypB396zWCcPiBIvdvSWHEg4= +github.com/aws/aws-sdk-go-v2/credentials v1.13.24/go.mod h1:jYPYi99wUOPIFi0rhiOvXeSEReVOzBqFNOX5bXYoG2o= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.3/go.mod h1:4Q0UFP0YJf0NrsEuEYHpM9fTSEVnD16Z3uyEF7J9JGM= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.33/go.mod h1:7i0PF1ME/2eUPFcjkVIwq+DOygHEoK92t5cDqNgYbIw= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.27/go.mod h1:UrHnn3QV/d0pBZ6QBAEQcqFLf8FAzLmoUfPVIueOvoM= +github.com/aws/aws-sdk-go-v2/internal/ini v1.3.34/go.mod h1:Etz2dj6UHYuw+Xw830KfzCfWGMzqvUTCjUj5b76GVDc= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.27/go.mod h1:EOwBD4J4S5qYszS5/3DpkejfuK+Z5/1uzICfPaZLtqw= +github.com/aws/aws-sdk-go-v2/service/sso v1.12.10/go.mod h1:ouy2P4z6sJN70fR3ka3wD3Ro3KezSxU6eKGQI2+2fjI= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.10/go.mod h1:AFvkxc8xfBe8XA+5St5XIHHrQQtkxqrRincx4hmMHOk= +github.com/aws/aws-sdk-go-v2/service/sts v1.19.0/go.mod h1:BgQOMsg8av8jset59jelyPW7NoZcZXLVpDsXunGDrk8= github.com/aws/smithy-go v1.13.5/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964 h1:y5HC9v93H5EPKqaS1UYVg1uYah5Xf51mBfIoWehClUQ= @@ -59,8 +59,8 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= -github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= +github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= diff --git a/opensearchapi/api.bulk.go b/opensearchapi/api.bulk.go index b19db6a21..2fef3fa51 100644 --- a/opensearchapi/api.bulk.go +++ b/opensearchapi/api.bulk.go @@ -200,7 +200,7 @@ func (r BulkRequest) Do(ctx context.Context, transport Transport) (*Response, er Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.cat.aliases.go b/opensearchapi/api.cat.aliases.go index 608a13c2a..22cb459c7 100644 --- a/opensearchapi/api.cat.aliases.go +++ b/opensearchapi/api.cat.aliases.go @@ -180,7 +180,7 @@ func (r CatAliasesRequest) Do(ctx context.Context, transport Transport) (*Respon Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.cat.allocation.go b/opensearchapi/api.cat.allocation.go index ff76b99c3..e15739fd5 100644 --- a/opensearchapi/api.cat.allocation.go +++ b/opensearchapi/api.cat.allocation.go @@ -192,7 +192,7 @@ func (r CatAllocationRequest) Do(ctx context.Context, transport Transport) (*Res Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.cat.cluster_manager.go b/opensearchapi/api.cat.cluster_manager.go index 1483478de..bf8aeaaa2 100644 --- a/opensearchapi/api.cat.cluster_manager.go +++ b/opensearchapi/api.cat.cluster_manager.go @@ -156,7 +156,7 @@ func (r CatClusterManagerRequest) Do(ctx context.Context, transport Transport) ( Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.cat.count.go b/opensearchapi/api.cat.count.go index 1991e0d3b..f56f6bc51 100644 --- a/opensearchapi/api.cat.count.go +++ b/opensearchapi/api.cat.count.go @@ -171,7 +171,7 @@ func (r CatCountRequest) Do(ctx context.Context, transport Transport) (*Response Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.cat.fielddata.go b/opensearchapi/api.cat.fielddata.go index 897512efd..931c35417 100644 --- a/opensearchapi/api.cat.fielddata.go +++ b/opensearchapi/api.cat.fielddata.go @@ -180,7 +180,7 @@ func (r CatFielddataRequest) Do(ctx context.Context, transport Transport) (*Resp Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.cat.health.go b/opensearchapi/api.cat.health.go index cadbe6750..3b32976ca 100644 --- a/opensearchapi/api.cat.health.go +++ b/opensearchapi/api.cat.health.go @@ -172,7 +172,7 @@ func (r CatHealthRequest) Do(ctx context.Context, transport Transport) (*Respons Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.cat.help.go b/opensearchapi/api.cat.help.go index 1489e23fa..4663cfd16 100644 --- a/opensearchapi/api.cat.help.go +++ b/opensearchapi/api.cat.help.go @@ -146,7 +146,7 @@ func (r CatHelpRequest) Do(ctx context.Context, transport Transport) (*Response, Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.cat.indices.go b/opensearchapi/api.cat.indices.go index 71b2c330c..5c051b4ec 100644 --- a/opensearchapi/api.cat.indices.go +++ b/opensearchapi/api.cat.indices.go @@ -216,7 +216,7 @@ func (r CatIndicesRequest) Do(ctx context.Context, transport Transport) (*Respon Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.cat.master.go b/opensearchapi/api.cat.master.go index cea90dedf..9fd681b06 100644 --- a/opensearchapi/api.cat.master.go +++ b/opensearchapi/api.cat.master.go @@ -175,7 +175,7 @@ func (r CatMasterRequest) Do(ctx context.Context, transport Transport) (*Respons Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.cat.nodeattrs.go b/opensearchapi/api.cat.nodeattrs.go index 7468b3542..a6fe51650 100644 --- a/opensearchapi/api.cat.nodeattrs.go +++ b/opensearchapi/api.cat.nodeattrs.go @@ -177,7 +177,7 @@ func (r CatNodeattrsRequest) Do(ctx context.Context, transport Transport) (*Resp Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.cat.nodes.go b/opensearchapi/api.cat.nodes.go index 90d770389..dd39e8336 100644 --- a/opensearchapi/api.cat.nodes.go +++ b/opensearchapi/api.cat.nodes.go @@ -197,7 +197,7 @@ func (r CatNodesRequest) Do(ctx context.Context, transport Transport) (*Response Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.cat.pending_tasks.go b/opensearchapi/api.cat.pending_tasks.go index 992dae7f2..e66265168 100644 --- a/opensearchapi/api.cat.pending_tasks.go +++ b/opensearchapi/api.cat.pending_tasks.go @@ -182,7 +182,7 @@ func (r CatPendingTasksRequest) Do(ctx context.Context, transport Transport) (*R Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.cat.plugins.go b/opensearchapi/api.cat.plugins.go index bc8b1e6ab..3805a209e 100644 --- a/opensearchapi/api.cat.plugins.go +++ b/opensearchapi/api.cat.plugins.go @@ -182,7 +182,7 @@ func (r CatPluginsRequest) Do(ctx context.Context, transport Transport) (*Respon Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.cat.recovery.go b/opensearchapi/api.cat.recovery.go index 5db084137..1ab175837 100644 --- a/opensearchapi/api.cat.recovery.go +++ b/opensearchapi/api.cat.recovery.go @@ -194,7 +194,7 @@ func (r CatRecoveryRequest) Do(ctx context.Context, transport Transport) (*Respo Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.cat.repositories.go b/opensearchapi/api.cat.repositories.go index c7057a981..d249335cf 100644 --- a/opensearchapi/api.cat.repositories.go +++ b/opensearchapi/api.cat.repositories.go @@ -177,7 +177,7 @@ func (r CatRepositoriesRequest) Do(ctx context.Context, transport Transport) (*R Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.cat.segments.go b/opensearchapi/api.cat.segments.go index aed566ee1..1ee4ab8eb 100644 --- a/opensearchapi/api.cat.segments.go +++ b/opensearchapi/api.cat.segments.go @@ -175,7 +175,7 @@ func (r CatSegmentsRequest) Do(ctx context.Context, transport Transport) (*Respo Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.cat.shards.go b/opensearchapi/api.cat.shards.go index 9d6549355..232045148 100644 --- a/opensearchapi/api.cat.shards.go +++ b/opensearchapi/api.cat.shards.go @@ -196,7 +196,7 @@ func (r CatShardsRequest) Do(ctx context.Context, transport Transport) (*Respons Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.cat.snapshots.go b/opensearchapi/api.cat.snapshots.go index 1c8e4021b..08d680a9a 100644 --- a/opensearchapi/api.cat.snapshots.go +++ b/opensearchapi/api.cat.snapshots.go @@ -191,7 +191,7 @@ func (r CatSnapshotsRequest) Do(ctx context.Context, transport Transport) (*Resp Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.cat.tasks.go b/opensearchapi/api.cat.tasks.go index 3592808f7..32412b7c8 100644 --- a/opensearchapi/api.cat.tasks.go +++ b/opensearchapi/api.cat.tasks.go @@ -186,7 +186,7 @@ func (r CatTasksRequest) Do(ctx context.Context, transport Transport) (*Response Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.cat.templates.go b/opensearchapi/api.cat.templates.go index c4d343eed..0f0f75e21 100644 --- a/opensearchapi/api.cat.templates.go +++ b/opensearchapi/api.cat.templates.go @@ -186,7 +186,7 @@ func (r CatTemplatesRequest) Do(ctx context.Context, transport Transport) (*Resp Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.cat.thread_pool.go b/opensearchapi/api.cat.thread_pool.go index fb1ea0d71..a3e572fa7 100644 --- a/opensearchapi/api.cat.thread_pool.go +++ b/opensearchapi/api.cat.thread_pool.go @@ -192,7 +192,7 @@ func (r CatThreadPoolRequest) Do(ctx context.Context, transport Transport) (*Res Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.clear_scroll.go b/opensearchapi/api.clear_scroll.go index 4fe1660a3..c205171e4 100644 --- a/opensearchapi/api.clear_scroll.go +++ b/opensearchapi/api.clear_scroll.go @@ -150,7 +150,7 @@ func (r ClearScrollRequest) Do(ctx context.Context, transport Transport) (*Respo Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.cluster.allocation_explain.go b/opensearchapi/api.cluster.allocation_explain.go index 089f13ba8..7da7ce72a 100644 --- a/opensearchapi/api.cluster.allocation_explain.go +++ b/opensearchapi/api.cluster.allocation_explain.go @@ -153,7 +153,7 @@ func (r ClusterAllocationExplainRequest) Do(ctx context.Context, transport Trans Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.cluster.delete_component_template.go b/opensearchapi/api.cluster.delete_component_template.go index 407848617..f7e8d388a 100644 --- a/opensearchapi/api.cluster.delete_component_template.go +++ b/opensearchapi/api.cluster.delete_component_template.go @@ -156,7 +156,7 @@ func (r ClusterDeleteComponentTemplateRequest) Do(ctx context.Context, transport Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.cluster.delete_voting_config_exclusions.go b/opensearchapi/api.cluster.delete_voting_config_exclusions.go index dcc7d8811..046b08058 100644 --- a/opensearchapi/api.cluster.delete_voting_config_exclusions.go +++ b/opensearchapi/api.cluster.delete_voting_config_exclusions.go @@ -141,7 +141,7 @@ func (r ClusterDeleteVotingConfigExclusionsRequest) Do(ctx context.Context, tran Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.cluster.exists_component_template.go b/opensearchapi/api.cluster.exists_component_template.go index d1fb93b84..36c951c2d 100644 --- a/opensearchapi/api.cluster.exists_component_template.go +++ b/opensearchapi/api.cluster.exists_component_template.go @@ -157,7 +157,7 @@ func (r ClusterExistsComponentTemplateRequest) Do(ctx context.Context, transport Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.cluster.get_component_template.go b/opensearchapi/api.cluster.get_component_template.go index b883b8f67..9e97ce881 100644 --- a/opensearchapi/api.cluster.get_component_template.go +++ b/opensearchapi/api.cluster.get_component_template.go @@ -159,7 +159,7 @@ func (r ClusterGetComponentTemplateRequest) Do(ctx context.Context, transport Tr Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.cluster.get_settings.go b/opensearchapi/api.cluster.get_settings.go index fd0608f77..bdf565fac 100644 --- a/opensearchapi/api.cluster.get_settings.go +++ b/opensearchapi/api.cluster.get_settings.go @@ -162,7 +162,7 @@ func (r ClusterGetSettingsRequest) Do(ctx context.Context, transport Transport) Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.cluster.health.go b/opensearchapi/api.cluster.health.go index 05869c546..4cdc8331a 100644 --- a/opensearchapi/api.cluster.health.go +++ b/opensearchapi/api.cluster.health.go @@ -206,7 +206,7 @@ func (r ClusterHealthRequest) Do(ctx context.Context, transport Transport) (*Res Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.cluster.pending_tasks.go b/opensearchapi/api.cluster.pending_tasks.go index 40040655c..9039cc28c 100644 --- a/opensearchapi/api.cluster.pending_tasks.go +++ b/opensearchapi/api.cluster.pending_tasks.go @@ -153,7 +153,7 @@ func (r ClusterPendingTasksRequest) Do(ctx context.Context, transport Transport) Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.cluster.post_voting_config_exclusions.go b/opensearchapi/api.cluster.post_voting_config_exclusions.go index dcc341bd2..63692fcc5 100644 --- a/opensearchapi/api.cluster.post_voting_config_exclusions.go +++ b/opensearchapi/api.cluster.post_voting_config_exclusions.go @@ -151,7 +151,7 @@ func (r ClusterPostVotingConfigExclusionsRequest) Do(ctx context.Context, transp Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.cluster.put_component_template.go b/opensearchapi/api.cluster.put_component_template.go index 1b003d641..ac12663a5 100644 --- a/opensearchapi/api.cluster.put_component_template.go +++ b/opensearchapi/api.cluster.put_component_template.go @@ -169,7 +169,7 @@ func (r ClusterPutComponentTemplateRequest) Do(ctx context.Context, transport Tr Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.cluster.put_settings.go b/opensearchapi/api.cluster.put_settings.go index ed01b6f0c..a898de36d 100644 --- a/opensearchapi/api.cluster.put_settings.go +++ b/opensearchapi/api.cluster.put_settings.go @@ -164,7 +164,7 @@ func (r ClusterPutSettingsRequest) Do(ctx context.Context, transport Transport) Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.cluster.remote_info.go b/opensearchapi/api.cluster.remote_info.go index 5e1fc95d6..c35166be5 100644 --- a/opensearchapi/api.cluster.remote_info.go +++ b/opensearchapi/api.cluster.remote_info.go @@ -134,7 +134,7 @@ func (r ClusterRemoteInfoRequest) Do(ctx context.Context, transport Transport) ( Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.cluster.reroute.go b/opensearchapi/api.cluster.reroute.go index a0f3d1b82..a5d0be0ea 100644 --- a/opensearchapi/api.cluster.reroute.go +++ b/opensearchapi/api.cluster.reroute.go @@ -179,7 +179,7 @@ func (r ClusterRerouteRequest) Do(ctx context.Context, transport Transport) (*Re Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.cluster.state.go b/opensearchapi/api.cluster.state.go index 520a90157..211c39e79 100644 --- a/opensearchapi/api.cluster.state.go +++ b/opensearchapi/api.cluster.state.go @@ -197,7 +197,7 @@ func (r ClusterStateRequest) Do(ctx context.Context, transport Transport) (*Resp Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.cluster.stats.go b/opensearchapi/api.cluster.stats.go index f76d38ff7..a40067876 100644 --- a/opensearchapi/api.cluster.stats.go +++ b/opensearchapi/api.cluster.stats.go @@ -158,7 +158,7 @@ func (r ClusterStatsRequest) Do(ctx context.Context, transport Transport) (*Resp Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.count.go b/opensearchapi/api.count.go index b38aff0c3..8f17475e5 100644 --- a/opensearchapi/api.count.go +++ b/opensearchapi/api.count.go @@ -220,7 +220,7 @@ func (r CountRequest) Do(ctx context.Context, transport Transport) (*Response, e Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.create.go b/opensearchapi/api.create.go index f86efa953..c247307bc 100644 --- a/opensearchapi/api.create.go +++ b/opensearchapi/api.create.go @@ -189,7 +189,7 @@ func (r CreateRequest) Do(ctx context.Context, transport Transport) (*Response, Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.dangling_indices.delete_dangling_index.go b/opensearchapi/api.dangling_indices.delete_dangling_index.go index c5c5ee11f..33c4588d1 100644 --- a/opensearchapi/api.dangling_indices.delete_dangling_index.go +++ b/opensearchapi/api.dangling_indices.delete_dangling_index.go @@ -162,7 +162,7 @@ func (r DanglingIndicesDeleteDanglingIndexRequest) Do(ctx context.Context, trans Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.dangling_indices.import_dangling_index.go b/opensearchapi/api.dangling_indices.import_dangling_index.go index a7cba7dba..e251b43ab 100644 --- a/opensearchapi/api.dangling_indices.import_dangling_index.go +++ b/opensearchapi/api.dangling_indices.import_dangling_index.go @@ -162,7 +162,7 @@ func (r DanglingIndicesImportDanglingIndexRequest) Do(ctx context.Context, trans Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.dangling_indices.list_dangling_indices.go b/opensearchapi/api.dangling_indices.list_dangling_indices.go index f54af68fd..a45237767 100644 --- a/opensearchapi/api.dangling_indices.list_dangling_indices.go +++ b/opensearchapi/api.dangling_indices.list_dangling_indices.go @@ -134,7 +134,7 @@ func (r DanglingIndicesListDanglingIndicesRequest) Do(ctx context.Context, trans Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.delete.go b/opensearchapi/api.delete.go index f26445348..f3a904028 100644 --- a/opensearchapi/api.delete.go +++ b/opensearchapi/api.delete.go @@ -184,7 +184,7 @@ func (r DeleteRequest) Do(ctx context.Context, transport Transport) (*Response, Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.delete_by_query.go b/opensearchapi/api.delete_by_query.go index f5cb18357..bd1d68d9f 100644 --- a/opensearchapi/api.delete_by_query.go +++ b/opensearchapi/api.delete_by_query.go @@ -319,7 +319,7 @@ func (r DeleteByQueryRequest) Do(ctx context.Context, transport Transport) (*Res Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.delete_by_query_rethrottle.go b/opensearchapi/api.delete_by_query_rethrottle.go index 63f98866e..befdf5adb 100644 --- a/opensearchapi/api.delete_by_query_rethrottle.go +++ b/opensearchapi/api.delete_by_query_rethrottle.go @@ -148,7 +148,7 @@ func (r DeleteByQueryRethrottleRequest) Do(ctx context.Context, transport Transp Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.delete_script.go b/opensearchapi/api.delete_script.go index af1a031b8..3f8e38597 100644 --- a/opensearchapi/api.delete_script.go +++ b/opensearchapi/api.delete_script.go @@ -156,7 +156,7 @@ func (r DeleteScriptRequest) Do(ctx context.Context, transport Transport) (*Resp Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.exists.go b/opensearchapi/api.exists.go index 40aec3cc2..cd229761c 100644 --- a/opensearchapi/api.exists.go +++ b/opensearchapi/api.exists.go @@ -197,7 +197,7 @@ func (r ExistsRequest) Do(ctx context.Context, transport Transport) (*Response, Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.exists_source.go b/opensearchapi/api.exists_source.go index 54ce0c25e..6b5eba2cc 100644 --- a/opensearchapi/api.exists_source.go +++ b/opensearchapi/api.exists_source.go @@ -193,7 +193,7 @@ func (r ExistsSourceRequest) Do(ctx context.Context, transport Transport) (*Resp Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.explain.go b/opensearchapi/api.explain.go index 264262868..f3891dc12 100644 --- a/opensearchapi/api.explain.go +++ b/opensearchapi/api.explain.go @@ -215,7 +215,7 @@ func (r ExplainRequest) Do(ctx context.Context, transport Transport) (*Response, Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.field_caps.go b/opensearchapi/api.field_caps.go index 2ab0d86ea..5dfedc896 100644 --- a/opensearchapi/api.field_caps.go +++ b/opensearchapi/api.field_caps.go @@ -175,7 +175,7 @@ func (r FieldCapsRequest) Do(ctx context.Context, transport Transport) (*Respons Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.get.go b/opensearchapi/api.get.go index bff13b716..0360d3e20 100644 --- a/opensearchapi/api.get.go +++ b/opensearchapi/api.get.go @@ -197,7 +197,7 @@ func (r GetRequest) Do(ctx context.Context, transport Transport) (*Response, err Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.get_script.go b/opensearchapi/api.get_script.go index 759a90cb5..9a8be7f89 100644 --- a/opensearchapi/api.get_script.go +++ b/opensearchapi/api.get_script.go @@ -151,7 +151,7 @@ func (r GetScriptRequest) Do(ctx context.Context, transport Transport) (*Respons Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.get_script_context.go b/opensearchapi/api.get_script_context.go index 6b04e1876..769a3d0c0 100644 --- a/opensearchapi/api.get_script_context.go +++ b/opensearchapi/api.get_script_context.go @@ -136,7 +136,7 @@ func (r GetScriptContextRequest) Do(ctx context.Context, transport Transport) (* Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.get_script_languages.go b/opensearchapi/api.get_script_languages.go index 919beaf9f..647bc8e0f 100644 --- a/opensearchapi/api.get_script_languages.go +++ b/opensearchapi/api.get_script_languages.go @@ -136,7 +136,7 @@ func (r GetScriptLanguagesRequest) Do(ctx context.Context, transport Transport) Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.get_source.go b/opensearchapi/api.get_source.go index 459879d66..f9525f933 100644 --- a/opensearchapi/api.get_source.go +++ b/opensearchapi/api.get_source.go @@ -193,7 +193,7 @@ func (r GetSourceRequest) Do(ctx context.Context, transport Transport) (*Respons Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.index.go b/opensearchapi/api.index.go index b4044ee4e..2f7c049a1 100644 --- a/opensearchapi/api.index.go +++ b/opensearchapi/api.index.go @@ -212,7 +212,7 @@ func (r IndexRequest) Do(ctx context.Context, transport Transport) (*Response, e Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.add_block.go b/opensearchapi/api.indices.add_block.go index 5a8705b25..59ee03c1d 100644 --- a/opensearchapi/api.indices.add_block.go +++ b/opensearchapi/api.indices.add_block.go @@ -176,7 +176,7 @@ func (r IndicesAddBlockRequest) Do(ctx context.Context, transport Transport) (*R Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.analyze.go b/opensearchapi/api.indices.analyze.go index cd8029d35..e3f039d1f 100644 --- a/opensearchapi/api.indices.analyze.go +++ b/opensearchapi/api.indices.analyze.go @@ -152,7 +152,7 @@ func (r IndicesAnalyzeRequest) Do(ctx context.Context, transport Transport) (*Re Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.clear_cache.go b/opensearchapi/api.indices.clear_cache.go index dd62c87ce..f3ce8cef6 100644 --- a/opensearchapi/api.indices.clear_cache.go +++ b/opensearchapi/api.indices.clear_cache.go @@ -184,7 +184,7 @@ func (r IndicesClearCacheRequest) Do(ctx context.Context, transport Transport) ( Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.clone.go b/opensearchapi/api.indices.clone.go index 2c1bce0e3..ce98843f1 100644 --- a/opensearchapi/api.indices.clone.go +++ b/opensearchapi/api.indices.clone.go @@ -172,7 +172,7 @@ func (r IndicesCloneRequest) Do(ctx context.Context, transport Transport) (*Resp Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.close.go b/opensearchapi/api.indices.close.go index 9ed4e2af7..830b104e2 100644 --- a/opensearchapi/api.indices.close.go +++ b/opensearchapi/api.indices.close.go @@ -177,7 +177,7 @@ func (r IndicesCloseRequest) Do(ctx context.Context, transport Transport) (*Resp Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.create.go b/opensearchapi/api.indices.create.go index bee47ff15..93b4aac1a 100644 --- a/opensearchapi/api.indices.create.go +++ b/opensearchapi/api.indices.create.go @@ -166,7 +166,7 @@ func (r IndicesCreateRequest) Do(ctx context.Context, transport Transport) (*Res Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.delete.go b/opensearchapi/api.indices.delete.go index 96ffaa6f9..92544be4d 100644 --- a/opensearchapi/api.indices.delete.go +++ b/opensearchapi/api.indices.delete.go @@ -170,7 +170,7 @@ func (r IndicesDeleteRequest) Do(ctx context.Context, transport Transport) (*Res Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.delete_alias.go b/opensearchapi/api.indices.delete_alias.go index 069e4e081..ee8dcd6d1 100644 --- a/opensearchapi/api.indices.delete_alias.go +++ b/opensearchapi/api.indices.delete_alias.go @@ -160,7 +160,7 @@ func (r IndicesDeleteAliasRequest) Do(ctx context.Context, transport Transport) Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.delete_index_template.go b/opensearchapi/api.indices.delete_index_template.go index 82a60a087..777e10103 100644 --- a/opensearchapi/api.indices.delete_index_template.go +++ b/opensearchapi/api.indices.delete_index_template.go @@ -156,7 +156,7 @@ func (r IndicesDeleteIndexTemplateRequest) Do(ctx context.Context, transport Tra Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.delete_template.go b/opensearchapi/api.indices.delete_template.go index f789c9af0..7a9b2cadb 100644 --- a/opensearchapi/api.indices.delete_template.go +++ b/opensearchapi/api.indices.delete_template.go @@ -156,7 +156,7 @@ func (r IndicesDeleteTemplateRequest) Do(ctx context.Context, transport Transpor Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.disk_usage.go b/opensearchapi/api.indices.disk_usage.go index b3c12c97e..da3ac56f5 100644 --- a/opensearchapi/api.indices.disk_usage.go +++ b/opensearchapi/api.indices.disk_usage.go @@ -168,7 +168,7 @@ func (r IndicesDiskUsageRequest) Do(ctx context.Context, transport Transport) (* Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.exists.go b/opensearchapi/api.indices.exists.go index fc3fd2991..70f6d047f 100644 --- a/opensearchapi/api.indices.exists.go +++ b/opensearchapi/api.indices.exists.go @@ -169,7 +169,7 @@ func (r IndicesExistsRequest) Do(ctx context.Context, transport Transport) (*Res Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.exists_alias.go b/opensearchapi/api.indices.exists_alias.go index 63020048e..a8782276d 100644 --- a/opensearchapi/api.indices.exists_alias.go +++ b/opensearchapi/api.indices.exists_alias.go @@ -167,7 +167,7 @@ func (r IndicesExistsAliasRequest) Do(ctx context.Context, transport Transport) Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.exists_index_template.go b/opensearchapi/api.indices.exists_index_template.go index bcc501fd3..901f0fe2d 100644 --- a/opensearchapi/api.indices.exists_index_template.go +++ b/opensearchapi/api.indices.exists_index_template.go @@ -162,7 +162,7 @@ func (r IndicesExistsIndexTemplateRequest) Do(ctx context.Context, transport Tra Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.exists_template.go b/opensearchapi/api.indices.exists_template.go index 096c97780..89e60498b 100644 --- a/opensearchapi/api.indices.exists_template.go +++ b/opensearchapi/api.indices.exists_template.go @@ -162,7 +162,7 @@ func (r IndicesExistsTemplateRequest) Do(ctx context.Context, transport Transpor Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.field_usage_stats.go b/opensearchapi/api.indices.field_usage_stats.go index 24577e35a..d4a81306d 100644 --- a/opensearchapi/api.indices.field_usage_stats.go +++ b/opensearchapi/api.indices.field_usage_stats.go @@ -163,7 +163,7 @@ func (r IndicesFieldUsageStatsRequest) Do(ctx context.Context, transport Transpo Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.flush.go b/opensearchapi/api.indices.flush.go index be820c853..347d474c9 100644 --- a/opensearchapi/api.indices.flush.go +++ b/opensearchapi/api.indices.flush.go @@ -168,7 +168,7 @@ func (r IndicesFlushRequest) Do(ctx context.Context, transport Transport) (*Resp Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.forcemerge.go b/opensearchapi/api.indices.forcemerge.go index 7fcd4ca53..712cb6d5a 100644 --- a/opensearchapi/api.indices.forcemerge.go +++ b/opensearchapi/api.indices.forcemerge.go @@ -173,7 +173,7 @@ func (r IndicesForcemergeRequest) Do(ctx context.Context, transport Transport) ( Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.get.go b/opensearchapi/api.indices.get.go index e9819bc46..86b2574ea 100644 --- a/opensearchapi/api.indices.get.go +++ b/opensearchapi/api.indices.get.go @@ -180,7 +180,7 @@ func (r IndicesGetRequest) Do(ctx context.Context, transport Transport) (*Respon Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.get_alias.go b/opensearchapi/api.indices.get_alias.go index 38d4dcffc..420b2faa1 100644 --- a/opensearchapi/api.indices.get_alias.go +++ b/opensearchapi/api.indices.get_alias.go @@ -169,7 +169,7 @@ func (r IndicesGetAliasRequest) Do(ctx context.Context, transport Transport) (*R Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.get_field_mapping.go b/opensearchapi/api.indices.get_field_mapping.go index fb161ea10..911b519a3 100644 --- a/opensearchapi/api.indices.get_field_mapping.go +++ b/opensearchapi/api.indices.get_field_mapping.go @@ -174,7 +174,7 @@ func (r IndicesGetFieldMappingRequest) Do(ctx context.Context, transport Transpo Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.get_index_template.go b/opensearchapi/api.indices.get_index_template.go index 6ad216813..c17e15e85 100644 --- a/opensearchapi/api.indices.get_index_template.go +++ b/opensearchapi/api.indices.get_index_template.go @@ -164,7 +164,7 @@ func (r IndicesGetIndexTemplateRequest) Do(ctx context.Context, transport Transp Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.get_mapping.go b/opensearchapi/api.indices.get_mapping.go index 716640dbc..c407a8edd 100644 --- a/opensearchapi/api.indices.get_mapping.go +++ b/opensearchapi/api.indices.get_mapping.go @@ -173,7 +173,7 @@ func (r IndicesGetMappingRequest) Do(ctx context.Context, transport Transport) ( Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.get_settings.go b/opensearchapi/api.indices.get_settings.go index d97b110c6..816202c42 100644 --- a/opensearchapi/api.indices.get_settings.go +++ b/opensearchapi/api.indices.get_settings.go @@ -190,7 +190,7 @@ func (r IndicesGetSettingsRequest) Do(ctx context.Context, transport Transport) Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.get_template.go b/opensearchapi/api.indices.get_template.go index a7d38625f..67eb1517b 100644 --- a/opensearchapi/api.indices.get_template.go +++ b/opensearchapi/api.indices.get_template.go @@ -164,7 +164,7 @@ func (r IndicesGetTemplateRequest) Do(ctx context.Context, transport Transport) Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.get_upgrade.go b/opensearchapi/api.indices.get_upgrade.go index 04fb22272..b18843dc8 100644 --- a/opensearchapi/api.indices.get_upgrade.go +++ b/opensearchapi/api.indices.get_upgrade.go @@ -158,7 +158,7 @@ func (r IndicesGetUpgradeRequest) Do(ctx context.Context, transport Transport) ( Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.open.go b/opensearchapi/api.indices.open.go index e444d34e4..a020f3e5c 100644 --- a/opensearchapi/api.indices.open.go +++ b/opensearchapi/api.indices.open.go @@ -177,7 +177,7 @@ func (r IndicesOpenRequest) Do(ctx context.Context, transport Transport) (*Respo Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.put_alias.go b/opensearchapi/api.indices.put_alias.go index f0504befd..bf0a9a002 100644 --- a/opensearchapi/api.indices.put_alias.go +++ b/opensearchapi/api.indices.put_alias.go @@ -167,7 +167,7 @@ func (r IndicesPutAliasRequest) Do(ctx context.Context, transport Transport) (*R Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.put_index_template.go b/opensearchapi/api.indices.put_index_template.go index 2ce88379e..e34c6c70f 100644 --- a/opensearchapi/api.indices.put_index_template.go +++ b/opensearchapi/api.indices.put_index_template.go @@ -169,7 +169,7 @@ func (r IndicesPutIndexTemplateRequest) Do(ctx context.Context, transport Transp Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.put_mapping.go b/opensearchapi/api.indices.put_mapping.go index d1f09c3f7..e7d721c27 100644 --- a/opensearchapi/api.indices.put_mapping.go +++ b/opensearchapi/api.indices.put_mapping.go @@ -186,7 +186,7 @@ func (r IndicesPutMappingRequest) Do(ctx context.Context, transport Transport) ( Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.put_settings.go b/opensearchapi/api.indices.put_settings.go index 370fa3199..711dd615e 100644 --- a/opensearchapi/api.indices.put_settings.go +++ b/opensearchapi/api.indices.put_settings.go @@ -191,7 +191,7 @@ func (r IndicesPutSettingsRequest) Do(ctx context.Context, transport Transport) Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.put_template.go b/opensearchapi/api.indices.put_template.go index 2329a3486..34a3a6b8f 100644 --- a/opensearchapi/api.indices.put_template.go +++ b/opensearchapi/api.indices.put_template.go @@ -169,7 +169,7 @@ func (r IndicesPutTemplateRequest) Do(ctx context.Context, transport Transport) Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.recovery.go b/opensearchapi/api.indices.recovery.go index c0e636aba..af634d6bf 100644 --- a/opensearchapi/api.indices.recovery.go +++ b/opensearchapi/api.indices.recovery.go @@ -153,7 +153,7 @@ func (r IndicesRecoveryRequest) Do(ctx context.Context, transport Transport) (*R Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.refresh.go b/opensearchapi/api.indices.refresh.go index 4cd2dc6c4..f666309a9 100644 --- a/opensearchapi/api.indices.refresh.go +++ b/opensearchapi/api.indices.refresh.go @@ -158,7 +158,7 @@ func (r IndicesRefreshRequest) Do(ctx context.Context, transport Transport) (*Re Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.resolve_index.go b/opensearchapi/api.indices.resolve_index.go index 2678e0fe6..1411d980e 100644 --- a/opensearchapi/api.indices.resolve_index.go +++ b/opensearchapi/api.indices.resolve_index.go @@ -149,7 +149,7 @@ func (r IndicesResolveIndexRequest) Do(ctx context.Context, transport Transport) Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.rollover.go b/opensearchapi/api.indices.rollover.go index 3b291b476..4c3f8c35f 100644 --- a/opensearchapi/api.indices.rollover.go +++ b/opensearchapi/api.indices.rollover.go @@ -180,7 +180,7 @@ func (r IndicesRolloverRequest) Do(ctx context.Context, transport Transport) (*R Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.segments.go b/opensearchapi/api.indices.segments.go index 0ac272382..60367e39e 100644 --- a/opensearchapi/api.indices.segments.go +++ b/opensearchapi/api.indices.segments.go @@ -163,7 +163,7 @@ func (r IndicesSegmentsRequest) Do(ctx context.Context, transport Transport) (*R Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.shard_stores.go b/opensearchapi/api.indices.shard_stores.go index 8e6bb57f7..181c0bcf8 100644 --- a/opensearchapi/api.indices.shard_stores.go +++ b/opensearchapi/api.indices.shard_stores.go @@ -163,7 +163,7 @@ func (r IndicesShardStoresRequest) Do(ctx context.Context, transport Transport) Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.shrink.go b/opensearchapi/api.indices.shrink.go index 685cf6b25..11763b35a 100644 --- a/opensearchapi/api.indices.shrink.go +++ b/opensearchapi/api.indices.shrink.go @@ -178,7 +178,7 @@ func (r IndicesShrinkRequest) Do(ctx context.Context, transport Transport) (*Res Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.simulate_index_template.go b/opensearchapi/api.indices.simulate_index_template.go index 2912ffd71..770f1d908 100644 --- a/opensearchapi/api.indices.simulate_index_template.go +++ b/opensearchapi/api.indices.simulate_index_template.go @@ -171,7 +171,7 @@ func (r IndicesSimulateIndexTemplateRequest) Do(ctx context.Context, transport T Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.simulate_template.go b/opensearchapi/api.indices.simulate_template.go index aeb573861..9808f2c26 100644 --- a/opensearchapi/api.indices.simulate_template.go +++ b/opensearchapi/api.indices.simulate_template.go @@ -173,7 +173,7 @@ func (r IndicesSimulateTemplateRequest) Do(ctx context.Context, transport Transp Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.split.go b/opensearchapi/api.indices.split.go index 49ea6c5e5..af2c3516a 100644 --- a/opensearchapi/api.indices.split.go +++ b/opensearchapi/api.indices.split.go @@ -178,7 +178,7 @@ func (r IndicesSplitRequest) Do(ctx context.Context, transport Transport) (*Resp Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.stats.go b/opensearchapi/api.indices.stats.go index 27b55d592..38065bd7c 100644 --- a/opensearchapi/api.indices.stats.go +++ b/opensearchapi/api.indices.stats.go @@ -199,7 +199,7 @@ func (r IndicesStatsRequest) Do(ctx context.Context, transport Transport) (*Resp Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.update_aliases.go b/opensearchapi/api.indices.update_aliases.go index 9f3bb772a..cc6cd3433 100644 --- a/opensearchapi/api.indices.update_aliases.go +++ b/opensearchapi/api.indices.update_aliases.go @@ -158,7 +158,7 @@ func (r IndicesUpdateAliasesRequest) Do(ctx context.Context, transport Transport Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.upgrade.go b/opensearchapi/api.indices.upgrade.go index e505b6f88..bf8550a47 100644 --- a/opensearchapi/api.indices.upgrade.go +++ b/opensearchapi/api.indices.upgrade.go @@ -168,7 +168,7 @@ func (r IndicesUpgradeRequest) Do(ctx context.Context, transport Transport) (*Re Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.validate_query.go b/opensearchapi/api.indices.validate_query.go index db19a59ec..8550dcdb4 100644 --- a/opensearchapi/api.indices.validate_query.go +++ b/opensearchapi/api.indices.validate_query.go @@ -212,7 +212,7 @@ func (r IndicesValidateQueryRequest) Do(ctx context.Context, transport Transport Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.info.go b/opensearchapi/api.info.go index 995c5e982..a16f7918c 100644 --- a/opensearchapi/api.info.go +++ b/opensearchapi/api.info.go @@ -149,7 +149,7 @@ func (r InfoRequest) Do(ctx context.Context, transport Transport) (*Response, er Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.ingest.delete_pipeline.go b/opensearchapi/api.ingest.delete_pipeline.go index 1e8dd1eee..beeebe3c7 100644 --- a/opensearchapi/api.ingest.delete_pipeline.go +++ b/opensearchapi/api.ingest.delete_pipeline.go @@ -158,7 +158,7 @@ func (r IngestDeletePipelineRequest) Do(ctx context.Context, transport Transport Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.ingest.get_pipeline.go b/opensearchapi/api.ingest.get_pipeline.go index bbfd41763..b0f3bae46 100644 --- a/opensearchapi/api.ingest.get_pipeline.go +++ b/opensearchapi/api.ingest.get_pipeline.go @@ -161,7 +161,7 @@ func (r IngestGetPipelineRequest) Do(ctx context.Context, transport Transport) ( Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.ingest.processor_grok.go b/opensearchapi/api.ingest.processor_grok.go index af506ab41..978dbeece 100644 --- a/opensearchapi/api.ingest.processor_grok.go +++ b/opensearchapi/api.ingest.processor_grok.go @@ -134,7 +134,7 @@ func (r IngestProcessorGrokRequest) Do(ctx context.Context, transport Transport) Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.ingest.put_pipeline.go b/opensearchapi/api.ingest.put_pipeline.go index 5a0bea0b6..d8343f3c0 100644 --- a/opensearchapi/api.ingest.put_pipeline.go +++ b/opensearchapi/api.ingest.put_pipeline.go @@ -165,7 +165,7 @@ func (r IngestPutPipelineRequest) Do(ctx context.Context, transport Transport) ( Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.ingest.simulate.go b/opensearchapi/api.ingest.simulate.go index 926d01994..682b8d30b 100644 --- a/opensearchapi/api.ingest.simulate.go +++ b/opensearchapi/api.ingest.simulate.go @@ -159,7 +159,7 @@ func (r IngestSimulateRequest) Do(ctx context.Context, transport Transport) (*Re Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.mget.go b/opensearchapi/api.mget.go index 546050f9e..5a04ca471 100644 --- a/opensearchapi/api.mget.go +++ b/opensearchapi/api.mget.go @@ -194,7 +194,7 @@ func (r MgetRequest) Do(ctx context.Context, transport Transport) (*Response, er Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.msearch.go b/opensearchapi/api.msearch.go index edbf7e308..9ad3bface 100644 --- a/opensearchapi/api.msearch.go +++ b/opensearchapi/api.msearch.go @@ -185,7 +185,7 @@ func (r MsearchRequest) Do(ctx context.Context, transport Transport) (*Response, Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.msearch_template.go b/opensearchapi/api.msearch_template.go index ea73c4eed..51a0913f4 100644 --- a/opensearchapi/api.msearch_template.go +++ b/opensearchapi/api.msearch_template.go @@ -177,7 +177,7 @@ func (r MsearchTemplateRequest) Do(ctx context.Context, transport Transport) (*R Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.mtermvectors.go b/opensearchapi/api.mtermvectors.go index 181d01f59..ba9243174 100644 --- a/opensearchapi/api.mtermvectors.go +++ b/opensearchapi/api.mtermvectors.go @@ -210,7 +210,7 @@ func (r MtermvectorsRequest) Do(ctx context.Context, transport Transport) (*Resp Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.nodes.hot_threads.go b/opensearchapi/api.nodes.hot_threads.go index d70906e7c..d9aaee6b9 100644 --- a/opensearchapi/api.nodes.hot_threads.go +++ b/opensearchapi/api.nodes.hot_threads.go @@ -173,7 +173,7 @@ func (r NodesHotThreadsRequest) Do(ctx context.Context, transport Transport) (*R Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.nodes.info.go b/opensearchapi/api.nodes.info.go index 02f604325..39b92976f 100644 --- a/opensearchapi/api.nodes.info.go +++ b/opensearchapi/api.nodes.info.go @@ -159,7 +159,7 @@ func (r NodesInfoRequest) Do(ctx context.Context, transport Transport) (*Respons Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.nodes.reload_secure_settings.go b/opensearchapi/api.nodes.reload_secure_settings.go index e210ba0fe..9030f0273 100644 --- a/opensearchapi/api.nodes.reload_secure_settings.go +++ b/opensearchapi/api.nodes.reload_secure_settings.go @@ -157,7 +157,7 @@ func (r NodesReloadSecureSettingsRequest) Do(ctx context.Context, transport Tran Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.nodes.stats.go b/opensearchapi/api.nodes.stats.go index 80899e114..6021814fb 100644 --- a/opensearchapi/api.nodes.stats.go +++ b/opensearchapi/api.nodes.stats.go @@ -201,7 +201,7 @@ func (r NodesStatsRequest) Do(ctx context.Context, transport Transport) (*Respon Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.nodes.usage.go b/opensearchapi/api.nodes.usage.go index 0d2d8968b..25db9326f 100644 --- a/opensearchapi/api.nodes.usage.go +++ b/opensearchapi/api.nodes.usage.go @@ -155,7 +155,7 @@ func (r NodesUsageRequest) Do(ctx context.Context, transport Transport) (*Respon Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.ping.go b/opensearchapi/api.ping.go index b80ed1692..f30ef61c0 100644 --- a/opensearchapi/api.ping.go +++ b/opensearchapi/api.ping.go @@ -134,7 +134,7 @@ func (r PingRequest) Do(ctx context.Context, transport Transport) (*Response, er Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.pointintime.create.go b/opensearchapi/api.pointintime.create.go index 3a251eacf..8a787ea34 100644 --- a/opensearchapi/api.pointintime.create.go +++ b/opensearchapi/api.pointintime.create.go @@ -174,10 +174,6 @@ func (r PointInTimeCreateRequest) Do(ctx context.Context, transport Transport) ( Header: res.Header, } - if err = response.Err(); err != nil { - return &response, nil, err - } - if len(r.FilterPath) != 0 { return &response, nil, nil } diff --git a/opensearchapi/api.pointintime.delete.go b/opensearchapi/api.pointintime.delete.go index ede0ec01a..bdc4c881b 100644 --- a/opensearchapi/api.pointintime.delete.go +++ b/opensearchapi/api.pointintime.delete.go @@ -162,10 +162,6 @@ func (r PointInTimeDeleteRequest) Do(ctx context.Context, transport Transport) ( Header: res.Header, } - if err = response.Err(); err != nil { - return &response, nil, err - } - if len(r.FilterPath) != 0 { return &response, nil, nil } diff --git a/opensearchapi/api.pointintime.get.go b/opensearchapi/api.pointintime.get.go index d972380cc..5bb002086 100644 --- a/opensearchapi/api.pointintime.get.go +++ b/opensearchapi/api.pointintime.get.go @@ -141,10 +141,6 @@ func (r PointInTimeGetRequest) Do(ctx context.Context, transport Transport) (*Re Header: res.Header, } - if err = response.Err(); err != nil { - return &response, nil, err - } - if len(r.FilterPath) != 0 { return &response, nil, nil } diff --git a/opensearchapi/api.put_script.go b/opensearchapi/api.put_script.go index c8dea2dad..48a1f6793 100644 --- a/opensearchapi/api.put_script.go +++ b/opensearchapi/api.put_script.go @@ -173,7 +173,7 @@ func (r PutScriptRequest) Do(ctx context.Context, transport Transport) (*Respons Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.rank_eval.go b/opensearchapi/api.rank_eval.go index 94489a2d9..68a819e17 100644 --- a/opensearchapi/api.rank_eval.go +++ b/opensearchapi/api.rank_eval.go @@ -172,7 +172,7 @@ func (r RankEvalRequest) Do(ctx context.Context, transport Transport) (*Response Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.reindex.go b/opensearchapi/api.reindex.go index 0bccd5160..2311ecb38 100644 --- a/opensearchapi/api.reindex.go +++ b/opensearchapi/api.reindex.go @@ -187,7 +187,7 @@ func (r ReindexRequest) Do(ctx context.Context, transport Transport) (*Response, Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.reindex_rethrottle.go b/opensearchapi/api.reindex_rethrottle.go index bc4fb5588..f51b414e1 100644 --- a/opensearchapi/api.reindex_rethrottle.go +++ b/opensearchapi/api.reindex_rethrottle.go @@ -148,7 +148,7 @@ func (r ReindexRethrottleRequest) Do(ctx context.Context, transport Transport) ( Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.render_search_template.go b/opensearchapi/api.render_search_template.go index 02a293a12..d5ddfdb3a 100644 --- a/opensearchapi/api.render_search_template.go +++ b/opensearchapi/api.render_search_template.go @@ -150,7 +150,7 @@ func (r RenderSearchTemplateRequest) Do(ctx context.Context, transport Transport Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.scripts_painless_execute.go b/opensearchapi/api.scripts_painless_execute.go index 2c26c3d3e..818954d55 100644 --- a/opensearchapi/api.scripts_painless_execute.go +++ b/opensearchapi/api.scripts_painless_execute.go @@ -143,7 +143,7 @@ func (r ScriptsPainlessExecuteRequest) Do(ctx context.Context, transport Transpo Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.scroll.go b/opensearchapi/api.scroll.go index f6b5e28d3..329828173 100644 --- a/opensearchapi/api.scroll.go +++ b/opensearchapi/api.scroll.go @@ -160,7 +160,7 @@ func (r ScrollRequest) Do(ctx context.Context, transport Transport) (*Response, Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.search.go b/opensearchapi/api.search.go index ca2c59291..d0451d818 100644 --- a/opensearchapi/api.search.go +++ b/opensearchapi/api.search.go @@ -371,7 +371,7 @@ func (r SearchRequest) Do(ctx context.Context, transport Transport) (*Response, Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.search_shards.go b/opensearchapi/api.search_shards.go index 2e8bc30a0..43d1e218f 100644 --- a/opensearchapi/api.search_shards.go +++ b/opensearchapi/api.search_shards.go @@ -173,7 +173,7 @@ func (r SearchShardsRequest) Do(ctx context.Context, transport Transport) (*Resp Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.search_template.go b/opensearchapi/api.search_template.go index 376950b8f..2edb1d1bd 100644 --- a/opensearchapi/api.search_template.go +++ b/opensearchapi/api.search_template.go @@ -218,7 +218,7 @@ func (r SearchTemplateRequest) Do(ctx context.Context, transport Transport) (*Re Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.snapshot.cleanup_repository.go b/opensearchapi/api.snapshot.cleanup_repository.go index 319c15276..c04785ea5 100644 --- a/opensearchapi/api.snapshot.cleanup_repository.go +++ b/opensearchapi/api.snapshot.cleanup_repository.go @@ -158,7 +158,7 @@ func (r SnapshotCleanupRepositoryRequest) Do(ctx context.Context, transport Tran Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.snapshot.clone.go b/opensearchapi/api.snapshot.clone.go index a8ade0c18..2642eaba3 100644 --- a/opensearchapi/api.snapshot.clone.go +++ b/opensearchapi/api.snapshot.clone.go @@ -166,7 +166,7 @@ func (r SnapshotCloneRequest) Do(ctx context.Context, transport Transport) (*Res Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.snapshot.create.go b/opensearchapi/api.snapshot.create.go index b29a9dd55..a6adc9db5 100644 --- a/opensearchapi/api.snapshot.create.go +++ b/opensearchapi/api.snapshot.create.go @@ -167,7 +167,7 @@ func (r SnapshotCreateRequest) Do(ctx context.Context, transport Transport) (*Re Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.snapshot.create_repository.go b/opensearchapi/api.snapshot.create_repository.go index ab2a1169a..cfbf684e2 100644 --- a/opensearchapi/api.snapshot.create_repository.go +++ b/opensearchapi/api.snapshot.create_repository.go @@ -169,7 +169,7 @@ func (r SnapshotCreateRepositoryRequest) Do(ctx context.Context, transport Trans Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.snapshot.delete.go b/opensearchapi/api.snapshot.delete.go index 1d2021ad2..6a136e1b2 100644 --- a/opensearchapi/api.snapshot.delete.go +++ b/opensearchapi/api.snapshot.delete.go @@ -154,7 +154,7 @@ func (r SnapshotDeleteRequest) Do(ctx context.Context, transport Transport) (*Re Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.snapshot.delete_repository.go b/opensearchapi/api.snapshot.delete_repository.go index 7aaa3c743..a9d919f29 100644 --- a/opensearchapi/api.snapshot.delete_repository.go +++ b/opensearchapi/api.snapshot.delete_repository.go @@ -156,7 +156,7 @@ func (r SnapshotDeleteRepositoryRequest) Do(ctx context.Context, transport Trans Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.snapshot.get.go b/opensearchapi/api.snapshot.get.go index 8cdb685aa..5a5b0e101 100644 --- a/opensearchapi/api.snapshot.get.go +++ b/opensearchapi/api.snapshot.get.go @@ -175,7 +175,7 @@ func (r SnapshotGetRequest) Do(ctx context.Context, transport Transport) (*Respo Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.snapshot.get_repository.go b/opensearchapi/api.snapshot.get_repository.go index 0466a90d0..3ad81f43f 100644 --- a/opensearchapi/api.snapshot.get_repository.go +++ b/opensearchapi/api.snapshot.get_repository.go @@ -159,7 +159,7 @@ func (r SnapshotGetRepositoryRequest) Do(ctx context.Context, transport Transpor Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.snapshot.restore.go b/opensearchapi/api.snapshot.restore.go index 46eb158b9..56823d560 100644 --- a/opensearchapi/api.snapshot.restore.go +++ b/opensearchapi/api.snapshot.restore.go @@ -169,7 +169,7 @@ func (r SnapshotRestoreRequest) Do(ctx context.Context, transport Transport) (*R Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.snapshot.status.go b/opensearchapi/api.snapshot.status.go index ee3be0ed6..b44e97b22 100644 --- a/opensearchapi/api.snapshot.status.go +++ b/opensearchapi/api.snapshot.status.go @@ -166,7 +166,7 @@ func (r SnapshotStatusRequest) Do(ctx context.Context, transport Transport) (*Re Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.snapshot.verify_repository.go b/opensearchapi/api.snapshot.verify_repository.go index 0d37d250e..cfd7152d4 100644 --- a/opensearchapi/api.snapshot.verify_repository.go +++ b/opensearchapi/api.snapshot.verify_repository.go @@ -158,7 +158,7 @@ func (r SnapshotVerifyRepositoryRequest) Do(ctx context.Context, transport Trans Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.tasks.cancel.go b/opensearchapi/api.tasks.cancel.go index 700724926..5996a4b76 100644 --- a/opensearchapi/api.tasks.cancel.go +++ b/opensearchapi/api.tasks.cancel.go @@ -167,7 +167,7 @@ func (r TasksCancelRequest) Do(ctx context.Context, transport Transport) (*Respo Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.tasks.get.go b/opensearchapi/api.tasks.get.go index e415b22b4..42d00b4b3 100644 --- a/opensearchapi/api.tasks.get.go +++ b/opensearchapi/api.tasks.get.go @@ -154,7 +154,7 @@ func (r TasksGetRequest) Do(ctx context.Context, transport Transport) (*Response Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.tasks.list.go b/opensearchapi/api.tasks.list.go index 061aea750..a0ffaadea 100644 --- a/opensearchapi/api.tasks.list.go +++ b/opensearchapi/api.tasks.list.go @@ -174,7 +174,7 @@ func (r TasksListRequest) Do(ctx context.Context, transport Transport) (*Respons Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.terms_enum.go b/opensearchapi/api.terms_enum.go index 83735ac14..f671d3d89 100644 --- a/opensearchapi/api.terms_enum.go +++ b/opensearchapi/api.terms_enum.go @@ -148,7 +148,7 @@ func (r TermsEnumRequest) Do(ctx context.Context, transport Transport) (*Respons Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.termvectors.go b/opensearchapi/api.termvectors.go index d67088026..7b1fefdbc 100644 --- a/opensearchapi/api.termvectors.go +++ b/opensearchapi/api.termvectors.go @@ -208,7 +208,7 @@ func (r TermvectorsRequest) Do(ctx context.Context, transport Transport) (*Respo Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.update.go b/opensearchapi/api.update.go index f17ea760f..6f02b88cf 100644 --- a/opensearchapi/api.update.go +++ b/opensearchapi/api.update.go @@ -216,7 +216,7 @@ func (r UpdateRequest) Do(ctx context.Context, transport Transport) (*Response, Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.update_by_query.go b/opensearchapi/api.update_by_query.go index 2b6103878..07ab5af17 100644 --- a/opensearchapi/api.update_by_query.go +++ b/opensearchapi/api.update_by_query.go @@ -330,7 +330,7 @@ func (r UpdateByQueryRequest) Do(ctx context.Context, transport Transport) (*Res Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/api.update_by_query_rethrottle.go b/opensearchapi/api.update_by_query_rethrottle.go index 9cc093902..2bf5d506c 100644 --- a/opensearchapi/api.update_by_query_rethrottle.go +++ b/opensearchapi/api.update_by_query_rethrottle.go @@ -148,7 +148,7 @@ func (r UpdateByQueryRethrottleRequest) Do(ctx context.Context, transport Transp Header: res.Header, } - return &response, response.Err() + return &response, nil } // WithContext sets the request context. diff --git a/opensearchapi/opensearchapi.error.go b/opensearchapi/opensearchapi.error.go deleted file mode 100644 index 5c5a30575..000000000 --- a/opensearchapi/opensearchapi.error.go +++ /dev/null @@ -1,53 +0,0 @@ -// 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" - -// Error represents the API error response. -type Error struct { - Err Err `json:"error"` - Status int `json:"status"` -} - -// Err represents the error of an API error response -type Err struct { - RootCause []RootCause `json:"root_cause"` - Type string `json:"type"` - Reason string `json:"reason"` - Index string `json:"index,omitempty"` - IndexUUID string `json:"index_uudi,omitempty"` -} - -// RootCause represents the root_cause of an API error response -type RootCause struct { - Type string `json:"type"` - Reason string `json:"reason"` - Index string `json:"index,omitempty"` - IndexUUID string `json:"index_uudi,omitempty"` -} - -// Error returns a string. -func (e *Error) Error() string { - return fmt.Sprintf("status: %d, type: %s, reason: %s, root_cause: %s", e.Status, e.Err.Type, e.Err.Reason, e.Err.RootCause) -} diff --git a/opensearchapi/opensearchapi.response.go b/opensearchapi/opensearchapi.response.go index 0f4c561f4..a0cb074d8 100644 --- a/opensearchapi/opensearchapi.response.go +++ b/opensearchapi/opensearchapi.response.go @@ -28,17 +28,16 @@ package opensearchapi import ( "bytes" - "encoding/json" "fmt" "io" "io/ioutil" "net/http" - "reflect" "strconv" "strings" ) // Response represents the API response. +// type Response struct { StatusCode int Header http.Header @@ -48,6 +47,7 @@ type Response struct { // String returns the response as a string. // // The intended usage is for testing or debugging only. +// func (r *Response) String() string { var ( out = new(bytes.Buffer) @@ -84,6 +84,7 @@ func (r *Response) String() string { } // Status returns the response status as a string. +// func (r *Response) Status() string { var b strings.Builder if r != nil { @@ -95,36 +96,19 @@ func (r *Response) Status() string { } // IsError returns true when the response status indicates failure. +// func (r *Response) IsError() bool { return r.StatusCode > 299 } // Warnings returns the deprecation warnings from response headers. +// func (r *Response) Warnings() []string { return r.Header["Warning"] } // HasWarnings returns true when the response headers contain deprecation warnings. +// func (r *Response) HasWarnings() bool { return len(r.Warnings()) > 0 } - -// Err returns an error when the response status indicates failures. -func (r *Response) Err() error { - if r.IsError() { - if r.Body == nil { - return fmt.Errorf(r.Status()) - } - body, err := io.ReadAll(r.Body) - if err != nil { - return fmt.Errorf(r.Status()) - } - var e *Error - err = json.Unmarshal(body, &e) - if err == nil && !reflect.ValueOf(e.Err).IsZero() { - return e - } - return fmt.Errorf("status: %d, error: %s", r.StatusCode, string(body)) - } - return nil -} diff --git a/opensearchapi/opensearchapi_benchmark_test.go b/opensearchapi/opensearchapi_benchmark_test.go index 5b9095590..24627600d 100644 --- a/opensearchapi/opensearchapi_benchmark_test.go +++ b/opensearchapi/opensearchapi_benchmark_test.go @@ -28,7 +28,6 @@ package opensearchapi_test import ( "context" - "errors" "io/ioutil" "net/http" "strconv" @@ -278,10 +277,7 @@ func BenchmarkAPI(b *testing.B) { _, err := fakeClientWithError.Search(fakeClientWithError.Search.WithContext(context.Background()), fakeClientWithError.Search.WithBody(body)) if err != nil { - var opensearchError *opensearchapi.Error - if !errors.As(err, &opensearchError) { - b.Errorf("Unexpected error when getting a response: %s", err) - } + b.Errorf("Unexpected error when getting a response: %s", err) } } }) @@ -305,10 +301,7 @@ func BenchmarkAPI(b *testing.B) { for i := 0; i < b.N; i++ { req := opensearchapi.SearchRequest{Body: body} if _, err := req.Do(context.Background(), fakeClientWithError); err != nil { - var opensearchError *opensearchapi.Error - if !errors.As(err, &opensearchError) { - b.Errorf("Unexpected error when getting a response: %s", err) - } + b.Errorf("Unexpected error when getting a response: %s", err) } } }) diff --git a/opensearchapi/opensearchapi_integration_test.go b/opensearchapi/opensearchapi_integration_test.go index fad24c830..940ca3569 100644 --- a/opensearchapi/opensearchapi_integration_test.go +++ b/opensearchapi/opensearchapi_integration_test.go @@ -24,7 +24,6 @@ // specific language governing permissions and limitations // under the License. -//go:build integration // +build integration package opensearchapi_test @@ -33,7 +32,6 @@ import ( "bytes" "context" "encoding/json" - "errors" "fmt" "strings" "testing" @@ -74,6 +72,10 @@ func TestAPI(t *testing.T) { } defer res.Body.Close() + if res.IsError() { + t.Fatalf("Error response: %s", res.String()) + } + var d map[string]interface{} err = json.NewDecoder(res.Body).Decode(&d) if err != nil { @@ -94,6 +96,10 @@ func TestAPI(t *testing.T) { } defer res.Body.Close() + if res.IsError() { + t.Fatalf("Error response: %s", res.String()) + } + if !strings.HasPrefix(res.String(), "[200 OK] ---") { t.Errorf("Unexpected response body: doesn't start with '[200 OK] ---'; %s", res.String()) } @@ -133,6 +139,9 @@ func TestAPI(t *testing.T) { if err != nil { t.Fatalf("Failed to reindex: %s", err) } + if res.IsError() { + t.Fatalf("Failed to reindex: %s", res.Status()) + } time.Sleep(10 * time.Millisecond) res, err = client.Tasks.List(client.Tasks.List.WithPretty()) @@ -140,6 +149,9 @@ func TestAPI(t *testing.T) { t.Fatalf("ERROR: %s", err) } res.Body.Close() + if res.IsError() { + t.Fatalf("Failed to get tasks: %s", res.Status()) + } // Get the list of tasks // @@ -149,6 +161,10 @@ func TestAPI(t *testing.T) { } defer res.Body.Close() + if res.IsError() { + t.Fatalf("Failed to get tasks: %s", res.Status()) + } + type task struct { Node string ID int @@ -193,7 +209,10 @@ func TestAPI(t *testing.T) { if err != nil { t.Fatalf("ERROR: %s", err) } - defer res.Body.Close() + res.Body.Close() + if res.IsError() { + t.Fatalf("Failed to cancel task: %s", res) + } } } } @@ -205,13 +224,7 @@ func TestAPI(t *testing.T) { opensearchDo := func(ctx context.Context, client *opensearch.Client, req opensearchapi.Request, msg string, t *testing.T) { _, err := req.Do(ctx, client) if err != nil { - var opensearchError *opensearchapi.Error - if errors.As(err, &opensearchError) { - if opensearchError.Err.Type == "snapshot_missing_exception" { - return - } - t.Fatalf("Failed to %s: %s", msg, err) - } + t.Fatalf("Error performing the request: %s\n", err) } } diff --git a/opensearchapi/opensearchapi_response_internal_test.go b/opensearchapi/opensearchapi_response_internal_test.go index 0cdc7c61f..80c786f72 100644 --- a/opensearchapi/opensearchapi_response_internal_test.go +++ b/opensearchapi/opensearchapi_response_internal_test.go @@ -24,14 +24,12 @@ // specific language governing permissions and limitations // under the License. -//go:build !integration // +build !integration package opensearchapi import ( "errors" - "io" "io/ioutil" "net/http" "strings" @@ -46,7 +44,6 @@ func TestAPIResponse(t *testing.T) { var ( body string res *Response - err error ) t.Run("String", func(t *testing.T) { @@ -106,78 +103,6 @@ func TestAPIResponse(t *testing.T) { } }) - t.Run("Error", func(t *testing.T) { - res = &Response{StatusCode: 201} - - if err = res.Err(); err != nil { - t.Errorf("Unexpected error for response: %s", res.Status()) - } - - res = &Response{StatusCode: 403} - - if err = res.Err(); err == nil { - t.Errorf("Expected error for response: %s", res.Status()) - } - - res = &Response{ - StatusCode: 404, - Body: io.NopCloser( - strings.NewReader(` - { - "_index":"index", - "_id":"2", - "matched":false - }`), - ), - } - err = res.Err() - if err == nil { - t.Errorf("Expected error for response: %s", res.Status()) - } - var errTest *Error - if errors.As(err, &errTest) { - t.Errorf("Expected error NOT to be of type opensearchapi.Error: %T", err) - } - - res = &Response{ - StatusCode: 400, - Body: io.NopCloser( - strings.NewReader(` - { - "error":{ - "root_cause":[{ - "type":"resource_already_exists_exception", - "reason":"index [test/HU2mN_RMRXGcS38j3yV-VQ] already exists", - "index":"test", - "index_uuid":"HU2mN_RMRXGcS38j3yV-VQ" - }], - "type":"resource_already_exists_exception", - "reason":"index [test/HU2mN_RMRXGcS38j3yV-VQ] already exists", - "index":"test", - "index_uuid":"HU2mN_RMRXGcS38j3yV-VQ" - }, - "status":400 - }`)), - } - - err = res.Err() - if err == nil { - t.Errorf("Expected error for response: %s", res.Status()) - } - if !errors.As(err, &errTest) { - t.Errorf("Expected error to be of type opensearchapi.Error: %T", err) - } - if errTest.Status != 400 || - errTest.Err.Reason != "index [test/HU2mN_RMRXGcS38j3yV-VQ] already exists" || - errTest.Err.Type != "resource_already_exists_exception" || - len(errTest.Err.RootCause) != 1 || - errTest.Err.RootCause[0].Type != "resource_already_exists_exception" || - errTest.Err.RootCause[0].Reason != "index [test/HU2mN_RMRXGcS38j3yV-VQ] already exists" { - - t.Errorf("Reponse Error was not parsed correctly") - } - }) - t.Run("Warnings", func(t *testing.T) { hdr := http.Header{} hdr.Add("Warning", "Foo 1") diff --git a/opensearchutil/json_reader_integration_test.go b/opensearchutil/json_reader_integration_test.go index 3e871334e..389626a28 100644 --- a/opensearchutil/json_reader_integration_test.go +++ b/opensearchutil/json_reader_integration_test.go @@ -24,7 +24,6 @@ // specific language governing permissions and limitations // under the License. -//go:build integration // +build integration package opensearchutil_test @@ -62,6 +61,10 @@ func TestJSONReaderIntegration(t *testing.T) { } defer res.Body.Close() + if res.IsError() { + t.Fatalf("Error response: %s", res.String()) + } + query := map[string]interface{}{ "query": map[string]interface{}{ "match": map[string]interface{}{ @@ -80,6 +83,10 @@ func TestJSONReaderIntegration(t *testing.T) { } defer res.Body.Close() + if res.IsError() { + t.Errorf("Error response: %s", res) + } + if !strings.Contains(res.String(), "Foo Bar") { t.Errorf("Unexpected response: %s", res) }