Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
flobernd committed Nov 21, 2024
1 parent 5f33f6f commit eaffb81
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 12 deletions.
46 changes: 38 additions & 8 deletions docs/migration-guide.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -292,13 +292,43 @@ As a last resort, the low-level client `Elastic.Transport` can be used to create

[source,csharp]
----
public class MyRequestParameters : RequestParameters
{
public bool Pretty
{
get => Q<bool>("pretty");
init => Q("pretty", value);
}
}
// ...
var body = """
{
"name": "my-api-key",
"expiration": "1d",
"...": "..."
}
""";
var response = await client.Transport.RequestAsync<StringResponse>(HttpMethod.POST, "/_security/api_key", PostData.String(body));
{
"name": "my-api-key",
"expiration": "1d",
"...": "..."
}
""";
MyRequestParameters requestParameters = new()
{
Pretty = true
};
var pathAndQuery = requestParameters.CreatePathWithQueryStrings("/_security/api_key",
client.ElasticsearchClientSettings);
var endpointPath = new EndpointPath(Elastic.Transport.HttpMethod.POST, pathAndQuery);
// Or, if the path does not contain query parameters:
// new EndpointPath(Elastic.Transport.HttpMethod.POST, "my_path")
var response = await client.Transport
.RequestAsync<StringResponse>(
endpointPath,
PostData.String(body),
null,
null,
cancellationToken: default)
.ConfigureAwait(false);
----
9 changes: 5 additions & 4 deletions docs/usage/index.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ If you're new to {es}, make sure also to read {ref}/getting-started.html[Elastic

NOTE: This is still a work in progress, more sections will be added in the near future.

include::recommendations.asciidoc[]
include::aggregations.asciidoc[]
include::esql.asciidoc[]
include::examples.asciidoc[]
include::query.asciidoc[]
include::mappings.asciidoc[]
include::aggregations.asciidoc[]
include::esql.asciidoc[]
include::query.asciidoc[]
include::recommendations.asciidoc[]
include::transport.asciidoc[]
47 changes: 47 additions & 0 deletions docs/usage/transport.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
[[transport]]
== Transport example

This page demonstrates how to use the low level transport to send requests.

[source,csharp]
----
public class MyRequestParameters : RequestParameters
{
public bool Pretty
{
get => Q<bool>("pretty");
init => Q("pretty", value);
}
}
// ...
var body = """
{
"name": "my-api-key",
"expiration": "1d",
"...": "..."
}
""";
MyRequestParameters requestParameters = new()
{
Pretty = true
};
var pathAndQuery = requestParameters.CreatePathWithQueryStrings("/_security/api_key",
client.ElasticsearchClientSettings);
var endpointPath = new EndpointPath(Elastic.Transport.HttpMethod.POST, pathAndQuery);
// Or, if the path does not contain query parameters:
// new EndpointPath(Elastic.Transport.HttpMethod.POST, "my_path")
var response = await client.Transport
.RequestAsync<StringResponse>(
endpointPath,
PostData.String(body),
null,
null,
cancellationToken: default)
.ConfigureAwait(false);
----

0 comments on commit eaffb81

Please sign in to comment.