Class DtoConverters
- java.lang.Object
-
- com.netflix.genie.common.internal.dtos.v4.converters.DtoConverters
-
public final class DtoConverters extends java.lang.Object
Utility class to help converting between V3 and V4 DTOs during migration period.- Since:
- 4.0.0
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
GENIE_ID_PREFIX
The Genie 3 prefix for resource ID added to the set of tags by the system.static java.lang.String
GENIE_NAME_PREFIX
The Genie 3 prefix for resource names added to the set of tags by the system.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ClusterCriteria
toClusterCriteria(Criterion criterion)
Convert the givencriterion
to a V3ClusterCriteria
object.static Application
toV3Application(Application v4Application)
Convert a V4 Application DTO to a V3 application DTO.static ApplicationStatus
toV3ApplicationStatus(ApplicationStatus v4Status)
Convert a V4ApplicationStatus
to a V3ApplicationStatus
.static Cluster
toV3Cluster(Cluster v4Cluster)
static ClusterStatus
toV3ClusterStatus(ClusterStatus v4Status)
Convert a V4ClusterStatus
to a V3ClusterStatus
.static Command
toV3Command(Command v4Command)
static CommandStatus
toV3CommandStatus(CommandStatus v4Status)
Convert a V4CommandStatus
to a V3CommandStatus
.static com.google.common.collect.ImmutableSet<java.lang.String>
toV3CriterionTags(Criterion criterion)
Convert a given V4criterion
to the equivalent representation in V3 set of tags.static JobRequest
toV3JobRequest(JobRequest v4JobRequest)
Helper method to convert a v4 JobRequest to a v3 job request.static JobStatus
toV3JobStatus(JobStatus v4Status)
static com.google.common.collect.ImmutableSet<java.lang.String>
toV3Tags(java.lang.String id, java.lang.String name, java.util.Set<java.lang.String> tags)
Convert the V4 values supplied to how the tags would have looked in Genie V3.static Application
toV4Application(Application v3Application)
Convert a V3 Application DTO to a V4 Application DTO.static ApplicationRequest
toV4ApplicationRequest(Application v3Application)
Convert a V3Application
to a corresponding V4ApplicationRequest
.static ApplicationStatus
toV4ApplicationStatus(ApplicationStatus v3Status)
Convert a V3ApplicationStatus
to a V4ApplicationStatus
.static ApplicationStatus
toV4ApplicationStatus(java.lang.String status)
Attempt to convert an Application status string into a known enumeration value fromApplicationStatus
.static Cluster
toV4Cluster(Cluster v3Cluster)
static ClusterRequest
toV4ClusterRequest(Cluster v3Cluster)
Convert aCluster
to a V4ClusterRequest
.static ClusterStatus
toV4ClusterStatus(ClusterStatus v3Status)
Convert a V3ClusterStatus
to a V4ClusterStatus
.static ClusterStatus
toV4ClusterStatus(java.lang.String status)
Attempt to convert a Cluster status string into a known enumeration value fromClusterStatus
.static Command
toV4Command(Command v3Command)
static CommandRequest
toV4CommandRequest(Command v3Command)
Convert a V3Command
to a V4CommandRequest
.static CommandStatus
toV4CommandStatus(CommandStatus v3Status)
Convert a V3CommandStatus
to a V4CommandStatus
.static CommandStatus
toV4CommandStatus(java.lang.String status)
Attempt to convert a Command status string into a known enumeration value fromCommandStatus
.static Criterion
toV4Criterion(ClusterCriteria criteria)
Convert a V3 Cluster Criteria to a V4 Criterion.static Criterion
toV4Criterion(java.util.Set<java.lang.String> tags)
Convert a set of V3 criterion tags to a V4 criterion object.static JobRequest
toV4JobRequest(JobRequest v3JobRequest)
Convert a V3 Job Request to a V4 Job Request.static JobStatus
toV4JobStatus(JobStatus v3Status)
static JobStatus
toV4JobStatus(java.lang.String status)
Attempt to convert a Job status string into a known enumeration value fromJobStatus
.
-
-
-
Field Detail
-
GENIE_ID_PREFIX
public static final java.lang.String GENIE_ID_PREFIX
The Genie 3 prefix for resource ID added to the set of tags by the system.- See Also:
- Constant Field Values
-
GENIE_NAME_PREFIX
public static final java.lang.String GENIE_NAME_PREFIX
The Genie 3 prefix for resource names added to the set of tags by the system.- See Also:
- Constant Field Values
-
-
Method Detail
-
toV4ApplicationRequest
public static ApplicationRequest toV4ApplicationRequest(Application v3Application) throws java.lang.IllegalArgumentException
Convert a V3Application
to a corresponding V4ApplicationRequest
.- Parameters:
v3Application
- The application to convert- Returns:
- An immutable
ApplicationRequest
instance - Throws:
java.lang.IllegalArgumentException
- If any field is invalid during the conversion
-
toV4Application
public static Application toV4Application(Application v3Application) throws java.lang.IllegalArgumentException
Convert a V3 Application DTO to a V4 Application DTO.- Parameters:
v3Application
- The V3 application to convert- Returns:
- The V4 application representation of the data in the V3 DTO
- Throws:
java.lang.IllegalArgumentException
- On invalid argument to one of the fields
-
toV3Application
public static Application toV3Application(Application v4Application) throws java.lang.IllegalArgumentException
Convert a V4 Application DTO to a V3 application DTO.- Parameters:
v4Application
- The V4 application to convert- Returns:
- The V3 application representation of the data in the V4 DTO
- Throws:
java.lang.IllegalArgumentException
- On invalid argument for one of the fields
-
toV4ClusterRequest
public static ClusterRequest toV4ClusterRequest(Cluster v3Cluster)
Convert aCluster
to a V4ClusterRequest
.- Parameters:
v3Cluster
- The V3 cluster instance to convert- Returns:
- An immutable
ClusterRequest
instance - Throws:
java.lang.IllegalArgumentException
- On any invalid field during conversion
-
toV4Cluster
public static Cluster toV4Cluster(Cluster v3Cluster) throws java.lang.IllegalArgumentException
- Parameters:
v3Cluster
- The cluster to convert- Returns:
- The V4 representation of the cluster
- Throws:
java.lang.IllegalArgumentException
- On any invalid field during conversion
-
toV3Cluster
public static Cluster toV3Cluster(Cluster v4Cluster) throws java.lang.IllegalArgumentException
- Parameters:
v4Cluster
- The cluster to convert- Returns:
- The v3 cluster
- Throws:
java.lang.IllegalArgumentException
- On any invalid field during conversion
-
toV4CommandRequest
public static CommandRequest toV4CommandRequest(Command v3Command) throws java.lang.IllegalArgumentException
Convert a V3Command
to a V4CommandRequest
.- Parameters:
v3Command
- The V3 command to convert- Returns:
- An immutable
CommandRequest
instance - Throws:
java.lang.IllegalArgumentException
- On any invalid field during conversion
-
toV4Command
public static Command toV4Command(Command v3Command) throws java.lang.IllegalArgumentException
- Parameters:
v3Command
- The V3 Command to convert- Returns:
- The V4 representation of the supplied command
- Throws:
java.lang.IllegalArgumentException
- On any invalid field during conversion
-
toV3Command
public static Command toV3Command(Command v4Command) throws java.lang.IllegalArgumentException
- Parameters:
v4Command
- The V4 command to convert- Returns:
- An immutable V3 Command instance
- Throws:
java.lang.IllegalArgumentException
- On any invalid field during conversion
-
toV4JobRequest
public static JobRequest toV4JobRequest(JobRequest v3JobRequest) throws GeniePreconditionException
Convert a V3 Job Request to a V4 Job Request.- Parameters:
v3JobRequest
- The v3 request to convert- Returns:
- The V4 version of the information contained in the V3 request
- Throws:
GeniePreconditionException
- When the criteria is invalid
-
toV3JobRequest
public static JobRequest toV3JobRequest(JobRequest v4JobRequest)
Helper method to convert a v4 JobRequest to a v3 job request.- Parameters:
v4JobRequest
- The v4 job request instance- Returns:
- The v3 job request instance
-
toV3Tags
public static com.google.common.collect.ImmutableSet<java.lang.String> toV3Tags(java.lang.String id, java.lang.String name, java.util.Set<java.lang.String> tags)
Convert the V4 values supplied to how the tags would have looked in Genie V3.- Parameters:
id
- The id of the resourcename
- The name of the resourcetags
- The tags on the resource- Returns:
- The set of tags as they would have been in Genie 3
-
toV3CriterionTags
public static com.google.common.collect.ImmutableSet<java.lang.String> toV3CriterionTags(Criterion criterion)
Convert a given V4criterion
to the equivalent representation in V3 set of tags.- Parameters:
criterion
- TheCriterion
to convert- Returns:
- A set of String's representing the criterion tags as they would have looked in V3
-
toClusterCriteria
public static ClusterCriteria toClusterCriteria(Criterion criterion)
Convert the givencriterion
to a V3ClusterCriteria
object.- Parameters:
criterion
- TheCriterion
to convert- Returns:
- The V3 criteria object
-
toV4Criterion
public static Criterion toV4Criterion(ClusterCriteria criteria) throws GeniePreconditionException
Convert a V3 Cluster Criteria to a V4 Criterion.- Parameters:
criteria
- The criteria to convert- Returns:
- The criterion
- Throws:
GeniePreconditionException
- If the criteria converts to an invalid criterion
-
toV4Criterion
public static Criterion toV4Criterion(java.util.Set<java.lang.String> tags) throws GeniePreconditionException
Convert a set of V3 criterion tags to a V4 criterion object.- Parameters:
tags
- The tags to convert- Returns:
- The V4 criterion
- Throws:
GeniePreconditionException
- If the tags convert to an invalid criterion
-
toV4ApplicationStatus
public static ApplicationStatus toV4ApplicationStatus(ApplicationStatus v3Status) throws java.lang.IllegalArgumentException
Convert a V3ApplicationStatus
to a V4ApplicationStatus
.- Parameters:
v3Status
- The V3 status to convert- Returns:
- The V4 status the V3 status maps to
- Throws:
java.lang.IllegalArgumentException
- if the V3 status has no current V4 mapping
-
toV4ApplicationStatus
public static ApplicationStatus toV4ApplicationStatus(java.lang.String status) throws java.lang.IllegalArgumentException
Attempt to convert an Application status string into a known enumeration value fromApplicationStatus
.- Parameters:
status
- The status string. Not null or empty.- Returns:
- An
ApplicationStatus
instance - Throws:
java.lang.IllegalArgumentException
- If the string couldn't be converted
-
toV3ApplicationStatus
public static ApplicationStatus toV3ApplicationStatus(ApplicationStatus v4Status) throws java.lang.IllegalArgumentException
Convert a V4ApplicationStatus
to a V3ApplicationStatus
.- Parameters:
v4Status
- The V4 status to convert- Returns:
- The V3 status the V4 status maps to
- Throws:
java.lang.IllegalArgumentException
- If the V4 status has no current V3 mapping
-
toV4CommandStatus
public static CommandStatus toV4CommandStatus(CommandStatus v3Status) throws java.lang.IllegalArgumentException
Convert a V3CommandStatus
to a V4CommandStatus
.- Parameters:
v3Status
- The V3 status to convert- Returns:
- The V4 status the V3 status maps to
- Throws:
java.lang.IllegalArgumentException
- if the V3 status has no current V4 mapping
-
toV4CommandStatus
public static CommandStatus toV4CommandStatus(java.lang.String status) throws java.lang.IllegalArgumentException
Attempt to convert a Command status string into a known enumeration value fromCommandStatus
.- Parameters:
status
- The status string. Not null or empty.- Returns:
- An
CommandStatus
instance - Throws:
java.lang.IllegalArgumentException
- If the string couldn't be converted
-
toV3CommandStatus
public static CommandStatus toV3CommandStatus(CommandStatus v4Status) throws java.lang.IllegalArgumentException
Convert a V4CommandStatus
to a V3CommandStatus
.- Parameters:
v4Status
- The V4 status to convert- Returns:
- The V3 status the V4 status maps to
- Throws:
java.lang.IllegalArgumentException
- If the V4 status has no current V3 mapping
-
toV4ClusterStatus
public static ClusterStatus toV4ClusterStatus(ClusterStatus v3Status) throws java.lang.IllegalArgumentException
Convert a V3ClusterStatus
to a V4ClusterStatus
.- Parameters:
v3Status
- The V3 status to convert- Returns:
- The V4 status the V3 status maps to
- Throws:
java.lang.IllegalArgumentException
- if the V3 status has no current V4 mapping
-
toV4ClusterStatus
public static ClusterStatus toV4ClusterStatus(java.lang.String status) throws java.lang.IllegalArgumentException
Attempt to convert a Cluster status string into a known enumeration value fromClusterStatus
.- Parameters:
status
- The status string. Not null or empty.- Returns:
- An
ClusterStatus
instance - Throws:
java.lang.IllegalArgumentException
- If the string couldn't be converted
-
toV3ClusterStatus
public static ClusterStatus toV3ClusterStatus(ClusterStatus v4Status) throws java.lang.IllegalArgumentException
Convert a V4ClusterStatus
to a V3ClusterStatus
.- Parameters:
v4Status
- The V4 status to convert- Returns:
- The V3 status the V4 status maps to
- Throws:
java.lang.IllegalArgumentException
- If the V4 status has no current V3 mapping
-
toV4JobStatus
public static JobStatus toV4JobStatus(JobStatus v3Status) throws java.lang.IllegalArgumentException
- Parameters:
v3Status
- The V3 status to convert- Returns:
- The V4 status the V3 status maps to
- Throws:
java.lang.IllegalArgumentException
- if the V3 status has no current V4 mapping
-
toV3JobStatus
public static JobStatus toV3JobStatus(JobStatus v4Status) throws java.lang.IllegalArgumentException
- Parameters:
v4Status
- The V4 status to convert- Returns:
- The V3 status the V4 status maps to
- Throws:
java.lang.IllegalArgumentException
- If the V4 status has no current V3 mapping
-
toV4JobStatus
public static JobStatus toV4JobStatus(java.lang.String status) throws java.lang.IllegalArgumentException
Attempt to convert a Job status string into a known enumeration value fromJobStatus
.- Parameters:
status
- The status string. Not null or empty.- Returns:
- A
JobStatus
instance - Throws:
java.lang.IllegalArgumentException
- If the string couldn't be converted
-
-