001package com.box.sdkgen.managers.legalholdpolicies; 002 003import com.box.sdkgen.internal.NullableFieldTracker; 004import com.box.sdkgen.internal.SerializableObject; 005import com.box.sdkgen.internal.utils.DateTimeUtils; 006import com.fasterxml.jackson.annotation.JsonFilter; 007import com.fasterxml.jackson.annotation.JsonProperty; 008import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 009import com.fasterxml.jackson.databind.annotation.JsonSerialize; 010import java.time.OffsetDateTime; 011import java.util.Objects; 012 013@JsonFilter("nullablePropertyFilter") 014public class CreateLegalHoldPolicyRequestBody extends SerializableObject { 015 016 /** The name of the policy. */ 017 @JsonProperty("policy_name") 018 protected final String policyName; 019 020 /** A description for the policy. */ 021 protected String description; 022 023 /** 024 * The filter start date. 025 * 026 * <p>When this policy is applied using a `custodian` legal hold assignments, it will only apply 027 * to file versions created or uploaded inside of the date range. Other assignment types, such as 028 * folders and files, will ignore the date filter. 029 * 030 * <p>Required if `is_ongoing` is set to `false`. 031 */ 032 @JsonProperty("filter_started_at") 033 @JsonSerialize(using = DateTimeUtils.DateTimeSerializer.class) 034 @JsonDeserialize(using = DateTimeUtils.DateTimeDeserializer.class) 035 protected OffsetDateTime filterStartedAt; 036 037 /** 038 * The filter end date. 039 * 040 * <p>When this policy is applied using a `custodian` legal hold assignments, it will only apply 041 * to file versions created or uploaded inside of the date range. Other assignment types, such as 042 * folders and files, will ignore the date filter. 043 * 044 * <p>Required if `is_ongoing` is set to `false`. 045 */ 046 @JsonProperty("filter_ended_at") 047 @JsonSerialize(using = DateTimeUtils.DateTimeSerializer.class) 048 @JsonDeserialize(using = DateTimeUtils.DateTimeDeserializer.class) 049 protected OffsetDateTime filterEndedAt; 050 051 /** 052 * Whether new assignments under this policy should continue applying to files even after 053 * initialization. 054 * 055 * <p>When this policy is applied using a legal hold assignment, it will continue applying the 056 * policy to any new file versions even after it has been applied. 057 * 058 * <p>For example, if a legal hold assignment is placed on a user today, and that user uploads a 059 * file tomorrow, that file will get held. This will continue until the policy is retired. 060 * 061 * <p>Required if no filter dates are set. 062 */ 063 @JsonProperty("is_ongoing") 064 protected Boolean isOngoing; 065 066 public CreateLegalHoldPolicyRequestBody(@JsonProperty("policy_name") String policyName) { 067 super(); 068 this.policyName = policyName; 069 } 070 071 protected CreateLegalHoldPolicyRequestBody(Builder builder) { 072 super(); 073 this.policyName = builder.policyName; 074 this.description = builder.description; 075 this.filterStartedAt = builder.filterStartedAt; 076 this.filterEndedAt = builder.filterEndedAt; 077 this.isOngoing = builder.isOngoing; 078 markNullableFieldsAsSet(builder.getExplicitlySetNullableFields()); 079 } 080 081 public String getPolicyName() { 082 return policyName; 083 } 084 085 public String getDescription() { 086 return description; 087 } 088 089 public OffsetDateTime getFilterStartedAt() { 090 return filterStartedAt; 091 } 092 093 public OffsetDateTime getFilterEndedAt() { 094 return filterEndedAt; 095 } 096 097 public Boolean getIsOngoing() { 098 return isOngoing; 099 } 100 101 @Override 102 public boolean equals(Object o) { 103 if (this == o) { 104 return true; 105 } 106 if (o == null || getClass() != o.getClass()) { 107 return false; 108 } 109 CreateLegalHoldPolicyRequestBody casted = (CreateLegalHoldPolicyRequestBody) o; 110 return Objects.equals(policyName, casted.policyName) 111 && Objects.equals(description, casted.description) 112 && Objects.equals(filterStartedAt, casted.filterStartedAt) 113 && Objects.equals(filterEndedAt, casted.filterEndedAt) 114 && Objects.equals(isOngoing, casted.isOngoing); 115 } 116 117 @Override 118 public int hashCode() { 119 return Objects.hash(policyName, description, filterStartedAt, filterEndedAt, isOngoing); 120 } 121 122 @Override 123 public String toString() { 124 return "CreateLegalHoldPolicyRequestBody{" 125 + "policyName='" 126 + policyName 127 + '\'' 128 + ", " 129 + "description='" 130 + description 131 + '\'' 132 + ", " 133 + "filterStartedAt='" 134 + filterStartedAt 135 + '\'' 136 + ", " 137 + "filterEndedAt='" 138 + filterEndedAt 139 + '\'' 140 + ", " 141 + "isOngoing='" 142 + isOngoing 143 + '\'' 144 + "}"; 145 } 146 147 public static class Builder extends NullableFieldTracker { 148 149 protected final String policyName; 150 151 protected String description; 152 153 protected OffsetDateTime filterStartedAt; 154 155 protected OffsetDateTime filterEndedAt; 156 157 protected Boolean isOngoing; 158 159 public Builder(String policyName) { 160 super(); 161 this.policyName = policyName; 162 } 163 164 public Builder description(String description) { 165 this.description = description; 166 return this; 167 } 168 169 public Builder filterStartedAt(OffsetDateTime filterStartedAt) { 170 this.filterStartedAt = filterStartedAt; 171 return this; 172 } 173 174 public Builder filterEndedAt(OffsetDateTime filterEndedAt) { 175 this.filterEndedAt = filterEndedAt; 176 return this; 177 } 178 179 public Builder isOngoing(Boolean isOngoing) { 180 this.isOngoing = isOngoing; 181 return this; 182 } 183 184 public CreateLegalHoldPolicyRequestBody build() { 185 return new CreateLegalHoldPolicyRequestBody(this); 186 } 187 } 188}