// 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.ContainerengineService;
using Oci.Common;
using Oci.Common.Auth;
namespace Oci.Sdk.DotNet.Example.Containerengine
{
public class UpdateClusterExample
{
public static async Task Main()
{
// Create a request and dependent object(s).
var updateClusterDetails = new Oci.ContainerengineService.Models.UpdateClusterDetails
{
Name = "EXAMPLE-name-Value",
KubernetesVersion = "EXAMPLE-kubernetesVersion-Value",
Options = new Oci.ContainerengineService.Models.UpdateClusterOptionsDetails
{
AdmissionControllerOptions = new Oci.ContainerengineService.Models.AdmissionControllerOptions
{
IsPodSecurityPolicyEnabled = false
},
PersistentVolumeConfig = new Oci.ContainerengineService.Models.PersistentVolumeConfigDetails
{
FreeformTags = new Dictionary<string, string>()
{
{
"EXAMPLE_KEY_6qRCa",
"EXAMPLE_VALUE_XgjVX148I3sLdOYHiCB1"
}
},
DefinedTags = new Dictionary<string, Dictionary<string, Object>>()
{
{
"EXAMPLE_KEY_G5uiB",
new Dictionary<string, Object>()
{
{
"EXAMPLE_KEY_tQOct",
"EXAMPLE--Value"
}
}
}
}
},
ServiceLbConfig = new Oci.ContainerengineService.Models.ServiceLbConfigDetails
{
FreeformTags = new Dictionary<string, string>()
{
{
"EXAMPLE_KEY_lQxlo",
"EXAMPLE_VALUE_AO5lIlwPVFVvd7CvgmC9"
}
},
DefinedTags = new Dictionary<string, Dictionary<string, Object>>()
{
{
"EXAMPLE_KEY_pD2P0",
new Dictionary<string, Object>()
{
{
"EXAMPLE_KEY_tjABf",
"EXAMPLE--Value"
}
}
}
},
BackendNsgIds = new List<string>
{
"EXAMPLE--Value"
}
},
OpenIdConnectTokenAuthenticationConfig = new Oci.ContainerengineService.Models.OpenIdConnectTokenAuthenticationConfig
{
IssuerUrl = "EXAMPLE-issuerUrl-Value",
ClientId = "ocid1.test.oc1..<unique_ID>EXAMPLE-clientId-Value",
UsernameClaim = "EXAMPLE-usernameClaim-Value",
UsernamePrefix = "EXAMPLE-usernamePrefix-Value",
GroupsClaim = "EXAMPLE-groupsClaim-Value",
GroupsPrefix = "EXAMPLE-groupsPrefix-Value",
RequiredClaims = new List<Oci.ContainerengineService.Models.KeyValue>
{
new Oci.ContainerengineService.Models.KeyValue
{
Key = "EXAMPLE-key-Value",
Value = "EXAMPLE-value-Value"
}
},
CaCertificate = "EXAMPLE-caCertificate-Value",
SigningAlgorithms = new List<string>
{
"EXAMPLE--Value"
},
IsOpenIdConnectAuthEnabled = false,
ConfigurationFile = "EXAMPLE-configurationFile-Value"
},
OpenIdConnectDiscovery = new Oci.ContainerengineService.Models.OpenIdConnectDiscovery
{
IsOpenIdConnectDiscoveryEnabled = false
}
},
FreeformTags = new Dictionary<string, string>()
{
{
"EXAMPLE_KEY_rR4zz",
"EXAMPLE_VALUE_CwK2N4N1J5Ur3DkfX8GJ"
}
},
DefinedTags = new Dictionary<string, Dictionary<string, Object>>()
{
{
"EXAMPLE_KEY_Vj20I",
new Dictionary<string, Object>()
{
{
"EXAMPLE_KEY_F6WC0",
"EXAMPLE--Value"
}
}
}
},
ImagePolicyConfig = new Oci.ContainerengineService.Models.UpdateImagePolicyConfigDetails
{
IsPolicyEnabled = true,
KeyDetails = new List<Oci.ContainerengineService.Models.KeyDetails>
{
new Oci.ContainerengineService.Models.KeyDetails
{
KmsKeyId = "ocid1.test.oc1..<unique_ID>EXAMPLE-kmsKeyId-Value"
}
}
},
Type = Oci.ContainerengineService.Models.ClusterType.BasicCluster
};
var updateClusterRequest = new Oci.ContainerengineService.Requests.UpdateClusterRequest
{
ClusterId = "ocid1.test.oc1..<unique_ID>EXAMPLE-clusterId-Value",
UpdateClusterDetails = updateClusterDetails,
IfMatch = "EXAMPLE-ifMatch-Value",
OpcRequestId = "RQSV7JHSKLY6D2IKNCAA<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 ContainerEngineClient(provider, new ClientConfiguration()))
{
var response = await client.UpdateCluster(updateClusterRequest);
// Retrieve value from the response.
var versionValue = response.httpResponseMessage.Version;
}
}
catch (Exception e)
{
Console.WriteLine($"UpdateCluster Failed with {e.Message}");
throw e;
}
}
}
}