2013-06-24 13:41:48 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) Citrix Systems, Inc.
|
|
|
|
* All rights reserved.
|
2017-09-13 18:14:07 +02:00
|
|
|
*
|
2013-06-24 13:41:48 +02:00
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
2017-09-13 18:14:07 +02:00
|
|
|
*
|
2013-06-24 13:41:48 +02:00
|
|
|
* 1) Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
2017-09-13 18:14:07 +02:00
|
|
|
*
|
2013-06-24 13:41:48 +02:00
|
|
|
* 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.
|
2017-09-13 18:14:07 +02:00
|
|
|
*
|
2013-06-24 13:41:48 +02:00
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2013-07-03 12:22:08 +02:00
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
using System;
|
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
2017-09-13 18:14:07 +02:00
|
|
|
using System.ComponentModel;
|
|
|
|
using System.Globalization;
|
2021-04-13 11:05:38 +02:00
|
|
|
using System.Linq;
|
2017-09-13 18:14:07 +02:00
|
|
|
using Newtonsoft.Json;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
|
|
|
|
|
|
namespace XenAPI
|
|
|
|
{
|
2014-05-16 17:58:13 +02:00
|
|
|
/// <summary>
|
|
|
|
/// A placeholder for a binary blob
|
|
|
|
/// First published in XenServer 5.0.
|
|
|
|
/// </summary>
|
2013-06-24 13:41:48 +02:00
|
|
|
public partial class Blob : XenObject<Blob>
|
|
|
|
{
|
2019-06-19 10:11:30 +02:00
|
|
|
#region Constructors
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
public Blob()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public Blob(string uuid,
|
|
|
|
string name_label,
|
|
|
|
string name_description,
|
|
|
|
long size,
|
|
|
|
bool pubblic,
|
|
|
|
DateTime last_updated,
|
|
|
|
string mime_type)
|
|
|
|
{
|
|
|
|
this.uuid = uuid;
|
|
|
|
this.name_label = name_label;
|
|
|
|
this.name_description = name_description;
|
|
|
|
this.size = size;
|
|
|
|
this.pubblic = pubblic;
|
|
|
|
this.last_updated = last_updated;
|
|
|
|
this.mime_type = mime_type;
|
|
|
|
}
|
|
|
|
|
2019-06-19 10:11:30 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Creates a new Blob from a Hashtable.
|
|
|
|
/// Note that the fields not contained in the Hashtable
|
|
|
|
/// will be created with their default values.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="table"></param>
|
|
|
|
public Blob(Hashtable table)
|
|
|
|
: this()
|
|
|
|
{
|
|
|
|
UpdateFrom(table);
|
|
|
|
}
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Creates a new Blob from a Proxy_Blob.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="proxy"></param>
|
|
|
|
public Blob(Proxy_Blob proxy)
|
|
|
|
{
|
2019-06-19 10:11:30 +02:00
|
|
|
UpdateFrom(proxy);
|
2013-06-24 13:41:48 +02:00
|
|
|
}
|
|
|
|
|
2019-06-19 10:11:30 +02:00
|
|
|
#endregion
|
|
|
|
|
2018-02-16 17:27:30 +01:00
|
|
|
/// <summary>
|
|
|
|
/// Updates each field of this instance with the value of
|
|
|
|
/// the corresponding field of a given Blob.
|
|
|
|
/// </summary>
|
2021-04-13 11:05:38 +02:00
|
|
|
public override void UpdateFrom(Blob record)
|
2013-06-24 13:41:48 +02:00
|
|
|
{
|
2021-04-13 11:05:38 +02:00
|
|
|
uuid = record.uuid;
|
|
|
|
name_label = record.name_label;
|
|
|
|
name_description = record.name_description;
|
|
|
|
size = record.size;
|
|
|
|
pubblic = record.pubblic;
|
|
|
|
last_updated = record.last_updated;
|
|
|
|
mime_type = record.mime_type;
|
2013-06-24 13:41:48 +02:00
|
|
|
}
|
|
|
|
|
2019-06-19 10:11:30 +02:00
|
|
|
internal void UpdateFrom(Proxy_Blob proxy)
|
2013-06-24 13:41:48 +02:00
|
|
|
{
|
2018-03-22 13:30:43 +01:00
|
|
|
uuid = proxy.uuid == null ? null : proxy.uuid;
|
|
|
|
name_label = proxy.name_label == null ? null : proxy.name_label;
|
|
|
|
name_description = proxy.name_description == null ? null : proxy.name_description;
|
|
|
|
size = proxy.size == null ? 0 : long.Parse(proxy.size);
|
2013-06-24 13:41:48 +02:00
|
|
|
pubblic = (bool)proxy.pubblic;
|
|
|
|
last_updated = proxy.last_updated;
|
2018-03-22 13:30:43 +01:00
|
|
|
mime_type = proxy.mime_type == null ? null : proxy.mime_type;
|
2013-06-24 13:41:48 +02:00
|
|
|
}
|
|
|
|
|
2018-02-16 17:27:30 +01:00
|
|
|
/// <summary>
|
|
|
|
/// Given a Hashtable with field-value pairs, it updates the fields of this Blob
|
|
|
|
/// 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.
|
2013-06-24 13:41:48 +02:00
|
|
|
/// </summary>
|
|
|
|
/// <param name="table"></param>
|
2018-02-16 17:27:30 +01:00
|
|
|
public void UpdateFrom(Hashtable table)
|
2013-06-24 13:41:48 +02:00
|
|
|
{
|
2018-02-16 17:27:30 +01:00
|
|
|
if (table.ContainsKey("uuid"))
|
2018-02-23 17:06:32 +01:00
|
|
|
uuid = Marshalling.ParseString(table, "uuid");
|
2018-02-16 17:27:30 +01:00
|
|
|
if (table.ContainsKey("name_label"))
|
2018-02-23 17:06:32 +01:00
|
|
|
name_label = Marshalling.ParseString(table, "name_label");
|
2018-02-16 17:27:30 +01:00
|
|
|
if (table.ContainsKey("name_description"))
|
2018-02-23 17:06:32 +01:00
|
|
|
name_description = Marshalling.ParseString(table, "name_description");
|
2018-02-16 17:27:30 +01:00
|
|
|
if (table.ContainsKey("size"))
|
2018-02-23 17:06:32 +01:00
|
|
|
size = Marshalling.ParseLong(table, "size");
|
2018-02-16 17:27:30 +01:00
|
|
|
if (table.ContainsKey("pubblic"))
|
2018-02-23 17:06:32 +01:00
|
|
|
pubblic = Marshalling.ParseBool(table, "pubblic");
|
2018-02-16 17:27:30 +01:00
|
|
|
if (table.ContainsKey("last_updated"))
|
2018-02-23 17:06:32 +01:00
|
|
|
last_updated = Marshalling.ParseDateTime(table, "last_updated");
|
2018-02-16 17:27:30 +01:00
|
|
|
if (table.ContainsKey("mime_type"))
|
2018-02-23 17:06:32 +01:00
|
|
|
mime_type = Marshalling.ParseString(table, "mime_type");
|
2013-06-24 13:41:48 +02:00
|
|
|
}
|
|
|
|
|
2021-04-13 11:05:38 +02:00
|
|
|
public Proxy_Blob ToProxy()
|
|
|
|
{
|
|
|
|
Proxy_Blob result_ = new Proxy_Blob();
|
|
|
|
result_.uuid = uuid ?? "";
|
|
|
|
result_.name_label = name_label ?? "";
|
|
|
|
result_.name_description = name_description ?? "";
|
|
|
|
result_.size = size.ToString();
|
|
|
|
result_.pubblic = pubblic;
|
|
|
|
result_.last_updated = last_updated;
|
|
|
|
result_.mime_type = mime_type ?? "";
|
|
|
|
return result_;
|
|
|
|
}
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
public bool DeepEquals(Blob other)
|
|
|
|
{
|
|
|
|
if (ReferenceEquals(null, other))
|
|
|
|
return false;
|
|
|
|
if (ReferenceEquals(this, other))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return Helper.AreEqual2(this._uuid, other._uuid) &&
|
|
|
|
Helper.AreEqual2(this._name_label, other._name_label) &&
|
|
|
|
Helper.AreEqual2(this._name_description, other._name_description) &&
|
|
|
|
Helper.AreEqual2(this._size, other._size) &&
|
|
|
|
Helper.AreEqual2(this._pubblic, other._pubblic) &&
|
|
|
|
Helper.AreEqual2(this._last_updated, other._last_updated) &&
|
|
|
|
Helper.AreEqual2(this._mime_type, other._mime_type);
|
|
|
|
}
|
|
|
|
|
|
|
|
public override string SaveChanges(Session session, string opaqueRef, Blob server)
|
|
|
|
{
|
|
|
|
if (opaqueRef == null)
|
2018-02-14 12:03:48 +01:00
|
|
|
{
|
|
|
|
System.Diagnostics.Debug.Assert(false, "Cannot create instances of this type on the server");
|
2013-06-24 13:41:48 +02:00
|
|
|
return "";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!Helper.AreEqual2(_name_label, server._name_label))
|
|
|
|
{
|
|
|
|
Blob.set_name_label(session, opaqueRef, _name_label);
|
|
|
|
}
|
|
|
|
if (!Helper.AreEqual2(_name_description, server._name_description))
|
|
|
|
{
|
|
|
|
Blob.set_name_description(session, opaqueRef, _name_description);
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
2021-04-13 11:05:38 +02:00
|
|
|
|
2014-05-16 17:58:13 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Get a record containing the current state of the given blob.
|
|
|
|
/// First published in XenServer 5.0.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="session">The session</param>
|
|
|
|
/// <param name="_blob">The opaque_ref of the given blob</param>
|
2013-06-24 13:41:48 +02:00
|
|
|
public static Blob get_record(Session session, string _blob)
|
|
|
|
{
|
2017-09-13 18:14:07 +02:00
|
|
|
if (session.JsonRpcClient != null)
|
2018-02-23 17:06:32 +01:00
|
|
|
return session.JsonRpcClient.blob_get_record(session.opaque_ref, _blob);
|
2017-09-13 18:14:07 +02:00
|
|
|
else
|
2020-01-30 01:02:24 +01:00
|
|
|
return new Blob(session.XmlRpcProxy.blob_get_record(session.opaque_ref, _blob ?? "").parse());
|
2013-06-24 13:41:48 +02:00
|
|
|
}
|
|
|
|
|
2014-05-16 17:58:13 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Get a reference to the blob instance with the specified UUID.
|
|
|
|
/// First published in XenServer 5.0.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="session">The session</param>
|
|
|
|
/// <param name="_uuid">UUID of object to return</param>
|
2013-06-24 13:41:48 +02:00
|
|
|
public static XenRef<Blob> get_by_uuid(Session session, string _uuid)
|
|
|
|
{
|
2017-09-13 18:14:07 +02:00
|
|
|
if (session.JsonRpcClient != null)
|
2018-02-23 17:06:32 +01:00
|
|
|
return session.JsonRpcClient.blob_get_by_uuid(session.opaque_ref, _uuid);
|
2017-09-13 18:14:07 +02:00
|
|
|
else
|
2020-01-30 01:02:24 +01:00
|
|
|
return XenRef<Blob>.Create(session.XmlRpcProxy.blob_get_by_uuid(session.opaque_ref, _uuid ?? "").parse());
|
2013-06-24 13:41:48 +02:00
|
|
|
}
|
|
|
|
|
2014-05-16 17:58:13 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Get all the blob instances with the given label.
|
|
|
|
/// First published in XenServer 5.0.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="session">The session</param>
|
|
|
|
/// <param name="_label">label of object to return</param>
|
2013-06-24 13:41:48 +02:00
|
|
|
public static List<XenRef<Blob>> get_by_name_label(Session session, string _label)
|
|
|
|
{
|
2017-09-13 18:14:07 +02:00
|
|
|
if (session.JsonRpcClient != null)
|
2018-02-23 17:06:32 +01:00
|
|
|
return session.JsonRpcClient.blob_get_by_name_label(session.opaque_ref, _label);
|
2017-09-13 18:14:07 +02:00
|
|
|
else
|
2020-01-30 01:02:24 +01:00
|
|
|
return XenRef<Blob>.Create(session.XmlRpcProxy.blob_get_by_name_label(session.opaque_ref, _label ?? "").parse());
|
2013-06-24 13:41:48 +02:00
|
|
|
}
|
|
|
|
|
2014-05-16 17:58:13 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Get the uuid field of the given blob.
|
|
|
|
/// First published in XenServer 5.0.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="session">The session</param>
|
|
|
|
/// <param name="_blob">The opaque_ref of the given blob</param>
|
2013-06-24 13:41:48 +02:00
|
|
|
public static string get_uuid(Session session, string _blob)
|
|
|
|
{
|
2017-09-13 18:14:07 +02:00
|
|
|
if (session.JsonRpcClient != null)
|
2018-02-23 17:06:32 +01:00
|
|
|
return session.JsonRpcClient.blob_get_uuid(session.opaque_ref, _blob);
|
2017-09-13 18:14:07 +02:00
|
|
|
else
|
2020-01-30 01:02:24 +01:00
|
|
|
return session.XmlRpcProxy.blob_get_uuid(session.opaque_ref, _blob ?? "").parse();
|
2013-06-24 13:41:48 +02:00
|
|
|
}
|
|
|
|
|
2014-05-16 17:58:13 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Get the name/label field of the given blob.
|
|
|
|
/// First published in XenServer 5.0.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="session">The session</param>
|
|
|
|
/// <param name="_blob">The opaque_ref of the given blob</param>
|
2013-06-24 13:41:48 +02:00
|
|
|
public static string get_name_label(Session session, string _blob)
|
|
|
|
{
|
2017-09-13 18:14:07 +02:00
|
|
|
if (session.JsonRpcClient != null)
|
2018-02-23 17:06:32 +01:00
|
|
|
return session.JsonRpcClient.blob_get_name_label(session.opaque_ref, _blob);
|
2017-09-13 18:14:07 +02:00
|
|
|
else
|
2020-01-30 01:02:24 +01:00
|
|
|
return session.XmlRpcProxy.blob_get_name_label(session.opaque_ref, _blob ?? "").parse();
|
2013-06-24 13:41:48 +02:00
|
|
|
}
|
|
|
|
|
2014-05-16 17:58:13 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Get the name/description field of the given blob.
|
|
|
|
/// First published in XenServer 5.0.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="session">The session</param>
|
|
|
|
/// <param name="_blob">The opaque_ref of the given blob</param>
|
2013-06-24 13:41:48 +02:00
|
|
|
public static string get_name_description(Session session, string _blob)
|
|
|
|
{
|
2017-09-13 18:14:07 +02:00
|
|
|
if (session.JsonRpcClient != null)
|
2018-02-23 17:06:32 +01:00
|
|
|
return session.JsonRpcClient.blob_get_name_description(session.opaque_ref, _blob);
|
2017-09-13 18:14:07 +02:00
|
|
|
else
|
2020-01-30 01:02:24 +01:00
|
|
|
return session.XmlRpcProxy.blob_get_name_description(session.opaque_ref, _blob ?? "").parse();
|
2013-06-24 13:41:48 +02:00
|
|
|
}
|
|
|
|
|
2014-05-16 17:58:13 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Get the size field of the given blob.
|
|
|
|
/// First published in XenServer 5.0.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="session">The session</param>
|
|
|
|
/// <param name="_blob">The opaque_ref of the given blob</param>
|
2013-06-24 13:41:48 +02:00
|
|
|
public static long get_size(Session session, string _blob)
|
|
|
|
{
|
2017-09-13 18:14:07 +02:00
|
|
|
if (session.JsonRpcClient != null)
|
2018-02-23 17:06:32 +01:00
|
|
|
return session.JsonRpcClient.blob_get_size(session.opaque_ref, _blob);
|
2017-09-13 18:14:07 +02:00
|
|
|
else
|
2020-01-30 01:02:24 +01:00
|
|
|
return long.Parse(session.XmlRpcProxy.blob_get_size(session.opaque_ref, _blob ?? "").parse());
|
2013-06-24 13:41:48 +02:00
|
|
|
}
|
|
|
|
|
2014-05-16 17:58:13 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Get the public field of the given blob.
|
|
|
|
/// First published in XenServer 6.1.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="session">The session</param>
|
|
|
|
/// <param name="_blob">The opaque_ref of the given blob</param>
|
2013-06-24 13:41:48 +02:00
|
|
|
public static bool get_public(Session session, string _blob)
|
|
|
|
{
|
2017-09-13 18:14:07 +02:00
|
|
|
if (session.JsonRpcClient != null)
|
2018-02-23 17:06:32 +01:00
|
|
|
return session.JsonRpcClient.blob_get_public(session.opaque_ref, _blob);
|
2017-09-13 18:14:07 +02:00
|
|
|
else
|
2020-01-30 01:02:24 +01:00
|
|
|
return (bool)session.XmlRpcProxy.blob_get_public(session.opaque_ref, _blob ?? "").parse();
|
2013-06-24 13:41:48 +02:00
|
|
|
}
|
|
|
|
|
2014-05-16 17:58:13 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Get the last_updated field of the given blob.
|
|
|
|
/// First published in XenServer 5.0.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="session">The session</param>
|
|
|
|
/// <param name="_blob">The opaque_ref of the given blob</param>
|
2013-06-24 13:41:48 +02:00
|
|
|
public static DateTime get_last_updated(Session session, string _blob)
|
|
|
|
{
|
2017-09-13 18:14:07 +02:00
|
|
|
if (session.JsonRpcClient != null)
|
2018-02-23 17:06:32 +01:00
|
|
|
return session.JsonRpcClient.blob_get_last_updated(session.opaque_ref, _blob);
|
2017-09-13 18:14:07 +02:00
|
|
|
else
|
2020-01-30 01:02:24 +01:00
|
|
|
return session.XmlRpcProxy.blob_get_last_updated(session.opaque_ref, _blob ?? "").parse();
|
2013-06-24 13:41:48 +02:00
|
|
|
}
|
|
|
|
|
2014-05-16 17:58:13 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Get the mime_type field of the given blob.
|
|
|
|
/// First published in XenServer 5.0.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="session">The session</param>
|
|
|
|
/// <param name="_blob">The opaque_ref of the given blob</param>
|
2013-06-24 13:41:48 +02:00
|
|
|
public static string get_mime_type(Session session, string _blob)
|
|
|
|
{
|
2017-09-13 18:14:07 +02:00
|
|
|
if (session.JsonRpcClient != null)
|
2018-02-23 17:06:32 +01:00
|
|
|
return session.JsonRpcClient.blob_get_mime_type(session.opaque_ref, _blob);
|
2017-09-13 18:14:07 +02:00
|
|
|
else
|
2020-01-30 01:02:24 +01:00
|
|
|
return session.XmlRpcProxy.blob_get_mime_type(session.opaque_ref, _blob ?? "").parse();
|
2013-06-24 13:41:48 +02:00
|
|
|
}
|
|
|
|
|
2014-05-16 17:58:13 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Set the name/label field of the given blob.
|
|
|
|
/// First published in XenServer 5.0.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="session">The session</param>
|
|
|
|
/// <param name="_blob">The opaque_ref of the given blob</param>
|
|
|
|
/// <param name="_label">New value to set</param>
|
2013-06-24 13:41:48 +02:00
|
|
|
public static void set_name_label(Session session, string _blob, string _label)
|
|
|
|
{
|
2017-09-13 18:14:07 +02:00
|
|
|
if (session.JsonRpcClient != null)
|
2018-02-23 17:06:32 +01:00
|
|
|
session.JsonRpcClient.blob_set_name_label(session.opaque_ref, _blob, _label);
|
2017-09-13 18:14:07 +02:00
|
|
|
else
|
2020-01-30 01:02:24 +01:00
|
|
|
session.XmlRpcProxy.blob_set_name_label(session.opaque_ref, _blob ?? "", _label ?? "").parse();
|
2013-06-24 13:41:48 +02:00
|
|
|
}
|
|
|
|
|
2014-05-16 17:58:13 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Set the name/description field of the given blob.
|
|
|
|
/// First published in XenServer 5.0.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="session">The session</param>
|
|
|
|
/// <param name="_blob">The opaque_ref of the given blob</param>
|
|
|
|
/// <param name="_description">New value to set</param>
|
2013-06-24 13:41:48 +02:00
|
|
|
public static void set_name_description(Session session, string _blob, string _description)
|
|
|
|
{
|
2017-09-13 18:14:07 +02:00
|
|
|
if (session.JsonRpcClient != null)
|
2018-02-23 17:06:32 +01:00
|
|
|
session.JsonRpcClient.blob_set_name_description(session.opaque_ref, _blob, _description);
|
2017-09-13 18:14:07 +02:00
|
|
|
else
|
2020-01-30 01:02:24 +01:00
|
|
|
session.XmlRpcProxy.blob_set_name_description(session.opaque_ref, _blob ?? "", _description ?? "").parse();
|
2013-06-24 13:41:48 +02:00
|
|
|
}
|
|
|
|
|
2014-05-16 17:58:13 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Set the public field of the given blob.
|
|
|
|
/// First published in XenServer 6.1.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="session">The session</param>
|
|
|
|
/// <param name="_blob">The opaque_ref of the given blob</param>
|
|
|
|
/// <param name="_public">New value to set</param>
|
2013-06-24 13:41:48 +02:00
|
|
|
public static void set_public(Session session, string _blob, bool _public)
|
|
|
|
{
|
2017-09-13 18:14:07 +02:00
|
|
|
if (session.JsonRpcClient != null)
|
2018-02-23 17:06:32 +01:00
|
|
|
session.JsonRpcClient.blob_set_public(session.opaque_ref, _blob, _public);
|
2017-09-13 18:14:07 +02:00
|
|
|
else
|
2020-01-30 01:02:24 +01:00
|
|
|
session.XmlRpcProxy.blob_set_public(session.opaque_ref, _blob ?? "", _public).parse();
|
2013-06-24 13:41:48 +02:00
|
|
|
}
|
|
|
|
|
2014-05-16 17:58:13 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Create a placeholder for a binary blob
|
|
|
|
/// First published in XenServer 5.0.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="session">The session</param>
|
|
|
|
/// <param name="_mime_type">The mime-type of the blob. Defaults to 'application/octet-stream' if the empty string is supplied</param>
|
|
|
|
public static XenRef<Blob> create(Session session, string _mime_type)
|
|
|
|
{
|
2017-09-13 18:14:07 +02:00
|
|
|
if (session.JsonRpcClient != null)
|
2018-02-23 17:06:32 +01:00
|
|
|
return session.JsonRpcClient.blob_create(session.opaque_ref, _mime_type);
|
2017-09-13 18:14:07 +02:00
|
|
|
else
|
2020-01-30 01:02:24 +01:00
|
|
|
return XenRef<Blob>.Create(session.XmlRpcProxy.blob_create(session.opaque_ref, _mime_type ?? "").parse());
|
2014-05-16 17:58:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Create a placeholder for a binary blob
|
|
|
|
/// First published in XenServer 5.0.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="session">The session</param>
|
|
|
|
/// <param name="_mime_type">The mime-type of the blob. Defaults to 'application/octet-stream' if the empty string is supplied</param>
|
|
|
|
/// <param name="_public">True if the blob should be publicly available First published in XenServer 6.1.</param>
|
2013-06-24 13:41:48 +02:00
|
|
|
public static XenRef<Blob> create(Session session, string _mime_type, bool _public)
|
|
|
|
{
|
2017-09-13 18:14:07 +02:00
|
|
|
if (session.JsonRpcClient != null)
|
2018-02-23 17:06:32 +01:00
|
|
|
return session.JsonRpcClient.blob_create(session.opaque_ref, _mime_type, _public);
|
2017-09-13 18:14:07 +02:00
|
|
|
else
|
2020-01-30 01:02:24 +01:00
|
|
|
return XenRef<Blob>.Create(session.XmlRpcProxy.blob_create(session.opaque_ref, _mime_type ?? "", _public).parse());
|
2013-06-24 13:41:48 +02:00
|
|
|
}
|
|
|
|
|
2014-05-16 17:58:13 +02:00
|
|
|
/// <summary>
|
|
|
|
///
|
|
|
|
/// First published in XenServer 5.0.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="session">The session</param>
|
|
|
|
/// <param name="_blob">The opaque_ref of the given blob</param>
|
|
|
|
public static void destroy(Session session, string _blob)
|
2013-06-24 13:41:48 +02:00
|
|
|
{
|
2017-09-13 18:14:07 +02:00
|
|
|
if (session.JsonRpcClient != null)
|
2018-02-23 17:06:32 +01:00
|
|
|
session.JsonRpcClient.blob_destroy(session.opaque_ref, _blob);
|
2017-09-13 18:14:07 +02:00
|
|
|
else
|
2020-01-30 01:02:24 +01:00
|
|
|
session.XmlRpcProxy.blob_destroy(session.opaque_ref, _blob ?? "").parse();
|
2013-06-24 13:41:48 +02:00
|
|
|
}
|
|
|
|
|
2014-05-16 17:58:13 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Return a list of all the blobs known to the system.
|
|
|
|
/// First published in XenServer 5.0.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="session">The session</param>
|
2013-06-24 13:41:48 +02:00
|
|
|
public static List<XenRef<Blob>> get_all(Session session)
|
|
|
|
{
|
2017-09-13 18:14:07 +02:00
|
|
|
if (session.JsonRpcClient != null)
|
2018-02-23 17:06:32 +01:00
|
|
|
return session.JsonRpcClient.blob_get_all(session.opaque_ref);
|
2017-09-13 18:14:07 +02:00
|
|
|
else
|
2020-01-30 01:02:24 +01:00
|
|
|
return XenRef<Blob>.Create(session.XmlRpcProxy.blob_get_all(session.opaque_ref).parse());
|
2013-06-24 13:41:48 +02:00
|
|
|
}
|
|
|
|
|
2014-05-16 17:58:13 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Get all the blob Records at once, in a single XML RPC call
|
|
|
|
/// First published in XenServer 5.0.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="session">The session</param>
|
2013-06-24 13:41:48 +02:00
|
|
|
public static Dictionary<XenRef<Blob>, Blob> get_all_records(Session session)
|
|
|
|
{
|
2017-09-13 18:14:07 +02:00
|
|
|
if (session.JsonRpcClient != null)
|
2018-02-23 17:06:32 +01:00
|
|
|
return session.JsonRpcClient.blob_get_all_records(session.opaque_ref);
|
2017-09-13 18:14:07 +02:00
|
|
|
else
|
2020-01-30 01:02:24 +01:00
|
|
|
return XenRef<Blob>.Create<Proxy_Blob>(session.XmlRpcProxy.blob_get_all_records(session.opaque_ref).parse());
|
2013-06-24 13:41:48 +02:00
|
|
|
}
|
|
|
|
|
2014-05-16 17:58:13 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Unique identifier/object reference
|
|
|
|
/// </summary>
|
|
|
|
public virtual string uuid
|
|
|
|
{
|
|
|
|
get { return _uuid; }
|
|
|
|
set
|
|
|
|
{
|
|
|
|
if (!Helper.AreEqual(value, _uuid))
|
|
|
|
{
|
|
|
|
_uuid = value;
|
|
|
|
NotifyPropertyChanged("uuid");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-09-13 18:14:07 +02:00
|
|
|
private string _uuid = "";
|
2013-06-24 13:41:48 +02:00
|
|
|
|
2014-05-16 17:58:13 +02:00
|
|
|
/// <summary>
|
|
|
|
/// a human-readable name
|
|
|
|
/// </summary>
|
|
|
|
public virtual string name_label
|
|
|
|
{
|
|
|
|
get { return _name_label; }
|
|
|
|
set
|
|
|
|
{
|
|
|
|
if (!Helper.AreEqual(value, _name_label))
|
|
|
|
{
|
|
|
|
_name_label = value;
|
|
|
|
NotifyPropertyChanged("name_label");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-09-13 18:14:07 +02:00
|
|
|
private string _name_label = "";
|
2013-06-24 13:41:48 +02:00
|
|
|
|
2014-05-16 17:58:13 +02:00
|
|
|
/// <summary>
|
|
|
|
/// a notes field containing human-readable description
|
|
|
|
/// </summary>
|
|
|
|
public virtual string name_description
|
|
|
|
{
|
|
|
|
get { return _name_description; }
|
|
|
|
set
|
|
|
|
{
|
|
|
|
if (!Helper.AreEqual(value, _name_description))
|
|
|
|
{
|
|
|
|
_name_description = value;
|
|
|
|
NotifyPropertyChanged("name_description");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-09-13 18:14:07 +02:00
|
|
|
private string _name_description = "";
|
2013-06-24 13:41:48 +02:00
|
|
|
|
2014-05-16 17:58:13 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Size of the binary data, in bytes
|
|
|
|
/// </summary>
|
|
|
|
public virtual long size
|
|
|
|
{
|
|
|
|
get { return _size; }
|
|
|
|
set
|
|
|
|
{
|
|
|
|
if (!Helper.AreEqual(value, _size))
|
|
|
|
{
|
|
|
|
_size = value;
|
|
|
|
NotifyPropertyChanged("size");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-06-24 13:41:48 +02:00
|
|
|
private long _size;
|
|
|
|
|
2014-05-16 17:58:13 +02:00
|
|
|
/// <summary>
|
|
|
|
/// True if the blob is publicly accessible
|
|
|
|
/// First published in XenServer 6.1.
|
|
|
|
/// </summary>
|
|
|
|
public virtual bool pubblic
|
|
|
|
{
|
|
|
|
get { return _pubblic; }
|
|
|
|
set
|
|
|
|
{
|
|
|
|
if (!Helper.AreEqual(value, _pubblic))
|
|
|
|
{
|
|
|
|
_pubblic = value;
|
|
|
|
NotifyPropertyChanged("pubblic");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-09-13 18:14:07 +02:00
|
|
|
private bool _pubblic = false;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
2014-05-16 17:58:13 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Time at which the data in the blob was last updated
|
|
|
|
/// </summary>
|
2017-09-13 18:14:07 +02:00
|
|
|
[JsonConverter(typeof(XenDateTimeConverter))]
|
2014-05-16 17:58:13 +02:00
|
|
|
public virtual DateTime last_updated
|
|
|
|
{
|
|
|
|
get { return _last_updated; }
|
|
|
|
set
|
|
|
|
{
|
|
|
|
if (!Helper.AreEqual(value, _last_updated))
|
|
|
|
{
|
|
|
|
_last_updated = value;
|
|
|
|
NotifyPropertyChanged("last_updated");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-06-24 13:41:48 +02:00
|
|
|
private DateTime _last_updated;
|
|
|
|
|
2014-05-16 17:58:13 +02:00
|
|
|
/// <summary>
|
|
|
|
/// The mime type associated with this object. Defaults to 'application/octet-stream' if the empty string is supplied
|
|
|
|
/// </summary>
|
|
|
|
public virtual string mime_type
|
|
|
|
{
|
|
|
|
get { return _mime_type; }
|
|
|
|
set
|
|
|
|
{
|
|
|
|
if (!Helper.AreEqual(value, _mime_type))
|
|
|
|
{
|
|
|
|
_mime_type = value;
|
|
|
|
NotifyPropertyChanged("mime_type");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-09-13 18:14:07 +02:00
|
|
|
private string _mime_type = "";
|
2013-06-24 13:41:48 +02:00
|
|
|
}
|
|
|
|
}
|