使用Cloud Server Node.js SDK

2020年12月31日19:42:44 发表评论 81 次浏览

notlogy Node.js SDK是一个Node.js库, 旨在通过REST API与notlogy云平台进行交互。

本指南包含有关如何开始使用该库以及如何通过Cloud Panel UI自动执行各种管理任务的说明。

总览

该SDK是Node.js编写的notlogy REST API的包装。针对API的所有操作均通过SSL执行, 并使用notlogy令牌密钥进行身份验证。 Node.js库有助于在notlogy平台上运行的实例中访问REST API。

有关Cloud Server for Node.js的更多信息, 请访问社区门户.

操作

伺服器

列出所有服务器:

oneandone.listServers(function (error, response, body) { //consume the result });

列出所有带有选项的服务器:

var options = {
    query: "node", page:1, perPage:1, sort:""
};
oneandone.listServersWithOptions(options, function (error, response, body) {//consume the result });

对响应中使用的服务器列表进行分页页和每页参数。组每页到将在每个页面中显示的服务器数量。页指示当前页面。当设置为小于或等于零的整数值时, 框架将忽略这些参数。

要接收按预期顺序排序的服务器列表, 请传递服务器属性(例如"名称")在分类参数。

采用询问参数以在响应中搜索字符串, 并仅返回包含该字符串的服务器实例。

要检索仅包含请求字段的服务器集合, 请传递以逗号分隔的属性列表(例如" id, 名称, 说明, hardware.ram")在领域参数。

如果有任何参数分类, 询问or领域设置为空字符串, 在请求中将被忽略。

检索单个服务器:

oneandone.getServer("server_id", function (error, response, body) {//consume the result });

列出固定大小的服务器模板:

oneandone.listHardwareFlavours(function (error, response, body) {//consume the result });

检索有关固定大小服务器模板的信息:

oneandone.getHardwareFlavour(hardware_flavour_id, function (error, response, body) {//consume the result });

检索有关服务器硬件的信息:

oneandone.getHardware(server.id, function (error, response, body) {//consume the result });

列出服务器的硬盘:

oneandone.listHdds(server_id, function (error, response, body) {//consume the result });

检索单个服务器硬盘:

oneandone.getHdd(server_id, hdd_id, function (error, response, body) {//consume the result });

检索有关服务器映像的信息:

oneandone.getServerImage(server_id, function (error, response, body) {//consume the result });

列出服务器的IP:

oneandone.listIps(server_id, function (error, response, body) {//consume the result });

检索有关单个服务器IP的信息:

oneandone.getIp(server_id, ip_id, function (error, response, body) {//consume the result });

列出分配给服务器IP的所有防火墙策略:

oneandone.listIpFirewallPolicies(server_id, ip_id, function (error, response, body) {//consume the result });

列出分配给服务器IP的所有负载均衡器:

oneandone.listIpLoadBalancer(server_id, ip_id, function (error, response, body) {//consume the result });

检索有关服务器状态的信息:

oneandone.getServerStatus(server_id, function (error, response, body) {//consume the result });

检索有关装入服务器的虚拟DVD单元中的DVD的信息:

oneandone.getDvd(server_id, function (error, response, body) {//consume the result });

列出服务器的专用网络:

oneandone.listServerPrivateNetworks(server_id, function (error, response, body) {//consume the result });

检索有关服务器专用网络的信息:

oneandone.getServerPrivateNetwork(server_id, current_privateNetwork_id, function (error, response, body) {//consume the result });

列出所有服务器的快照:

oneandone.listSnapshots(server_id, function (error, response, body) {//consume the result });

创建服务器:

var serverData = {
  "name": "My server", "description": "My server description", "hardware": {
    "vcore": 2, "cores_per_processor": 1, "ram": 2, "hdds": [
    {
      "size": 40, "is_main": true
    }, {
      "size": 20, "is_main": false
    }
    ]
  }, "appliance_id": "B5F778B85C041347BCDCFC3172AB3F3C", "datacenter_id": "908DC2072407C94C8054610AD5A53B8C"
};
oneandone.createServer(serverData, function (error, response, body) {//consume the result });

创建一个固定大小的服务器, 然后返回该服务器的IP地址和第一个密码:

var serverData = {
    "name": "Node Fixed Instance server", "description": "My server description", "hardware": {
        "fixed_instance_size_id": "65929629F35BBFBA63022008F773F3EB"
    }, "appliance_id": "B5F778B85C041347BCDCFC3172AB3F3C", "datacenter_id": "908DC2072407C94C8054610AD5A53B8C"
};
oneandone.createServer(serverData, function (error, response, body) {//consume the result });

更新服务器:

var updateData = {
    "name": "Node Server - UPDATED", "description": "desc"
};
oneandone.updateServer(server_id, updateData, function (error, response, body) {//consume the result });

删除服务器:

oneandone.deleteServer(server_id, keep_ips, function (error, response, body) {//consume the result });

组keep_ips参数true用于在删除服务器后保留服务器IP。

更新服务器的硬件:

var updateHardwareData = {
    "vcore": 4, "cores_per_processor": 2, "ram": 6
};
oneandone.updateHardware(server_id, updateHardwareData, function (error, response, body) {//consume the result });

将新硬盘添加到服务器:

var hddData = {
    "hdds": [
        {
            "size": 40, "is_main": false
        }
    ]
};
oneandone.addHdd(server_id, hddData, function (error, response, body) {//consume the result });

调整服务器硬盘的大小:

var updateData = {
    "size": 40
};
oneandone.updateHdd(server_id, hdd_id, updateData, function (error, response, body) {//consume the result });

卸下服务器的硬盘:

oneandone.deleteHdd(server_id, hdd_id, function (error, response, body) {//consume the result });

将DVD装入服务器的虚拟DVD单元:

var updateDVD = {
    "id": "908DC2072407C94C8054610AD5A53B8C"
};
oneandone.loadDvd(server_id, updateDVD, function (error, response, body) {//consume the result });

从服务器的虚拟DVD单元中卸载DVD:

oneandone.unloadDvd(server_id, function (error, response, body) {//consume the result });

将新映像重新安装到服务器中:

var updateData = {
    "id": "908DC2072407C94C8054610AD5A53B8C", //imageid
    "password": "Test123!"
};
oneandone.updateServerImage(server_id, updateData, function (error, response, body) {//consume the result });

为服务器分配新的IP:

var ipData = {
    "type": "IPV4"
};
oneandone.addIp(server_id, ipData, function (error, response, body) {//consume the result });

释放IP并有选择地将其从服务器中删除:

var keepip = {
    "keep_ip": false
};
oneandone.deleteIp(server_id, ip_id, keepip, function (error, response, body) {//consume the result });

组keep_ip如果不删除IP就释放IP, 则为true。

将新的防火墙策略分配给服务器的IP:

var firewallPolicyData = {
    "id": "071C8EB665DBA2EE574F3ED1256E5694"
};
oneandone.addFirewallPolicy(server_id, ip_id, firewallPolicyData, function (error, response, body) {//consume the result });

从服务器的IP中删除防火墙策略:

oneandone.deleteIpFirewallPolicy(server_id, ip_id, function (error, response, body) {//consume the result });

将新的负载均衡器分配给服务器的IP:

var loadBalancerData = {
    "load_balancer_id": "071C8EB665DBA2EE574F3ED1256E5694"
};
oneandone.addIpLoadBalancer(server_id, ip_id, loadBalancerData, function (error, response, body) {//consume the result });

从服务器的IP删除负载均衡器:

oneandone.deleteIpLoadBalancer(server_id, ip_id, load_balancer_id, function (error, response, body) {//consume the result });

启动服务器:

var updateData = {
    "action": oneandone.ServerUpdateAction.POWER_ON, "method": oneandone.ServerUpdateMethod.SOFTWARE
};
oneandone.updateServerStatus(server_id, updateData, function (error, response, body) {//consume the result });

组setMethod要么为了Types.ServerActionMethod.SOFTWAREorTypes.ServerActionMethod.HARDWARE有关重启的方法。

重新启动服务器:

var updateData = {
    "action": oneandone.ServerUpdateAction.REBOOT, "method": oneandone.ServerUpdateMethod.SOFTWARE
    };
oneandone.updateServerStatus(server_id, updateData, function (error, response, body) {//consume the result });

组setMethod要么为了Types.ServerActionMethod.SOFTWAREorTypes.ServerActionMethod.HARDWARE有关重启的方法。

关闭服务器:

var updateData = {
    "action": oneandone.ServerUpdateAction.POWER_OFF, "method": oneandone.ServerUpdateMethod.SOFTWARE
    };
oneandone.updateServerStatus(server_id, updateData, function (error, response, body) {//consume the result });

组方法要么为了oneandone.ServerUpdateMethod.SOFTWAREoroneandone.ServerUpdateMethod.HARDWARE有关重启的方法。

将专用网络分配给服务器:

var pnData = {
    "id": "071C8EB665DBA2EE574F3ED1256E5694"
};
oneandone.assignPrivateNetworkToServer(server_id, pnData, function (error, response, body) {//consume the result });

删除服务器的专用网络:

oneandone.deletePrivateNetworkFromServer(server_id, current_privateNetwork_id, function (error, response, body) {//consume the result });

创建新服务器的快照:

oneandone.createSnapshot(server_id, null, function (error, response, body) {//consume the result });

还原服务器的快照:

oneandone.restoreSnapshot(server_id, current_snapShot_id, null, function (error, response, body) {//consume the result });

删除服务器的快照:

oneandone.deleteSnapshot(server_id, current_snapShot_id, function (error, response, body) {//consume the result });

克隆服务器:

var cloneData = {
    "name": "node clone", "datacenter_id": "datacenter_id"
};
oneandone.clone(server.id, cloneData, function (error, response, body) {//consume the result });

图片

列出所有图像:

oneandone.listImages(function (error, response, body) {//consume the result });

列出所有带有选项的图像:

var options = {
    query: "node", page:1, perPage:1, sort:""
};
oneandone.listImagesWithOptions(options, function (error, response, body) {//consume the result });

对响应中使用的负载均衡器列表进行分页页和每页参数。组每页到将在每个页面中显示的负载均衡器的数量。页指示当前页面。当设置为小于或等于零的整数值时, 框架将忽略这些参数。

要接收按预期顺序排序的负载均衡器列表, 请传递负载均衡器属性(例如"名称")在分类参数。在排序属性前面加上-符号以降序排列。

采用询问参数以在响应中搜索字符串, 并仅返回包含该字符串的负载均衡器实例。

要检索仅包含请求字段的负载均衡器集合, 请传递以逗号分隔的属性列表(例如" ip, 名称, 方法")在领域参数。

如果有任何参数分类, 询问or领域设置为空字符串, 在请求中将被忽略。

检索单个图像:

oneandone.getImage(image_id, function (error, response, body) {//consume the result });

创建图像:

var imageData = {
    "server_id": server.id, "name": "node image", "description": "My image description", "frequency": oneandone.ImageFrequency.WEEKLY, "num_images": 1
};
oneandone.createImage(imageData, function (error, response, body) {//consume the result });

除了所有字段描述是必须的。频率可以设置为"一旦", "日常"or"每周".

更新图像:

var updateData = {
    "name": "image updated nodejs", "description": "New image description", "frequency": oneandone.ImageFrequency.ONCE
};
oneandone.updateImage(image_id, updateData, function (error, response, body) {//consume the result });

频率可以设置为"一旦", "日常"or"每周".

删除图片:

oneandone.deleteImage(image_id, function (error, response, body) {//consume the result });

共享存储

列出所有共享存储:

oneandone.listSharedStorages(function (error, response, body) {//consume the result });

列出所有共享存储, 并提供以下选项:

var options = {
    query: "node", page:1, perPage:1, sort:""
};
oneandone.listSharedStoragesWithOptions(options, function (error, response, body) {//consume the result });

对响应中使用的负载均衡器列表进行分页页和每页参数。组每页到将在每个页面中显示的负载均衡器的数量。页指示当前页面。当设置为小于或等于零的整数值时, 框架将忽略这些参数。

要接收按预期顺序排序的负载均衡器列表, 请传递负载均衡器属性(例如"名称")在分类参数。在排序属性前面加上-符号以降序排列。

采用询问参数以在响应中搜索字符串, 并仅返回包含该字符串的负载均衡器实例。

要检索仅包含请求字段的负载均衡器集合, 请传递以逗号分隔的属性列表(例如" ip, 名称, 方法")在领域参数。

如果有任何参数分类, 询问or领域设置为空字符串, 在请求中将被忽略。

检索共享存储:

oneandone.getSharedStorage(shared_storage_id, function (error, response, body) {//consume the result });

创建共享存储:

var storageData = {
    "name": "Node storage test", "description": "My shared storage test description", "size": 50
};
oneandone.createSharedStorage(storageData, function (error, response, body) {//consume the result });

描述是可选参数。

更新共享存储:

updateData = {
    "name": "node js storage test rename", "description": "My shared storage rename"
};
oneandone.updateSharedStorage(shared_storage_id, updateData, function (error, response, body) {//consume the result });

所有请求的参数都是可选的。

删除共享存储:

oneandone.deleteSharedStorage(shared_storage_id, function (error, response, body) {//consume the result });

列出共享存储服务器:

oneandone.listSharedStorageServers(shared_storage_id, function (error, response, body) {//consume the result });

检索共享存储服务器:

oneandone.getSharedStorageServer(shared_storage_id, server_id, function (error, response, body) {//consume the result });

将服务器添加到共享存储中:

var attachData = {
    "servers": [
        {
            "id": server_id, "rights": oneandone.StorageServerRights.RW
        }
    ]
};
oneandone.attachServerToSharedStorage(shared_storage_id, attachData, function (error, response, body) {//consume the result });

StorageServerRights可以设置为[RorRW串。

从共享存储中删除服务器:

oneandone.detachServerFromSharedStorage(shared_storage_id, server_id, function (error, response, body) {//consume the result });

检索访问共享存储的凭据:

oneandone.getAccessCredentials(function (error, response, body) {//consume the result });

更改用于访问共享存储的密码:

var updateData = {
    "password": "Test123!"
};
oneandone.changePassword(updateData, function (error, response, body) {//consume the result });

防火墙政策

列出防火墙策略:

oneandone.listFirewallPolicies(function (error, response, body) {//consume the result });

列出所有防火墙策略以及选项:

var options = {
    query: "node", page:1, perPage:1, sort:""
};
oneandone.listFirewallPoliciesWithOptions(options, function (error, response, body) {//consume the result });

对响应中使用的负载均衡器列表进行分页页和每页参数。组每页到将在每个页面中显示的负载均衡器的数量。页指示当前页面。当设置为小于或等于零的整数值时, 框架将忽略这些参数。

要接收按预期顺序排序的负载均衡器列表, 请传递负载均衡器属性(例如"名称")在分类参数。在排序属性前面加上-符号以降序排列。

采用询问参数以在响应中搜索字符串, 并仅返回包含该字符串的负载均衡器实例。

要检索仅包含请求字段的负载均衡器集合, 请传递以逗号分隔的属性列表(例如" ip, 名称, 方法")在领域参数。

如果有任何参数分类, 询问or领域设置为空字符串, 在请求中将被忽略。

检索单个防火墙策略:

oneandone.getFirewallPolicy(firewall_policy_id, function (error, response, body) {//consume the result });

创建防火墙策略:

var firewallData = {
    "name": "node firewall policy", "description": "My firewall policy description", "rules": [
        {
            "protocol": "TCP", "port_from": 80, "port_to": 80, "source": "0.0.0.0"
        }, {
            "protocol": "TCP", "port_from": 443, "port_to": 443, "source": "0.0.0.0"
        }
    ]
};
oneandone.createFirewallPolicy(firewallData, function (error, response, body) {//consume the result });

setSource和setDescription是可选参数。

更新防火墙策略:

var updateData = {
    "name": "node js Firewall test rename", "description": "My Firewall Policy rename"
};
oneandone.updateFirewallPolicy(firewall_policy_id, updateData, function (error, response, body) {//consume the result });

删除防火墙策略:

oneandone.deleteFirewallPolicy(firewall_policy_id, function (error, response, body) {//consume the result });

列出附加到防火墙策略的服务器/ IP:

oneandone.listFirewallPolicyServerIps(firewall_policy_id, function (error, response, body) {//consume the result });

检索有关分配给防火墙策略的服务器/ IP的信息:

oneandone.getFirewallPolicyServerIp(firewall_policy_id, server_ip_id, function (error, response, body) {//consume the result });

将服务器/ IP添加到防火墙策略:

var assignData = {
    "server_ips": [
        server_ip_id
    ]
};
oneandone.assignServerIpToFirewallPolicy(firewall_policy_id, assignData, function (error, response, body) {//consume the result });

从防火墙策略中删除服务器/ IP:

oneandone.unassignServerIpFromFirewallPolicy(firewall_policy_id, server_ip_id, function (error, response, body) {//consume the result });

列出防火墙策略的规则:

oneandone.listFirewallPolicyRules(firewall_policy_id, function (error, response, body) {//consume the result });

检索有关防火墙策略规则的信息:

oneandone.getFirewallPolicyRule(firewall_policy_id, firewall_policy_rule_id, function (error, response, body) {//consume the result });

向防火墙策略添加新规则:

var ruleData = {
    "rules": [
        {
            "protocol": oneandone.RuleProtocol.TCP, "port_from": 4567, "port_to": 4567, "source": "0.0.0.0"
        }
    ]
};
oneandone.addRulesToFirewallPolicy(firewall_policy_id, ruleData, function (error, response, body) {//consume the result });

从防火墙策略中删除规则:

oneandone.removeRuleFromFirewallPolicy(firewall_policy_id, firewall_policy_rule_id, function (error, response, body) {//consume the result });

负载均衡器

列出负载均衡器:

oneandone.listLoadBalancers(function (error, response, body) {//consume the result });

列出所有负载均衡器以及选项:

var options = {
    query: "node", page:1, perPage:1, sort:""
};
oneandone.listLoadBalancersWithOptions(options, function (error, response, body) {//consume the result });

对响应中使用的负载均衡器列表进行分页页和每页参数。组每页到将在每个页面中显示的负载均衡器的数量。页指示当前页面。当设置为小于或等于零的整数值时, 框架将忽略这些参数。

要接收按预期顺序排序的负载均衡器列表, 请传递负载均衡器属性(例如"名称")在分类参数。在排序属性前面加上-符号以降序排列。

采用询问参数以在响应中搜索字符串, 并仅返回包含该字符串的负载均衡器实例。

要检索仅包含请求字段的负载均衡器集合, 请传递以逗号分隔的属性列表(例如" ip, 名称, 方法")在领域参数。

如果有任何参数分类, 询问or领域设置为空字符串, 在请求中将被忽略。

检索单个负载均衡器:

oneandone.getLoadBalancer(load_balancer_id, function (error, response, body) {//consume the result });

创建一个负载均衡器:

var balancerData = {
    "name": "node balancer", "description": "My load balancer description", "health_check_test": oneandone.HealthCheckTestTypes.TCP, "health_check_interval": 1, "health_check_path": "path", "health_check_parser": null, "persistence": true, "persistence_time": 200, "method": oneandone.LoadBalancerMethod.ROUND_ROBIN, "rules": [
        {
            "protocol": "TCP", "port_balancer": 80, "port_server": 80, "source": "0.0.0.0"
        }, {
            "protocol": "TCP", "port_balancer": 9999, "port_server": 8888, "source": "0.0.0.0"
        }
    ]
};
oneandone.createLoadBalancer(balancerData, function (error, response, body) {//consume the result });

可选参数是HealthCheckPath, HealthCheckPathParser, 资源和描述。负载均衡器方法必须设置为" ROUND_ROBIN"or" LEAST_CONNECTIONS".

更新负载均衡器:

var updateData = {
            "name": "node balancer rename", "description": "My load balancer rename description", "health_check_test": oneandone.HealthCheckTestTypes.TCP, "health_check_interval": 40, "persistence": true, "persistence_time": 1200, "method": oneandone.LoadBalancerMethod.ROUND_ROBIN
        };
oneandone.updateLoadBalancer(load_balancer_id, updateData, function (error, response, body) {//consume the result });

所有可更新字段都是可选的。

删除负载均衡器:

oneandone.deleteLoadBalancer(load_balancer_id, function (error, response, body) {//consume the result });

列出连接到负载均衡器的服务器/ IP:

oneandone.listLoadBalancerServerIps(load_balancer_id, function (error, response, body) {//consume the result });

检索有关分配给负载均衡器的服务器/ IP的信息:

oneandone.getLoadBalancerServerIp(load_balancer_id, server_ip_id, function (error, response, body) {//consume the result });

将服务器/ IP添加到负载均衡器:

var assignData = {
    "server_ips": [
        server_ip_id
    ]
};
oneandone.assignServerIpToLoadBalancer(load_balancer_id, assignData, function (error, response, body) {//consume the result });

从负载均衡器中删除服务器/ IP:

oneandone.unassignServerIpFromLoadBalancer(load_balancer_id, server_ip_id, function (error, response, body) {//consume the result });

列出负载均衡器的规则:

oneandone.listLoadBalancerRules(load_balancer_id, function (error, response, body) {//consume the result });

检索有关负载均衡器规则的信息:

oneandone.getLoadBalancerRule(load_balancer_id, loadBalancer_rule_id, function (error, response, body) {//consume the result });

向负载均衡器添加新规则:

var ruleData = {
    "rules": [
        {
            "protocol": oneandone.RuleProtocol.TCP, "port_balancer": 82, "port_server": 82, "source": "0.0.0.0"
        }
    ]
};
oneandone.addRulesToLoadBalancer(load_balancer_id, ruleData, function (error, response, body) {//consume the result });

从负载均衡器中删除规则:

oneandone.removeRuleFromLoadBalancer(load_balancer_id, loadBalancer_rule_id, function (error, response, body) {//consume the result });

公开IP

检索你的公共IP列表:

oneandone.listPublicIps(function (error, response, body) {//consume the result });

检索带有选项的公共IP列表:

var options = {
    query: "node", page:1, perPage:1, sort:""
};

oneandone.listPublicIpsWithOptions(选项, 函数(错误, 响应, 正文){//使用结果});

对响应使用中收到的公共IP列表进行分页页和每页参数。组每页每页将显示的公共IP数量。页指示当前页面。当设置为小于或等于零的整数值时, 框架将忽略这些参数。

要接收按预期顺序排序的公共IP列表, 请传递公共IP属性(例如" ip")在分类参数。在排序属性前面加上-符号以降序排列。

采用询问参数以在响应中搜索字符串, 并仅返回包含该字符串的公共IP实例。

要检索仅包含请求字段的公共IP集合, 请传递以逗号分隔的属性列表(例如" id, ip, reverse_dns")在领域参数。

如果有任何参数分类, 询问or领域设置为空字符串, 在请求中将被忽略。

检索单个公共IP:

oneandone.getPublicIp(public_ip_id, function (error, response, body) {//consume the result });

创建一个公共IP:

var publicIpData = {
    "reverse_dns": "node.com", "type": oneandone.IPType.IPV4
};
oneandone.createPublicIp(publicIpData, function (error, response, body) {//consume the result });

这两个参数都是可选的, 可以留空。类型可以设置为" IPV4"or" IPV6"。当前, 仅支持IPV4。

更新公共IP的反向DNS:

var updateData = {
    "reverse_dns": "example.es"
};
oneandone.updatePublicIp(public_ip_id, updateData, function (error, response, body) {//consume the result });

如果传入一个空字符串reverseDns, 它删除了公共IP的先前反向DNS。

删除公共IP:

oneandone.deletePublicIp(public_ip_id, function (error, response, body) {//consume the result });

私人网络

列出所有专用网络:

oneandone.listPrivateNetworks(function (error, response, body) {//consume the result });

使用以下选项检索你的专用网络列表:

var options = {
    query: "node", page:1, perPage:1, sort:""
};
oneandone.listPrivateNetworksWithOptions(options, function (error, response, body) {//consume the result });

对在响应使用中收到的专用网络列表进行分页页和每页参数。组每页到将在每个页面中显示的专用网络的数量。页指示当前页面。当设置为小于或等于零的整数值时, 框架将忽略这些参数。

要接收按预期顺序排序的专用网络列表, 请传递一个专用网络属性(例如"-创建日期")在分类参数。在排序属性前面加上-符号以降序排列。

采用询问参数以在响应中搜索字符串, 并仅返回包含该字符串的专用网络实例。

要检索仅包含请求字段的专用网络集合, 请传递以逗号分隔的属性列表(例如" id, 名称, creation_date")在领域参数。

如果有任何参数分类, 询问or领域为空白, 在请求中将被忽略。

检索有关专用网络的信息:

oneandone.getPrivateNetwork(private_network_id, function (error, response, body) {//consume the result });

创建一个新的专用网络:

var pnData = {
    "name": "node Private Network", "description": "node Private network description", "network_address": "192.168.1.0", "subnet_mask": "255.255.255.0"
};
oneandone.createPrivateNetwork(pnData, function (error, response, body) {//consume the result });

专用网名称是必填参数。

修改专用网络:

updateData = {
    "name": "node update Private Network", "description": "Private network description", "network_address": "192.168.1.0", "subnet_mask": "255.255.255.0"
};
oneandone.updatePrivateNetwork(private_network_id, updateData, function (error, response, body) {//consume the result });

请求中的所有参数都是可选的。

删除专用网络:

oneandone.deletePrivateNetwork(private_network_id, function (error, response, body) {//consume the result });

列出连接到专用网络的所有服务器:

oneandone.listPrivateNetworkServers(private_network_id, function (error, response, body) {//consume the result });

检索连接到专用网络的服务器:

oneandone.getPrivateNetworkServer(private_network_id, server_id, function (error, response, body) {//consume the result });

将服务器连接到专用网络:

var attach = {
    "servers": [
        "server_id"
    ]
};
oneandone.attachServerToPrivateNetwork(private_network_id, attach, function (error, response, body) {

注意:如果服务器当前具有快照, 则不能将它们连接到专用网络。

从专用网络中删除服务器:

oneandone.detachServerFromPrivateNetwork(private_network_id, server_id, function (error, response, body) {

注意:如果服务器当前具有快照或已打开电源, 则无法将其从专用网络中删除。

虚拟专用网

列出所有VPN:

oneandone.listVpns(function (error, response, body) {//consume the result });

使用选项检索你的VPN列表:

var options = {
    query: "node", page:1, perPage:1, sort:""
};

oneandone.listVpnsWithOptions(选项, 函数(错误, 响应, 正文){//消耗结果});

对响应中使用的VPN列表进行分页页和每页参数。组每页每页将显示的VPN数量。页指示当前页面。当设置为小于或等于零的整数值时, 框架将忽略这些参数。

要接收按预期顺序排序的VPN列表, 请传递VPN属性(例如"名称")在分类参数。在排序属性前面加上-符号以降序排列。

采用询问参数以在响应中搜索字符串, 并仅返回包含该字符串的VPN实例。

要检索仅包含请求字段的VPN集合, 请传递以逗号分隔的属性列表(例如" id, 名称, creation_date")在领域参数。

如果有任何参数分类, 询问or领域设置为空字符串, 在请求中将被忽略。

检索有关VPN的信息:

oneandone.getVpn(vpn.id, function (error, response, body) {//consume the result });

创建一个VPN:

var vpnData = {
  "name": "My VPN", "description": "My VPN description", "datacenter_id": "D0F6D8C8ED29D3036F94C27BBB7BAD36"
};
oneandone.createVpn(vpnData, function (error, response, body) {//consume the result });

修改VPN:

var updateData = {
    "name": "node VPN rename", "description": "node VPN rename description"
};
oneandone.updateVpn(vpn.id, updateData, function (error, response, body) {//consume the result });

删除VPN:

oneandone.deleteVpn(vpnToRemove.id, function (error, response, body) {//consume the result });

检索VPN的配置文件:

oneandone.getConfigurationFile(vpn.id, function (error, response, body) {//consume the result });

监控中心

列出监视服务器的所有用法和警报:

oneandone.listMonitoringCenters(function (error, response, body) {//consume the result });

使用选项列出监视服务器的所有使用情况和警报:

var options = {
    query: "node", page:1, perPage:1, sort:""
};

oneandone.listMonitoringCentersWithOption(选项, 函数(错误, 响应, 正文){//消耗结果});

对响应使用中收到的服务器使用情况列表进行分页页和每页参数。组每页每页中将显示的服务器使用率。页指示当前页面。当设置为小于或等于零的整数值时, 框架将忽略这些参数。

要接收按预期顺序排序的服务器使用情况列表, 请传递服务器使用情况属性(例如"名称")在分类参数。在排序属性前面加上-符号以降序排列。

采用询问参数以在响应中搜索字符串, 并仅返回包含该字符串的用法实例。

要检索仅包含请求字段的服务器使用情况的集合, 请传递以逗号分隔的属性列表(例如" id, 名称, status.state")在领域参数。

如果有任何参数分类, 询问or领域为空白, 在请求中将被忽略。

检索监视服务器的用法和警报:

oneandone.getServerMonitoringCenterFixedPeriod(server_id, oneandone.PeriodType.LAST_24H, function (error, response, body) {//consume the result });

期可以设置为"上一个小时", " LAST_24H", " LAST_7D", " LAST_30D", " LAST_365D"or"自定义"。如果期被设置为"自定义",

检索客户时段内监视服务器的使用情况和警报:

Mneandone.getServerMonitoringCenterCustomPeriod(server_id, start_date, end_date, function (error, response, body) {//consume the result });

监控政策

列出所有监视策略:

oneandone.listMonitoringPolicies(function (error, response, body) {//consume the result });

使用选项列出监视服务器的所有使用情况和警报:

var options = {
    query: "node", page:1, perPage:1, sort:""
};
oneandone.listMonitoringPoliciesWithOptions(options, function (error, response, body) {//consume the result });

对响应使用中收到的监视策略列表进行分页页和每页参数。组每页到将在每个页面中显示的监视策略的数量。页指示当前页面。当设置为小于或等于零的整数值时, 框架将忽略这些参数。

要接收按预期顺序排序的监控策略列表, 请传递监控策略属性(例如"名称")在分类参数。在排序属性前面加上-符号以降序排列。

采用询问参数以在响应中搜索字符串, 并仅返回包含该字符串的监视策略实例。

要检索仅包含请求字段的监视策略集合, 请传递以逗号分隔的属性列表(例如" id, 名称, creation_date")在领域参数。

如果有任何参数分类, 询问or领域设置为空字符串, 在请求中将被忽略。

检索单个监视策略:

oneandone.getMonitoringPolicy(policy_id, function (error, response, body) {//consume the result });

创建监视策略:

var policyData = {
    "name": "node monitoring policy", "description": "node monitoring policy description", "email": "", "agent": true, "thresholds": {
        "cpu": {
            "warning": {
                "value": 90, "alert": false
            }, "critical": {
                "value": 95, "alert": false
            }
        }, "ram": {
            "warning": {
                "value": 90, "alert": false
            }, "critical": {
                "value": 95, "alert": false
            }
        }, "disk": {
            "warning": {
                "value": 80, "alert": false
            }, "critical": {
                "value": 90, "alert": false
            }
        }, "transfer": {
            "warning": {
                "value": 1000, "alert": false
            }, "critical": {
                "value": 2000, "alert": false
            }
        }, "internal_ping": {
            "warning": {
                "value": 50, "alert": false
            }, "critical": {
                "value": 100, "alert": false
            }
        }
    }, "ports": [
        {
            "protocol": "TCP", "port": "22", "alert_if": "RESPONDING", "email_notification": true
        }
    ], "processes": [
        {
            "process": "test", "alert_if": "NOT_RUNNING", "email_notification": true
        }
    ]
};
oneandone.createMonitoringPolicy(policyData, function (error, response, body) {//consume the result });

所有字段, 除了描述, 是必须的。AlertIf属性接受值"回应"/"没有响应"用于港口, 以及「跑步中」/" NOT_RUNNING"用于流程。

更新监视策略:

var updateData = {
    "name": "node Monitoring Policy reName", "description": "node Monitoring Policy Description", "email": "test2@gmail.com", "thresholds": {
        "cpu": {
            "warning": {
                "value": 90, "alert": false
            }, "critical": {
                "value": 95, "alert": false
            }
        }, "ram": {
            "warning": {
                "value": 90, "alert": false
            }, "critical": {
                "value": 95, "alert": false
            }
        }, "disk": {
            "warning": {
                "value": 80, "alert": false
            }, "critical": {
                "value": 90, "alert": false
            }
        }, "transfer": {
            "warning": {
                "value": 1000, "alert": false
            }, "critical": {
                "value": 2000, "alert": false
            }
        }, "internal_ping": {
            "warning": {
                "value": 50, "alert": false
            }, "critical": {
                "value": 100, "alert": false
            }
        }
    }
};
oneandone.updateMonitoringPolicy(policy_id, updateData, function (error, response, body) {//consume the result });

请求的所有字段都是可选的。在请求中指定阈值时, 阈值字段是必需的。

删除监控策略:

oneandone.deleteMonitoringPolicy(policy_id, function (error, response, body) {//consume the result });

列出监视策略的所有端口:

oneandone.listMonitoringPoliciesPorts(policy_id, function (error, response, body) {//consume the result });

检索有关监视策略端口的信息:

oneandone.getPortsMonitoringPolicy(policy_id, port_id, function (error, response, body) {//consume the result });

将新端口添加到监视策略:

var portsData = {
    "ports": [
        {
            "protocol": oneandone.ProtocolType.TCP, "port": "80", "alert_if": oneandone.AlertIfType.NOT_RESPONDING, "email_notification": false
        }
    ]
};
oneandone.createMonitoringPolicyForPorts(policy_id, portsData, function (error, response, body) {//consume the result });

端口属性是必需的。

修改监控策略的端口:

var updatePortData = {
    "ports": {
        "protocol": oneandone.ProtocolType.TCP, "port": "80", "alert_if": oneandone.AlertIfType.RESPONDING, "email_notification": false
    }
};
oneandone.updatePortsMonitoringPolicy(policy_id, port_id, updatePortData, function (error, response, body) {//consume the result });

注意:协议和港口无法更改。

从监视策略中删除端口:

oneandone.deletePortsMonitoringPolicy(policy.id, port.id, function (error, response, body) {//consume the result });

列出监视策略的过程:

oneandone.listMonitoringPoliciesProcesses(policy_id, function (error, response, body) {//consume the result });

检索有关监视策略过程的信息:

oneandone.getProcessesMonitoringPolicy(policy_id, process_id, function (error, response, body) {//consume the result });

将新流程添加到监视策略:

var processesData = {
    "processes": [
        {
            "process": "taskmmgr", "alert_if": oneandone.ProcessAlertType.RUNNING, "email_notification": false
        }
    ]
};
oneandone.createMonitoringPolicyForProcesses(policy_id, processesData, function (error, response, body) {//consume the result });

的所有属性监控流程实例是必需的。

修改监视策略的过程:

var updatePortData = {
    "processes": {
        "process": "test", "alert_if": oneandone.ProcessAlertType.RUNNING, "email_notification": false
    }
};
oneandone.updateProcessesMonitoringPolicy(policy_id, process_id, updatePortData, function (error, response, body) {//consume the result });

注意:进程名称无法更改。

从监视策略中删除进程:

oneandone.deleteProcessesMonitoringPolicy(policy_id, process_id, function (error, response, body) {//consume the result });

列出附加到监视策略的所有服务器:

oneandone.listMonitoringPoliciesServers(policy_id, function (error, response, body) {//consume the result });

检索有关附加到监视策略的服务器的信息:

oneandone.getServersMonitoringPolicy(policy_id, server_id, function (error, response, body) {//consume the result });

将服务器附加到监视策略:

var serversData = {
    "servers": [
        "server_id"
    ]
};
oneandone.createMonitoringPolicyForServers(policy_id, serversData, function (error, response, body) {//consume the result });

从监视策略中删除服务器:

oneandone.deleteServersMonitoringPolicy(policy_id, server_id, function (error, response, body) {//consume the result });

日志

列出所有日志:

var options = {
    query: "node", page:1, perPage:1, sort:""
};

oneandone.listLogsFixedPeriodWithOptions(oneandone.PeriodType.LAST_7D, 选项, 函数(错误, 响应, 正文){//使用结果});

期可以设置为"上一个小时", " LAST_24H", " LAST_7D", " LAST_30D", " LAST_365D".

可以使用其他查询参数。

要分页在响应中收到的日志列表, 请使用页和每页参数。组每页到将在每个页面中显示的日志数。页指示当前页面。当设置为小于或等于零的整数值时, 框架将忽略这些参数。

要接收按预期顺序排序的日志列表, 请传递logs属性(例如"行动")在分类参数。在排序属性前面加上-符号以降序排列。

采用询问参数以在响应中搜索字符串, 并仅返回包含该字符串的日志实例。

要检索仅包含请求字段的日志集合, 请传递以逗号分隔的属性列表(例如" id, 动作, 类型")在领域参数。

如果有任何参数分类, 询问or领域设置为空字符串, 在请求中将被忽略。

列出自定义期间的所有日志:

var options = {
    query: "node", page:1, perPage:1, sort:""
};

oneandone.listLogsCustomPeriodWithOptions(开始日期, 结束日期, 选项, 函数(错误, 响应, 正文){//使用结果});

可以使用其他查询参数。

要分页在响应中收到的日志列表, 请使用页和每页参数。组每页到将在每个页面中显示的日志数。页指示当前页面。当设置为小于或等于零的整数值时, 框架将忽略这些参数。

要接收按预期顺序排序的日志列表, 请传递logs属性(例如"行动")在分类参数。在排序属性前面加上-符号以降序排列。

采用询问参数以在响应中搜索字符串, 并仅返回包含该字符串的日志实例。

要检索仅包含请求字段的日志集合, 请传递以逗号分隔的属性列表(例如" id, 动作, 类型")在领域参数。

如果有任何参数分类, 询问or领域设置为空字符串, 在请求中将被忽略。

检索单个日志:

oneandone.getLog(log.id, function (error, response, body) {//consume the result });

用户数

列出所有用户:

oneandone.listUsers(function (error, response, body) {//consume the result });

列出所有用户的选项:

var options = {
    query: "node", page:1, perPage:1, sort:""
};
oneandone.listUsersWithOptions(options, function (error, response, body) {//consume the result });

对响应中使用的用户列表进行分页页和每页参数。组每页每页显示的用户数。页指示当前页面。当设置为小于或等于零的整数值时, 框架将忽略这些参数。

要接收按预期顺序排序的用户列表, 请传递用户属性(例如"名称")在分类参数。在排序属性前面加上-符号以降序排列。

采用询问参数以在响应中搜索字符串, 并仅返回包含该字符串的用户实例。

要检索仅包含请求字段的用户集合, 请传递以逗号分隔的属性列表(例如" ID, 名称, 创建日期, 电子邮件")在领域参数。

如果有任何参数分类, 询问or领域设置为空字符串, 在请求中将被忽略。

检索有关用户的信息:

oneandone.getUser(user_id, function (error, response, body) {//consume the result });

创建一个用户:

var userData = {
    "name": " node user", "description": "User description", "password": "test2015", "email": "test@arsys.es"
};
oneandone.createUser(userData, function (error, response, body) {//consume the result });

名称和密码是必填参数。密码必须至少包含8个字符, 使用大写字母, 数字和其他特殊符号。

修改用户:

var updateData = {
    "name": "Manager role", "description": "Manager role description", "state": "ACTIVE"
};
oneandone.updateUser(user_id, updateData, function (error, response, body) {//consume the result });

请求中所有列出的字段都是可选的。州可以设置为"活性"or"已禁用".

删除用户:

oneandone.deleteUser(user_id, function (error, response, body) {//consume the result });

检索有关用户的API特权的信息:

`oneandone.getUserApiInformation(user_id, 函数(错误, 响应, 正文){//使用结果});

检索用户的API密钥:

oneandone.getUserApiKey(user_id, function (error, response, body) {//consume the result });

列出允许用户进行API访问的IP:

oneandone.getUserApiAllowedIPs(user_id, function (error, response, body) {//consume the result });

向用户添加新IP:

var ipList = {
    "ips": [
        "192.168.1.1"
    ]
};
oneandone.addUserAPIAllowedIPs(user_id, ipList, function (error, response, body) {//consume the result });

删除IP并禁止从其中访问API:

oneandone.deleteUserAPIAllowedIPs(user_id, "192.168.1.1", function (error, response, body) {//consume the result });

修改用户的API权限:

var updateApi = {
    "active": true
};
oneandone.updateUserApiInformation(user.id, updateApi, function (error, response, body) {//consume the result });

续订用户的API密钥:

oneandone.updateUserApiKey(user.id, function (error, response, body) {//consume the result });

的角色

列出所有角色:

oneandone.listRoles(function (error, response, body) {//consume the result });

列出所有角色以及选项:

var options = {
    query: "node", page:1, perPage:1, sort:""
};
oneandone.listRolesWithOptions(options, function (error, response, body) {//consume the result });

对响应中使用的角色列表进行分页页和每页参数。组每页到将在每个页面中显示的角色数。页指示当前页面。当设置为小于或等于零的整数值时, 框架将忽略这些参数。

要接收按预期顺序排序的角色列表, 请传递role属性(例如"名称")在分类参数。在排序属性前面加上-符号以降序排列。

采用询问参数以在响应中搜索字符串, 并仅返回包含该字符串的角色实例。

要检索仅包含请求字段的角色集合, 请传递以逗号分隔的属性列表(例如" id, 名称, creation_date")在领域参数。

如果有任何参数分类, 询问or领域设置为空字符串, 在请求中将被忽略。

检索有关角色的信息:

oneandone.getRole(role_id, function (error, response, body) {//consume the result });

创建一个角色:

var roleData = {
    "name": "node role"
};
oneandone.createRole(roleData, function (error, response, body) {//consume the result });

克隆角色:

var cloneRoleData = {
    "name": "node role"
};
oneandone.cloneRole(role_id, cloneRoleData, function (error, response, body) {//consume the result });

修改角色:

var updateRole = {
    "name": "node Manager role", "description": "Manager role description", "state": "ACTIVE"
};
oneandone.updateRole(role_id, updateRole, function (error, response, body) {//consume the result });

活性和禁用是该状态的有效值。

删除角色:

oneandone.deleteRole(role_id, function (error, response, body) {//consume the result });

检索有关角色权限的信息:

oneandone.getRolePermissions(role_id, function (error, response, body) {//consume the result });

修改角色的权限:

var updatePermissions = {
    "servers": {
        "show": true, "create": true, "delete": false, "set_name": true, "set_description": true, "start": true, "restart": true, "shutdown": true
    }, "images": {
        "show": true, "create": true, "delete": false, "set_name": true, "set_description": true, "disable_automatic_creation": true
    }
};
oneandone.updateRolePermissions(role_id, updatePermissions, function (error, response, body) {//consume the result });

为用户分配角色:

var usersToAdd = {
    "users": [
        user_id
    ]
};

usersList是用户ID的字符串列表。

列出角色的用户:

oneandone.listRoleUsers(role_id, function (error, response, body) {//consume the result });

检索有关角色用户的信息:

oneandone.getRoleUser(role_id, user_id, function (error, response, body) {//consume the result });

删除角色的用户:

oneandone.removeRoleFromUser(role_id, user_id, function (error, response, body) {//consume the result });

用法

列出你的用法和选项:

var options = {
    query: "node", page:1, perPage:1, sort:""
};

oneandone.listUsagesFixedPeriodWithOptions(oneandone.PeriodType.LAST_30D, 选项, 函数(错误, 响应, 正文){//使用结果});

期可以设置为"上一个小时", " LAST_24H", " LAST_7D", " LAST_30D", " LAST_365D".

列出自定义期间的用法:

var options = {
    query: "node", page:1, perPage:1, sort:""
};

oneandone.listUsagesCustomPeriodWithOptions(start_date, end_date, null, 函数(错误, 响应, 正文){//使用结果});

对响应使用中收到的用法列表进行分页页和每页参数。组每页每页将显示的使用次数。页指示当前页面。当设置为小于或等于零的整数值时, 框架将忽略这些参数。

要接收按预期顺序排序的用法列表, 请传递用法属性(例如"名称")在分类参数。在排序属性前面加上-符号以降序排列。

采用询问参数以在响应中搜索字符串, 并仅返回包含该字符串的用法实例。

要检索仅包含请求字段的用法集合, 请传递以逗号分隔的属性列表(例如"身份证, 姓名")在领域参数。

如果有任何参数分类, 询问or领域设置为空字符串, 在请求中将被忽略。

服务器设备

列出可用于创建服务器的所有设备:

oneandone.listServerAppliances(function (error, response, body) {//consume the result });

服务器设备

列出可用于创建服务器的所有设备:

var options = {
    query: "node", page:1, perPage:1, sort:""
};

oneandone.listServerAppliancesWithOptions(选项, 函数(错误, 响应, 正文){//使用结果});

对响应使用中收到的服务器设备列表进行分页页和每页参数。组每页每页将显示的服务器设备的数量。页指示当前页面。当设置为小于或等于零的整数值时, 框架将忽略这些参数。

要接收按预期顺序排序的服务器设备列表, 请传递服务器设备属性(例如" os")在分类参数。在排序属性前面加上-符号以降序排列。

采用询问参数以在响应中搜索字符串, 并仅返回包含该字符串的服务器设备实例。

要检索仅包含请求字段的服务器设备的集合, 请传递以逗号分隔的属性列表(例如" id, os, 体系结构")在领域参数。

如果有任何参数分类, 询问or领域为空白, 在请求中将被忽略。

检索有关特定设备的信息:

oneandone.getServerAppliance(appliance.id, function (error, response, body) {//consume the result });

DVD ISO

列出可以加载到虚拟DVD单元中的所有操作系统和工具:

oneandone.listDvdIso(function (error, response, body) {//consume the result });
var options = {
    query: "node", page:1, perPage:1, sort:""
};
oneandone.listDvdIsoWithOptions(options, function (error, response, body) {//consume the result });

要对响应中使用的ISO DVD列表进行分页页和每页参数。组每页每页将显示的ISO DVD数量。页指示当前页面。当设置为小于或等于零的整数值时, 框架将忽略这些参数。

要接收按预期顺序排序的ISO DVD列表, 请传递ISO DVD属性(例如"类型")在分类参数。在排序属性前面加上-符号以降序排列。

采用询问参数以在响应中搜索字符串, 并仅返回包含该字符串的ISO DVD实例。

要检索仅包含请求字段的ISO DVD集合, 请传递以逗号分隔的属性列表(例如" id, 名称, 类型")在领域参数。

如果有任何参数分类, 询问or领域为空白, 在请求中将被忽略。

检索特定的ISO映像:

oneandone.getDvdIso(dvdIso.id, function (error, response, body) {//consume the result });

检查notlogy REST API是否正在运行:

oneandone.pingApi(function (error, response, body) {//consume the result });

如果API正在运行, 则响应为傍.

验证notlogy REST API是否正在运行并且授权令牌是否有效:

oneandone.pingApiAuthentication(function (error, response, body) {//consume the result });

响应是傍。如果API正在运行并且令牌有效。

价钱

在"云面板"中显示所有可用资源的价格:

oneandone.getPricing(function (error, response, body) {//consume the result });

数据中心

列出所有Cloud Server数据中心:

oneandone.listDatacenters(function (error, response, body) {//consume the result });

列出所有Cloud Server数据中心, 并提供以下选项:

var options = {
    query: "node", page:1, perPage:1, sort:""
};
oneandone.listDatacentersWithOptions(options, function (error, response, body) {//consume the result });

检索特定的数据中心:

oneandone.getDatacenters(dataCenter.id, function (error, response, body) {//consume the result });

例子

下面的示例是Node.js中的一个主类, 该主类创建IP, 防火墙策略和负载平衡器。之后, 它将创建服务器并等待其部署并打开电源。

创建服务器后, 我们将防火墙策略和负载均衡器分配给服务器, 最后我们将所有内容清除掉。

public class main {

    static OneAndOneApi oneandoneApi = new OneAndOneApi();

    /**
     * @param args the command line arguments
     * @throws Node.js.lang.InterruptedException
     */
    public static void main(String[] args) throws InterruptedException {
        try {
            CreateServers();
        } catch (Exception ex) {
            Logger.getLogger(main.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    static void CreateServers() throws RestClientException, IOException, InterruptedException {
        String firewallPolicyName = "TestfirewallPolicyNode.js";
        String loadBalancerName = "TestLoadBalancerNode.js";
        String serverName = "ExampleServerNode.js";
        String publicIpId = "";

        try {
            //create a firewall policy
            //define the required rules
            System.out.println("Creating Firewall Policy with name " + firewallPolicyName);
            List<CreateFirewallPocliyRule> newRules = new ArrayList<CreateFirewallPocliyRule>();
            CreateFirewallPocliyRule rule1 = new CreateFirewallPocliyRule();
            rule1.setPortTo(80);
            rule1.setPortFrom(80);
            rule1.setProtocol(Types.RuleProtocol.TCP);
            rule1.setSource("0.0.0.0");

            CreateFirewallPocliyRule rule2 = new CreateFirewallPocliyRule();
            rule2.setPortTo(443);
            rule2.setPortFrom(443);
            rule2.setProtocol(Types.RuleProtocol.TCP);
            rule2.setSource("0.0.0.0");

            CreateFirewallPocliyRule rule3 = new CreateFirewallPocliyRule();
            rule3.setPortTo(8447);
            rule3.setPortFrom(8447);
            rule3.setProtocol(Types.RuleProtocol.TCP);
            rule3.setSource("0.0.0.0");

            CreateFirewallPocliyRule rule4 = new CreateFirewallPocliyRule();
            rule4.setPortTo(3389);
            rule4.setPortFrom(3389);
            rule4.setProtocol(Types.RuleProtocol.TCP);
            rule4.setSource("0.0.0.0");

            CreateFirewallPocliyRule rule5 = new CreateFirewallPocliyRule();
            rule5.setPortTo(8443);
            rule5.setPortFrom(8443);
            rule5.setProtocol(Types.RuleProtocol.TCP);
            rule5.setSource("0.0.0.0");

            newRules.add(rule1);
            newRules.add(rule2);
            newRules.add(rule3);
            newRules.add(rule4);
            newRules.add(rule5);

            CreateFirewallPolicyRequest policyRequest = new CreateFirewallPolicyRequest();
            policyRequest.setName(firewallPolicyName);
            policyRequest.setRules(newRules);
            policyRequest.setDescription("test firewall policy with 80, 443, 8447, 3389 and 8443 ports open");

            FirewallPolicyResponse firewallPolicyResult = oneandoneApi.getFirewallPoliciesApi().createFirewallPolicy(policyRequest);

            System.out.println("Creating LoadBalancer with name " + loadBalancerName);
            //create a loadbalancer
            List<LoadBalancerRuleRequest> loadBalancersRules = new ArrayList<LoadBalancerRuleRequest>();
            LoadBalancerRuleRequest rule = new LoadBalancerRuleRequest();
            rule.setPortServer(80);
            rule.setPortBalancer(80);
            rule.setProtocol(Types.LBRuleProtocol.TCP);
            rule.setSource("0.0.0.0");
            loadBalancersRules.add(rule);

            CreateLoadBalancerRequest loadBalancerRequest = new CreateLoadBalancerRequest();
            loadBalancerRequest.setName(loadBalancerName);
            loadBalancerRequest.setDescription("LB with a round robin method and works on port 80");
            loadBalancerRequest.setHealthCheckInterval(1);
            loadBalancerRequest.setPersistence(true);
            loadBalancerRequest.setPersistenceTime(30);
            loadBalancerRequest.setHealthCheckTest(Types.HealthCheckTestTypes.NONE);
            loadBalancerRequest.setMethod(Types.LoadBalancerMethod.ROUND_ROBIN);
            loadBalancerRequest.setRules(loadBalancersRules);

            LoadBalancerResponse loadBalancerResult = oneandoneApi.getLoadBalancerApi().createLoadBalancer(loadBalancerRequest);

            //create a public IP and use it for the server creation
            CreatePublicIPRequest ipRequest = new CreatePublicIPRequest();
            ipRequest.setType(Types.IPType.IPV4);
            PublicIPResponse publicIP = oneandoneApi.getPublicIPApi().createPublicIp(ipRequest);
            publicIpId = publicIP.getId();

            System.out.println("Creating Server with name 'Example Server Node.js'");
            //define the number of cores to give the server
            int vcore = 4;
            //number of cores per processor
            int CoresPerProcessor = 2;
            //get server appliance with OS family type Windows
            List<ServerAppliancesResponse> appliances = oneandoneApi.getServerAppliancesApi().getServerAppliances(0, 0, null, "", "");
            ServerAppliancesResponse appliance = null;
            if (appliances != null && !appliances.isEmpty()) {
                appliance = appliances.get(0);
            }

            CreateServerRequest serverRequest = new CreateServerRequest();
            if (appliance != null) {
                serverRequest.setApplianceId(appliance.getId());
            }
            if (publicIP != null) {
                serverRequest.setIpId(publicIP.getId());
            }

            serverRequest.setName(serverName);
            serverRequest.setDescription("a server with a firewall policy and a loadbalancer");
            //hardware request
            HardwareRequest hardwareRequest = new HardwareRequest();
            //creating a list of hdds to add
            List<HddRequest> hdds = new ArrayList<HddRequest>();
            HddRequest hdd = new HddRequest();
            hdd.setIsMain(Boolean.TRUE);
            hdd.setSize(80);
            hdds.add(hdd);
            hardwareRequest.setCoresPerProcessor(CoresPerProcessor);
            hardwareRequest.setRam(8);
            hardwareRequest.setVcore(vcore);
            hardwareRequest.setHdds(hdds);

            serverRequest.setHardware(hardwareRequest);
            serverRequest.setPowerOn(Boolean.TRUE);
            serverRequest.setPassword("Test123!");

            System.out.println("Server created waiting to be deployed and turned on");

            ServerResponse result = oneandoneApi.getServerApi().createServer(serverRequest);

            //check if the server is deployed and ready for further operations
            ServerResponse testServer = oneandoneApi.getServerApi().getServer(result.getId());
            String serverLoading = ".";
            while (testServer.getStatus().getState() != ServerState.POWERED_ON) {
                serverLoading += ".";
                System.out.println(serverLoading);
                Thread.sleep(1000);
                testServer = oneandoneApi.getServerApi().getServer(testServer.getId());
            }

            System.out.println("Server is Powered up and running");
            //attaching a firewall policy to the server after creation:
            //Get a windows firewall policy by sending the query parameter Windows
            System.out.println("Assigning " + firewallPolicyName + "to " + serverName);

            FirewallPolicyResponse firewallPolicy = oneandoneApi.getFirewallPoliciesApi().getFirewallPolicies(0, 0, null, firewallPolicyName, null).get(0);
            IdRequest fpRequest = new IdRequest();
            fpRequest.setId(firewallPolicy.getId());
            oneandoneApi.getServerIpsApi().updateServerIPFirewallPolicy(testServer.getId(), testServer.getIps().get(0).getId(), fpRequest);
            System.out.println("Assigning " + loadBalancerName + "to " + serverName);
            // attaching a loadbalancer to the server
            LoadBalancerResponse loadbalancer = oneandoneApi.getLoadBalancerApi().getLoadBalancers(0, 0, null, loadBalancerName, null).get(0);
            AssignLoadBalancerRequest lbRequest = new AssignLoadBalancerRequest();
            lbRequest.setLoadBalancerId(loadbalancer.getId());
            oneandoneApi.getServerIpsApi().createServerIPLoadBalancer(testServer.getId(), testServer.getIps().get(0).getId(), lbRequest);
            //cleaning up
            System.out.println("Cleaning up all the created test data");
            System.out.println("Press any key to start cleaning");
            System.in.read();

            oneandoneApi.getServerApi().deleteServer(testServer.getId(), true);
            System.out.println("Server removed");
            oneandoneApi.getLoadBalancerApi().deleteLoadBalancer(loadBalancerResult.getId());
            System.out.println("loadbalancer removed");
            oneandoneApi.getFirewallPoliciesApi().deleteFirewallPolicy(firewallPolicyResult.getId());
            System.out.println("firewall policy removed");
            if (!publicIpId.isEmpty()) {
                oneandoneApi.getPublicIPApi().deletePublicIp(publicIpId);
                System.out.println("public ip removed");
            }

            System.out.println("Finished cleaning press any key to exit");

            System.in.read();
        } catch (Exception ex) {
            Logger.getLogger(main.class.getName()).log(Level.SEVERE, null, ex);
            try {

                List<ServerResponse> servers = oneandoneApi.getServerApi().getAllServers(0, 0, null, serverName, null);
                if (servers.size() > 0) {
                    oneandoneApi.getServerApi().deleteServer(servers.get(0).getId(), true);
                }
            } catch (Exception serverEx) {
                Logger.getLogger(main.class.getName()).log(Level.SEVERE, null, serverEx);
            }
            try {
                List<LoadBalancerResponse> balancers = oneandoneApi.getLoadBalancerApi().getLoadBalancers(0, 0, null, loadBalancerName, null);
                if (balancers.size() > 0) {
                    oneandoneApi.getLoadBalancerApi().deleteLoadBalancer(balancers.get(0).getId());
                }
            } catch (Exception balancerEx) {
                Logger.getLogger(main.class.getName()).log(Level.SEVERE, null, balancerEx);
            }
            try {
                List<FirewallPolicyResponse> firewallPolices = oneandoneApi.getFirewallPoliciesApi().getFirewallPolicies(0, 0, null, firewallPolicyName, null);
                if (firewallPolices.size() > 0) {
                    oneandoneApi.getFirewallPoliciesApi().deleteFirewallPolicy(firewallPolices.get(0).getId());
                }
            } catch (Exception firewallPolicyex) {
                Logger.getLogger(main.class.getName()).log(Level.SEVERE, null, firewallPolicyex);
            }
            try {
                if (!publicIpId.isEmpty()) {
                    oneandoneApi.getPublicIPApi().deletePublicIp(publicIpId);
                }
            } catch (Exception firewallPolicyex) {
                Logger.getLogger(main.class.getName()).log(Level.SEVERE, null, firewallPolicyex);
            }
        }
    }
}

编号

listDvdIso: function (callback) {
        req.is_get([this.dvdIsoEndPointPath], callback)
    }
getDvdIso: function (dvd_id, callback) {
        req.is_get([this.dvdIsoEndPointPath, dvd_id], callback)
    }
listFirewallPolicies: function (callback) {
        req.is_get([this.fpEndPointPath], callback)
    }
getFirewallPolicy: function (fp_id, callback) {
        req.is_get([this.fpEndPointPath, fp_id], callback)
    }
getFirewallPolicy: function (fp_id, callback) {
        req.is_get([this.fpEndPointPath, fp_id], callback)
    }
deleteFirewallPolicy: function (fp_id, callback) {
        req.is_del([this.fpEndPointPath, fp_id], callback)
    }
updateFirewallPolicy: function (fp_id, json, callback) {
        req.is_put([this.fpEndPointPath, fp_id], json, callback)
    }
listFirewallPolicyRules: function (fp_id, callback) {
        req.is_get([this.fpEndPointPath, fp_id, "rules"], callback)
    }
getFirewallPolicyRule: function (fp_id, rule_id, callback) {
        req.is_get([this.fpEndPointPath, fp_id, "rules", rule_id], callback)
    }
addRulesToFirewallPolicy: function (fp_id, json, callback) {
        req.is_post([this.fpEndPointPath, fp_id, "rules"], json, callback)
    }
removeRuleFromFirewallPolicy: function (fp_id, rule_id, json, callback) {
        req.is_del([this.fpEndPointPath, fp_id, "rules", rule_id], json, callback)
    }
listFirewallPolicyServerIps: function (fp_id, callback) {
        req.is_get([this.fpEndPointPath, fp_id, "server_ips"], callback)
    }
getFirewallPolicyServerIp: function (fp_id, ip_id, callback) {
        req.is_get([this.fpEndPointPath, fp_id, "server_ips", ip_id], callback)
    }
assignServerIpToFirewallPolicy: function (fp_id, json, callback) {
        req.is_post([this.fpEndPointPath, fp_id, "server_ips"], json, callback)
    }
unassignServerIpFromFirewallPolicy: function (fp_id, ip_id, json, callback) {
        req.is_del([this.fpEndPointPath, fp_id, "server_ips", ip_id], json, callback)
    }
listImages: function (callback) {
        req.is_get([this.imageEndPointPath], callback)
    }
getImage: function (srv_id, callback) {
        req.is_get([this.imageEndPointPath, srv_id], callback)
    }
createImage: function (json, callback) {
        req.is_post([this.imageEndPointPath], json, callback)
    }
deleteImage: function (srv_id, callback) {
        req.is_del([this.imageEndPointPath, srv_id], callback)
    }
updateImage: function (srv_id, json, callback) {
        req.is_put([this.imageEndPointPath, srv_id], json, callback)
    }
listLoadBalancerRules: function (lb_id, callback) {
        req.is_get([this.lbEndPointPath, lb_id, "rules"], callback)
    }
getLoadBalancerRule: function (lb_id, rule_id, callback) {
        req.is_get([this.lbEndPointPath, lb_id, "rules", rule_id], callback)
    }
addRulesToLoadBalancer: function (lb_id, json, callback) {
        req.is_post([this.lbEndPointPath, lb_id, "rules"], json, callback)
    }
removeRuleFromLoadBalancer: function (lb_id, rule_id, json, callback) {
        req.is_del([this.lbEndPointPath, lb_id, "rules", rule_id], json, callback)
    }
listLoadBalancers: function (callback) {
        req.is_get([this.lbEndPointPath], callback)
    }
getLoadBalancer: function (lb_id, callback) {
        req.is_get([this.lbEndPointPath, lb_id], callback)
    }
createLoadBalancer: function (json, callback) {
        req.is_post([this.lbEndPointPath], json, callback)
    }
deleteLoadBalancer: function (lb_id, callback) {
        req.is_del([this.lbEndPointPath, lb_id], callback)
    }
updateLoadBalancer: function (lb_id, json, callback) {
        req.is_put([this.lbEndPointPath, lb_id], json, callback)
    }
listLoadBalancerServerIps: function (lb_id, callback) {
        req.is_get([this.lbEndPointPath, lb_id, "server_ips"], callback)
    }
getLoadBalancerServerIp: function (lb_id, ip_id, callback) {
        req.is_get([this.lbEndPointPath, lb_id, "server_ips", ip_id], callback)
    }
assignServerIpToLoadBalancer: function (lb_id, json, callback) {
        req.is_post([this.lbEndPointPath, lb_id, "server_ips"], json, callback)
    }
unassignServerIpFromLoadBalancer: function (lb_id, ip_id, json, callback) {
        req.is_del([this.lbEndPointPath, lb_id, "server_ips", ip_id], json, callback)
    }
listLogsCustomPeriodWithOptions: function (startDate, endDate, options, callback) {
        var path = this.logEndPointPath + "?period=CUSTOM";
        path += "&start_date=" + startDate + "&end_date=" + endDate;

        if (options) {
            if (options.page) {
                path += "&page=" + options.page;
            }
            if (options.perPage) {
                path += "&per_page=" + options.perPage;
            }
            if (options.sort) {
                path += "&sort=" + options.sort;
            }
            if (options.query) {
                path += "&q=" + options.query;
            }
            if (options.fields) {
                path += "&fields=" + options.fields;
            }
        }
        req.is_get([path], callback)
    }
listLogsFixedPeriodWithOptions: function (period, options, callback) {
        var path = this.logEndPointPath + "?period=" + period;
        if (options) {
            if (options.page) {
                path += "&page=" + options.page;
            }
            if (options.perPage) {
                path += "&per_page=" + options.perPage;
            }
            if (options.sort) {
                path += "&sort=" + options.sort;
            }
            if (options.query) {
                path += "&q=" + options.query;
            }
            if (options.fields) {
                path += "&fields=" + options.fields;
            }
        }
        req.is_get([path], callback)
    }
getLog: function (log_id, callback) {
        req.is_get([this.logEndPointPath, log_id], callback)
    }
listMonitoringCenters: function (callback) {
        req.is_get([this.mcEndPointPath], callback)
    }
getServerMonitoringCenterCustomPeriod: function (srv_id, startDate, endDate, callback) {
        var path = "?period=CUSTOM";
        path += "&start_date=" + startDate + "&end_date=" + endDate;
        req.is_get([this.mcEndPointPath, srv_id, path], callback)
    }
getServerMonitoringCenterFixedPeriod: function (srv_id, period, callback) {
        var path = "?period=" + period;
        req.is_get([this.mcEndPointPath, srv_id, path], callback)
    }
listMonitoringPolicies: function (callback) {
        req.is_get([this.mpEndPointPath], callback)
    }
getMonitoringPolicy: function (mp_id, callback) {
        req.is_get([this.mpEndPointPath, mp_id], callback)
    }
createMonitoringPolicy: function (json, callback) {
        req.is_post([this.mpEndPointPath], json, callback)
    }
deleteMonitoringPolicy: function (mp_id, callback) {
        req.is_del([this.mpEndPointPath, mp_id], callback)
    }
updateMonitoringPolicy: function (mp_id, json, callback) {
        req.is_put([this.mpEndPointPath, mp_id], json, callback)
    }
listMonitoringPoliciesPorts: function (mp_id, callback) {
        req.is_get([this.mpEndPointPath, mp_id, this.portsPath], callback)
    }
getPortsMonitoringPolicy: function (mp_id, port_id, callback) {
        req.is_get([this.mpEndPointPath, mp_id, this.portsPath, port_id], callback)
    }
createMonitoringPolicyForPorts: function (mp_id, json, callback) {
        req.is_post([this.mpEndPointPath, mp_id, this.portsPath], json, callback)
    }
deletePortsMonitoringPolicy: function (mp_id, port_id, callback) {
        req.is_del([this.mpEndPointPath, mp_id, this.portsPath, port_id], callback)
    }
updatePortsMonitoringPolicy: function (mp_id, port_id, json, callback) {
        req.is_put([this.mpEndPointPath, mp_id, this.portsPath, port_id], json, callback)
    }
listMonitoringPoliciesProcesses: function (mp_id, callback) {
        req.is_get([this.mpEndPointPath, mp_id, this.processesPath], callback)
    }
getProcessesMonitoringPolicy: function (mp_id, process_id, callback) {
        req.is_get([this.mpEndPointPath, mp_id, this.processesPath, process_id], callback)
    }
createMonitoringPolicyForProcesses: function (mp_id, json, callback) {
        req.is_post([this.mpEndPointPath, mp_id, this.processesPath], json, callback)
    }
deleteProcessesMonitoringPolicy: function (mp_id, process_id, callback) {
        req.is_del([this.mpEndPointPath, mp_id, this.processesPath, process_id], callback)
    }
updateProcessesMonitoringPolicy: function (mp_id, process_id, json, callback) {
        req.is_put([this.mpEndPointPath, mp_id, this.processesPath, process_id], json, callback)
    }
listMonitoringPoliciesServers: function (mp_id, callback) {
        req.is_get([this.mpEndPointPath, mp_id, this.serversPath], callback)
    }
getServersMonitoringPolicy: function (mp_id, server_id, callback) {
        req.is_get([this.mpEndPointPath, mp_id, this.serversPath, server_id], callback)
    }
createMonitoringPolicyForServers: function (mp_id, json, callback) {
        req.is_post([this.mpEndPointPath, mp_id, this.serversPath], json, callback)
    }
deleteServersMonitoringPolicy: function (mp_id, server_id, callback) {
        req.is_del([this.mpEndPointPath, mp_id, this.serversPath, server_id], callback)
    }
listPrivateNetworkServers: function (pn_id, callback) {
        req.is_get([this.pnEndPointPath, pn_id, "servers"], callback)
    }
getPrivateNetworkServer: function (pn_id, srv_id, callback) {
        req.is_get([this.pnEndPointPath, pn_id, "servers", srv_id], callback)
    }
attachServerToPrivateNetwork: function (pn_id, json, callback) {
        req.is_post([this.pnEndPointPath, pn_id, "servers"], json, callback)
    }
detachServerFromPrivateNetwork: function (pn_id, srv_id, json, callback) {
        req.is_del([this.pnEndPointPath, pn_id, "servers", srv_id], json, callback)
    }
listPrivateNetworks: function (callback) {
        req.is_get([this.pnEndPointPath], callback)
    }
getPrivateNetwork: function (pn_id, callback) {
        req.is_get([this.pnEndPointPath, pn_id], callback)
    }
createPrivateNetwork: function (json, callback) {
        req.is_post([this.pnEndPointPath], json, callback)
    }
deletePrivateNetwork: function (pn_id, callback) {
        req.is_del([this.pnEndPointPath, pn_id], callback)
    }
updatePrivateNetwork: function (pn_id, json, callback) {
        req.is_put([this.pnEndPointPath, pn_id], json, callback)
    }
listPublicIps: function (callback) {
        req.is_get([this.ipEndPointPath], callback)
    }
getPublicIp: function (ip_id, callback) {
        req.is_get([this.ipEndPointPath, ip_id], callback)
    }
createPublicIp: function (json, callback) {
        req.is_post([this.ipEndPointPath], json, callback)
    }
deletePublicIp: function (ip_id, callback) {
        req.is_del([this.ipEndPointPath, ip_id], callback)
    }
updatePublicIp: function (ip_id, json, callback) {
        req.is_put([this.ipEndPointPath, ip_id], json, callback)
    }
listServers: function (callback) {
        req.is_get(["servers"], callback)
    }
getServer: function (srv_id, callback) {
        req.is_get(["servers", srv_id], callback)
    }
listHardwareFlavours: function (callback) {
        req.is_get(["servers/fixed_instance_sizes"], callback)
    }
getHardwareFlavour: function (favour_id, callback) {
        req.is_get(["servers", "fixed_instance_sizes", favour_id], callback)
    }
getServerStatus: function (srv_id, callback) {
        req.is_get(["servers", srv_id, "status"], callback)
    }
createServer: function (json, callback) {
        req.is_post(["servers"], json, callback)
    }
deleteServer: function (srv_id, keep_ips, callback) {
        if (!keep_ips) {
            keep_ips = false;
        }
        req.is_del(["servers", srv_id + "?keep_ips=" + keep_ips], callback)
    }
updateServer: function (srv_id, json, callback) {
        req.is_put(["servers", srv_id], json, callback)
    }
updateServerStatus: function (srv_id, json, callback) {
        req.is_put(["servers", srv_id, "status/action"], json, callback)
    }
listServerPrivateNetworks: function (srv_id, callback) {
        req.is_get(["servers", srv_id, "private_networks"], callback)
    }
getServerPrivateNetwork: function (srv_id, private_network_id, callback) {
        req.is_get(["servers", srv_id, "private_networks", private_network_id], callback)
    }
assignPrivateNetworkToServer: function (srv_id, json, callback) {
        req.is_post(["servers", srv_id, "private_networks"], json, callback)
    }
deletePrivateNetworkFromServer: function (srv_id, private_network_id, callback) {
        req.is_del(["servers", srv_id, "private_networks", private_network_id], callback)
    }
listSnapshots: function (srv_id, callback) {
        req.is_get(["servers", srv_id, "snapshots"], callback)
    }
restoreSnapshot: function (srv_id, snapshot_id, callback) {
        req.is_put(["servers", srv_id, "snapshots", snapshot_id], null, callback)
    }
createSnapshot: function (srv_id, callback) {
        req.is_post(["servers", srv_id, "snapshots"], null, callback)
    }
deleteSnapshot: function (srv_id, snapshot_id, callback) {
        req.is_del(["servers", srv_id, "snapshots", snapshot_id], callback)
    }
clone: function (srv_id, json, callback) {
        req.is_post(["servers", srv_id, "clone"], json, callback)
    }
listServerAppliances: function (callback) {
        req.is_get([this.appliancesEndPointPath], callback)
    }
getServerAppliance: function (aplnc_id, callback) {
        req.is_get([this.appliancesEndPointPath, aplnc_id], callback)
    }
getHardware: function (srv_id, callback) {
        req.is_get(["servers", srv_id, "hardware"], callback)
    }
updateHardware: function (srv_id, json, callback) {
        req.is_put(["servers", srv_id, "hardware"], json, callback)
    }
getDvd: function (srv_id, callback) {
        req.is_get(["servers", srv_id, "dvd"], callback)
    }
loadDvd: function (srv_id, json, callback) {
        req.is_put(["servers", srv_id, "dvd"], json, callback)
    }
unloadDvd: function (srv_id, callback) {
        req.is_del(["servers", srv_id, "dvd"], callback)
    }
listHdds: function (srv_id, callback) {
        req.is_get(["servers", srv_id, "hardware/hdds"], callback)
    }
getHdd: function (srv_id, hdd_id, callback) {
        req.is_get(["servers", srv_id, "hardware/hdds", hdd_id], callback)
    }
addHdd: function (srv_id, json, callback) {
        req.is_post(["servers", srv_id, "hardware/hdds"], json, callback)
    }
updateHdd: function (srv_id, hdd_id, json, callback) {
        req.is_put(["servers", srv_id, "hardware/hdds", hdd_id], json, callback)
    }
deleteHdd: function (srv_id, hdd_id, callback) {
        req.is_del(["servers", srv_id, "hardware/hdds", hdd_id], callback)
    }
getServerImage: function (srv_id, callback) {
        req.is_get(["servers", srv_id, "image"], callback)
    }
updateServerImage: function (srv_id, json, callback) {
        req.is_put(["servers", srv_id, "image"], json, callback)
    }
getIp: function (srv_id, ip_id, callback) {
        req.is_get(["servers", srv_id, "ips", ip_id], callback)
    }
addIp: function (srv_id, json, callback) {
        req.is_post(["servers", srv_id, "ips"], json, callback)
    }
listIps: function (srv_id, callback) {
        req.is_get(["servers", srv_id, "ips"], callback)
    }
deleteIp: function (srv_id, ip_id, json, callback) {
        req.is_delWithBody(["servers", srv_id, "ips", ip_id], json, callback)
    }
listIpFirewallPolicies: function (srv_id, ip_id, callback) {
        req.is_get(["servers", srv_id, "ips", ip_id, "firewall_policy"], callback)
    }
addFirewallPolicy: function (srv_id, ip_id, json, callback) {
        req.is_put(["servers", srv_id, "ips", ip_id, "firewall_policy"], json, callback)
    }
deleteIpFirewallPolicy: function (srv_id, ip_id, callback) {
        req.is_del(["servers", srv_id, "ips", ip_id, "firewall_policy"], callback)
    }
listIpLoadBalancer: function (srv_id, ip_id, callback) {
        req.is_get(["servers", srv_id, "ips", ip_id, "load_balancers"], callback)
    }
addIpLoadBalancer: function (srv_id, ip_id, json, callback) {
        req.is_post(["servers", srv_id, "ips", ip_id, "load_balancers"], json, callback)
    }
deleteIpLoadBalancer: function (srv_id, ip_id, load_balancer_id, callback) {
        req.is_del(["servers", srv_id, "ips", ip_id, "load_balancers", load_balancer_id], callback)
    }
listSharedStorages: function (callback) {
        req.is_get([this.ssEndPointPath], callback)
    }
getSharedStorage: function (strg_id, callback) {
        req.is_get([this.ssEndPointPath, strg_id], callback)
    }
createSharedStorage: function (json, callback) {
        req.is_post([this.ssEndPointPath], json, callback)
    }
deleteSharedStorage: function (strg_id, callback) {
        req.is_del([this.ssEndPointPath, strg_id], callback)
    }
updateSharedStorage: function (strg_id, json, callback) {
        req.is_put([this.ssEndPointPath, strg_id], json, callback)
    }
listSharedStorageServers: function (strg_id, callback) {
        req.is_get([this.ssEndPointPath, strg_id, "servers"], callback)
    }
getSharedStorageServer: function (strg_id, srv_id, callback) {
        req.is_get([this.ssEndPointPath, strg_id, "servers", srv_id], callback)
    }
attachServerToSharedStorage: function (strg_id, json, callback) {
        req.is_post([this.ssEndPointPath, strg_id, "servers"], json, callback)
    }
detachServerFromSharedStorage: function (strg_id, srv_id, json, callback) {
        req.is_del([this.ssEndPointPath, strg_id, "servers", srv_id], json, callback)
    }
getAccessCredentials: function (callback) {
        req.is_get([this.ssEndPointPath, "access"], callback)
    }
changePassword: function (json, callback) {
        req.is_put([this.ssEndPointPath, "access"], json, callback)
    }
listUsagesCustomPeriodWithOptions: function (startDate, endDate, options, callback) {
        var path = this.usagesEndPointPath + "?period=CUSTOM";
        path += "&start_date=" + startDate + "&end_date=" + endDate;

        if (options) {
            if (options.page) {
                path += "&page=" + options.page;
            }
            if (options.perPage) {
                path += "&per_page=" + options.perPage;
            }
            if (options.sort) {
                path += "&sort=" + options.sort;
            }
            if (options.query) {
                path += "&q=" + options.query;
            }
            if (options.fields) {
                path += "&fields=" + options.fields;
            }
        }
        req.is_get([path], callback)
    }
listUsagesFixedPeriodWithOptions: function (period, options, callback) {
        var path = this.usagesEndPointPath + "?period=" + period;
        if (options) {
            if (options.page) {
                path += "&page=" + options.page;
            }
            if (options.perPage) {
                path += "&per_page=" + options.perPage;
            }
            if (options.sort) {
                path += "&sort=" + options.sort;
            }
            if (options.query) {
                path += "&q=" + options.query;
            }
            if (options.fields) {
                path += "&fields=" + options.fields;
            }
        }
        req.is_get([path], callback)
    }
getUserApiInformation: function (usr_id, callback) {
        req.is_get([this.usrEndPointPath, usr_id, "api"], callback)
    }
updateUserApiInformation: function (usr_id, json, callback) {
        req.is_put([this.usrEndPointPath, usr_id, "api"], json, callback)
    }
getUserApiKey: function (usr_id, callback) {
        req.is_get([this.usrEndPointPath, usr_id, "api", "key"], callback)
    }
updateUserApiKey: function (usr_id, callback) {
        req.is_put([this.usrEndPointPath, usr_id, "api", "key"], null, callback)
    }
getUserApiAllowedIPs: function (usr_id, callback) {
        req.is_get([this.usrEndPointPath, usr_id, "api", "ips"], callback)
    }
addUserAPIAllowedIPs: function (usr_id, json, callback) {
        req.is_post([this.usrEndPointPath, usr_id, "api", "ips"], json, callback)
    }
deleteUserAPIAllowedIPs: function (usr_id, ip, callback) {
        req.is_del([this.usrEndPointPath, usr_id, "api", "ips", ip], callback)
    }
listUsers: function (callback) {
        req.is_get([this.usrEndPointPath], callback)
    }
getUser: function (usr_id, callback) {
        req.is_get([this.usrEndPointPath, usr_id], callback)
    }
createUser: function (json, callback) {
        req.is_post([this.usrEndPointPath], json, callback)
    }
deleteUser: function (usr_id, callback) {
        req.is_del([this.usrEndPointPath, usr_id], callback)
    }
updateUser: function (usr_id, json, callback) {
        req.is_put([this.usrEndPointPath, usr_id], json, callback)
    }
listVpns: function (callback) {
        req.is_get([this.vpnEndPointPath], callback)
    }
getVpn: function (vpn_id, callback) {
        req.is_get([this.vpnEndPointPath, vpn_id], callback)
    }
getConfigurationFile: function (vpn_id, callback) {
        req.is_get([this.vpnEndPointPath, vpn_id, "configuration_file"], callback)
    }
createVpn: function (json, callback) {
        req.is_post([this.vpnEndPointPath], json, callback)
    }
deleteVpn: function (vpn_id, callback) {
        req.is_del([this.vpnEndPointPath, vpn_id], callback)
    }
updateVpn: function (vpn_id, json, callback) {
        req.is_put([this.vpnEndPointPath, vpn_id], json, callback)
    }
listRoles: function (callback) {
        req.is_get([this.roleEndPointPath], callback)
    }
getRole: function (role_id, callback) {
        req.is_get([this.roleEndPointPath, role_id], callback)
    }
createRole: function (json, callback) {
        req.is_post([this.roleEndPointPath], json, callback)
    }
deleteRole: function (role_id, callback) {
        req.is_del([this.roleEndPointPath, role_id], callback)
    }
updateRole: function (role_id, json, callback) {
        req.is_put([this.roleEndPointPath, role_id], json, callback)
    }
cloneRole: function (role_id, json, callback) {
        req.is_post([this.roleEndPointPath, role_id, "clone"], json, callback)
    }
getRolePermissions: function (role_id, callback) {
        req.is_get([this.roleEndPointPath, role_id, "permissions"], callback)
    }
updateRolePermissions: function (role_id, json, callback) {
        req.is_put([this.roleEndPointPath, role_id, "permissions"], json, callback)
    }
listRoleUsers: function (role_id, callback) {
        req.is_get([this.roleEndPointPath, role_id, "users"], callback)
    }
getRoleUser: function (role_id, usr_id, callback) {
        req.is_get([this.roleEndPointPath, role_id, "users", usr_id], callback)
    }
addUsersToRole: function (role_id, json, callback) {
        req.is_post([this.roleEndPointPath, role_id, "users"], json, callback)
    }
removeRoleFromUser: function (role_id, usr_id, callback) {
        req.is_del([this.roleEndPointPath, role_id, "users", usr_id], callback)
    }
pingApi: function (callback) {
        req.is_get(["ping"], callback)
    }
pingApiAuthentication: function (callback) {
        req.is_get(["ping_auth"], callback)
    }
getPricing: function (callback) {
        req.is_get(["pricing"], callback)
    }
listDatacenters: function (callback) {
        req.is_get([this.datacentersEndPointPath], callback)
    }
getDatacenters: function (dc_id, callback) {
        req.is_get([this.datacentersEndPointPath, dc_id], callback)
    }

更新6/29/17

一盏木

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: