-
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.
Regenerate client from commit 824086bb of spec repo
- Loading branch information
ci.datadog-api-spec
committed
Jul 11, 2023
1 parent
847cfd5
commit ee38c3a
Showing
9 changed files
with
578 additions
and
8 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
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,82 @@ | ||
// Create a new dashboard with a timeseries widget using formulas and functions cloud cost query | ||
|
||
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.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 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))))))) | ||
.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(); | ||
} | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
src/main/java/com/datadog/api/client/v1/model/FormulaAndFunctionCloudCostDataSource.java
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,61 @@ | ||
/* | ||
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. | ||
* This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
* Copyright 2019-Present Datadog, Inc. | ||
*/ | ||
|
||
package com.datadog.api.client.v1.model; | ||
|
||
import com.datadog.api.client.ModelEnum; | ||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.core.JsonGenerator; | ||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.fasterxml.jackson.databind.SerializerProvider; | ||
import com.fasterxml.jackson.databind.annotation.JsonSerialize; | ||
import com.fasterxml.jackson.databind.ser.std.StdSerializer; | ||
import java.io.IOException; | ||
import java.util.Arrays; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
/** Data source for Cloud Cost queries. */ | ||
@JsonSerialize( | ||
using = | ||
FormulaAndFunctionCloudCostDataSource.FormulaAndFunctionCloudCostDataSourceSerializer.class) | ||
public class FormulaAndFunctionCloudCostDataSource extends ModelEnum<String> { | ||
|
||
private static final Set<String> allowedValues = new HashSet<String>(Arrays.asList("cloud_cost")); | ||
|
||
public static final FormulaAndFunctionCloudCostDataSource CLOUD_COST = | ||
new FormulaAndFunctionCloudCostDataSource("cloud_cost"); | ||
|
||
FormulaAndFunctionCloudCostDataSource(String value) { | ||
super(value, allowedValues); | ||
} | ||
|
||
public static class FormulaAndFunctionCloudCostDataSourceSerializer | ||
extends StdSerializer<FormulaAndFunctionCloudCostDataSource> { | ||
public FormulaAndFunctionCloudCostDataSourceSerializer( | ||
Class<FormulaAndFunctionCloudCostDataSource> t) { | ||
super(t); | ||
} | ||
|
||
public FormulaAndFunctionCloudCostDataSourceSerializer() { | ||
this(null); | ||
} | ||
|
||
@Override | ||
public void serialize( | ||
FormulaAndFunctionCloudCostDataSource value, | ||
JsonGenerator jgen, | ||
SerializerProvider provider) | ||
throws IOException, JsonProcessingException { | ||
jgen.writeObject(value.value); | ||
} | ||
} | ||
|
||
@JsonCreator | ||
public static FormulaAndFunctionCloudCostDataSource fromValue(String value) { | ||
return new FormulaAndFunctionCloudCostDataSource(value); | ||
} | ||
} |
Oops, something went wrong.