All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.nutanix.dp1.mic.microseg.v4.operation.UpgradeJob Maven / Gradle / Ivy

The newest version!
/*
 * Generated file ..
 *
 * Product version: 4.0.1-beta-1
 *
 * Part of the Nutanix Microseg Versioned APIs
 *
 * (c) 2024 Nutanix Inc.  All rights reserved
 *
 */

package com.nutanix.dp1.mic.microseg.v4.operation;

import com.fasterxml.jackson.annotation.JsonAnySetter;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.AccessLevel;
import com.nutanix.devplatform.models.PrettyModeViews.*;
import com.fasterxml.jackson.annotation.JsonView;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.stream.Collectors;
import com.nutanix.dp1.mic.deserializers.MicObjectTypeTypedObject;

import javax.validation.constraints.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static com.nutanix.dp1.mic.deserializers.MicDeserializerUtils.*;


/**
 * __Request body for Config Upgrade__
 * 
 * It contains two fields:
 * - isDryRun
 * - spec
 * 
 * The spec can be one of two types based on isDryRun boolean value.
 * 
 * A sample request body with the flag set would look like this:
 * ```
 * {
 * "isDryRun": true,
 * "spec": {
 *   "policyNames" : [],
 *   "shouldIncludeSecureSubnetsInfo" : false
 *   }
 * }
 * ```
 * 
 * A sample request body with the flag unset would look like this:
 * ```
 * {
 * "isDryRun": false,
 * "spec": {
 *   "isForceMonitor" : true,
 *   "shouldUpgradeSecuredSubnetsOnly" : false
 *   }
 * }
 * ```
 * 
 */



@Data
@lombok.extern.slf4j.Slf4j
public class UpgradeJob implements java.io.Serializable, MicObjectTypeTypedObject {

  

  public UpgradeJob() {

    this.$objectType = this.initialize$objectType();
    this.$reserved = new java.util.LinkedHashMap<>();
    this.$reserved.put("$fv", this.initialize$fv());
    this.$unknownFields = new java.util.LinkedHashMap<>();

  }

  @lombok.Builder(builderMethodName = "UpgradeJobBuilder")
  public UpgradeJob(Boolean isDryRun, Object spec) {
    this.$objectType = this.initialize$objectType();
    this.$reserved = new java.util.LinkedHashMap<>();
    this.$reserved.put("$fv", this.initialize$fv());
    this.$unknownFields = new java.util.LinkedHashMap<>();

    this.setIsDryRun(isDryRun);
    this.setSpecInWrapper(spec);
      }


  protected String initialize$objectType() {
    return "microseg.v4.operation.UpgradeJob";
  }


  protected String initialize$fv() {
    return "v4.r0.b1";
  }

  @JsonAnySetter
  private void setUndeserializedFields(String name, String value) {
    $unknownFields.put(name, value);
  }


  
  

  
    /**
    * If set to true, it will trigger a dry run of Flow configuration upgrade. As part of this dry run, the policies and subnets will not be upgraded.<br>
If set to false, the configuration upgrade is triggered.

    */
    
    @JsonProperty("isDryRun")
    public Boolean isDryRun = false;
  
  
    
    
    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
    @Getter
    private String $specItemDiscriminator = null;
    
    @Data
    @com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = OneOfSpecWrapper.OneOfSpecWrapperJsonDeserializer.class)
    public static class OneOfSpecWrapper {
    
    
      public OneOfSpecWrapper() {
      }
    
    
    
      public OneOfSpecWrapper(com.nutanix.dp1.mic.microseg.v4.operation.UpgradeSpec data) {
        this.oneOfType0 = data;

        this.discriminator = data.get$objectType();
        this.$objectType = data.get$objectType();
      }
      public OneOfSpecWrapper(com.nutanix.dp1.mic.microseg.v4.operation.DryRunSpec data) {
        this.oneOfType1 = data;

        this.discriminator = data.get$objectType();
        this.$objectType = data.get$objectType();
      }
    
      @com.nutanix.dp1.mic.annotations.MicJsonDeserializer
      private static class OneOfSpecWrapperJsonDeserializer extends com.nutanix.dp1.mic.deserializers.MicOneOfDeserializer  {
        private static final com.fasterxml.jackson.databind.type.TypeFactory TYPE_FACTORY = com.fasterxml.jackson.databind.type.TypeFactory.defaultInstance();
        private static final com.fasterxml.jackson.databind.JavaType ONE_OF_TYPE0 = TYPE_FACTORY.constructType(com.nutanix.dp1.mic.microseg.v4.operation.UpgradeSpec.class);
        private static final com.fasterxml.jackson.databind.JavaType ONE_OF_TYPE1 = TYPE_FACTORY.constructType(com.nutanix.dp1.mic.microseg.v4.operation.DryRunSpec.class);
    
        public OneOfSpecWrapperJsonDeserializer() {
          super(TYPE_FACTORY.constructType(OneOfSpecWrapper.class));
        }
    
        @Override
        protected void setDataObject(OneOfSpecWrapper oneOfObject, Object nestedObject) {
          if (oneOfObject == null) {
            throw new IllegalArgumentException("Instance of OneOfSpecWrapper provided is null");
          }
          if(ONE_OF_TYPE0.getRawClass().isAssignableFrom(nestedObject.getClass())) {
            oneOfObject.setValue(nestedObject);
            if (oneOfObject.getValue() != null) {
                return;
            }
          }
          if(ONE_OF_TYPE1.getRawClass().isAssignableFrom(nestedObject.getClass())) {
            oneOfObject.setValue(nestedObject);
            if (oneOfObject.getValue() != null) {
                return;
            }
          }
    
          throw new IllegalArgumentException("Attempting to set unsupported object type in OneOfSpecWrapper:" + nestedObject.getClass().getName());
        }
    
        public String getPackagePrefix() {
          return "com.nutanix.dp1.mic";
        }
      }
    
      @com.fasterxml.jackson.annotation.JsonIgnore
      @lombok.Getter(lombok.AccessLevel.NONE)
      @lombok.Setter(lombok.AccessLevel.NONE)

      private com.nutanix.dp1.mic.microseg.v4.operation.UpgradeSpec oneOfType0;
      @com.fasterxml.jackson.annotation.JsonIgnore
      @lombok.Getter(lombok.AccessLevel.NONE)
      @lombok.Setter(lombok.AccessLevel.NONE)

      private com.nutanix.dp1.mic.microseg.v4.operation.DryRunSpec oneOfType1;
    
      @lombok.Setter(lombok.AccessLevel.NONE)
      private String discriminator;
    
    
      @com.fasterxml.jackson.annotation.JsonIgnore
      @lombok.Setter(lombok.AccessLevel.NONE)
      private String $objectType;
    
      @com.fasterxml.jackson.annotation.JsonGetter
      public Object getValue() {

        if(oneOfType0 != null && oneOfType0.get$objectType().equals(this.discriminator)) {
          return this.oneOfType0;
        }

        if(oneOfType1 != null && oneOfType1.get$objectType().equals(this.discriminator)) {
          return this.oneOfType1;
        }
        throw new IllegalArgumentException("Unrecognized discriminator:" + this.discriminator);
      }
    
      public void setValue(Object value) {
        if(value == null) {

          log.warn("null passed to setValue function. OneOf's value will not be set.");
          return;
        }
    

        if (value instanceof com.nutanix.dp1.mic.microseg.v4.operation.UpgradeSpec) {
          this.oneOfType0 = (com.nutanix.dp1.mic.microseg.v4.operation.UpgradeSpec) value;

          this.discriminator = this.oneOfType0.get$objectType();
          this.$objectType = this.oneOfType0.get$objectType();
          return;
        }

        if (value instanceof com.nutanix.dp1.mic.microseg.v4.operation.DryRunSpec) {
          this.oneOfType1 = (com.nutanix.dp1.mic.microseg.v4.operation.DryRunSpec) value;

          this.discriminator = this.oneOfType1.get$objectType();
          this.$objectType = this.oneOfType1.get$objectType();
          return;
        }
    
        throw new IllegalArgumentException("Attempting to set unsupported object type in OneOfSpecWrapper:" + value.getClass().getName());
    
      }
    
    }
  
    private OneOfSpecWrapper spec = null;
  
    /**
     * @deprecated
     * @param value one of wrapper instance
     */
    public void setSpec(OneOfSpecWrapper value) {
      log.warn("Deprecating this method, please use setDataInWrapper instead");
      if (value == null) {
        return;
      }
      this.spec = value;
      this.$specItemDiscriminator = this.spec.getDiscriminator();
    }
  
    /**
     * @param value value of one of field spec
     */
    @com.fasterxml.jackson.annotation.JsonIgnore
    public void setSpecInWrapper(Object value) {
      if (value == null) {
        return;
      }
      if (this.spec == null) {
        this.spec = new OneOfSpecWrapper();
      }
      this.spec.setValue(value);
      this.$specItemDiscriminator = this.spec.getDiscriminator();
    }
  
    /**
     * Get spec in one of possible types :
     * 
    *
  • com.nutanix.dp1.mic.microseg.v4.operation.UpgradeSpec
  • *
  • com.nutanix.dp1.mic.microseg.v4.operation.DryRunSpec
  • *
* @return Object */ @com.fasterxml.jackson.databind.annotation.JsonSerialize(using = com.nutanix.dp1.mic.serializers.MicOneOfSerializer.class) public Object getSpec() { if (this.spec == null) { log.debug("OneOf property spec was never set. Returning null..."); return null; } return this.spec.getValue(); } @Getter @JsonView({StandardView.class}) protected final Map $reserved; @Getter @JsonView({StandardView.class}) protected final String $objectType; @Getter @JsonView({StandardView.class}) protected final Map $unknownFields; }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy