/*
* Copyright (c) Cloud Software Group, Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1) Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2) Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.Linq;
using Newtonsoft.Json;
namespace XenAPI
{
///
/// Describes the storage that is available to a PVS site for caching purposes
/// First published in XenServer 7.1.
///
public partial class PVS_cache_storage : XenObject
{
#region Constructors
public PVS_cache_storage()
{
}
public PVS_cache_storage(string uuid,
XenRef host,
XenRef SR,
XenRef site,
long size,
XenRef VDI)
{
this.uuid = uuid;
this.host = host;
this.SR = SR;
this.site = site;
this.size = size;
this.VDI = VDI;
}
///
/// Creates a new PVS_cache_storage from a Hashtable.
/// Note that the fields not contained in the Hashtable
/// will be created with their default values.
///
///
public PVS_cache_storage(Hashtable table)
: this()
{
UpdateFrom(table);
}
#endregion
///
/// Updates each field of this instance with the value of
/// the corresponding field of a given PVS_cache_storage.
///
public override void UpdateFrom(PVS_cache_storage record)
{
uuid = record.uuid;
host = record.host;
SR = record.SR;
site = record.site;
size = record.size;
VDI = record.VDI;
}
///
/// Given a Hashtable with field-value pairs, it updates the fields of this PVS_cache_storage
/// with the values listed in the Hashtable. Note that only the fields contained
/// in the Hashtable will be updated and the rest will remain the same.
///
///
public void UpdateFrom(Hashtable table)
{
if (table.ContainsKey("uuid"))
uuid = Marshalling.ParseString(table, "uuid");
if (table.ContainsKey("host"))
host = Marshalling.ParseRef(table, "host");
if (table.ContainsKey("SR"))
SR = Marshalling.ParseRef(table, "SR");
if (table.ContainsKey("site"))
site = Marshalling.ParseRef(table, "site");
if (table.ContainsKey("size"))
size = Marshalling.ParseLong(table, "size");
if (table.ContainsKey("VDI"))
VDI = Marshalling.ParseRef(table, "VDI");
}
public bool DeepEquals(PVS_cache_storage other)
{
if (ReferenceEquals(null, other))
return false;
if (ReferenceEquals(this, other))
return true;
return Helper.AreEqual2(_uuid, other._uuid) &&
Helper.AreEqual2(_host, other._host) &&
Helper.AreEqual2(_SR, other._SR) &&
Helper.AreEqual2(_site, other._site) &&
Helper.AreEqual2(_size, other._size) &&
Helper.AreEqual2(_VDI, other._VDI);
}
public override string SaveChanges(Session session, string opaqueRef, PVS_cache_storage server)
{
if (opaqueRef == null)
{
var reference = create(session, this);
return reference == null ? null : reference.opaque_ref;
}
else
{
throw new InvalidOperationException("This type has no read/write properties");
}
}
///
/// Get a record containing the current state of the given PVS_cache_storage.
/// First published in XenServer 7.1.
///
/// The session
/// The opaque_ref of the given pvs_cache_storage
public static PVS_cache_storage get_record(Session session, string _pvs_cache_storage)
{
return session.JsonRpcClient.pvs_cache_storage_get_record(session.opaque_ref, _pvs_cache_storage);
}
///
/// Get a reference to the PVS_cache_storage instance with the specified UUID.
/// First published in XenServer 7.1.
///
/// The session
/// UUID of object to return
public static XenRef get_by_uuid(Session session, string _uuid)
{
return session.JsonRpcClient.pvs_cache_storage_get_by_uuid(session.opaque_ref, _uuid);
}
///
/// Create a new PVS_cache_storage instance, and return its handle.
/// First published in XenServer 7.1.
///
/// The session
/// All constructor arguments
public static XenRef create(Session session, PVS_cache_storage _record)
{
return session.JsonRpcClient.pvs_cache_storage_create(session.opaque_ref, _record);
}
///
/// Create a new PVS_cache_storage instance, and return its handle.
/// First published in XenServer 7.1.
///
/// The session
/// All constructor arguments
public static XenRef async_create(Session session, PVS_cache_storage _record)
{
return session.JsonRpcClient.async_pvs_cache_storage_create(session.opaque_ref, _record);
}
///
/// Destroy the specified PVS_cache_storage instance.
/// First published in XenServer 7.1.
///
/// The session
/// The opaque_ref of the given pvs_cache_storage
public static void destroy(Session session, string _pvs_cache_storage)
{
session.JsonRpcClient.pvs_cache_storage_destroy(session.opaque_ref, _pvs_cache_storage);
}
///
/// Destroy the specified PVS_cache_storage instance.
/// First published in XenServer 7.1.
///
/// The session
/// The opaque_ref of the given pvs_cache_storage
public static XenRef async_destroy(Session session, string _pvs_cache_storage)
{
return session.JsonRpcClient.async_pvs_cache_storage_destroy(session.opaque_ref, _pvs_cache_storage);
}
///
/// Get the uuid field of the given PVS_cache_storage.
/// First published in XenServer 7.1.
///
/// The session
/// The opaque_ref of the given pvs_cache_storage
public static string get_uuid(Session session, string _pvs_cache_storage)
{
return session.JsonRpcClient.pvs_cache_storage_get_uuid(session.opaque_ref, _pvs_cache_storage);
}
///
/// Get the host field of the given PVS_cache_storage.
/// First published in XenServer 7.1.
///
/// The session
/// The opaque_ref of the given pvs_cache_storage
public static XenRef get_host(Session session, string _pvs_cache_storage)
{
return session.JsonRpcClient.pvs_cache_storage_get_host(session.opaque_ref, _pvs_cache_storage);
}
///
/// Get the SR field of the given PVS_cache_storage.
/// First published in XenServer 7.1.
///
/// The session
/// The opaque_ref of the given pvs_cache_storage
public static XenRef get_SR(Session session, string _pvs_cache_storage)
{
return session.JsonRpcClient.pvs_cache_storage_get_sr(session.opaque_ref, _pvs_cache_storage);
}
///
/// Get the site field of the given PVS_cache_storage.
/// First published in XenServer 7.1.
///
/// The session
/// The opaque_ref of the given pvs_cache_storage
public static XenRef get_site(Session session, string _pvs_cache_storage)
{
return session.JsonRpcClient.pvs_cache_storage_get_site(session.opaque_ref, _pvs_cache_storage);
}
///
/// Get the size field of the given PVS_cache_storage.
/// First published in XenServer 7.1.
///
/// The session
/// The opaque_ref of the given pvs_cache_storage
public static long get_size(Session session, string _pvs_cache_storage)
{
return session.JsonRpcClient.pvs_cache_storage_get_size(session.opaque_ref, _pvs_cache_storage);
}
///
/// Get the VDI field of the given PVS_cache_storage.
/// First published in XenServer 7.1.
///
/// The session
/// The opaque_ref of the given pvs_cache_storage
public static XenRef get_VDI(Session session, string _pvs_cache_storage)
{
return session.JsonRpcClient.pvs_cache_storage_get_vdi(session.opaque_ref, _pvs_cache_storage);
}
///
/// Return a list of all the PVS_cache_storages known to the system.
/// First published in XenServer 7.1.
///
/// The session
public static List> get_all(Session session)
{
return session.JsonRpcClient.pvs_cache_storage_get_all(session.opaque_ref);
}
///
/// Get all the PVS_cache_storage Records at once, in a single XML RPC call
/// First published in XenServer 7.1.
///
/// The session
public static Dictionary, PVS_cache_storage> get_all_records(Session session)
{
return session.JsonRpcClient.pvs_cache_storage_get_all_records(session.opaque_ref);
}
///
/// Unique identifier/object reference
///
public virtual string uuid
{
get { return _uuid; }
set
{
if (!Helper.AreEqual(value, _uuid))
{
_uuid = value;
NotifyPropertyChanged("uuid");
}
}
}
private string _uuid = "";
///
/// The host on which this object defines PVS cache storage
///
[JsonConverter(typeof(XenRefConverter))]
public virtual XenRef host
{
get { return _host; }
set
{
if (!Helper.AreEqual(value, _host))
{
_host = value;
NotifyPropertyChanged("host");
}
}
}
private XenRef _host = new XenRef("OpaqueRef:NULL");
///
/// SR providing storage for the PVS cache
///
[JsonConverter(typeof(XenRefConverter))]
public virtual XenRef SR
{
get { return _SR; }
set
{
if (!Helper.AreEqual(value, _SR))
{
_SR = value;
NotifyPropertyChanged("SR");
}
}
}
private XenRef _SR = new XenRef("OpaqueRef:NULL");
///
/// The PVS_site for which this object defines the storage
///
[JsonConverter(typeof(XenRefConverter))]
public virtual XenRef site
{
get { return _site; }
set
{
if (!Helper.AreEqual(value, _site))
{
_site = value;
NotifyPropertyChanged("site");
}
}
}
private XenRef _site = new XenRef("OpaqueRef:NULL");
///
/// The size of the cache VDI (in bytes)
///
public virtual long size
{
get { return _size; }
set
{
if (!Helper.AreEqual(value, _size))
{
_size = value;
NotifyPropertyChanged("size");
}
}
}
private long _size = 21474836480;
///
/// The VDI used for caching
///
[JsonConverter(typeof(XenRefConverter))]
public virtual XenRef VDI
{
get { return _VDI; }
set
{
if (!Helper.AreEqual(value, _VDI))
{
_VDI = value;
NotifyPropertyChanged("VDI");
}
}
}
private XenRef _VDI = new XenRef("OpaqueRef:NULL");
}
}