// 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.BatchService;
using Oci.Common;
using Oci.Common.Auth;
namespace Oci.Sdk.DotNet.Example.Batch
{
public class CreateBatchContextExample
{
public static async Task Main()
{
// Create a request and dependent object(s).
var createBatchContextDetails = new Oci.BatchService.Models.CreateBatchContextDetails
{
CompartmentId = "ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value",
DisplayName = "EXAMPLE-displayName-Value",
Description = "EXAMPLE-description-Value",
FreeformTags = new Dictionary<string, string>()
{
{
"EXAMPLE_KEY_KL08H",
"EXAMPLE_VALUE_4Y6bzit1r6zBPlrQgSTA"
}
},
DefinedTags = new Dictionary<string, Dictionary<string, Object>>()
{
{
"EXAMPLE_KEY_2bc1k",
new Dictionary<string, Object>()
{
{
"EXAMPLE_KEY_vKOqN",
"EXAMPLE--Value"
}
}
}
},
JobPriorityConfigurations = new List<Oci.BatchService.Models.JobPriorityConfiguration>
{
new Oci.BatchService.Models.JobPriorityConfiguration
{
TagNamespace = "EXAMPLE-tagNamespace-Value",
TagKey = "EXAMPLE-tagKey-Value",
Weight = -35,
Values = new Dictionary<string, Int32>()
{
{
"EXAMPLE_KEY_P4wDF",
1680012640
}
}
}
},
Network = new Oci.BatchService.Models.CreateNetworkDetails
{
SubnetId = "ocid1.test.oc1..<unique_ID>EXAMPLE-subnetId-Value",
NsgIds = new List<string>
{
"EXAMPLE--Value"
}
},
Fleets = new List<Oci.BatchService.Models.CreateFleetDetails>
{
new Oci.BatchService.Models.CreateServiceManagedGpuFleetDetails
{
Name = "EXAMPLE-name-Value",
Shape = new Oci.BatchService.Models.CreateFixedGpuFleetShapeDetails
{
ShapeName = "EXAMPLE-shapeName-Value",
DiskSizeInGBs = 610
},
MaxConcurrentTasks = 456
}
},
Entitlements = new Dictionary<string, Int32>()
{
{
"EXAMPLE_KEY_qTxUW",
-211094204
}
},
LoggingConfiguration = new Oci.BatchService.Models.OciLoggingConfiguration
{
LogGroupId = "ocid1.test.oc1..<unique_ID>EXAMPLE-logGroupId-Value",
LogId = "ocid1.test.oc1..<unique_ID>EXAMPLE-logId-Value",
IsJobTaskEventsPropagationEnabled = false
}
};
var createBatchContextRequest = new Oci.BatchService.Requests.CreateBatchContextRequest
{
CreateBatchContextDetails = createBatchContextDetails,
OpcRetryToken = "EXAMPLE-opcRetryToken-Value",
OpcRequestId = "EOAKRLSUDEVEIEXX7PNZ<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 BatchComputingClient(provider, new ClientConfiguration()))
{
var response = await client.CreateBatchContext(createBatchContextRequest);
// Retrieve value from the response.
var id = response.BatchContext.Id;
}
}
catch (Exception e)
{
Console.WriteLine($"CreateBatchContext Failed with {e.Message}");
throw e;
}
}
}
}