Пример #1
0
 /// <summary>アプライアンスを強制停止します。
 ///
 /// <returns>this</returns>
 /// </summary>
 public Appliance Stop()
 {
     this._Client.Request("DELETE", this._ApiPath() + "/" + Util.UrlEncode(this._Id()) + "/power", new System.Collections.Generic.Dictionary <string, object> {
         { "Force", true }
     });
     return(this);
 }
Пример #2
0
        /// <summary>このルータ+スイッチでIPv6アドレスを有効にします。
        ///
        /// <returns>有効化されたIPv6ネットワーク</returns>
        /// </summary>
        public Ipv6Net AddIpv6Net()
        {
            object result = this._Client.Request("POST", this._ApiPath() + "/" + Util.UrlEncode(this._Id()) + "/ipv6net");

            this.Reload();
            return(new Ipv6Net(this._Client, (result as System.Collections.Generic.Dictionary <string, object>)["IPv6Net"]));
        }
Пример #3
0
        internal Resource _Save()
        {
            object r     = this.ApiSerialize();
            object query = this._Query;

            this._Query = new System.Collections.Generic.Dictionary <string, object> {
            };
            System.Collections.Generic.List <string> keys = Util.DictionaryKeys(query);
            for (int __it1 = 0; __it1 < (keys as System.Collections.IList).Count; __it1++)
            {
                var    k = keys[__it1];
                object v = (query as System.Collections.Generic.Dictionary <string, object>)[k];
                (r as System.Collections.Generic.Dictionary <string, object>)[k] = v;
            }
            string method = this.IsNew ? "POST" : "PUT";
            string path   = this._ApiPath();

            if (!this.IsNew)
            {
                path += "/" + Util.UrlEncode(this._Id());
            }
            object q = new System.Collections.Generic.Dictionary <string, object> {
            };

            (q as System.Collections.Generic.Dictionary <string, object>)[this._RootKey()] = r;
            this._OnBeforeSave(q);
            object result = this._Client.Request(method, path, q);

            this.ApiDeserialize(result, true);
            return(this);
        }
Пример #4
0
        public Activity _Fetch(System.DateTime?startDate = null, System.DateTime?endDate = null)
        {
            object query = new System.Collections.Generic.Dictionary <string, object> {
            };

            if (startDate != null)
            {
                (query as System.Collections.Generic.Dictionary <string, object>)["Start"] = Util.Date2str(startDate);
            }
            if (endDate != null)
            {
                (query as System.Collections.Generic.Dictionary <string, object>)["End"] = Util.Date2str(endDate);
            }
            string path = this._ApiPathPrefix() + "/" + Util.UrlEncode(this._SourceId) + this._ApiPathSuffix();
            object data = this._Client.Request("GET", path);

            if (data == null)
            {
                return(null);
            }
            data = (data as System.Collections.Generic.Dictionary <string, object>)["Data"];
            if (data == null)
            {
                return(null);
            }
            System.Collections.Generic.List <string> dates = Util.DictionaryKeys(data);
            dates = Util.SortArray(dates);
            for (int __it1 = 0; __it1 < (dates as System.Collections.IList).Count; __it1++)
            {
                var date = dates[__it1];
                this._AddSample(date, (data as System.Collections.Generic.Dictionary <string, object>)[date]);
            }
            return(this);
        }
Пример #5
0
        /// <summary>サーバに挿入されているISOイメージを排出します。
        ///
        /// <returns>this</returns>
        /// </summary>
        public Server EjectIsoImage()
        {
            string path = this._ApiPath() + "/" + Util.UrlEncode(this._Id()) + "/cdrom";

            this._Client.Request("DELETE", path);
            this.Reload();
            return(this);
        }
Пример #6
0
        /// <summary>サーバプランを変更します。
        ///
        /// 成功時はリソースIDが変わることにご注意ください。
        ///
        /// <param name="planTo" />
        /// <returns>this</returns>
        /// </summary>
        public Server ChangePlan(ServerPlan planTo)
        {
            string path   = this._ApiPath() + "/" + Util.UrlEncode(this._Id()) + "/to/plan/" + Util.UrlEncode(planTo._Id());
            object result = this._Client.Request("PUT", path);

            this.ApiDeserialize(result, true);
            return(this);
        }
Пример #7
0
        /// <summary>FTPSを終了し、アーカイブを利用可能な状態にします。
        ///
        /// <returns>this</returns>
        /// </summary>
        public Archive CloseFtp()
        {
            string path = this._ApiPath() + "/" + Util.UrlEncode(this._Id()) + "/ftp";

            this._Client.Request("DELETE", path);
            this._FtpInfo = null;
            return(this);
        }
Пример #8
0
        /// <summary>このローカルオブジェクトのIDと一致するリソースの削除リクエストをAPIに送信します。
        /// </summary>
        public void Destroy()
        {
            if (this.IsNew)
            {
                return;
            }
            string path = this._ApiPath() + "/" + Util.UrlEncode(this._Id());

            this.RequestRetry("DELETE", path);
        }
Пример #9
0
        internal Resource _GetById(string id)
        {
            object query = this._Query.Build();

            this._Reset();
            object result = this._Client.Request("GET", this._ApiPath() + "/" + Util.UrlEncode(id), query);

            this._Total = 1;
            this._Count = 1;
            return(this._CreateResourceImpl(result, true));
        }
Пример #10
0
        internal Resource _Reload()
        {
            string id = this._Id();

            if (id != null)
            {
                object result = this.RequestRetry("GET", this._ApiPath() + "/" + Util.UrlEncode(id));
                this.ApiDeserialize(result, true);
            }
            return(this);
        }
Пример #11
0
        /// <summary>このルータ+スイッチの帯域プランを変更します。
        ///
        /// 成功時はリソースIDが変わることにご注意ください。
        ///
        /// <param name="bandWidthMbps" />
        /// <returns>this</returns>
        /// </summary>
        public Router ChangePlan(long bandWidthMbps)
        {
            string path = this._ApiPath() + "/" + Util.UrlEncode(this._Id()) + "/bandwidth";
            object q    = new System.Collections.Generic.Dictionary <string, object> {
            };

            Util.SetByPath(q, "Internet.BandWidthMbps", bandWidthMbps);
            object result = this._Client.Request("PUT", path, q);

            this.ApiDeserialize(result, true);
            return(this);
        }
Пример #12
0
        /// <summary>このルータ+スイッチにスタティックルートを追加します。
        ///
        /// <param name="maskLen" />
        /// <param name="nextHop" />
        /// <returns>追加されたスタティックルート</returns>
        /// </summary>
        public Ipv4Net AddStaticRoute(long maskLen, string nextHop)
        {
            object q = new System.Collections.Generic.Dictionary <string, object> {
            };

            Util.SetByPath(q, "NetworkMaskLen", maskLen);
            Util.SetByPath(q, "NextHop", nextHop);
            object result = this._Client.Request("POST", this._ApiPath() + "/" + Util.UrlEncode(this._Id()) + "/subnet", q);

            this.Reload();
            return(new Ipv4Net(this._Client, (result as System.Collections.Generic.Dictionary <string, object>)["Subnet"]));
        }
Пример #13
0
        /// <summary>FTPSを開始し、イメージファイルをアップロード・ダウンロードできる状態にします。
        ///
        /// アカウント情報は、ftpInfo プロパティから取得することができます。
        ///
        /// <param name="reset">既にFTPSが開始されているとき、trueを指定してこのメソッドを呼ぶことでパスワードを再設定します。</param>
        /// <returns>this</returns>
        /// </summary>
        public Archive OpenFtp(bool reset = false)
        {
            string path = this._ApiPath() + "/" + Util.UrlEncode(this._Id()) + "/ftp";
            object q    = new System.Collections.Generic.Dictionary <string, object> {
            };

            Util.SetByPath(q, "ChangePassword", reset);
            object result = this._Client.Request("PUT", path, q);

            this._OnAfterApiDeserialize(null, result);
            return(this);
        }
Пример #14
0
        /// <summary>サーバにISOイメージを挿入します。
        ///
        /// <param name="iso" />
        /// <returns>this</returns>
        /// </summary>
        public Server InsertIsoImage(IsoImage iso)
        {
            string path = this._ApiPath() + "/" + Util.UrlEncode(this._Id()) + "/cdrom";
            object q    = new System.Collections.Generic.Dictionary <string, object> {
                { "CDROM", new System.Collections.Generic.Dictionary <string, object> {
                      { "ID", iso._Id() }
                  } }
            };

            this._Client.Request("PUT", path, q);
            this.Reload();
            return(this);
        }
Пример #15
0
        /// <summary>監視対象サーバのステータスを最新の状態に更新します。
        /// </summary>
        public LoadBalancer ReloadStatus()
        {
            object result = this.RequestRetry("GET", this._ApiPath() + "/" + Util.UrlEncode(this._Id()) + "/status");

            if (result != null && (result as System.Collections.Generic.Dictionary <string, object>).ContainsKey("LoadBalancer"))
            {
                System.Collections.Generic.List <object> vips = ((System.Collections.Generic.List <object>)((result as System.Collections.Generic.Dictionary <string, object>)["LoadBalancer"]));
                for (int __it1 = 0; __it1 < (vips as System.Collections.IList).Count; __it1++)
                {
                    var         vipDyn = vips[__it1];
                    string      vipStr = ((string)((vipDyn as System.Collections.Generic.Dictionary <string, object>)["VirtualIPAddress"]));
                    LbVirtualIp vip    = this.GetVirtualIpByAddress(vipStr);
                    if (vip == null)
                    {
                        continue;
                    }
                    vip.UpdateStatus(((System.Collections.Generic.List <object>)((vipDyn as System.Collections.Generic.Dictionary <string, object>)["Servers"])));
                }
            }
            return(this);
        }
Пример #16
0
 /// <summary>アプライアンスを強制再起動します。
 ///
 /// <returns>this</returns>
 /// </summary>
 public Appliance Reboot()
 {
     this._Client.Request("PUT", this._ApiPath() + "/" + Util.UrlEncode(this._Id()) + "/reset");
     return(this);
 }
Пример #17
0
 /// <summary>アプライアンスの設定を反映します。
 ///
 /// <returns>this</returns>
 /// </summary>
 public Appliance Apply()
 {
     this._Client.Request("PUT", this._ApiPath() + "/" + Util.UrlEncode(this._Id()) + "/config");
     return(this);
 }
Пример #18
0
 /// <summary>スイッチから切断します。
 ///
 /// <returns>this</returns>
 /// </summary>
 public Iface DisconnectFromSwytch()
 {
     this._Client.Request("DELETE", this._ApiPath() + "/" + Util.UrlEncode(this._Id()) + "/to/switch");
     return(this.Reload());
 }
Пример #19
0
 /// <summary>共有セグメントに接続します。
 ///
 /// <returns>this</returns>
 /// </summary>
 public Iface ConnectToSharedSegment()
 {
     this._Client.Request("PUT", this._ApiPath() + "/" + Util.UrlEncode(this._Id()) + "/to/switch/shared");
     return(this.Reload());
 }
Пример #20
0
 /// <summary>指定したIDのスイッチに接続します。
 ///
 /// <param name="swytchId">接続先のスイッチID。</param>
 /// <returns>this</returns>
 /// </summary>
 public Iface ConnectToSwytchById(string swytchId)
 {
     this._Client.Request("PUT", this._ApiPath() + "/" + Util.UrlEncode(this._Id()) + "/to/switch/" + swytchId);
     return(this.Reload());
 }
Пример #21
0
 /// <summary>スイッチに接続します。
 ///
 /// <param name="swytch">接続先のスイッチ。</param>
 /// <returns>this</returns>
 /// </summary>
 public Iface ConnectToSwytch(Swytch swytch)
 {
     this._Client.Request("PUT", this._ApiPath() + "/" + Util.UrlEncode(this._Id()) + "/to/switch/" + Util.UrlEncode(swytch._Id()));
     return(this.Reload());
 }
Пример #22
0
 /// <summary>アプライアンスをシャットダウンします。
 ///
 /// <returns>this</returns>
 /// </summary>
 public Appliance Shutdown()
 {
     this._Client.Request("DELETE", this._ApiPath() + "/" + Util.UrlEncode(this._Id()) + "/power");
     return(this);
 }
Пример #23
0
 /// <summary>このルータ+スイッチからスタティックルートを削除します。
 ///
 /// <param name="ipv4Net" />
 /// <returns>this</returns>
 /// </summary>
 public Router RemoveStaticRoute(Ipv4Net ipv4Net)
 {
     this._Client.Request("DELETE", this._ApiPath() + "/" + Util.UrlEncode(this._Id()) + "/subnet/" + ipv4Net._Id());
     this.Reload();
     return(this);
 }
Пример #24
0
 /// <summary>サーバを強制再起動します。
 ///
 /// <returns>this</returns>
 /// </summary>
 public Server Reboot()
 {
     this._Client.Request("PUT", this._ApiPath() + "/" + Util.UrlEncode(this._Id()) + "/reset");
     return(this.Reload());
 }
Пример #25
0
 /// <summary>サーバをシャットダウンします。
 ///
 /// <returns>this</returns>
 /// </summary>
 public Server Shutdown()
 {
     this._Client.Request("DELETE", this._ApiPath() + "/" + Util.UrlEncode(this._Id()) + "/power");
     return(this.Reload());
 }