// 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.FilestorageService;
using Oci.Common;
using Oci.Common.Auth;

namespace Oci.Sdk.DotNet.Example.Filestorage
{
    public class UpdateFilesystemSnapshotPolicyExample
    {
        public static async Task Main()
        {
            // Create a request and dependent object(s).
			var updateFilesystemSnapshotPolicyDetails = new Oci.FilestorageService.Models.UpdateFilesystemSnapshotPolicyDetails
			{
				DisplayName = "EXAMPLE-displayName-Value",
				PolicyPrefix = "EXAMPLE-policyPrefix-Value",
				Schedules = new List<Oci.FilestorageService.Models.SnapshotSchedule>
				{
					new Oci.FilestorageService.Models.SnapshotSchedule
					{
						SchedulePrefix = "EXAMPLE-schedulePrefix-Value",
						TimeScheduleStart = DateTime.Parse("10/19/2021 19:24:13"),
						Period = Oci.FilestorageService.Models.SnapshotSchedule.PeriodEnum.Hourly,
						RetentionDurationInSeconds = 1000,
						TimeZone = Oci.FilestorageService.Models.SnapshotSchedule.TimeZoneEnum.RegionalDataCenterTime,
						HourOfDay = 10,
						DayOfWeek = Oci.FilestorageService.Models.SnapshotSchedule.DayOfWeekEnum.Sunday,
						DayOfMonth = 24,
						Month = Oci.FilestorageService.Models.SnapshotSchedule.MonthEnum.April
					}
				},
				FreeformTags = new Dictionary<string, string>()
				{
					{
						"EXAMPLE_KEY_4N0IP", 
						"EXAMPLE_VALUE_aEMLTZxpqVt9M7pr38Jc"
					}
				},
				DefinedTags = new Dictionary<string, Dictionary<string, Object>>()
				{
					{
						"EXAMPLE_KEY_wHPxK", 
						new Dictionary<string, Object>()
						{
							{
								"EXAMPLE_KEY_FIMIq", 
								"EXAMPLE--Value"
							}
						}
					}
				}
			};
			var updateFilesystemSnapshotPolicyRequest = new Oci.FilestorageService.Requests.UpdateFilesystemSnapshotPolicyRequest
			{
				FilesystemSnapshotPolicyId = "ocid1.test.oc1..<unique_ID>EXAMPLE-filesystemSnapshotPolicyId-Value",
				UpdateFilesystemSnapshotPolicyDetails = updateFilesystemSnapshotPolicyDetails,
				IfMatch = "EXAMPLE-ifMatch-Value",
				OpcRequestId = "AZXOWHIDTO4BTIFVN0ZZ<unique_ID>",
				IsLockOverride = false
			};

            // 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 FileStorageClient(provider, new ClientConfiguration()))
				{
					var response = await client.UpdateFilesystemSnapshotPolicy(updateFilesystemSnapshotPolicyRequest);
					// Retrieve value from the response.
					var id = response.FilesystemSnapshotPolicy.Id;
				}
            }
            catch (Exception e)
            {
                Console.WriteLine($"UpdateFilesystemSnapshotPolicy Failed with {e.Message}");
                throw e;
            }
        }

    }
}

Was this article helpful?