Skip to content

Commit 523c2cb

Browse files
ReveristRealmDaniel Jackson
andauthored
Multi-Language Support for Spec-Insert -> Python (#10187)
* Updating Spect Insert tool to support client code translations Signed-off-by: Daniel Jackson <[email protected]> * Continued working on the Spect Insert feature for automatic conversion of API calls into Language SDK. Signed-off-by: Daniel Jackson <[email protected]> * Continued working on the Spect Insert feature for automatic conversion of API calls into Language SDK. Refactored code base to make "api" tag optional for quicker tag placements Examples: <!-- spec_insert_start component: example_code rest: GET /_cat/allocation?v=true&format=json&bytes=mb --> <!-- spec_insert_end --> <!-- spec_insert_start component: example_code rest: GET /users/_doc/42?_source=name,email include_client_setup: T --> Signed-off-by: Daniel Jackson <[email protected]> * Continued working on the Spec-Insert tool. - Added test examples to test files. Signed-off-by: Daniel Jackson <[email protected]> * Continued working on the Spec-Insert tool. - Added more test examples to fixtures file. - Included test for NDJSON files. - Included test to showcase multi-line for body tag Signed-off-by: Daniel Jackson <[email protected]> * Finished Python Client Code Conversion from HTTP w/ some minor tweaks. - Changed "include_client_setup" to be called from "insert_arguments.rb" for scalability and clarity. Also changed it so that you have to state "true" or "false". - Included "skip" tag. This is for when you come across a spec-insert that cant be converted to a client.You can do it manually, and it won't mess with future renders - Allowed for the body tag to be in multiple lines instead of one. Signed-off-by: Daniel Jackson <[email protected]> * Finished Python Client Code Conversion from HTTP w/ some minor tweaks. - Fixed minor query params issue. - Implemented steps in the developer guide. - Removed un-reachable code logic. - Included example with NDJSON body in test files. Signed-off-by: Daniel Jackson <[email protected]> --------- Signed-off-by: Daniel Jackson <[email protected]> Co-authored-by: Daniel Jackson <[email protected]>
1 parent dcfdc0f commit 523c2cb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+710
-49
lines changed

DEVELOPER_GUIDE.md

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
- [Query parameters](#query-parameters)
99
- [Path parameters](#path-parameters)
1010
- [Endpoints](#endpoints)
11-
11+
- [Example_Code](#example_code)
12+
1213
## Introduction
1314

1415
The `.md` documents in this repository are rendered into HTML pages using [Jekyll](https://jekyllrb.com/). These HTML pages are hosted on [opensearch.org](https://docs.opensearch.org/latest/).
@@ -88,6 +89,65 @@ All spec insert components accept the following arguments:
8889
- `component` (String; required): The name of the component to render, such as `query_parameters`, `path_parameters`, or `endpoints`.
8990
- `omit_header` (Boolean; Default is `false`): If set to `true`, the markdown header of the component will not be rendered.
9091

92+
### Example_Code
93+
94+
- `api` should not be placed for the `component: example_code` tag. `rest` is mapped to the correct API by regex mapping.
95+
- `rest` (String; required): The HTTP request line (`HTTP method` + `endpoint path`) that is regex mapped to the `opensearch-openapi.yaml`.
96+
97+
The following tags are included to help with additional needs:
98+
99+
- `body` (String; optional): The request body for the API call, using YAML `|` to preserve newlines and indentation.
100+
- `include_client_setup:` (Boolean; Default is `false`): If set to `true`, the client setup for the language will be rendered.
101+
- `skip` (Boolean; Default is `false`): If set to `true`, the language conversions will not render/re-render. Use for manual conversions.
102+
103+
To insert multi-language support for the `cat.allocation` API, use the following snippet:
104+
105+
```markdown
106+
<!-- spec_insert_start
107+
component: example_code
108+
rest: GET /_cat/allocation?v
109+
-->
110+
<!-- spec_insert_end -->
111+
```
112+
113+
To insert multi-language support for the `index` API with a request body, use the following snippet. The `|` is needed for multiline support for the body:
114+
115+
```markdown
116+
<!-- spec_insert_start
117+
component: example_code
118+
rest: PUT /_settings?expand_wildcards=all&analyze_wildcard
119+
body: |
120+
{
121+
"index": {
122+
"number_of_replicas": 2
123+
}
124+
}
125+
-->
126+
<!-- spec_insert_end -->
127+
```
128+
129+
To insert multi-language support for the `index` API and include the client setup for each language, use the following snippet:
130+
131+
```markdown
132+
<!-- spec_insert_start
133+
component: example_code
134+
rest: PUT /_settings?expand_wildcards=all&analyze_wildcard
135+
include_client_setup: true
136+
-->
137+
<!-- spec_insert_end -->
138+
```
139+
140+
To insert multi-language support for the `index` API but need to manually set the multi-language example for the `index` API, use the following snippet:
141+
142+
```markdown
143+
<!-- spec_insert_start
144+
component: example_code
145+
rest: PUT /_settings?expand_wildcards=all&analyze_wildcard
146+
skip: true
147+
-->
148+
<!-- spec_insert_end -->
149+
```
150+
91151
### Endpoints
92152
To insert endpoints for the `search` API, use the following snippet:
93153

_api-reference/cat/cat-aliases.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ include_deprecated: false
3737
-->
3838
## Query parameters
3939

40-
The following table lists the available query parameters. All query parameters are optional.
40+
The following table lists the available query parameters.
4141

4242
| Parameter | Data type | Description | Default |
4343
| :--- | :--- | :--- | :--- |

_api-reference/cat/cat-allocation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ include_deprecated: false
3636
-->
3737
## Query parameters
3838

39-
The following table lists the available query parameters. All query parameters are optional.
39+
The following table lists the available query parameters.
4040

4141
| Parameter | Data type | Description | Default |
4242
| :--- | :--- | :--- | :--- |

_api-reference/cat/cat-cluster_manager.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ include_deprecated: false
3434
-->
3535
## Query parameters
3636

37-
The following table lists the available query parameters. All query parameters are optional.
37+
The following table lists the available query parameters.
3838

3939
| Parameter | Data type | Description | Default |
4040
| :--- | :--- | :--- | :--- |

_api-reference/cat/cat-count.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ include_deprecated: false
3636
-->
3737
## Query parameters
3838

39-
The following table lists the available query parameters. All query parameters are optional.
39+
The following table lists the available query parameters.
4040

4141
| Parameter | Data type | Description | Default |
4242
| :--- | :--- | :--- | :--- |

_api-reference/cat/cat-field-data.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ include_deprecated: false
3434
-->
3535
## Query parameters
3636

37-
The following table lists the available query parameters. All query parameters are optional.
37+
The following table lists the available query parameters.
3838

3939
| Parameter | Data type | Description | Default |
4040
| :--- | :--- | :--- | :--- |

_api-reference/cat/cat-health.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ include_deprecated: false
3434
-->
3535
## Query parameters
3636

37-
The following table lists the available query parameters. All query parameters are optional.
37+
The following table lists the available query parameters.
3838

3939
| Parameter | Data type | Description | Default |
4040
| :--- | :--- | :--- | :--- |

_api-reference/cat/cat-indices.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ include_deprecated: false
3535
-->
3636
## Query parameters
3737

38-
The following table lists the available query parameters. All query parameters are optional.
38+
The following table lists the available query parameters.
3939

4040
| Parameter | Data type | Description | Default |
4141
| :--- | :--- | :--- | :--- |

_api-reference/cat/cat-nodeattrs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ include_deprecated: false
3434
-->
3535
## Query parameters
3636

37-
The following table lists the available query parameters. All query parameters are optional.
37+
The following table lists the available query parameters.
3838

3939
| Parameter | Data type | Description | Default |
4040
| :--- | :--- | :--- | :--- |

_api-reference/cat/cat-nodes.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ include_deprecated: false
3636
-->
3737
## Query parameters
3838

39-
The following table lists the available query parameters. All query parameters are optional.
39+
The following table lists the available query parameters.
4040

4141
| Parameter | Data type | Description | Default |
4242
| :--- | :--- | :--- | :--- |
@@ -47,7 +47,7 @@ The following table lists the available query parameters. All query parameters a
4747
| `h` | List | A comma-separated list of column names to display. | N/A |
4848
| `help` | Boolean | Returns help information. | `false` |
4949
| `s` | List | A comma-separated list of column names or column aliases to sort by. | N/A |
50-
| `time` | String | Specifies the time units, for example, `5d` or `7h`. For more information, see [Supported units]({{site.url}}{{site.baseurl}}/api-reference/units/). <br> Valid values are: `nanos`, `micros`, `ms`, `s`, `m`, `h`, and `d`. | N/A |
50+
| `time` | String | Specifies the time units, for example, `5d` or `7h`. For more information, see [Supported units](https://opensearch.org/docs/latest/api-reference/units/). <br> Valid values are: `nanos`, `micros`, `ms`, `s`, `m`, `h`, and `d`. | N/A |
5151
| `v` | Boolean | Enables verbose mode, which displays column headers. | `false` |
5252

5353
<!-- spec_insert_end -->

0 commit comments

Comments
 (0)