// This is an automatically generated code sample.
// To make this code sample work in your Oracle Cloud tenancy,
// please replace the values for any parameters whose current values do not fit
// your use case (such as resource IDs, strings containing ‘EXAMPLE’ or ‘unique_id’, and
// boolean, number, and enum parameters with values not fitting your use case).
import * as usageapi from "oci-usageapi";
import common = require("oci-common");
// Create a default authentication provider that uses the DEFAULT
// profile in the configuration file.
// Refer to <see href="https://docs.cloud.oracle.com/en-us/iaas/Content/API/Concepts/sdkconfig.htm#SDK_and_CLI_Configuration_File>the public documentation</see> on how to prepare a configuration file.
const provider: common.ConfigFileAuthenticationDetailsProvider = new common.ConfigFileAuthenticationDetailsProvider();
(async () => {
try {
// Create a service client
const client = new usageapi.UsageapiClient({ authenticationDetailsProvider: provider });
// Create a request and dependent object(s).
const updateQueryDetails = {
queryDefinition: {
displayName: "EXAMPLE-displayName-Value",
reportQuery: {
tenantId: "ocid1.test.oc1..<unique_ID>EXAMPLE-tenantId-Value",
timeUsageStarted: new Date("Wed Sep 05 11:40:13 UTC 2001"),
timeUsageEnded: new Date("Mon Nov 22 02:31:25 UTC 2004"),
granularity: usageapi.models.ReportQuery.Granularity.Hourly,
isAggregateByTime: true,
forecast: {
forecastType: usageapi.models.Forecast.ForecastType.Basic,
timeForecastStarted: new Date("Thu Jun 09 05:59:49 UTC 2005"),
timeForecastEnded: new Date("Tue Apr 23 21:03:16 UTC 2002"),
}
,
queryType: usageapi.models.ReportQuery.QueryType.Usage,
groupBy: ["EXAMPLE--Value" ],
groupByTag: [{
namespace: "EXAMPLE-namespace-Value",
key: "EXAMPLE-key-Value",
value: "EXAMPLE-value-Value",
}
],
compartmentDepth: 3.1801724,
filter: {
operator: usageapi.models.Filter.Operator.Not,
dimensions: [{
key: "EXAMPLE-key-Value",
value: "EXAMPLE-value-Value",
}
],
tags: [{
namespace: "EXAMPLE-namespace-Value",
key: "EXAMPLE-key-Value",
value: "EXAMPLE-value-Value",
}
],
}
,
dateRangeName: usageapi.models.ReportQuery.DateRangeName.LastThreeMonths,
}
,
costAnalysisUI: {
graph: usageapi.models.CostAnalysisUI.Graph.StackedLines,
isCumulativeGraph: false,
}
,
version: 6113.9556,
}
,
}
const updateQueryRequest: usageapi.requests.UpdateQueryRequest = {
updateQueryDetails: updateQueryDetails,
queryId: "ocid1.test.oc1..<unique_ID>EXAMPLE-queryId-Value",
opcRequestId: "H3MODYTCZ1CSE3AWL6A1<unique_ID>",
ifMatch: "EXAMPLE-ifMatch-Value",
};
// Send request to the Client.
const updateQueryResponse = await client.updateQuery(updateQueryRequest);
}
catch (error) {
console.log("updateQuery Failed with error " + error);
}
})();