// 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.FleetappsmanagementService;
using Oci.Common;
using Oci.Common.Auth;
namespace Oci.Sdk.DotNet.Example.Fleetappsmanagement
{
public class CreateTaskRecordExample
{
public static async Task Main()
{
// Create a request and dependent object(s).
var createTaskRecordDetails = new Oci.FleetappsmanagementService.Models.CreateTaskRecordDetails
{
DisplayName = "EXAMPLE-displayName-Value",
Description = "EXAMPLE-description-Value",
Details = new Oci.FleetappsmanagementService.Models.Details
{
ExecutionDetails = new Oci.FleetappsmanagementService.Models.ScriptBasedExecutionDetails
{
Variables = new Oci.FleetappsmanagementService.Models.TaskVariable
{
InputVariables = new List<Oci.FleetappsmanagementService.Models.InputArgument>
{
new Oci.FleetappsmanagementService.Models.OutputVariableInputArgument
{
Name = "EXAMPLE-name-Value",
Description = "EXAMPLE-description-Value"
}
},
OutputVariables = new List<string>
{
"EXAMPLE--Value"
}
},
Content = new Oci.FleetappsmanagementService.Models.CatalogContentDetails
{
CatalogId = "ocid1.test.oc1..<unique_ID>EXAMPLE-catalogId-Value"
},
Command = "EXAMPLE-command-Value",
Credentials = new List<Oci.FleetappsmanagementService.Models.ConfigAssociationDetails>
{
new Oci.FleetappsmanagementService.Models.ConfigAssociationDetails
{
Id = "ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value",
DisplayName = "EXAMPLE-displayName-Value"
}
},
IsLocked = true,
IsExecutableContent = true
},
Platform = "EXAMPLE-platform-Value",
OsType = Oci.FleetappsmanagementService.Models.OsType.Generic,
Scope = Oci.FleetappsmanagementService.Models.TaskScope.Local,
Properties = new Oci.FleetappsmanagementService.Models.Properties
{
NumRetries = 884,
TimeoutInSeconds = 784
},
IsDiscoveryOutputTask = false,
IsApplySubjectTask = true,
Operation = "EXAMPLE-operation-Value"
},
CompartmentId = "ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value",
FreeformTags = new Dictionary<string, string>()
{
{
"EXAMPLE_KEY_b34BP",
"EXAMPLE_VALUE_Sx6rD49o2KIJN7ACMazV"
}
},
DefinedTags = new Dictionary<string, Dictionary<string, Object>>()
{
{
"EXAMPLE_KEY_SVwue",
new Dictionary<string, Object>()
{
{
"EXAMPLE_KEY_NqV4A",
"EXAMPLE--Value"
}
}
}
}
};
var createTaskRecordRequest = new Oci.FleetappsmanagementService.Requests.CreateTaskRecordRequest
{
CreateTaskRecordDetails = createTaskRecordDetails,
OpcRetryToken = "EXAMPLE-opcRetryToken-Value",
OpcRequestId = "US6GKYQIVT65M2ZSGEMA<unique_ID>"
};
// 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 FleetAppsManagementRunbooksClient(provider, new ClientConfiguration()))
{
var response = await client.CreateTaskRecord(createTaskRecordRequest);
// Retrieve value from the response.
var id = response.TaskRecord.Id;
}
}
catch (Exception e)
{
Console.WriteLine($"CreateTaskRecord Failed with {e.Message}");
throw e;
}
}
}
}