// 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).

using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Oci.OpsiService;
using Oci.Common;
using Oci.Common.Auth;

namespace Oci.Sdk.DotNet.Example.Opsi
{
    public class IngestSqlStatsExample
    {
        public static async Task Main()
        {
            // Create a request and dependent object(s).
			var ingestSqlStatsDetails = new Oci.OpsiService.Models.IngestSqlStatsDetails
			{
				Items = new List<Oci.OpsiService.Models.SqlStats>
				{
					new Oci.OpsiService.Models.SqlStats
					{
						SqlIdentifier = "EXAMPLE-sqlIdentifier-Value",
						PlanHashValue = 241,
						TimeCollected = DateTime.Parse("11/07/2010 11:48:32"),
						InstanceName = "EXAMPLE-instanceName-Value",
						LastActiveTime = "EXAMPLE-lastActiveTime-Value",
						ParseCalls = 58,
						DiskReads = 817,
						DirectReads = 363,
						DirectWrites = 153,
						BufferGets = 711,
						RowsProcessed = 549,
						SerializableAborts = 800,
						Fetches = 749,
						Executions = 492,
						AvoidedExecutions = 946,
						EndOfFetchCount = 263,
						Loads = 806,
						VersionCount = 280,
						Invalidations = 661,
						ObsoleteCount = 486,
						PxServersExecutions = 673,
						CpuTimeInUs = 661,
						ElapsedTimeInUs = 677,
						AvgHardParseTimeInUs = 453,
						ConcurrencyWaitTimeInUs = 215,
						ApplicationWaitTimeInUs = 826,
						ClusterWaitTimeInUs = 986,
						UserIoWaitTimeInUs = 512,
						PlsqlExecTimeInUs = 93,
						JavaExecTimeInUs = 90,
						Sorts = 524,
						SharableMem = 132,
						TotalSharableMem = 668,
						TypeCheckMem = 850,
						IoCellOffloadEligibleBytes = 163,
						IoInterconnectBytes = 336,
						PhysicalReadRequests = 439,
						PhysicalReadBytes = 413,
						PhysicalWriteRequests = 19,
						PhysicalWriteBytes = 453,
						ExactMatchingSignature = "EXAMPLE-exactMatchingSignature-Value",
						ForceMatchingSignature = "EXAMPLE-forceMatchingSignature-Value",
						IoCellUncompressedBytes = 466,
						IoCellOffloadReturnedBytes = 947,
						ChildNumber = 200,
						CommandType = 75,
						UsersOpening = 672,
						UsersExecuting = 725,
						OptimizerCost = 389,
						FullPlanHashValue = "EXAMPLE-fullPlanHashValue-Value",
						Module = "EXAMPLE-module-Value",
						Service = "EXAMPLE-service-Value",
						Action = "EXAMPLE-action-Value",
						SqlProfile = "EXAMPLE-sqlProfile-Value",
						SqlPatch = "EXAMPLE-sqlPatch-Value",
						SqlPlanBaseline = "EXAMPLE-sqlPlanBaseline-Value",
						DeltaExecutionCount = 980,
						DeltaCpuTime = 290,
						DeltaIoBytes = 977,
						DeltaCpuRank = 344,
						DeltaExecsRank = 400,
						SharableMemRank = 921,
						DeltaIoRank = 893,
						HarmonicSum = 452,
						WtHarmonicSum = 159,
						TotalSqlCount = 903
					}
				}
			};
			var ingestSqlStatsRequest = new Oci.OpsiService.Requests.IngestSqlStatsRequest
			{
				IngestSqlStatsDetails = ingestSqlStatsDetails,
				DatabaseId = "ocid1.test.oc1..<unique_ID>EXAMPLE-databaseId-Value",
				Id = "ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value",
				OpcRequestId = "MJJ4RU1C1FROZSO5R34F<unique_ID>",
				IfMatch = "EXAMPLE-ifMatch-Value",
				OpcRetryToken = "EXAMPLE-opcRetryToken-Value"
			};

            // 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. 
            var provider = new ConfigFileAuthenticationDetailsProvider("DEFAULT");
            try
            {
                // Create a service client and send the request.
				using (var client = new OperationsInsightsClient(provider, new ClientConfiguration()))
				{
					var response = await client.IngestSqlStats(ingestSqlStatsRequest);
					// Retrieve value from the response.
					var messageValue = response.IngestSqlStatsResponseDetails.Message;
				}
            }
            catch (Exception e)
            {
                Console.WriteLine($"IngestSqlStats Failed with {e.Message}");
                throw e;
            }
        }

    }
}