mirror of https://github.com/apache/jclouds.git
Move static methods out of SnapshotPolicySchedule into new class util.SnapshotPolicySchedules (and fix the FIXMEs and a missing license header at the same time)
This commit is contained in:
parent
1ba06c8973
commit
b69f27a9b8
|
@ -1,32 +1,35 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.cloudstack.domain;
|
||||
|
||||
/**
|
||||
* Describes the schedule of a snapshot policy.
|
||||
*
|
||||
* @see org.jclouds.cloudstack.util.SnapshotPolicySchedules
|
||||
* @author Richard Downer
|
||||
*/
|
||||
public class SnapshotPolicySchedule {
|
||||
|
||||
public static SnapshotPolicySchedule hourly(int minute) {
|
||||
return new SnapshotPolicySchedule(Snapshot.Interval.HOURLY, "FIXME");
|
||||
}
|
||||
|
||||
public static SnapshotPolicySchedule daily(int hour, int minute) {
|
||||
return new SnapshotPolicySchedule(Snapshot.Interval.DAILY, "FIXME");
|
||||
}
|
||||
|
||||
public static SnapshotPolicySchedule weekly(int day, int hour, int minute) {
|
||||
return new SnapshotPolicySchedule(Snapshot.Interval.WEEKLY, "FIXME");
|
||||
}
|
||||
|
||||
public static SnapshotPolicySchedule monthly(int day, int hour, int minute) {
|
||||
return new SnapshotPolicySchedule(Snapshot.Interval.MONTHLY, String.format("%02d:%02d:%02d", minute, hour, day));
|
||||
}
|
||||
|
||||
private Snapshot.Interval interval;
|
||||
private String time;
|
||||
|
||||
private SnapshotPolicySchedule(Snapshot.Interval interval, String time) {
|
||||
public SnapshotPolicySchedule(Snapshot.Interval interval, String time) {
|
||||
this.interval = interval;
|
||||
this.time = time;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.cloudstack.util;
|
||||
|
||||
import org.jclouds.cloudstack.domain.Snapshot;
|
||||
import org.jclouds.cloudstack.domain.SnapshotPolicySchedule;
|
||||
|
||||
/**
|
||||
* Methods to create SnapshotPolicySchedule objects in the format required by Cloudstack.
|
||||
*
|
||||
* @author Richard Downer
|
||||
*/
|
||||
public class SnapshotPolicySchedules {
|
||||
public static SnapshotPolicySchedule hourly(int minute) {
|
||||
return new SnapshotPolicySchedule(Snapshot.Interval.HOURLY, String.format("%02d", minute));
|
||||
}
|
||||
|
||||
public static SnapshotPolicySchedule daily(int hour, int minute) {
|
||||
return new SnapshotPolicySchedule(Snapshot.Interval.DAILY, String.format("%02d:%02d", minute, hour));
|
||||
}
|
||||
|
||||
public static SnapshotPolicySchedule weekly(int day, int hour, int minute) {
|
||||
return new SnapshotPolicySchedule(Snapshot.Interval.WEEKLY, String.format("%02d:%02d:%02d", minute, hour, day));
|
||||
}
|
||||
|
||||
public static SnapshotPolicySchedule monthly(int day, int hour, int minute) {
|
||||
return new SnapshotPolicySchedule(Snapshot.Interval.MONTHLY, String.format("%02d:%02d:%02d", minute, hour, day));
|
||||
}
|
||||
}
|
|
@ -26,6 +26,7 @@ import org.jclouds.cloudstack.domain.SnapshotPolicySchedule;
|
|||
import org.jclouds.cloudstack.options.CreateSnapshotOptions;
|
||||
import org.jclouds.cloudstack.options.ListSnapshotPoliciesOptions;
|
||||
import org.jclouds.cloudstack.options.ListSnapshotsOptions;
|
||||
import org.jclouds.cloudstack.util.SnapshotPolicySchedules;
|
||||
import org.jclouds.functions.IdentityFunction;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
||||
|
@ -149,7 +150,7 @@ public class SnapshotAsyncClientTest extends BaseCloudStackAsyncClientTest<Snaps
|
|||
|
||||
public void testCreateSnapshotPolicy() throws NoSuchMethodException {
|
||||
Method method = SnapshotAsyncClient.class.getMethod("createSnapshotPolicy", SnapshotPolicySchedule.class, long.class, String.class, long.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, SnapshotPolicySchedule.monthly(5, 6, 7), 10, "UTC", 12);
|
||||
HttpRequest httpRequest = processor.createRequest(method, SnapshotPolicySchedules.monthly(5, 6, 7), 10, "UTC", 12);
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET http://localhost:8080/client/api?response=json&command=createSnapshotPolicy&timezone=UTC&maxsnaps=10&volumeid=12&intervaltype=MONTHLY&schedule=07%3A06%3A05 HTTP/1.1");
|
||||
|
|
Loading…
Reference in New Issue