Skip to content

Commit eaffb81

Browse files
committed
Update documentation
1 parent 5f33f6f commit eaffb81

File tree

3 files changed

+90
-12
lines changed

3 files changed

+90
-12
lines changed

Diff for: docs/migration-guide.asciidoc

+38-8
Original file line numberDiff line numberDiff line change
@@ -292,13 +292,43 @@ As a last resort, the low-level client `Elastic.Transport` can be used to create
292292

293293
[source,csharp]
294294
----
295+
public class MyRequestParameters : RequestParameters
296+
{
297+
public bool Pretty
298+
{
299+
get => Q<bool>("pretty");
300+
init => Q("pretty", value);
301+
}
302+
}
303+
304+
// ...
305+
295306
var body = """
296-
{
297-
"name": "my-api-key",
298-
"expiration": "1d",
299-
"...": "..."
300-
}
301-
""";
302-
303-
var response = await client.Transport.RequestAsync<StringResponse>(HttpMethod.POST, "/_security/api_key", PostData.String(body));
307+
{
308+
"name": "my-api-key",
309+
"expiration": "1d",
310+
"...": "..."
311+
}
312+
""";
313+
314+
MyRequestParameters requestParameters = new()
315+
{
316+
Pretty = true
317+
};
318+
319+
var pathAndQuery = requestParameters.CreatePathWithQueryStrings("/_security/api_key",
320+
client.ElasticsearchClientSettings);
321+
var endpointPath = new EndpointPath(Elastic.Transport.HttpMethod.POST, pathAndQuery);
322+
323+
// Or, if the path does not contain query parameters:
324+
// new EndpointPath(Elastic.Transport.HttpMethod.POST, "my_path")
325+
326+
var response = await client.Transport
327+
.RequestAsync<StringResponse>(
328+
endpointPath,
329+
PostData.String(body),
330+
null,
331+
null,
332+
cancellationToken: default)
333+
.ConfigureAwait(false);
304334
----

Diff for: docs/usage/index.asciidoc

+5-4
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ If you're new to {es}, make sure also to read {ref}/getting-started.html[Elastic
1414

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

17-
include::recommendations.asciidoc[]
17+
include::aggregations.asciidoc[]
18+
include::esql.asciidoc[]
1819
include::examples.asciidoc[]
19-
include::query.asciidoc[]
2020
include::mappings.asciidoc[]
21-
include::aggregations.asciidoc[]
22-
include::esql.asciidoc[]
21+
include::query.asciidoc[]
22+
include::recommendations.asciidoc[]
23+
include::transport.asciidoc[]

Diff for: docs/usage/transport.asciidoc

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
[[transport]]
2+
== Transport example
3+
4+
This page demonstrates how to use the low level transport to send requests.
5+
6+
[source,csharp]
7+
----
8+
public class MyRequestParameters : RequestParameters
9+
{
10+
public bool Pretty
11+
{
12+
get => Q<bool>("pretty");
13+
init => Q("pretty", value);
14+
}
15+
}
16+
17+
// ...
18+
19+
var body = """
20+
{
21+
"name": "my-api-key",
22+
"expiration": "1d",
23+
"...": "..."
24+
}
25+
""";
26+
27+
MyRequestParameters requestParameters = new()
28+
{
29+
Pretty = true
30+
};
31+
32+
var pathAndQuery = requestParameters.CreatePathWithQueryStrings("/_security/api_key",
33+
client.ElasticsearchClientSettings);
34+
var endpointPath = new EndpointPath(Elastic.Transport.HttpMethod.POST, pathAndQuery);
35+
36+
// Or, if the path does not contain query parameters:
37+
// new EndpointPath(Elastic.Transport.HttpMethod.POST, "my_path")
38+
39+
var response = await client.Transport
40+
.RequestAsync<StringResponse>(
41+
endpointPath,
42+
PostData.String(body),
43+
null,
44+
null,
45+
cancellationToken: default)
46+
.ConfigureAwait(false);
47+
----

0 commit comments

Comments
 (0)