# SolidFire .NET SDK Examples
These examples walk through all interactions with a Schedule. Schedules control when automatic Snapshots will be taken of Volumes on the SolidFire cluster.
Examples for:
Further documentation for each method and type can be found at our .NET documentation site.
ListSchedules method documentation
To list all the schedules on a cluster:
/ Create connection to SF Cluster
var sfe = ElementFactory.Create("ip-address-of-cluster", "username", "password");
// send the request and gather the result
var listSchedulesResult = sfe.ListSchedules();
// iterate the schedules array on the result object and display each Schedule
foreach(Schedule schedule in listSchedulesResult.Schedules)
{
Console.WriteLine(schedule.ToString());
}
GetSchedule method documentation
To get a single schedule you must have the ScheduleID
:
// Create connection to SF Cluster
var sfe = ElementFactory.Create("ip-address-of-cluster", "username", "password");
// send the request and gather the result
var getSchedulesResult = sfe.GetSchedule(56);
// display the schedule from the result object
Console.WriteLine(getSchedulesResult.Schedule.ToString());
CreateSchedule method documentation
In order for automatic snapshots to be taken, you need to create a Schedule. There are three types of schedules that can be created:
All three types of schedules are demonstrated here:
This type of Schedule will base snapshots on a time interval frequency. Each Snapshot will be taken after the specified amount of time has passed. Control the duration by setting any mix of days
, hours
, and minutes
on the TimeIntervalFrequency object.
var schedule = new Schedule();
schedule.Name = "SnapshotEvery3AndAHalfDays";
schedule.Frequency = new TimeIntervalFrequency()
{
Days = 3,
Hours = 12
};
This type of Schedule will base snapshots on a weekly frequency. Each Snapshot will be taken on the specified days of the week at the time specified. Control the schedule by setting weekdays
, hours
, and minutes
on the DaysOfWeekFrequency object. Use the Weekday enum for each day of the week desired.
var schedule = new Schedule();
schedule.Name = "SnapshotOnMonWedFriAt3am";
schedule.Frequency = new DaysOfWeekFrequency()
{
Weekdays = new Weekday[] {Weekday.Monday, Weekday.Wednesday, Weekday.Friday},
Hours = 3
};
This type of Schedule will base snapshots on a monthly frequency. Each Snapshot will be taken on the specified month days at the time specified in the hours and minutes properties. Control the schedule by setting monthdays
, hours
, and minutes
on the DaysOfMonthFrequency object.
var schedule = new Schedule();
schedule.Name = "SnapshotOn7th14thAnd21stAt0130Hours";
schedule.Frequency = new DaysOfMonthFrequency()
{
Monthdays = new long[] {7, 14, 21},
Hours = 3,
Minutes = 30
};
After creating the Schedule and setting the frequency to Time Interval, Days Of Week, or Days Of Month, complete the object by setting the ScheduleInfo
property. This controls information about the resulting Snapshot such as which volumes are in it, its name, and how long it should be retained.
Continuing on with the Time Interval example from above:
var schedule = new Schedule();
schedule.Name = "SnapshotEvery12Hours";
schedule.Frequency = new TimeIntervalFrequency()
{
Hours = 12
};
schedule.ScheduleInfo = new ScheduleInfo()
{
VolumeIDs = new long[] {1, 3, 5},
SnapshotName = "12th hour snapshot",
Retention = "72:00:00" // in HH:mm:ss format
};
// When should the schedule start?
schedule.StartingDate = "2016-12-01T00:00:00Z"; // in UTC format
// Create connection to SF Cluster
var sfe = ElementFactory.Create("ip-address-of-cluster", "username", "password");
// call the CreateSchedule method with the newly created schedule object
var createScheduleResult = sfe.CreateSchedule(schedule);
// Grab the schedule ID from the result object
var newScheduleId = createScheduleResult.ScheduleID;
At this point we have created a new Schedule called “SnapshotEvery12Hours” that creates a Snapshot whose name is prepended with “12th hour snapshot” every 12 hours for volumes 1, 3, and 5 being retained for 72 hours.
ModifySchedule method documentation
To modify a Schedule, first you must have a valid Schedule object with its ScheduleID
set. You can create one manually but it is preferred to retrieve it from the cluster, modify the properties needed and then send it back. Here is an example:
// Create connection to SF Cluster
var sfe = ElementFactory.Create("ip-address-of-cluster", "username", "password";
// send the requst with the scheduleID and gather the result
var getScheduleResult = sfe.GetSchedule(newScheduleId);
// set a schedule variable from the Schedule in the result for ease of use
var schedule = getScheduleResult.Schedule;
// set paused to true in order to pause the schedule
schedule.Paused = true;
// send the request to modify this schedule
sfe.ModifySchedule(schedule);