var assign = require('object-assign');
var Node = require('./Node');
/**
* Initialize a new depot instance.
*
* @param {Object} obj Data from the server, which doesn't follow typical
* javaScript naming conventions.
* @constructor
* @memberof models
*/
function Depot(obj) {
this._data = obj || {};
/**
* The immediate directories and files under this depot.
*
* @type {Array<PathItem>}
*/
this.children = [];
var self = this;
Object.defineProperties(this, {
/**
* The name of the Depot
*
* @type string
* @name models.Depot#depot
* @memberOf models.Depot
*/
'depot': {
get: function() {
return self._data['Depot'];
},
set: function(x) {
self._data['Depot'] = x;
return x;
}
},
/**
* The created date of the depot
*
* @type Date
* @name models.Depot#date
* @memberOf models.Depot
* @readonly
*/
'date': {
get: function() {
if (self._data['Date']) {
return new Date(self._data['Date']);
}
}
},
/**
* The Depot type, one of 'local', 'remote', 'spec', 'stream', 'unload', or
* 'archive'.
*
* @type string
* @name models.Depot#type
* @memberOf models.Depot
*/
'type': {
get: function() {
return self._date['Type'];
},
set: function(x) {
// TODO validate x
self._date['Type'] = x;
}
},
/**
* If `type` is 'remote', this is the P4PORT address of the remote server.
*
* @type string
* @name models.Depot#address
* @memberOf models.Depot
*/
'address': {
get: function() {
return self._date['Address'];
},
set: function(x) {
self._date['Type'] = x;
}
},
/**
* If `type` is 'local', 'spec', or 'archive', this points to the relative
* location of the depot subdirectory.
*
* @type string
* @name models.Depot#map
* @memberOf models.Depot
*/
'map': {
get: function() {
return self._date['Map'];
},
set: function(x) {
self._date['Map'] = x;
return x;
}
},
/**
* A short description of the depot's purpose.
*
* @type string
* @name models.Depot#description
* @memberOf models.Depot
*/
'description': {
get: function() {
return self._date['Description'];
},
set: function(x) {
self._date['Description'] = x;
return x;
}
},
/**
* The user login that owns the Depot.
*
* @type string
* @name models.Depot#owner
* @memberOf models.Depot
*/
'owner': {
get: function() {
return self._data['Owner'];
},
set: function(x) {
self._data['Owner'] = x;
return x;
}
},
/**
* If the `type` is 'spec', this holds an optional suffix for generated
* paths to objects in the spec depot.
*
* @type string
* @name models.Depot#suffix
* @memberOf models.Depot
*/
'suffix': {
get: function() {
return self._data['Suffix'];
},
set: function(x) {
self._data['Suffix'] = x;
return x;
}
},
/**
* When type is 'spec', this an optional description of what specs should
* be saved.
*
* @type string
* @name models.Depot#specMap
* @memberOf models.Depot
*/
'specMap': {
get: function() {
return self._data['SpecMap'];
}
},
/**
* The representation of the depot suitable to POST back to the Helix
* Web Services Perforce API.
*
* @type object
* @name models.Depot#data
* @memberOf models.Depot
* @readonly
*/
'data': {
get: function() {
return self._data;
}
},
/**
* Used by our underlying Node representation
*
* @type string
* @name models.Depot#name
* @memberOf models.Depot
* @readonly
*/
'name': {
get: function() {
return self.depot;
}
},
/**
* Used by our underlying Node representation
*
* @type string
* @name models.Depot#pathId
* @memberOf models.Depot
* @readonly
*/
'pathId': {
get: function() {
return [self.depot];
}
}
});
}
assign(Depot.prototype, Node);
module.exports = Depot;