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

org.jclouds.googlecomputeengine.options.NetworkCreationOptions Maven / Gradle / Ivy

There is a newer version: 2.6.0
Show newest version
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF 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.googlecomputeengine.options;

import static com.google.common.base.Preconditions.checkNotNull;

import org.jclouds.javax.annotation.Nullable;
import org.jclouds.json.SerializedNames;

import com.google.auto.value.AutoValue;

/**
 * Represents a network used to enable instance communication.
 */
@AutoValue
public abstract class NetworkCreationOptions {

   public abstract String name();

   @Nullable public abstract String description();

   /**
    * The range of internal addresses that are legal on this network. This range is a CIDR
    * specification, for example: {@code 192.168.0.0/16}.
    */
   @Nullable public abstract String rangeIPv4();

   /**
    * This must be within the range specified by IPv4Range, and is typically the first usable address in that range.
    * If not specified, the default value is the first usable address in IPv4Range.
    */
   @Nullable public abstract String gatewayIPv4();
   
   @Nullable public abstract Boolean autoCreateSubnetworks();

   @SerializedNames({ "name", "description", "IPv4Range", "gatewayIPv4", "autoCreateSubnetworks" })
   public static NetworkCreationOptions create(String name, String description, String rangeIPv4,
         String gatewayIPv4, Boolean autoCreateSubnetworks) {
      return new AutoValue_NetworkCreationOptions(name, description, rangeIPv4, gatewayIPv4, autoCreateSubnetworks);
   }

   NetworkCreationOptions() {
   }

   public static class Builder {
      private String name;
      private String description;
      private String rangeIPv4;
      private String gatewayIPv4;
      private Boolean autoCreateSubnetworks;
      
      public Builder(String name) {
         this.name = name;
      }
      
      public Builder rangeIPv4(String rangeIPv4) {
         this.rangeIPv4 = rangeIPv4;
         return this;
      }

      public Builder description(String description) {
         this.description = description;
         return this;
      }

      public Builder gatewayIPv4(String gatewayIPv4) {
         this.gatewayIPv4 = gatewayIPv4;
         return this;
      }
      
      public Builder autoCreateSubnetworks(Boolean autoCreateSubnetworks) {
         this.autoCreateSubnetworks = autoCreateSubnetworks;
         return this;
      }

      public NetworkCreationOptions build() {
         checkNotNull(name, "NetworkCreationOptions name cannot be null");
         return create(name, description, rangeIPv4, gatewayIPv4, autoCreateSubnetworks);
      }

   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy