// 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 CreateFleetExample
{
public static async Task Main()
{
// Create a request and dependent object(s).
var createFleetDetails = new Oci.FleetappsmanagementService.Models.CreateFleetDetails
{
DisplayName = "EXAMPLE-displayName-Value",
Description = "EXAMPLE-description-Value",
CompartmentId = "ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value",
Details = new Oci.FleetappsmanagementService.Models.GenericFleetDetails
{
},
Products = new List<string>
{
"EXAMPLE--Value"
},
EnvironmentType = "EXAMPLE-environmentType-Value",
ResourceSelection = new Oci.FleetappsmanagementService.Models.DynamicResourceSelection
{
RuleSelectionCriteria = new Oci.FleetappsmanagementService.Models.SelectionCriteria
{
MatchCondition = Oci.FleetappsmanagementService.Models.SelectionCriteria.MatchConditionEnum.Any,
Rules = new List<Oci.FleetappsmanagementService.Models.Rule>
{
new Oci.FleetappsmanagementService.Models.Rule
{
Basis = "EXAMPLE-basis-Value",
CompartmentId = "ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value",
ResourceCompartmentId = "ocid1.test.oc1..<unique_ID>EXAMPLE-resourceCompartmentId-Value",
Conditions = new List<Oci.FleetappsmanagementService.Models.Condition>
{
new Oci.FleetappsmanagementService.Models.Condition
{
AttrGroup = "EXAMPLE-attrGroup-Value",
AttrKey = "EXAMPLE-attrKey-Value",
AttrValue = "EXAMPLE-attrValue-Value"
}
}
}
}
}
},
NotificationPreferences = new List<Oci.FleetappsmanagementService.Models.NotificationPreference>
{
new Oci.FleetappsmanagementService.Models.NotificationPreference
{
TopicId = "ocid1.test.oc1..<unique_ID>EXAMPLE-topicId-Value",
CompartmentId = "ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value",
Preferences = new Oci.FleetappsmanagementService.Models.Preferences
{
UpcomingSchedule = new Oci.FleetappsmanagementService.Models.UpcomingSchedule
{
OnUpcomingSchedule = false,
NotifyBefore = "EXAMPLE-notifyBefore-Value"
},
OnJobFailure = false,
OnTopologyModification = false,
OnTaskPause = false,
OnTaskFailure = false,
OnTaskSuccess = true,
OnResourceNonCompliance = true,
OnRunbookNewerVersion = true
}
}
},
Resources = new List<Oci.FleetappsmanagementService.Models.AssociatedFleetResourceDetails>
{
new Oci.FleetappsmanagementService.Models.AssociatedFleetResourceDetails
{
ResourceId = "ocid1.test.oc1..<unique_ID>EXAMPLE-resourceId-Value",
FleetResourceType = "EXAMPLE-fleetResourceType-Value",
CompartmentId = "ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value",
TenancyId = "ocid1.test.oc1..<unique_ID>EXAMPLE-tenancyId-Value"
}
},
Credentials = new List<Oci.FleetappsmanagementService.Models.AssociatedFleetCredentialDetails>
{
new Oci.FleetappsmanagementService.Models.AssociatedFleetCredentialDetails
{
DisplayName = "EXAMPLE-displayName-Value",
CompartmentId = "ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value",
EntitySpecifics = new Oci.FleetappsmanagementService.Models.ResourceCredentialEntitySpecificDetails
{
ResourceId = "ocid1.test.oc1..<unique_ID>EXAMPLE-resourceId-Value"
},
User = new Oci.FleetappsmanagementService.Models.VaultSecretCredentialDetails
{
SecretId = "ocid1.test.oc1..<unique_ID>EXAMPLE-secretId-Value",
SecretVersion = "EXAMPLE-secretVersion-Value"
},
}
},
Properties = new List<Oci.FleetappsmanagementService.Models.AssociatedFleetPropertyDetails>
{
new Oci.FleetappsmanagementService.Models.AssociatedFleetPropertyDetails
{
CompartmentId = "ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value",
DisplayName = "EXAMPLE-displayName-Value",
FleetPropertyType = Oci.FleetappsmanagementService.Models.AssociatedFleetPropertyDetails.FleetPropertyTypeEnum.Number,
Value = "EXAMPLE-value-Value",
IsRequired = true
}
},
ParentFleetId = "ocid1.test.oc1..<unique_ID>EXAMPLE-parentFleetId-Value",
IsTargetAutoConfirm = false,
FreeformTags = new Dictionary<string, string>()
{
{
"EXAMPLE_KEY_MPkEq",
"EXAMPLE_VALUE_ZcTBGKDTxFKtMjRI7uUe"
}
},
DefinedTags = new Dictionary<string, Dictionary<string, Object>>()
{
{
"EXAMPLE_KEY_BcC7x",
new Dictionary<string, Object>()
{
{
"EXAMPLE_KEY_cFwUj",
"EXAMPLE--Value"
}
}
}
}
};
var createFleetRequest = new Oci.FleetappsmanagementService.Requests.CreateFleetRequest
{
CreateFleetDetails = createFleetDetails,
OpcRetryToken = "EXAMPLE-opcRetryToken-Value",
OpcRequestId = "B68QOVD8HWCR204LB2CI<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 FleetAppsManagementClient(provider, new ClientConfiguration()))
{
var response = await client.CreateFleet(createFleetRequest);
// Retrieve value from the response.
var id = response.Fleet.Id;
}
}
catch (Exception e)
{
Console.WriteLine($"CreateFleet Failed with {e.Message}");
throw e;
}
}
}
}