// 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 ListManagedInstancesExample
    {
        public static async Task Main()
        {
            // Create a request and dependent object(s).
			var listManagedInstancesRequest = new Oci.OsmanagementhubService.Requests.ListManagedInstancesRequest
			{
				CompartmentId = "ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value",
				DisplayName = new List<string>
				{
					"EXAMPLE--Value"
				},
				DisplayNameContains = "EXAMPLE-displayNameContains-Value",
				ManagedInstanceId = "ocid1.test.oc1..<unique_ID>EXAMPLE-managedInstanceId-Value",
				Status = new List<Oci.OsmanagementhubService.Models.ManagedInstanceStatus>
				{
					Oci.OsmanagementhubService.Models.ManagedInstanceStatus.Normal
				},
				ArchType = new List<Oci.OsmanagementhubService.Models.ArchType>
				{
					Oci.OsmanagementhubService.Models.ArchType.I686
				},
				OsFamily = new List<Oci.OsmanagementhubService.Models.OsFamily>
				{
					Oci.OsmanagementhubService.Models.OsFamily.OracleLinux7
				},
				IsManagementStation = true,
				Group = "EXAMPLE-group-Value",
				GroupNotEqualTo = "EXAMPLE-groupNotEqualTo-Value",
				LifecycleStage = "EXAMPLE-lifecycleStage-Value",
				LifecycleStageNotEqualTo = "EXAMPLE-lifecycleStageNotEqualTo-Value",
				IsAttachedToGroupOrLifecycleStage = false,
				SoftwareSourceId = "ocid1.test.oc1..<unique_ID>EXAMPLE-softwareSourceId-Value",
				AdvisoryName = new List<string>
				{
					"EXAMPLE--Value"
				},
				LifecycleEnvironment = "EXAMPLE-lifecycleEnvironment-Value",
				LifecycleEnvironmentNotEqualTo = "EXAMPLE-lifecycleEnvironmentNotEqualTo-Value",
				Location = new List<Oci.OsmanagementhubService.Models.ManagedInstanceLocation>
				{
					Oci.OsmanagementhubService.Models.ManagedInstanceLocation.OciCompute
				},
				LocationNotEqualTo = new List<Oci.OsmanagementhubService.Models.ManagedInstanceLocation>
				{
					Oci.OsmanagementhubService.Models.ManagedInstanceLocation.Ec2
				},
				Profile = new List<string>
				{
					"EXAMPLE--Value"
				},
				ProfileNotEqualTo = new List<string>
				{
					"EXAMPLE--Value"
				},
				IsProfileAttached = false,
				IsManagedByAutonomousLinux = true,
				Limit = 98,
				Page = "EXAMPLE-page-Value",
				SortOrder = Oci.OsmanagementhubService.Models.SortOrder.Desc,
				SortBy = Oci.OsmanagementhubService.Requests.ListManagedInstancesRequest.SortByEnum.TimeCreated,
				OpcRequestId = "HQYXTGNILBMCJWSRXVOL<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 ManagedInstanceClient(provider, new ClientConfiguration()))
				{
					var response = await client.ListManagedInstances(listManagedInstancesRequest);
					// Retrieve value from the response.
					var itemsValue = response.ManagedInstanceCollection.Items;
				}
            }
            catch (Exception e)
            {
                Console.WriteLine($"ListManagedInstances Failed with {e.Message}");
                throw e;
            }
        }

    }
}