require 'date'
module HelixWebServices
# The depot specification, which is the shared repository Perforce stores files in.
class DepotCommand
# The depot name.
attr_accessor :depot
# The user who owns the depot.\nBy default, this is the user who created the depot.\n\nThe specified owner does not have to be a Perforce user.\nYou might want to use an arbitrary name if the user does not yet exist, or if you have deleted the user and need a placeholder until you can assign the spec to a new user.
attr_accessor :owner
# A short description of the depot’s purpose. Optional.
attr_accessor :description
# `local`, `remote`, `spec`, `stream`, `unload`, `archive` or `tangent`.\n\nA local depot is writable, and is the default depot type.\nFiles reside in the server's root directory and are managed directly by the server.\n\nA stream depot is also writable, but contains streams, a type of branch that includes hierarchy and policy.\n\nA remote depot references files that reside on other servers, and cannot be written to.\n\nThe spec depot, if present, automatically archives edited forms.\n\nThe unload depot, if present, holds infrequently-used metadata (about old client workspaces and labels) that has been unloaded with the p4 unload command.\n\nAn archive depot is used in conjunction with the p4 archive and p4 restore commands to facilitate offline (or near-line) storage of infrequently-accessed revisions, typically large binaries.\n\nA tangent depot defines a read-only location that holds tangents created by the p4 fetch -t command.\nThe tangent depot named tangent is automatically created by p4 fetch -t if one does not already exist.
attr_accessor :type
# If the `Type:` is `remote`, the address should be the P4PORT address of the remote server.\nIf the `Type:` is local or spec, this field is ignored.
attr_accessor :address
# If the Type: is spec, this field holds an optional suffix for generated paths to objects in the spec depot.\n\nThe default suffix is .p4s.\nYou do not need a suffix to use the spec depot, but supplying a file extension to your Perforce server’s versioned specs enables users of GUI client software to associate Perforce specifications with a preferred text editor.\nIf the Type: is local or remote, this field is ignored.
attr_accessor :suffix
# For stream depots, the optional depth to be used for stream paths in the depot, where depth specifies the number of slashes following the depot name of a stream. ]\n\nThis field is used when streams are being created.\nThe default is 1, matching the traditional stream name.\nYou cannot update this value once streams or archive data exist in a depot.
attr_accessor :stream_depth
# If the Type: is local, spec, or archive, set the map to point to the relative location of the depot subdirectory.\nThe map must contain the `...` wildcard; for example, a local depot new might have a Map: of `new/...`.\n\nIf the Type: is remote, set the map to point to a location in the remote depot's physical namespace, for example, `//depot/new/rel2/...`.\nThis directory will be the root of the local representation of the remote depot.
attr_accessor :map
# For spec depots, an optional description of which specs should be saved, expressed as a view.
attr_accessor :spec_map
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'depot' => :'depot',
:'owner' => :'owner',
:'description' => :'description',
:'type' => :'type',
:'address' => :'address',
:'suffix' => :'suffix',
:'stream_depth' => :'streamDepth',
:'map' => :'map',
:'spec_map' => :'specMap'
}
end
# Attribute type mapping.
def self.swagger_types
{
:'depot' => :'String',
:'owner' => :'String',
:'description' => :'String',
:'type' => :'String',
:'address' => :'String',
:'suffix' => :'String',
:'stream_depth' => :'String',
:'map' => :'String',
:'spec_map' => :'Array<String>'
}
end
def initialize(attributes = {})
return unless attributes.is_a?(Hash)
# convert string to symbol for hash key
attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
if attributes[:'depot']
self.depot = attributes[:'depot']
end
if attributes[:'owner']
self.owner = attributes[:'owner']
end
if attributes[:'description']
self.description = attributes[:'description']
end
if attributes[:'type']
self.type = attributes[:'type']
end
if attributes[:'address']
self.address = attributes[:'address']
end
if attributes[:'suffix']
self.suffix = attributes[:'suffix']
end
if attributes[:'streamDepth']
self.stream_depth = attributes[:'streamDepth']
end
if attributes[:'map']
self.map = attributes[:'map']
end
if attributes[:'specMap']
if (value = attributes[:'specMap']).is_a?(Array)
self.spec_map = value
end
end
end
# Check equality by comparing each attribute.
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
depot == o.depot &&
owner == o.owner &&
description == o.description &&
type == o.type &&
address == o.address &&
suffix == o.suffix &&
stream_depth == o.stream_depth &&
map == o.map &&
spec_map == o.spec_map
end
# @see the `==` method
def eql?(o)
self == o
end
# Calculate hash code according to all attributes.
def hash
[depot, owner, description, type, address, suffix, stream_depth, map, spec_map].hash
end
# build the object from hash
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
self.class.swagger_types.each_pair do |key, type|
if type =~ /^Array<(.*)>/i
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
else
#TODO show warning in debug mode
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
else
# data not found in attributes(hash), not an issue as the data can be optional
end
end
self
end
def _deserialize(type, value)
case type.to_sym
when :DateTime
DateTime.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :BOOLEAN
if value.to_s =~ /^(true|t|yes|y|1)$/i
true
else
false
end
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
when :Object
value
else # model
_model = HelixWebServices.const_get(type).new
_model.build_from_hash(value)
end
end
def to_s
to_hash.to_s
end
# to_body is an alias to to_body (backward compatibility))
def to_body
to_hash
end
# return the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
next if value.nil?
hash[param] = _to_hash(value)
end
hash
end
# Method to output non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
def _to_hash(value)
if value.is_a?(Array)
value.compact.map{ |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end