// 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("Fri Nov 29 13:41:04 UTC 2024"),
				timeUsageEnded: new Date("Thu Jul 12 16:59:51 UTC 2046"),
				granularity: usageapi.models.ReportQuery.Granularity.Daily,
				isAggregateByTime: false,
				forecast: {
					forecastType: usageapi.models.Forecast.ForecastType.Basic,
					timeForecastStarted: new Date("Mon Dec 10 05:01:37 UTC 2001"),
					timeForecastEnded: new Date("Sat Apr 27 21:51:29 UTC 2024"),

					}
,
				queryType: usageapi.models.ReportQuery.QueryType.Expiredcredit,
				groupBy: ["EXAMPLE--Value"						],
				groupByTag: [{
						namespace: "EXAMPLE-namespace-Value",
						key: "EXAMPLE-key-Value",
						value: "EXAMPLE-value-Value",

						}
						],
				compartmentDepth: 5.39675,
				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.LastSevenDays,

				}
,
			costAnalysisUI: {
				graph: usageapi.models.CostAnalysisUI.Graph.Bars,
				isCumulativeGraph: false,

				}
,
			version: 4434.609,

			}
,

		}

	const updateQueryRequest: usageapi.requests.UpdateQueryRequest = { 
	updateQueryDetails: updateQueryDetails,
	queryId: "ocid1.test.oc1..<unique_ID>EXAMPLE-queryId-Value",
	opcRequestId: "UOBUZ20DBQ3UA1OXOSWH<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);
     }
})();