Skip to content

Commit 5a6373a

Browse files
nkzouHantingZhang2
andauthored
Include tag description on API instances, simplify generation script (#76)
Co-authored-by: Hanting ZHANG <[email protected]>
1 parent 745853b commit 5a6373a

File tree

86 files changed

+296
-34
lines changed

Some content is hidden

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

86 files changed

+296
-34
lines changed

.generator/src/generator/cli.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,14 @@ def cli(specs, output):
113113
fp.write(mod_model_j2.render(apis=apis, models=models))
114114

115115
all_operations = []
116+
tags_by_name = {tag["name"]: tag for tag in spec["tags"]}
116117

117118
for name, operations in apis.items():
118119
filename = "api_" + formatter.snake_case(name) + ".rs"
119120
api_path = resources_dir / "api" / filename
120121
api_path.parent.mkdir(parents=True, exist_ok=True)
121122
with api_path.open("w") as fp:
122-
fp.write(api_j2.render(name=name, operations=operations))
123+
fp.write(api_j2.render(name=name, operations=operations, description=tags_by_name[name]["description"]))
123124
all_operations.append((name, operations))
124125

125126
mod_path = resources_dir / "api" / "mod.rs"

.generator/src/generator/templates/api.j2

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ pub enum {{operation.operationId}}Error {
8181
}
8282
{% endfor %}
8383

84+
{{ description|block_comment }}
8485
#[derive(Debug, Clone)]
8586
pub struct {{ structName }} {
8687
config: datadog::Configuration,

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ repos:
44
- id: generate
55
name: Generate
66
language: system
7-
entry: bash -c "./generate.sh && ./generate-examples.sh"
7+
entry: bash -c "./generate.sh"
88
files: '^(\.generator/.*|\.pre-commit-config\.yaml|Makefile|\tests/scenarios/features/.*)'
99
pass_filenames: false
1010
verbose: true

generate-examples.sh

Lines changed: 0 additions & 31 deletions
This file was deleted.

generate.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,12 @@ pre_commit_wrapper () {
2323
echo "command 'pre-commit run --all-files --hook-stage=manual ${1}' success"
2424
}
2525

26+
cargo install genemichaels --quiet
2627
rm -rf src/*
28+
rm -rf examples/*
2729
pre_commit_wrapper generator
28-
pre_commit_wrapper format
30+
pre_commit_wrapper examples
2931
pre_commit_wrapper lint
32+
genemichaels --log silent examples/*.rs
33+
cargo fmt
34+
cargo fmt # don't think too hard about this... cargo fmt idempotency edge case

src/datadogV1/api/api_authentication.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@ pub enum ValidateError {
1414
UnknownValue(serde_json::Value),
1515
}
1616

17+
/// All requests to Datadog’s API must be authenticated.
18+
/// Requests that write data require reporting access and require an `API key`.
19+
/// Requests that read data require full access and also require an `application key`.
20+
///
21+
/// **Note:** All Datadog API clients are configured by default to consume Datadog US site APIs.
22+
/// If you are on the Datadog EU site, set the environment variable `DATADOG_HOST` to
23+
/// `<https://api.datadoghq.eu`> or override this value directly when creating your client.
24+
///
25+
/// [Manage your account’s API and application keys](<https://app.datadoghq.com/organization-settings/>) in Datadog, and see the [API and Application Keys page](<https://docs.datadoghq.com/account_management/api-app-keys/>) in the documentation.
1726
#[derive(Debug, Clone)]
1827
pub struct AuthenticationAPI {
1928
config: datadog::Configuration,

src/datadogV1/api/api_aws_integration.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,8 @@ pub enum UpdateAWSAccountError {
196196
UnknownValue(serde_json::Value),
197197
}
198198

199+
/// Configure your Datadog-AWS integration directly through the Datadog API.
200+
/// For more information, see the [AWS integration page](<https://docs.datadoghq.com/integrations/amazon_web_services>).
199201
#[derive(Debug, Clone)]
200202
pub struct AWSIntegrationAPI {
201203
config: datadog::Configuration,

src/datadogV1/api/api_aws_logs_integration.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ pub enum ListAWSLogsServicesError {
7979
UnknownValue(serde_json::Value),
8080
}
8181

82+
/// Configure your Datadog-AWS-Logs integration directly through Datadog API.
83+
/// For more information, see the [AWS integration page](<https://docs.datadoghq.com/integrations/amazon_web_services/#log-collection>).
8284
#[derive(Debug, Clone)]
8385
pub struct AWSLogsIntegrationAPI {
8486
config: datadog::Configuration,

src/datadogV1/api/api_azure_integration.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ pub enum UpdateAzureIntegrationError {
6060
UnknownValue(serde_json::Value),
6161
}
6262

63+
/// Configure your Datadog-Azure integration directly through the Datadog API.
64+
/// For more information, see the [Datadog-Azure integration page](<https://docs.datadoghq.com/integrations/azure>).
6365
#[derive(Debug, Clone)]
6466
pub struct AzureIntegrationAPI {
6567
config: datadog::Configuration,

src/datadogV1/api/api_dashboard_lists.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ pub enum UpdateDashboardListError {
6060
UnknownValue(serde_json::Value),
6161
}
6262

63+
/// Interact with your dashboard lists through the API to
64+
/// organize, find, and share all of your dashboards with your team and
65+
/// organization.
6366
#[derive(Debug, Clone)]
6467
pub struct DashboardListsAPI {
6568
config: datadog::Configuration,

0 commit comments

Comments
 (0)