// 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 updateUsageCarbonEmissionsQueryDetails = {
queryDefinition: {
displayName: "EXAMPLE-displayName-Value",
reportQuery: {
tenantId: "ocid1.test.oc1..<unique_ID>EXAMPLE-tenantId-Value",
timeUsageStarted: new Date("Thu Nov 22 01:44:53 UTC 2012"),
timeUsageEnded: new Date("Sun Jul 07 06:10:09 UTC 2002"),
isAggregateByTime: true,
groupBy: ["EXAMPLE--Value"],
groupByTag: [
{
namespace: "EXAMPLE-namespace-Value",
key: "EXAMPLE-key-Value",
value: "EXAMPLE-value-Value"
}
],
compartmentDepth: 4,
filter: {
operator: usageapi.models.Filter.Operator.And,
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.UsageCarbonEmissionsReportQuery.DateRangeName.LastThreeMonths
},
costAnalysisUI: {
graph: usageapi.models.CostAnalysisUI.Graph.Bars,
isCumulativeGraph: true
},
version: 7067
}
};
const updateUsageCarbonEmissionsQueryRequest: usageapi.requests.UpdateUsageCarbonEmissionsQueryRequest = {
updateUsageCarbonEmissionsQueryDetails: updateUsageCarbonEmissionsQueryDetails,
usageCarbonEmissionsQueryId:
"ocid1.test.oc1..<unique_ID>EXAMPLE-usageCarbonEmissionsQueryId-Value",
opcRequestId: "MN9H2MYURJHZTFJISR15<unique_ID>",
ifMatch: "EXAMPLE-ifMatch-Value"
};
// Send request to the Client.
const updateUsageCarbonEmissionsQueryResponse = await client.updateUsageCarbonEmissionsQuery(
updateUsageCarbonEmissionsQueryRequest
);
} catch (error) {
console.log("updateUsageCarbonEmissionsQuery Failed with error " + error);
}
})();