-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure clients can handle empty oneOf objects (#2493)
Co-authored-by: ci.datadog-api-spec <[email protected]>
- Loading branch information
1 parent
8a317be
commit efa3b40
Showing
5 changed files
with
156 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
// Clients deserialize a dashboard with a empty time object | ||
|
||
import com.datadog.api.client.ApiClient; | ||
import com.datadog.api.client.ApiException; | ||
import com.datadog.api.client.v1.api.DashboardsApi; | ||
import com.datadog.api.client.v1.model.Dashboard; | ||
import com.datadog.api.client.v1.model.DashboardLayoutType; | ||
import com.datadog.api.client.v1.model.FormulaAndFunctionCloudCostDataSource; | ||
import com.datadog.api.client.v1.model.FormulaAndFunctionCloudCostQueryDefinition; | ||
import com.datadog.api.client.v1.model.FormulaAndFunctionQueryDefinition; | ||
import com.datadog.api.client.v1.model.FormulaAndFunctionResponseFormat; | ||
import com.datadog.api.client.v1.model.TimeseriesWidgetDefinition; | ||
import com.datadog.api.client.v1.model.TimeseriesWidgetDefinitionType; | ||
import com.datadog.api.client.v1.model.TimeseriesWidgetRequest; | ||
import com.datadog.api.client.v1.model.Widget; | ||
import com.datadog.api.client.v1.model.WidgetDefinition; | ||
import com.datadog.api.client.v1.model.WidgetDisplayType; | ||
import com.datadog.api.client.v1.model.WidgetFormula; | ||
import com.datadog.api.client.v1.model.WidgetLegacyLiveSpan; | ||
import com.datadog.api.client.v1.model.WidgetLineType; | ||
import com.datadog.api.client.v1.model.WidgetLineWidth; | ||
import com.datadog.api.client.v1.model.WidgetRequestStyle; | ||
import com.datadog.api.client.v1.model.WidgetTextAlign; | ||
import com.datadog.api.client.v1.model.WidgetTime; | ||
import java.util.Collections; | ||
|
||
public class Example { | ||
public static void main(String[] args) { | ||
ApiClient defaultClient = ApiClient.getDefaultApiClient(); | ||
DashboardsApi apiInstance = new DashboardsApi(defaultClient); | ||
|
||
Dashboard body = | ||
new Dashboard() | ||
.title("Example-Dashboard") | ||
.widgets( | ||
Collections.singletonList( | ||
new Widget() | ||
.definition( | ||
new WidgetDefinition( | ||
new TimeseriesWidgetDefinition() | ||
.title("Example Cloud Cost Query") | ||
.titleSize("16") | ||
.titleAlign(WidgetTextAlign.LEFT) | ||
.type(TimeseriesWidgetDefinitionType.TIMESERIES) | ||
.requests( | ||
Collections.singletonList( | ||
new TimeseriesWidgetRequest() | ||
.formulas( | ||
Collections.singletonList( | ||
new WidgetFormula().formula("query1"))) | ||
.queries( | ||
Collections.singletonList( | ||
new FormulaAndFunctionQueryDefinition( | ||
new FormulaAndFunctionCloudCostQueryDefinition() | ||
.dataSource( | ||
FormulaAndFunctionCloudCostDataSource | ||
.CLOUD_COST) | ||
.name("query1") | ||
.query( | ||
"sum:aws.cost.amortized{*} by" | ||
+ " {aws_product}.rollup(sum," | ||
+ " monthly)")))) | ||
.responseFormat( | ||
FormulaAndFunctionResponseFormat.TIMESERIES) | ||
.style( | ||
new WidgetRequestStyle() | ||
.palette("dog_classic") | ||
.lineType(WidgetLineType.SOLID) | ||
.lineWidth(WidgetLineWidth.NORMAL)) | ||
.displayType(WidgetDisplayType.BARS))) | ||
.time(new WidgetTime(new WidgetLegacyLiveSpan())))))) | ||
.layoutType(DashboardLayoutType.ORDERED); | ||
|
||
try { | ||
Dashboard result = apiInstance.createDashboard(body); | ||
System.out.println(result); | ||
} catch (ApiException e) { | ||
System.err.println("Exception when calling DashboardsApi#createDashboard"); | ||
System.err.println("Status code: " + e.getCode()); | ||
System.err.println("Reason: " + e.getResponseBody()); | ||
System.err.println("Response headers: " + e.getResponseHeaders()); | ||
e.printStackTrace(); | ||
} | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...ces/cassettes/features/v1/Clients_deserialize_a_dashboard_with_a_empty_time_object.freeze
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
2024-09-24T19:19:31.807Z |
58 changes: 58 additions & 0 deletions
58
...urces/cassettes/features/v1/Clients_deserialize_a_dashboard_with_a_empty_time_object.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
[ | ||
{ | ||
"httpRequest": { | ||
"body": { | ||
"type": "JSON", | ||
"json": "{\"layout_type\":\"ordered\",\"title\":\"Test-Clients_deserialize_a_dashboard_with_a_empty_time_object-1727205571\",\"widgets\":[{\"definition\":{\"requests\":[{\"display_type\":\"bars\",\"formulas\":[{\"formula\":\"query1\"}],\"queries\":[{\"data_source\":\"cloud_cost\",\"name\":\"query1\",\"query\":\"sum:aws.cost.amortized{*} by {aws_product}.rollup(sum, monthly)\"}],\"response_format\":\"timeseries\",\"style\":{\"line_type\":\"solid\",\"line_width\":\"normal\",\"palette\":\"dog_classic\"}}],\"time\":{},\"title\":\"Example Cloud Cost Query\",\"title_align\":\"left\",\"title_size\":\"16\",\"type\":\"timeseries\"}}]}" | ||
}, | ||
"headers": {}, | ||
"method": "POST", | ||
"path": "/api/v1/dashboard", | ||
"keepAlive": false, | ||
"secure": true | ||
}, | ||
"httpResponse": { | ||
"body": "{\"id\":\"han-5zg-c32\",\"title\":\"Test-Clients_deserialize_a_dashboard_with_a_empty_time_object-1727205571\",\"description\":null,\"author_handle\":\"[email protected]\",\"author_name\":null,\"layout_type\":\"ordered\",\"url\":\"/dashboard/han-5zg-c32/test-clientsdeserializeadashboardwithaemptytimeobject-1727205571\",\"is_read_only\":false,\"template_variables\":null,\"widgets\":[{\"definition\":{\"requests\":[{\"display_type\":\"bars\",\"formulas\":[{\"formula\":\"query1\"}],\"queries\":[{\"data_source\":\"cloud_cost\",\"name\":\"query1\",\"query\":\"sum:aws.cost.amortized{*} by {aws_product}.rollup(sum, monthly)\"}],\"response_format\":\"timeseries\",\"style\":{\"line_type\":\"solid\",\"line_width\":\"normal\",\"palette\":\"dog_classic\"}}],\"time\":{},\"title\":\"Example Cloud Cost Query\",\"title_align\":\"left\",\"title_size\":\"16\",\"type\":\"timeseries\"},\"id\":4274057372149908}],\"notify_list\":null,\"created_at\":\"2024-09-24T19:19:32.071328+00:00\",\"modified_at\":\"2024-09-24T19:19:32.071328+00:00\",\"experience_type\":\"default\",\"restricted_roles\":[]}\n", | ||
"headers": { | ||
"Content-Type": [ | ||
"application/json" | ||
] | ||
}, | ||
"statusCode": 200, | ||
"reasonPhrase": "OK" | ||
}, | ||
"times": { | ||
"remainingTimes": 1 | ||
}, | ||
"timeToLive": { | ||
"unlimited": true | ||
}, | ||
"id": "25f142c7-7556-d0a0-7f60-c9aea7b1aa17" | ||
}, | ||
{ | ||
"httpRequest": { | ||
"headers": {}, | ||
"method": "DELETE", | ||
"path": "/api/v1/dashboard/han-5zg-c32", | ||
"keepAlive": false, | ||
"secure": true | ||
}, | ||
"httpResponse": { | ||
"body": "{\"deleted_dashboard_id\":\"han-5zg-c32\"}\n", | ||
"headers": { | ||
"Content-Type": [ | ||
"application/json" | ||
] | ||
}, | ||
"statusCode": 200, | ||
"reasonPhrase": "OK" | ||
}, | ||
"times": { | ||
"remainingTimes": 1 | ||
}, | ||
"timeToLive": { | ||
"unlimited": true | ||
}, | ||
"id": "9350b5ff-5d55-807a-27b7-1a985a5d0edd" | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters