// 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.OsmanagementhubService;
using Oci.Common;
using Oci.Common.Auth;
namespace Oci.Sdk.DotNet.Example.Osmanagementhub
{
public class CreateDynamicSetExample
{
public static async Task Main()
{
// Create a request and dependent object(s).
var createDynamicSetDetails = new Oci.OsmanagementhubService.Models.CreateDynamicSetDetails
{
DisplayName = "EXAMPLE-displayName-Value",
Description = "EXAMPLE-description-Value",
CompartmentId = "ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value",
TargetCompartments = new List<Oci.OsmanagementhubService.Models.TargetCompartmentDetails>
{
new Oci.OsmanagementhubService.Models.TargetCompartmentDetails
{
CompartmentId = "ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value",
DoesIncludeChildren = false
}
},
MatchType = Oci.OsmanagementhubService.Models.MatchType.All,
MatchingRule = new Oci.OsmanagementhubService.Models.MatchingRule
{
Tags = new List<Oci.OsmanagementhubService.Models.Tag>
{
new Oci.OsmanagementhubService.Models.DefinedTag
{
Namespace = "EXAMPLE-namespace-Value",
Key = "EXAMPLE-key-Value",
Value = "EXAMPLE-value-Value"
}
},
ManagedInstanceIds = new List<string>
{
"EXAMPLE--Value"
},
ManagedInstanceGroupIds = new List<string>
{
"EXAMPLE--Value"
},
DisplayNames = new List<string>
{
"EXAMPLE--Value"
},
OsNames = new List<Oci.OsmanagementhubService.Models.OsName>
{
Oci.OsmanagementhubService.Models.OsName.OracleLinux
},
Architectures = new List<Oci.OsmanagementhubService.Models.CpuArchType>
{
Oci.OsmanagementhubService.Models.CpuArchType.Aarch64
},
OsFamilies = new List<Oci.OsmanagementhubService.Models.OsFamily>
{
Oci.OsmanagementhubService.Models.OsFamily.WindowsServer2016
},
Statuses = new List<Oci.OsmanagementhubService.Models.ManagedInstanceStatus>
{
Oci.OsmanagementhubService.Models.ManagedInstanceStatus.Rebooting
},
Locations = new List<Oci.OsmanagementhubService.Models.ManagedInstanceLocation>
{
Oci.OsmanagementhubService.Models.ManagedInstanceLocation.Gcp
},
IsRebootRequired = true
},
FreeformTags = new Dictionary<string, string>()
{
{
"EXAMPLE_KEY_lCYG1",
"EXAMPLE_VALUE_HxjTXHAybcQFpnD3pyxx"
}
},
DefinedTags = new Dictionary<string, Dictionary<string, Object>>()
{
{
"EXAMPLE_KEY_KX6tl",
new Dictionary<string, Object>()
{
{
"EXAMPLE_KEY_abIhw",
"EXAMPLE--Value"
}
}
}
}
};
var createDynamicSetRequest = new Oci.OsmanagementhubService.Requests.CreateDynamicSetRequest
{
CreateDynamicSetDetails = createDynamicSetDetails,
OpcRetryToken = "EXAMPLE-opcRetryToken-Value",
OpcRequestId = "PDCWPIP28U601641EBTU<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 DynamicSetClient(provider, new ClientConfiguration()))
{
var response = await client.CreateDynamicSet(createDynamicSetRequest);
// Retrieve value from the response.
var id = response.DynamicSet.Id;
}
}
catch (Exception e)
{
Console.WriteLine($"CreateDynamicSet Failed with {e.Message}");
throw e;
}
}
}
}