Search in sources :

Example 1 with GcsBucketLifecycle

use of bio.terra.cli.serialization.userfacing.input.GcsBucketLifecycle in project terra-cli by DataBiosphere.

the class WorkspaceManagerService method fromCLIObject.

/**
 * This method converts this CLI-defined POJO class into a list of WSM client library-defined
 * request objects.
 *
 * @return list of lifecycle rules in the format expected by the WSM client library
 */
private static List<GcpGcsBucketLifecycleRule> fromCLIObject(GcsBucketLifecycle lifecycle) {
    List<GcpGcsBucketLifecycleRule> wsmLifecycleRules = new ArrayList<>();
    for (GcsBucketLifecycle.Rule rule : lifecycle.rule) {
        GcpGcsBucketLifecycleRuleAction action = new GcpGcsBucketLifecycleRuleAction().type(rule.action.type.toWSMEnum());
        if (rule.action.storageClass != null) {
            action.storageClass(rule.action.storageClass.toWSMEnum());
        }
        GcpGcsBucketLifecycleRuleCondition condition = new GcpGcsBucketLifecycleRuleCondition().age(rule.condition.age).createdBefore(dateAtMidnightAndUTC(rule.condition.createdBefore)).customTimeBefore(dateAtMidnightAndUTC(rule.condition.customTimeBefore)).daysSinceCustomTime(rule.condition.daysSinceCustomTime).daysSinceNoncurrentTime(rule.condition.daysSinceNoncurrentTime).live(rule.condition.isLive).matchesStorageClass(rule.condition.matchesStorageClass.stream().map(GcsStorageClass::toWSMEnum).collect(Collectors.toList())).noncurrentTimeBefore(dateAtMidnightAndUTC(rule.condition.noncurrentTimeBefore)).numNewerVersions(rule.condition.numNewerVersions);
        GcpGcsBucketLifecycleRule lifecycleRuleRequestObject = new GcpGcsBucketLifecycleRule().action(action).condition(condition);
        wsmLifecycleRules.add(lifecycleRuleRequestObject);
    }
    return wsmLifecycleRules;
}
Also used : GcsStorageClass(bio.terra.cli.serialization.userfacing.input.GcsStorageClass) GcpGcsBucketLifecycleRuleCondition(bio.terra.workspace.model.GcpGcsBucketLifecycleRuleCondition) GcpGcsBucketLifecycleRuleAction(bio.terra.workspace.model.GcpGcsBucketLifecycleRuleAction) GcpGcsBucketLifecycleRule(bio.terra.workspace.model.GcpGcsBucketLifecycleRule) ArrayList(java.util.ArrayList) GcsBucketLifecycle(bio.terra.cli.serialization.userfacing.input.GcsBucketLifecycle) GcpGcsBucketLifecycle(bio.terra.workspace.model.GcpGcsBucketLifecycle)

Aggregations

GcsBucketLifecycle (bio.terra.cli.serialization.userfacing.input.GcsBucketLifecycle)1 GcsStorageClass (bio.terra.cli.serialization.userfacing.input.GcsStorageClass)1 GcpGcsBucketLifecycle (bio.terra.workspace.model.GcpGcsBucketLifecycle)1 GcpGcsBucketLifecycleRule (bio.terra.workspace.model.GcpGcsBucketLifecycleRule)1 GcpGcsBucketLifecycleRuleAction (bio.terra.workspace.model.GcpGcsBucketLifecycleRuleAction)1 GcpGcsBucketLifecycleRuleCondition (bio.terra.workspace.model.GcpGcsBucketLifecycleRuleCondition)1 ArrayList (java.util.ArrayList)1