Skip to content

Commit

Permalink
fixed merge issues
Browse files Browse the repository at this point in the history
Signed-off-by: Abhinav Garg <[email protected]>
  • Loading branch information
AbhinavGarg90 committed Dec 5, 2023
2 parents 35a7405 + 7548c9f commit c8a5434
Show file tree
Hide file tree
Showing 18 changed files with 641 additions and 184 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ jobs:
- name: Increment Patch Version
run: |
echo Incrementing $CURRENT_VERSION to $NEXT_VERSION
sed -i '' -e "s/^version = \"$CURRENT_VERSION\"/version = \"$NEXT_VERSION\"/g" opensearch/Cargo.toml
sed -i '' -e "s/^version = \"$CURRENT_VERSION\"/version = \"$NEXT_VERSION\"/g" api_generator/Cargo.toml
sed -i '' -e "s/^version = \"$CURRENT_VERSION\"/version = \"$NEXT_VERSION\"/g" yaml_test_runner/Cargo.toml
sed -i'' -e "s/^version = \"$CURRENT_VERSION\"/version = \"$NEXT_VERSION\"/g" opensearch/Cargo.toml
sed -i'' -e "s/^version = \"$CURRENT_VERSION\"/version = \"$NEXT_VERSION\"/g" api_generator/Cargo.toml
sed -i'' -e "s/^version = \"$CURRENT_VERSION\"/version = \"$NEXT_VERSION\"/g" yaml_test_runner/Cargo.toml
- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
Expand Down
39 changes: 24 additions & 15 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,13 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
## [Unreleased]

### Added
- Added InfoResponse structure ([#187](https://github.com/opensearch-project/opensearch-rs/pull/187))

### Dependencies
- Bumps `sysinfo` from 0.28.0 to 0.29.0
- Bumps `serde_with` from ~2 to ~3
- Bumps `itertools` from 0.10.0 to 0.11.0
- Bumps `syn` from 1.0 to 2.0
- Bumps `toml` from 0.7.1 to 0.8.0
- Bumps `dialoguer` from 0.10.2 to 0.11.0
- Bumps `aws-*` dependencies to `1` ([#219](https://github.com/opensearch-project/opensearch-rs/pull/219))
- Bumps `itertools` from 0.11.0 to 0.12.0
- Bumps `hyper` from 0.14 to 1 in tests ([#221](https://github.com/opensearch-project/opensearch-rs/pull/221))

### Changed
- Moved @aditjind to Emeritus maintainers ([#170](https://github.com/opensearch-project/opensearch-rs/pull/170))

### Deprecated

Expand All @@ -24,6 +20,24 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

### Security

## [2.2.0]

### Added
- Added InfoResponse structure ([#187](https://github.com/opensearch-project/opensearch-rs/pull/187))
- Added documentation on how to make raw json requests ([#196](https://github.com/opensearch-project/opensearch-rs/pull/196))

### Dependencies
- Bumps `sysinfo` from 0.28.0 to 0.29.0
- Bumps `serde_with` from ~2 to ~3
- Bumps `itertools` from 0.10.0 to 0.11.0
- Bumps `syn` from 1.0 to 2.0
- Bumps `toml` from 0.7.1 to 0.8.0
- Bumps `dialoguer` from 0.10.2 to 0.11.0
- Bumps `aws-*` from >=0.53 to >=0.57 ([#201](https://github.com/opensearch-project/opensearch-rs/pull/201))

### Changed
- Moved @aditjind to Emeritus maintainers ([#170](https://github.com/opensearch-project/opensearch-rs/pull/170))

## [2.1.0]

### Added
Expand Down Expand Up @@ -53,16 +67,11 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Updates GitHub workflow to additionally run `cargo make test` ([#120](https://github.com/opensearch-project/opensearch-rs/pull/120))
- Updates GitHub workflows to use caching to speed up builds ([#121](https://github.com/opensearch-project/opensearch-rs/pull/121))

### Deprecated

### Removed

### Fixed
- Fixes `cargo make test` failing out of the box ([#117](https://github.com/opensearch-project/opensearch-rs/pull/117))
- Fixes f64 comparison in `yaml_test_runner` to use numeric-based comparison instead of string-based ([#150](https://github.com/opensearch-project/opensearch-rs/pull/150))
- Fixes YAML spec tests by adding u64 (unsigned long) support ([#167](https://github.com/opensearch-project/opensearch-rs/pull/167))
- Fixes `DEVELOPER_GUIDE.md` to include complete information about setting up ([#194](https://github.com/opensearch-project/opensearch-rs/pull/194))
### Security

[Unreleased]: https://github.com/opensearch-project/opensearch-rs/compare/v2.1.0...HEAD
[Unreleased]: https://github.com/opensearch-project/opensearch-rs/compare/v2.2.0...HEAD
[2.2.0]: https://github.com/opensearch-project/opensearch-rs/compare/v2.1.0...v2.2.0
[2.1.0]: https://github.com/opensearch-project/opensearch-rs/compare/v2.0.0...v2.1.0
89 changes: 89 additions & 0 deletions USER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- [Add a Document to the Index](#add-a-document-to-the-index)
- [Search for a Document](#search-for-a-document)
- [Delete the Index](#delete-the-index)
- [Make Raw Json Requests](#make-raw-json-requests)
- [Amazon OpenSearch and OpenSearch Serverless](#amazon-opensearch-and-opensearch-serverless)
- [Create a Client](#create-a-client-1)

Expand Down Expand Up @@ -108,6 +109,94 @@ client
.await?;
```

### Make Raw Json Requests

To invoke an API that is not supported by the client, use the `client.send` method to do so. See [examples/json](./opensearch/examples/json.rs) for a complete working example.

#### GET
The following example returns the server version information via `GET /`.
```rust
let info: Value = client
.send::<(), ()>(
Method::Get,
"/",
HeaderMap::new(),
None,
None,
None,
)
.await?
.json()
.await?;

println!("Welcome to {} {}" , info["version"]["distribution"] , info["version"]["number"]);

```
#### PUT
The following example creates an index.

```rust
let index_body: JsonBody<_> = json!({
"settings": {
"index": {
"number_of_shards" : 4
}
}
}).into();

client
.send(
Method::Put,
"/movies",
HeaderMap::new(),
Option::<&()>::None,
Some(index_body),
None,
)
.await?;
```
#### POST
The following example searches for a document.

```rust
let q = "miller";

let query: JsonBody<_> = json!({
"size": 5,
"query": {
"multi_match": {
"query": q,
"fields": ["title^2", "director"]
}
}
}).into();
client
.send(
Method::Post,
"/movies/_search",
HeaderMap::new(),
Option::<&()>::None,
Some(query),
None,
)
.await?;
```

#### DELETE
The following example deletes an index.
```rust
client
.send::<(), ()>(
Method::Delete,
"/movies",
HeaderMap::new(),
None,
None,
None,
)
.await?;
```

## Amazon OpenSearch and OpenSearch Serverless

This library supports [Amazon OpenSearch Service](https://aws.amazon.com/opensearch-service/) and [OpenSearch Serverless](https://docs.aws.amazon.com/opensearch-service/latest/developerguide/serverless.html).
Expand Down
4 changes: 2 additions & 2 deletions api_generator/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "api_generator"
version = "2.1.0"
version = "3.0.0"
publish = false
description = "Generates source code for opensearch package, from the OpenSearch REST API specs"
repository = "https://github.com/opensearch-project/opensearch-rs"
Expand All @@ -15,7 +15,7 @@ dialoguer = "0.11.0"
flate2 = "1"
globset = "0.4"
Inflector = "0.11.4"
itertools = "0.11.0"
itertools = "0.12.0"
lazy_static = "1.4.0"
log = "0.4.8"
path-slash = "0.2.1"
Expand Down
24 changes: 15 additions & 9 deletions opensearch/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "opensearch"
version = "2.1.0"
version = "3.0.0"
edition = "2018"
authors = ["Elastic and Contributors", "OpenSearch Contributors"]
description = "Official OpenSearch Rust client"
Expand All @@ -26,7 +26,7 @@ native-tls = ["reqwest/native-tls"]
rustls-tls = ["reqwest/rustls-tls"]

# AWS SigV4 Auth support
aws-auth = ["aws-credential-types", "aws-sigv4", "aws-types"]
aws-auth = ["aws-credential-types", "aws-sigv4", "aws-smithy-runtime-api", "aws-types"]

[dependencies]
base64 = "0.21"
Expand All @@ -40,22 +40,28 @@ serde = { version = "1", features = ["derive"] }
serde_json = "1"
serde_with = "3"
void = "1.0.2"
aws-credential-types = { version = ">= 0.53", optional = true }
aws-sigv4 = { version = ">= 0.53", optional = true }
aws-types = { version = ">= 0.53", optional = true }
aws-credential-types = { version = "1", optional = true }
aws-sigv4 = { version = "1", optional = true }
aws-smithy-runtime-api = { version = "1", optional = true, features = ["client"]}
aws-types = { version = "1", optional = true }

[dev-dependencies]
anyhow = "1.0"
aws-config = ">= 0.53"
aws-config = "1"
aws-smithy-async = "1"
chrono = { version = "0.4", features = ["serde"] }
clap = "2"
futures = "0.3.1"
http = "0.2"
hyper = { version = "0.14", default-features = false, features = ["tcp", "stream", "server"] }
http-body-util = "0.1.0"
hyper = { version = "1", features = ["full"] }
hyper-util = { version = "0.1", features = ["full"] }
regex="1.4"
sysinfo = "0.29.0"
test-case = "3"
textwrap = "0.16"
tokio = { version = "1.0", default-features = false, features = ["macros", "net", "time", "rt-multi-thread"] }
tokio = { version = "1", features = ["full"] }
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
xml-rs = "0.8"

[build-dependencies]
Expand Down
28 changes: 20 additions & 8 deletions opensearch/examples/advanced_index_actions.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
use opensearch::auth::Credentials;
use opensearch::indices::{
IndicesAddBlockParts, IndicesClearCacheParts, IndicesCloneParts, IndicesCloseParts,
IndicesCreateParts, IndicesDeleteParts, IndicesFlushParts, IndicesForcemergeParts,
IndicesOpenParts, IndicesPutSettingsParts, IndicesRefreshParts, IndicesSplitParts,
};
/*
* 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.
*/

use opensearch::{
cert::CertificateValidation, http::transport::SingleNodeConnectionPool,
http::transport::TransportBuilder, OpenSearch,
auth::Credentials,
cert::CertificateValidation,
http::transport::{SingleNodeConnectionPool, TransportBuilder},
indices::{
IndicesAddBlockParts, IndicesClearCacheParts, IndicesCloneParts, IndicesCloseParts,
IndicesCreateParts, IndicesDeleteParts, IndicesFlushParts, IndicesForcemergeParts,
IndicesOpenParts, IndicesPutSettingsParts, IndicesRefreshParts, IndicesSplitParts,
},
OpenSearch,
};
use serde_json::json;
use url::Url;
Expand Down
20 changes: 15 additions & 5 deletions opensearch/examples/index_lifecycle.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
use opensearch::auth::Credentials;
use opensearch::cert::CertificateValidation;
use opensearch::http::transport::{SingleNodeConnectionPool, TransportBuilder};
use opensearch::OpenSearch;
/*
* 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.
*/

use opensearch::{
auth::Credentials,
cert::CertificateValidation,
http::transport::{SingleNodeConnectionPool, TransportBuilder},
indices::{
IndicesCreateParts, IndicesDeleteParts, IndicesExistsParts, IndicesGetParts,
IndicesPutMappingParts, IndicesPutSettingsParts,
},
IndexParts,
IndexParts, OpenSearch,
};
use serde_json::json;
use url::Url;
Expand Down
27 changes: 19 additions & 8 deletions opensearch/examples/index_template.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
use opensearch::auth::Credentials;
use opensearch::cluster::{ClusterDeleteComponentTemplateParts, ClusterPutComponentTemplateParts};
use opensearch::indices::{
IndicesCreateParts, IndicesDeleteIndexTemplateParts, IndicesDeleteParts,
IndicesGetIndexTemplateParts, IndicesGetParts, IndicesPutIndexTemplateParts,
};
/*
* 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.
*/
use opensearch::{
cert::CertificateValidation, http::transport::SingleNodeConnectionPool,
http::transport::TransportBuilder, OpenSearch,
auth::Credentials,
cert::CertificateValidation,
cluster::{ClusterDeleteComponentTemplateParts, ClusterPutComponentTemplateParts},
http::transport::{SingleNodeConnectionPool, TransportBuilder},
indices::{
IndicesCreateParts, IndicesDeleteIndexTemplateParts, IndicesDeleteParts,
IndicesGetIndexTemplateParts, IndicesGetParts, IndicesPutIndexTemplateParts,
},
OpenSearch,
};
use serde_json::json;
use url::Url;
Expand Down
Loading

0 comments on commit c8a5434

Please sign in to comment.