mirror of
https://github.com/containous/traefik.git
synced 2024-12-21 09:34:05 +03:00
Migrate to go-acme/lego.
This commit is contained in:
parent
4a68d29ce2
commit
87da7520de
2
.gitattributes
vendored
2
.gitattributes
vendored
@ -1 +1 @@
|
||||
# vendor/github.com/xenolf/lego/providers/dns/cloudxns/cloudxns.go eol=crlf
|
||||
# vendor/github.com/go-acme/lego/providers/dns/cloudxns/cloudxns.go eol=crlf
|
||||
|
210
Gopkg.lock
generated
210
Gopkg.lock
generated
@ -653,12 +653,12 @@
|
||||
revision = "89ef8af493ab468a45a42bb0d89a06fccdd2fb22"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:a12a1a87292cc2c5923b070b478109cffc86f22cc368481cd8d589b35e446802"
|
||||
digest = "1:6f26e34204ddad638d25456c6443c2763aa38954558226722c253e08e9f491fa"
|
||||
name = "github.com/exoscale/egoscale"
|
||||
packages = ["."]
|
||||
pruneopts = "NUT"
|
||||
revision = "d8dfca6802ad5c1a5300e52fa68067e791322035"
|
||||
version = "v0.11.4"
|
||||
revision = "0a91ac8209d6a805f259ff881d0c2654221d0346"
|
||||
version = "v0.14.3"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:b0d5e98ac0f0a509eb320f542e748582d637aae09e74538212e9712d1e71064b"
|
||||
@ -697,6 +697,94 @@
|
||||
pruneopts = "NUT"
|
||||
revision = "73d445a93680fa1a78ae23a5839bad48f32ba1ee"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:7dcfb91047873eb70b3a20ed5c400c4d05d9c1e73c9dac0e71ec0d44589d208a"
|
||||
name = "github.com/go-acme/lego"
|
||||
packages = [
|
||||
"acme",
|
||||
"acme/api",
|
||||
"acme/api/internal/nonces",
|
||||
"acme/api/internal/secure",
|
||||
"acme/api/internal/sender",
|
||||
"certcrypto",
|
||||
"certificate",
|
||||
"challenge",
|
||||
"challenge/dns01",
|
||||
"challenge/http01",
|
||||
"challenge/resolver",
|
||||
"challenge/tlsalpn01",
|
||||
"lego",
|
||||
"log",
|
||||
"platform/config/env",
|
||||
"platform/wait",
|
||||
"providers/dns",
|
||||
"providers/dns/acmedns",
|
||||
"providers/dns/alidns",
|
||||
"providers/dns/auroradns",
|
||||
"providers/dns/azure",
|
||||
"providers/dns/bluecat",
|
||||
"providers/dns/cloudflare",
|
||||
"providers/dns/cloudns",
|
||||
"providers/dns/cloudns/internal",
|
||||
"providers/dns/cloudxns",
|
||||
"providers/dns/cloudxns/internal",
|
||||
"providers/dns/conoha",
|
||||
"providers/dns/conoha/internal",
|
||||
"providers/dns/designate",
|
||||
"providers/dns/digitalocean",
|
||||
"providers/dns/dnsimple",
|
||||
"providers/dns/dnsmadeeasy",
|
||||
"providers/dns/dnsmadeeasy/internal",
|
||||
"providers/dns/dnspod",
|
||||
"providers/dns/dreamhost",
|
||||
"providers/dns/duckdns",
|
||||
"providers/dns/dyn",
|
||||
"providers/dns/exec",
|
||||
"providers/dns/exoscale",
|
||||
"providers/dns/fastdns",
|
||||
"providers/dns/gandi",
|
||||
"providers/dns/gandiv5",
|
||||
"providers/dns/gcloud",
|
||||
"providers/dns/glesys",
|
||||
"providers/dns/godaddy",
|
||||
"providers/dns/hostingde",
|
||||
"providers/dns/httpreq",
|
||||
"providers/dns/iij",
|
||||
"providers/dns/inwx",
|
||||
"providers/dns/lightsail",
|
||||
"providers/dns/linode",
|
||||
"providers/dns/linodev4",
|
||||
"providers/dns/mydnsjp",
|
||||
"providers/dns/namecheap",
|
||||
"providers/dns/namedotcom",
|
||||
"providers/dns/netcup",
|
||||
"providers/dns/netcup/internal",
|
||||
"providers/dns/nifcloud",
|
||||
"providers/dns/nifcloud/internal",
|
||||
"providers/dns/ns1",
|
||||
"providers/dns/oraclecloud",
|
||||
"providers/dns/otc",
|
||||
"providers/dns/ovh",
|
||||
"providers/dns/pdns",
|
||||
"providers/dns/rackspace",
|
||||
"providers/dns/rfc2136",
|
||||
"providers/dns/route53",
|
||||
"providers/dns/sakuracloud",
|
||||
"providers/dns/selectel",
|
||||
"providers/dns/selectel/internal",
|
||||
"providers/dns/stackpath",
|
||||
"providers/dns/transip",
|
||||
"providers/dns/vegadns",
|
||||
"providers/dns/vscale",
|
||||
"providers/dns/vscale/internal",
|
||||
"providers/dns/vultr",
|
||||
"providers/dns/zoneee",
|
||||
"registration",
|
||||
]
|
||||
pruneopts = "NUT"
|
||||
revision = "0c87df143e630a1c50b4c36c8fbdda6cd993ebba"
|
||||
|
||||
[[projects]]
|
||||
branch = "fork-containous"
|
||||
digest = "1:8292ab171d5fe91cd39fa4888157dd7bb485b07928231b06ffed4ecaae59ec39"
|
||||
@ -1388,6 +1476,17 @@
|
||||
pruneopts = "NUT"
|
||||
revision = "1f5c07e90700ae93ddcba0c7af7d9c7201646ccc"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:b52f6b7059f06a11ab6ab039714dda0d93878d9227f84c84ca9b6f046bfb5fef"
|
||||
name = "github.com/oracle/oci-go-sdk"
|
||||
packages = [
|
||||
"common",
|
||||
"dns",
|
||||
]
|
||||
pruneopts = "NUT"
|
||||
revision = "0306ff0303b6c9f6ea6458021adc9f8f09f562b0"
|
||||
version = "v4.2.0"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:4e9d94fd7812a4c41e403796decb682a8f18fa50fa1f48532967dddc279303f5"
|
||||
@ -1758,91 +1857,6 @@
|
||||
pruneopts = "NUT"
|
||||
revision = "0c8571ac0ce161a5feb57375a9cdf148c98c0f70"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:2a8f3a3c32e8a622b4053f0653c1e172b0480e75493636d75f0324b77c620805"
|
||||
name = "github.com/xenolf/lego"
|
||||
packages = [
|
||||
"acme",
|
||||
"acme/api",
|
||||
"acme/api/internal/nonces",
|
||||
"acme/api/internal/secure",
|
||||
"acme/api/internal/sender",
|
||||
"certcrypto",
|
||||
"certificate",
|
||||
"challenge",
|
||||
"challenge/dns01",
|
||||
"challenge/http01",
|
||||
"challenge/resolver",
|
||||
"challenge/tlsalpn01",
|
||||
"lego",
|
||||
"log",
|
||||
"platform/config/env",
|
||||
"platform/wait",
|
||||
"providers/dns",
|
||||
"providers/dns/acmedns",
|
||||
"providers/dns/alidns",
|
||||
"providers/dns/auroradns",
|
||||
"providers/dns/azure",
|
||||
"providers/dns/bluecat",
|
||||
"providers/dns/cloudflare",
|
||||
"providers/dns/cloudxns",
|
||||
"providers/dns/cloudxns/internal",
|
||||
"providers/dns/conoha",
|
||||
"providers/dns/conoha/internal",
|
||||
"providers/dns/designate",
|
||||
"providers/dns/digitalocean",
|
||||
"providers/dns/dnsimple",
|
||||
"providers/dns/dnsmadeeasy",
|
||||
"providers/dns/dnsmadeeasy/internal",
|
||||
"providers/dns/dnspod",
|
||||
"providers/dns/dreamhost",
|
||||
"providers/dns/duckdns",
|
||||
"providers/dns/dyn",
|
||||
"providers/dns/exec",
|
||||
"providers/dns/exoscale",
|
||||
"providers/dns/fastdns",
|
||||
"providers/dns/gandi",
|
||||
"providers/dns/gandiv5",
|
||||
"providers/dns/gcloud",
|
||||
"providers/dns/glesys",
|
||||
"providers/dns/godaddy",
|
||||
"providers/dns/hostingde",
|
||||
"providers/dns/httpreq",
|
||||
"providers/dns/iij",
|
||||
"providers/dns/inwx",
|
||||
"providers/dns/lightsail",
|
||||
"providers/dns/linode",
|
||||
"providers/dns/linodev4",
|
||||
"providers/dns/mydnsjp",
|
||||
"providers/dns/namecheap",
|
||||
"providers/dns/namedotcom",
|
||||
"providers/dns/netcup",
|
||||
"providers/dns/netcup/internal",
|
||||
"providers/dns/nifcloud",
|
||||
"providers/dns/nifcloud/internal",
|
||||
"providers/dns/ns1",
|
||||
"providers/dns/otc",
|
||||
"providers/dns/ovh",
|
||||
"providers/dns/pdns",
|
||||
"providers/dns/rackspace",
|
||||
"providers/dns/rfc2136",
|
||||
"providers/dns/route53",
|
||||
"providers/dns/sakuracloud",
|
||||
"providers/dns/selectel",
|
||||
"providers/dns/selectel/internal",
|
||||
"providers/dns/stackpath",
|
||||
"providers/dns/transip",
|
||||
"providers/dns/vegadns",
|
||||
"providers/dns/vscale",
|
||||
"providers/dns/vscale/internal",
|
||||
"providers/dns/vultr",
|
||||
"providers/dns/zoneee",
|
||||
"registration",
|
||||
]
|
||||
pruneopts = "NUT"
|
||||
revision = "52e43eb318b07ace590c2144804292c89aa74802"
|
||||
version = "v2.2.0"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:30c1930f8c9fee79f3af60c8b7cd92edd12a4f22187f5527d53509b1a794f555"
|
||||
@ -2354,6 +2368,16 @@
|
||||
"github.com/eapache/channels",
|
||||
"github.com/elazarl/go-bindata-assetfs",
|
||||
"github.com/gambol99/go-marathon",
|
||||
"github.com/go-acme/lego/certcrypto",
|
||||
"github.com/go-acme/lego/certificate",
|
||||
"github.com/go-acme/lego/challenge",
|
||||
"github.com/go-acme/lego/challenge/dns01",
|
||||
"github.com/go-acme/lego/challenge/http01",
|
||||
"github.com/go-acme/lego/challenge/tlsalpn01",
|
||||
"github.com/go-acme/lego/lego",
|
||||
"github.com/go-acme/lego/log",
|
||||
"github.com/go-acme/lego/providers/dns",
|
||||
"github.com/go-acme/lego/registration",
|
||||
"github.com/go-check/check",
|
||||
"github.com/go-kit/kit/log",
|
||||
"github.com/go-kit/kit/metrics",
|
||||
@ -2420,16 +2444,6 @@
|
||||
"github.com/vulcand/oxy/roundrobin",
|
||||
"github.com/vulcand/oxy/utils",
|
||||
"github.com/vulcand/predicate",
|
||||
"github.com/xenolf/lego/certcrypto",
|
||||
"github.com/xenolf/lego/certificate",
|
||||
"github.com/xenolf/lego/challenge",
|
||||
"github.com/xenolf/lego/challenge/dns01",
|
||||
"github.com/xenolf/lego/challenge/http01",
|
||||
"github.com/xenolf/lego/challenge/tlsalpn01",
|
||||
"github.com/xenolf/lego/lego",
|
||||
"github.com/xenolf/lego/log",
|
||||
"github.com/xenolf/lego/providers/dns",
|
||||
"github.com/xenolf/lego/registration",
|
||||
"golang.org/x/net/http/httpguts",
|
||||
"golang.org/x/net/http2",
|
||||
"golang.org/x/net/http2/hpack",
|
||||
|
@ -178,8 +178,9 @@
|
||||
name = "github.com/vulcand/oxy"
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/xenolf/lego"
|
||||
version = "2.2.0"
|
||||
branch = "master"
|
||||
name = "github.com/go-acme/lego"
|
||||
# version = "2.4.0"
|
||||
|
||||
[[constraint]]
|
||||
name = "google.golang.org/grpc"
|
||||
|
@ -31,8 +31,8 @@ import (
|
||||
"github.com/containous/traefik/tracing/zipkin"
|
||||
"github.com/containous/traefik/types"
|
||||
assetfs "github.com/elazarl/go-bindata-assetfs"
|
||||
"github.com/go-acme/lego/challenge/dns01"
|
||||
jaegercli "github.com/uber/jaeger-client-go"
|
||||
"github.com/xenolf/lego/challenge/dns01"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -113,61 +113,63 @@ Use the `DNS-01` challenge to generate and renew ACME certificates by provisioni
|
||||
Here is a list of supported `providers`, that can automate the DNS verification, along with the required environment variables and their [wildcard & root domain support](#wildcard-domains).
|
||||
Do not hesitate to complete it.
|
||||
|
||||
| Provider Name | Provider Code | Environment Variables | Wildcard & Root Domain Support |
|
||||
|-------------------------------------------------------------|----------------|-------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------|
|
||||
| [ACME DNS](https://github.com/joohoi/acme-dns) | `acme-dns` | `ACME_DNS_API_BASE`, `ACME_DNS_STORAGE_PATH` | Not tested yet |
|
||||
| [Alibaba Cloud](https://www.vultr.com) | `alidns` | `ALICLOUD_ACCESS_KEY`, `ALICLOUD_SECRET_KEY`, `ALICLOUD_REGION_ID` | Not tested yet |
|
||||
| [Auroradns](https://www.pcextreme.com/aurora/dns) | `auroradns` | `AURORA_USER_ID`, `AURORA_KEY`, `AURORA_ENDPOINT` | Not tested yet |
|
||||
| [Azure](https://azure.microsoft.com/services/dns/) | `azure` | `AZURE_CLIENT_ID`, `AZURE_CLIENT_SECRET`, `AZURE_SUBSCRIPTION_ID`, `AZURE_TENANT_ID`, `AZURE_RESOURCE_GROUP`, `[AZURE_METADATA_ENDPOINT]` | Not tested yet |
|
||||
| [Blue Cat](https://www.bluecatnetworks.com/) | `bluecat` | `BLUECAT_SERVER_URL`, `BLUECAT_USER_NAME`, `BLUECAT_PASSWORD`, `BLUECAT_CONFIG_NAME`, `BLUECAT_DNS_VIEW` | Not tested yet |
|
||||
| [Cloudflare](https://www.cloudflare.com) | `cloudflare` | `CF_API_EMAIL`, `CF_API_KEY` - The `Global API Key` needs to be used, not the `Origin CA Key` | YES |
|
||||
| [CloudXNS](https://www.cloudxns.net) | `cloudxns` | `CLOUDXNS_API_KEY`, `CLOUDXNS_SECRET_KEY` | Not tested yet |
|
||||
| [ConoHa](https://www.conoha.jp) | `conoha` | `CONOHA_TENANT_ID`, `CONOHA_API_USERNAME`, `CONOHA_API_PASSWORD` | YES |
|
||||
| [DigitalOcean](https://www.digitalocean.com) | `digitalocean` | `DO_AUTH_TOKEN` | YES |
|
||||
| [DNSimple](https://dnsimple.com) | `dnsimple` | `DNSIMPLE_OAUTH_TOKEN`, `DNSIMPLE_BASE_URL` | YES |
|
||||
| [DNS Made Easy](https://dnsmadeeasy.com) | `dnsmadeeasy` | `DNSMADEEASY_API_KEY`, `DNSMADEEASY_API_SECRET`, `DNSMADEEASY_SANDBOX` | Not tested yet |
|
||||
| [DNSPod](https://www.dnspod.com/) | `dnspod` | `DNSPOD_API_KEY` | Not tested yet |
|
||||
| [DreamHost](https://www.dreamhost.com/) | `dreamhost` | `DREAMHOST_API_KEY` | YES |
|
||||
| [Duck DNS](https://www.duckdns.org/) | `duckdns` | `DUCKDNS_TOKEN` | YES |
|
||||
| [Dyn](https://dyn.com) | `dyn` | `DYN_CUSTOMER_NAME`, `DYN_USER_NAME`, `DYN_PASSWORD` | Not tested yet |
|
||||
| External Program | `exec` | `EXEC_PATH` | YES |
|
||||
| [Exoscale](https://www.exoscale.com) | `exoscale` | `EXOSCALE_API_KEY`, `EXOSCALE_API_SECRET`, `EXOSCALE_ENDPOINT` | YES |
|
||||
| [Fast DNS](https://www.akamai.com/) | `fastdns` | `AKAMAI_CLIENT_TOKEN`, `AKAMAI_CLIENT_SECRET`, `AKAMAI_ACCESS_TOKEN` | YES |
|
||||
| [Gandi](https://www.gandi.net) | `gandi` | `GANDI_API_KEY` | Not tested yet |
|
||||
| [Gandi v5](http://doc.livedns.gandi.net) | `gandiv5` | `GANDIV5_API_KEY` | YES |
|
||||
| [Glesys](https://glesys.com/) | `glesys` | `GLESYS_API_USER`, `GLESYS_API_KEY`, `GLESYS_DOMAIN` | Not tested yet |
|
||||
| [GoDaddy](https://godaddy.com/domains) | `godaddy` | `GODADDY_API_KEY`, `GODADDY_API_SECRET` | Not tested yet |
|
||||
| [Google Cloud DNS](https://cloud.google.com/dns/docs/) | `gcloud` | `GCE_PROJECT`, Application Default Credentials (2) (3), [`GCE_SERVICE_ACCOUNT_FILE`] | YES |
|
||||
| [hosting.de](https://www.hosting.de) | `hostingde` | `HOSTINGDE_API_KEY`, `HOSTINGDE_ZONE_NAME` | Not tested yet |
|
||||
| HTTP request | `httpreq` | `HTTPREQ_ENDPOINT`, `HTTPREQ_MODE`, `HTTPREQ_USERNAME`, `HTTPREQ_PASSWORD` (1) | YES |
|
||||
| [IIJ](https://www.iij.ad.jp/) | `iij` | `IIJ_API_ACCESS_KEY`, `IIJ_API_SECRET_KEY`, `IIJ_DO_SERVICE_CODE` | Not tested yet |
|
||||
| [INWX](https://www.inwx.de/en) | `inwx` | `INWX_USERNAME`, `INWX_PASSWORD` | YES |
|
||||
| [Lightsail](https://aws.amazon.com/lightsail/) | `lightsail` | `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, `DNS_ZONE` | Not tested yet |
|
||||
| [Linode](https://www.linode.com) | `linode` | `LINODE_API_KEY` | Not tested yet |
|
||||
| [Linode v4](https://www.linode.com) | `linodev4` | `LINODE_TOKEN` | Not tested yet |
|
||||
| manual | - | none, but you need to run Traefik interactively, turn on `acmeLogging` to see instructions and press <kbd>Enter</kbd>. | YES |
|
||||
| [MyDNS.jp](https://www.mydns.jp/) | `mydnsjp` | `MYDNSJP_MASTER_ID`, `MYDNSJP_PASSWORD` | YES |
|
||||
| [Namecheap](https://www.namecheap.com) | `namecheap` | `NAMECHEAP_API_USER`, `NAMECHEAP_API_KEY` | YES |
|
||||
| [name.com](https://www.name.com/) | `namedotcom` | `NAMECOM_USERNAME`, `NAMECOM_API_TOKEN`, `NAMECOM_SERVER` | Not tested yet |
|
||||
| [Netcup](https://www.netcup.eu/) | `netcup` | `NETCUP_CUSTOMER_NUMBER`, `NETCUP_API_KEY`, `NETCUP_API_PASSWORD` | Not tested yet |
|
||||
| [NIFCloud](https://cloud.nifty.com/service/dns.htm) | `nifcloud` | `NIFCLOUD_ACCESS_KEY_ID`, `NIFCLOUD_SECRET_ACCESS_KEY` | Not tested yet |
|
||||
| [Ns1](https://ns1.com/) | `ns1` | `NS1_API_KEY` | Not tested yet |
|
||||
| [Open Telekom Cloud](https://cloud.telekom.de) | `otc` | `OTC_DOMAIN_NAME`, `OTC_USER_NAME`, `OTC_PASSWORD`, `OTC_PROJECT_NAME`, `OTC_IDENTITY_ENDPOINT` | Not tested yet |
|
||||
| [OVH](https://www.ovh.com) | `ovh` | `OVH_ENDPOINT`, `OVH_APPLICATION_KEY`, `OVH_APPLICATION_SECRET`, `OVH_CONSUMER_KEY` | YES |
|
||||
| [Openstack Designate](https://docs.openstack.org/designate) | `designate` | `OS_AUTH_URL`, `OS_USERNAME`, `OS_PASSWORD`, `OS_TENANT_NAME`, `OS_REGION_NAME` |YES |
|
||||
| [PowerDNS](https://www.powerdns.com) | `pdns` | `PDNS_API_KEY`, `PDNS_API_URL` | Not tested yet |
|
||||
| [Rackspace](https://www.rackspace.com/cloud/dns) | `rackspace` | `RACKSPACE_USER`, `RACKSPACE_API_KEY` | Not tested yet |
|
||||
| [RFC2136](https://tools.ietf.org/html/rfc2136) | `rfc2136` | `RFC2136_TSIG_KEY`, `RFC2136_TSIG_SECRET`, `RFC2136_TSIG_ALGORITHM`, `RFC2136_NAMESERVER` | Not tested yet |
|
||||
| [Route 53](https://aws.amazon.com/route53/) | `route53` | `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, `[AWS_REGION]`, `[AWS_HOSTED_ZONE_ID]` or a configured user/instance IAM profile. | YES |
|
||||
| [Sakura Cloud](https://cloud.sakura.ad.jp/) | `sakuracloud` | `SAKURACLOUD_ACCESS_TOKEN`, `SAKURACLOUD_ACCESS_TOKEN_SECRET` | Not tested yet |
|
||||
| [Selectel](https://selectel.ru/en/) | `selectel` | `SELECTEL_API_TOKEN` | YES |
|
||||
| [Stackpath](https://www.stackpath.com/) | `stackpath` | `STACKPATH_CLIENT_ID`, `STACKPATH_CLIENT_SECRET`, `STACKPATH_STACK_ID` | Not tested yet |
|
||||
| [TransIP](https://www.transip.nl/) | `transip` | `TRANSIP_ACCOUNT_NAME`, `TRANSIP_PRIVATE_KEY_PATH` | YES |
|
||||
| [VegaDNS](https://github.com/shupp/VegaDNS-API) | `vegadns` | `SECRET_VEGADNS_KEY`, `SECRET_VEGADNS_SECRET`, `VEGADNS_URL` | Not tested yet |
|
||||
| [Vscale](https://vscale.io/) | `vscale` | `VSCALE_API_TOKEN` | YES |
|
||||
| [VULTR](https://www.vultr.com) | `vultr` | `VULTR_API_KEY` | Not tested yet |
|
||||
| [Zone.ee](https://www.zone.ee) | `zoneee` | `ZONEEE_API_USER`, `ZONEEE_API_KEY` | YES |
|
||||
|
||||
| Provider Name | Provider Code | Environment Variables | Wildcard & Root Domain Support |
|
||||
|-------------------------------------------------------------|----------------|---------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------|
|
||||
| [ACME DNS](https://github.com/joohoi/acme-dns) | `acme-dns` | `ACME_DNS_API_BASE`, `ACME_DNS_STORAGE_PATH` | Not tested yet |
|
||||
| [Alibaba Cloud](https://www.vultr.com) | `alidns` | `ALICLOUD_ACCESS_KEY`, `ALICLOUD_SECRET_KEY`, `ALICLOUD_REGION_ID` | Not tested yet |
|
||||
| [Auroradns](https://www.pcextreme.com/aurora/dns) | `auroradns` | `AURORA_USER_ID`, `AURORA_KEY`, `AURORA_ENDPOINT` | Not tested yet |
|
||||
| [Azure](https://azure.microsoft.com/services/dns/) | `azure` | `AZURE_CLIENT_ID`, `AZURE_CLIENT_SECRET`, `AZURE_SUBSCRIPTION_ID`, `AZURE_TENANT_ID`, `AZURE_RESOURCE_GROUP`, `[AZURE_METADATA_ENDPOINT]` | Not tested yet |
|
||||
| [Blue Cat](https://www.bluecatnetworks.com/) | `bluecat` | `BLUECAT_SERVER_URL`, `BLUECAT_USER_NAME`, `BLUECAT_PASSWORD`, `BLUECAT_CONFIG_NAME`, `BLUECAT_DNS_VIEW` | Not tested yet |
|
||||
| [ClouDNS](https://www.cloudns.net/) | `cloudns` | `CLOUDNS_AUTH_ID`, `CLOUDNS_AUTH_PASSWORD` | YES |
|
||||
| [Cloudflare](https://www.cloudflare.com) | `cloudflare` | `CF_API_EMAIL`, `CF_API_KEY` - The `Global API Key` needs to be used, not the `Origin CA Key` | YES |
|
||||
| [CloudXNS](https://www.cloudxns.net) | `cloudxns` | `CLOUDXNS_API_KEY`, `CLOUDXNS_SECRET_KEY` | Not tested yet |
|
||||
| [ConoHa](https://www.conoha.jp) | `conoha` | `CONOHA_TENANT_ID`, `CONOHA_API_USERNAME`, `CONOHA_API_PASSWORD` | YES |
|
||||
| [DigitalOcean](https://www.digitalocean.com) | `digitalocean` | `DO_AUTH_TOKEN` | YES |
|
||||
| [DNSimple](https://dnsimple.com) | `dnsimple` | `DNSIMPLE_OAUTH_TOKEN`, `DNSIMPLE_BASE_URL` | YES |
|
||||
| [DNS Made Easy](https://dnsmadeeasy.com) | `dnsmadeeasy` | `DNSMADEEASY_API_KEY`, `DNSMADEEASY_API_SECRET`, `DNSMADEEASY_SANDBOX` | Not tested yet |
|
||||
| [DNSPod](https://www.dnspod.com/) | `dnspod` | `DNSPOD_API_KEY` | Not tested yet |
|
||||
| [DreamHost](https://www.dreamhost.com/) | `dreamhost` | `DREAMHOST_API_KEY` | YES |
|
||||
| [Duck DNS](https://www.duckdns.org/) | `duckdns` | `DUCKDNS_TOKEN` | YES |
|
||||
| [Dyn](https://dyn.com) | `dyn` | `DYN_CUSTOMER_NAME`, `DYN_USER_NAME`, `DYN_PASSWORD` | Not tested yet |
|
||||
| External Program | `exec` | `EXEC_PATH` | YES |
|
||||
| [Exoscale](https://www.exoscale.com) | `exoscale` | `EXOSCALE_API_KEY`, `EXOSCALE_API_SECRET`, `EXOSCALE_ENDPOINT` | YES |
|
||||
| [Fast DNS](https://www.akamai.com/) | `fastdns` | `AKAMAI_CLIENT_TOKEN`, `AKAMAI_CLIENT_SECRET`, `AKAMAI_ACCESS_TOKEN` | YES |
|
||||
| [Gandi](https://www.gandi.net) | `gandi` | `GANDI_API_KEY` | Not tested yet |
|
||||
| [Gandi v5](http://doc.livedns.gandi.net) | `gandiv5` | `GANDIV5_API_KEY` | YES |
|
||||
| [Glesys](https://glesys.com/) | `glesys` | `GLESYS_API_USER`, `GLESYS_API_KEY`, `GLESYS_DOMAIN` | Not tested yet |
|
||||
| [GoDaddy](https://godaddy.com/domains) | `godaddy` | `GODADDY_API_KEY`, `GODADDY_API_SECRET` | Not tested yet |
|
||||
| [Google Cloud DNS](https://cloud.google.com/dns/docs/) | `gcloud` | `GCE_PROJECT`, Application Default Credentials (2) (3), [`GCE_SERVICE_ACCOUNT_FILE`] | YES |
|
||||
| [hosting.de](https://www.hosting.de) | `hostingde` | `HOSTINGDE_API_KEY`, `HOSTINGDE_ZONE_NAME` | Not tested yet |
|
||||
| HTTP request | `httpreq` | `HTTPREQ_ENDPOINT`, `HTTPREQ_MODE`, `HTTPREQ_USERNAME`, `HTTPREQ_PASSWORD` (1) | YES |
|
||||
| [IIJ](https://www.iij.ad.jp/) | `iij` | `IIJ_API_ACCESS_KEY`, `IIJ_API_SECRET_KEY`, `IIJ_DO_SERVICE_CODE` | Not tested yet |
|
||||
| [INWX](https://www.inwx.de/en) | `inwx` | `INWX_USERNAME`, `INWX_PASSWORD` | YES |
|
||||
| [Lightsail](https://aws.amazon.com/lightsail/) | `lightsail` | `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, `DNS_ZONE` | Not tested yet |
|
||||
| [Linode](https://www.linode.com) | `linode` | `LINODE_API_KEY` | Not tested yet |
|
||||
| [Linode v4](https://www.linode.com) | `linodev4` | `LINODE_TOKEN` | Not tested yet |
|
||||
| manual | - | none, but you need to run Traefik interactively, turn on `acmeLogging` to see instructions and press <kbd>Enter</kbd>. | YES |
|
||||
| [MyDNS.jp](https://www.mydns.jp/) | `mydnsjp` | `MYDNSJP_MASTER_ID`, `MYDNSJP_PASSWORD` | YES |
|
||||
| [Namecheap](https://www.namecheap.com) | `namecheap` | `NAMECHEAP_API_USER`, `NAMECHEAP_API_KEY` | YES |
|
||||
| [name.com](https://www.name.com/) | `namedotcom` | `NAMECOM_USERNAME`, `NAMECOM_API_TOKEN`, `NAMECOM_SERVER` | Not tested yet |
|
||||
| [Netcup](https://www.netcup.eu/) | `netcup` | `NETCUP_CUSTOMER_NUMBER`, `NETCUP_API_KEY`, `NETCUP_API_PASSWORD` | Not tested yet |
|
||||
| [NIFCloud](https://cloud.nifty.com/service/dns.htm) | `nifcloud` | `NIFCLOUD_ACCESS_KEY_ID`, `NIFCLOUD_SECRET_ACCESS_KEY` | Not tested yet |
|
||||
| [Ns1](https://ns1.com/) | `ns1` | `NS1_API_KEY` | Not tested yet |
|
||||
| [Open Telekom Cloud](https://cloud.telekom.de) | `otc` | `OTC_DOMAIN_NAME`, `OTC_USER_NAME`, `OTC_PASSWORD`, `OTC_PROJECT_NAME`, `OTC_IDENTITY_ENDPOINT` | Not tested yet |
|
||||
| [OVH](https://www.ovh.com) | `ovh` | `OVH_ENDPOINT`, `OVH_APPLICATION_KEY`, `OVH_APPLICATION_SECRET`, `OVH_CONSUMER_KEY` | YES |
|
||||
| [Openstack Designate](https://docs.openstack.org/designate) | `designate` | `OS_AUTH_URL`, `OS_USERNAME`, `OS_PASSWORD`, `OS_TENANT_NAME`, `OS_REGION_NAME` | YES |
|
||||
| [Oracle Cloud](https://cloud.oracle.com/home) | `oraclecloud` | `OCI_COMPARTMENT_OCID`, `OCI_PRIVKEY_FILE`, `OCI_PRIVKEY_PASS`, `OCI_PUBKEY_FINGERPRINT`, `OCI_REGION`, `OCI_TENANCY_OCID`, `OCI_USER_OCID` | YES |
|
||||
| [PowerDNS](https://www.powerdns.com) | `pdns` | `PDNS_API_KEY`, `PDNS_API_URL` | Not tested yet |
|
||||
| [Rackspace](https://www.rackspace.com/cloud/dns) | `rackspace` | `RACKSPACE_USER`, `RACKSPACE_API_KEY` | Not tested yet |
|
||||
| [RFC2136](https://tools.ietf.org/html/rfc2136) | `rfc2136` | `RFC2136_TSIG_KEY`, `RFC2136_TSIG_SECRET`, `RFC2136_TSIG_ALGORITHM`, `RFC2136_NAMESERVER` | Not tested yet |
|
||||
| [Route 53](https://aws.amazon.com/route53/) | `route53` | `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, `[AWS_REGION]`, `[AWS_HOSTED_ZONE_ID]` or a configured user/instance IAM profile. | YES |
|
||||
| [Sakura Cloud](https://cloud.sakura.ad.jp/) | `sakuracloud` | `SAKURACLOUD_ACCESS_TOKEN`, `SAKURACLOUD_ACCESS_TOKEN_SECRET` | Not tested yet |
|
||||
| [Selectel](https://selectel.ru/en/) | `selectel` | `SELECTEL_API_TOKEN` | YES |
|
||||
| [Stackpath](https://www.stackpath.com/) | `stackpath` | `STACKPATH_CLIENT_ID`, `STACKPATH_CLIENT_SECRET`, `STACKPATH_STACK_ID` | Not tested yet |
|
||||
| [TransIP](https://www.transip.nl/) | `transip` | `TRANSIP_ACCOUNT_NAME`, `TRANSIP_PRIVATE_KEY_PATH` | YES |
|
||||
| [VegaDNS](https://github.com/shupp/VegaDNS-API) | `vegadns` | `SECRET_VEGADNS_KEY`, `SECRET_VEGADNS_SECRET`, `VEGADNS_URL` | Not tested yet |
|
||||
| [Vscale](https://vscale.io/) | `vscale` | `VSCALE_API_TOKEN` | YES |
|
||||
| [VULTR](https://www.vultr.com) | `vultr` | `VULTR_API_KEY` | Not tested yet |
|
||||
| [Zone.ee](https://www.zone.ee) | `zoneee` | `ZONEEE_API_USER`, `ZONEEE_API_KEY` | YES |
|
||||
|
||||
- (1): more information about the HTTP message format can be found [here](https://go-acme.github.io/lego/dns/httpreq/)
|
||||
- (2): https://cloud.google.com/docs/authentication/production#providing_credentials_to_your_application
|
||||
- (3): https://github.com/golang/oauth2/blob/36a7019397c4c86cf59eeab3bc0d188bac444277/google/default.go#L61-L76
|
||||
|
@ -18,8 +18,8 @@ import (
|
||||
"github.com/containous/traefik/log"
|
||||
acmeprovider "github.com/containous/traefik/provider/acme"
|
||||
"github.com/containous/traefik/types"
|
||||
"github.com/xenolf/lego/certcrypto"
|
||||
"github.com/xenolf/lego/registration"
|
||||
"github.com/go-acme/lego/certcrypto"
|
||||
"github.com/go-acme/lego/registration"
|
||||
)
|
||||
|
||||
// Account is used to store lets encrypt registration info
|
||||
|
@ -26,18 +26,18 @@ import (
|
||||
"github.com/containous/traefik/types"
|
||||
"github.com/containous/traefik/version"
|
||||
"github.com/eapache/channels"
|
||||
"github.com/xenolf/lego/certificate"
|
||||
"github.com/xenolf/lego/challenge"
|
||||
"github.com/xenolf/lego/challenge/dns01"
|
||||
"github.com/xenolf/lego/challenge/http01"
|
||||
"github.com/xenolf/lego/lego"
|
||||
legolog "github.com/xenolf/lego/log"
|
||||
"github.com/xenolf/lego/providers/dns"
|
||||
"github.com/xenolf/lego/registration"
|
||||
"github.com/go-acme/lego/certificate"
|
||||
"github.com/go-acme/lego/challenge"
|
||||
"github.com/go-acme/lego/challenge/dns01"
|
||||
"github.com/go-acme/lego/challenge/http01"
|
||||
"github.com/go-acme/lego/lego"
|
||||
legolog "github.com/go-acme/lego/log"
|
||||
"github.com/go-acme/lego/providers/dns"
|
||||
"github.com/go-acme/lego/registration"
|
||||
)
|
||||
|
||||
var (
|
||||
// OSCPMustStaple enables OSCP stapling as from https://github.com/xenolf/lego/issues/270
|
||||
// OSCPMustStaple enables OSCP stapling as from https://github.com/go-acme/lego/issues/270
|
||||
OSCPMustStaple = false
|
||||
)
|
||||
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
"github.com/containous/traefik/log"
|
||||
"github.com/containous/traefik/old/cluster"
|
||||
"github.com/containous/traefik/safe"
|
||||
"github.com/xenolf/lego/challenge"
|
||||
"github.com/go-acme/lego/challenge"
|
||||
)
|
||||
|
||||
var _ challenge.ProviderTimeout = (*challengeHTTPProvider)(nil)
|
||||
|
@ -11,8 +11,8 @@ import (
|
||||
"github.com/containous/traefik/log"
|
||||
"github.com/containous/traefik/old/cluster"
|
||||
"github.com/containous/traefik/safe"
|
||||
"github.com/xenolf/lego/challenge"
|
||||
"github.com/xenolf/lego/challenge/tlsalpn01"
|
||||
"github.com/go-acme/lego/challenge"
|
||||
"github.com/go-acme/lego/challenge/tlsalpn01"
|
||||
)
|
||||
|
||||
var _ challenge.ProviderTimeout = (*challengeTLSProvider)(nil)
|
||||
|
@ -32,8 +32,8 @@ import (
|
||||
"github.com/containous/traefik/provider/docker"
|
||||
"github.com/containous/traefik/provider/file"
|
||||
newtypes "github.com/containous/traefik/types"
|
||||
"github.com/go-acme/lego/challenge/dns01"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/xenolf/lego/challenge/dns01"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -8,8 +8,8 @@ import (
|
||||
"crypto/x509"
|
||||
|
||||
"github.com/containous/traefik/log"
|
||||
"github.com/xenolf/lego/certcrypto"
|
||||
"github.com/xenolf/lego/registration"
|
||||
"github.com/go-acme/lego/certcrypto"
|
||||
"github.com/go-acme/lego/registration"
|
||||
)
|
||||
|
||||
// Account is used to store lets encrypt registration info
|
||||
|
@ -10,8 +10,8 @@ import (
|
||||
"github.com/containous/mux"
|
||||
"github.com/containous/traefik/log"
|
||||
"github.com/containous/traefik/safe"
|
||||
"github.com/xenolf/lego/challenge"
|
||||
"github.com/xenolf/lego/challenge/http01"
|
||||
"github.com/go-acme/lego/challenge"
|
||||
"github.com/go-acme/lego/challenge/http01"
|
||||
)
|
||||
|
||||
var _ challenge.ProviderTimeout = (*challengeHTTP)(nil)
|
||||
|
@ -5,8 +5,8 @@ import (
|
||||
|
||||
"github.com/containous/traefik/log"
|
||||
"github.com/containous/traefik/types"
|
||||
"github.com/xenolf/lego/challenge"
|
||||
"github.com/xenolf/lego/challenge/tlsalpn01"
|
||||
"github.com/go-acme/lego/challenge"
|
||||
"github.com/go-acme/lego/challenge/tlsalpn01"
|
||||
)
|
||||
|
||||
var _ challenge.Provider = (*challengeTLSALPN)(nil)
|
||||
|
@ -22,19 +22,19 @@ import (
|
||||
traefiktls "github.com/containous/traefik/tls"
|
||||
"github.com/containous/traefik/types"
|
||||
"github.com/containous/traefik/version"
|
||||
"github.com/go-acme/lego/certificate"
|
||||
"github.com/go-acme/lego/challenge"
|
||||
"github.com/go-acme/lego/challenge/dns01"
|
||||
"github.com/go-acme/lego/lego"
|
||||
legolog "github.com/go-acme/lego/log"
|
||||
"github.com/go-acme/lego/providers/dns"
|
||||
"github.com/go-acme/lego/registration"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/xenolf/lego/certificate"
|
||||
"github.com/xenolf/lego/challenge"
|
||||
"github.com/xenolf/lego/challenge/dns01"
|
||||
"github.com/xenolf/lego/lego"
|
||||
legolog "github.com/xenolf/lego/log"
|
||||
"github.com/xenolf/lego/providers/dns"
|
||||
"github.com/xenolf/lego/registration"
|
||||
)
|
||||
|
||||
var (
|
||||
// oscpMustStaple enables OSCP stapling as from https://github.com/xenolf/lego/issues/270
|
||||
// oscpMustStaple enables OSCP stapling as from https://github.com/go-acme/lego/issues/270
|
||||
oscpMustStaple = false
|
||||
)
|
||||
|
||||
|
@ -7,8 +7,8 @@ import (
|
||||
|
||||
"github.com/containous/traefik/safe"
|
||||
"github.com/containous/traefik/types"
|
||||
"github.com/go-acme/lego/certcrypto"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/xenolf/lego/certcrypto"
|
||||
)
|
||||
|
||||
func TestGetUncheckedCertificates(t *testing.T) {
|
||||
|
@ -9,8 +9,8 @@ import (
|
||||
"github.com/containous/traefik/log"
|
||||
"github.com/containous/traefik/tls/generate"
|
||||
"github.com/containous/traefik/types"
|
||||
"github.com/go-acme/lego/challenge/tlsalpn01"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/xenolf/lego/challenge/tlsalpn01"
|
||||
)
|
||||
|
||||
// Manager is the TLS option/store/configuration factory
|
||||
|
105
vendor/github.com/exoscale/egoscale/accounts.go
generated
vendored
105
vendor/github.com/exoscale/egoscale/accounts.go
generated
vendored
@ -1,32 +1,12 @@
|
||||
package egoscale
|
||||
|
||||
import "fmt"
|
||||
|
||||
// AccountType represents the type of an Account
|
||||
//
|
||||
// http://docs.cloudstack.apache.org/projects/cloudstack-administration/en/4.8/accounts.html#accounts-users-and-domains
|
||||
type AccountType int16
|
||||
|
||||
//go:generate stringer -type AccountType
|
||||
const (
|
||||
// UserAccount represents a User
|
||||
UserAccount AccountType = 0
|
||||
// AdminAccount represents an Admin
|
||||
AdminAccount AccountType = 1
|
||||
// DomainAdminAccount represents a Domain Admin
|
||||
DomainAdminAccount AccountType = 2
|
||||
)
|
||||
|
||||
// Account provides the detailed account information
|
||||
type Account struct {
|
||||
AccountDetails map[string]string `json:"accountdetails,omitempty" doc:"details for the account"`
|
||||
AccountType AccountType `json:"accounttype,omitempty" doc:"account type (admin, domain-admin, user)"`
|
||||
CPUAvailable string `json:"cpuavailable,omitempty" doc:"the total number of cpu cores available to be created for this account"`
|
||||
CPULimit string `json:"cpulimit,omitempty" doc:"the total number of cpu cores the account can own"`
|
||||
CPUTotal int64 `json:"cputotal,omitempty" doc:"the total number of cpu cores owned by account"`
|
||||
DefaultZoneID *UUID `json:"defaultzoneid,omitempty" doc:"the default zone of the account"`
|
||||
Domain string `json:"domain,omitempty" doc:"name of the Domain the account belongs too"`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"id of the Domain the account belongs too"`
|
||||
EipLimit string `json:"eiplimit,omitempty" doc:"the total number of public elastic ip addresses this account can acquire"`
|
||||
Groups []string `json:"groups,omitempty" doc:"the list of acl groups that account belongs to"`
|
||||
ID *UUID `json:"id,omitempty" doc:"the id of the account"`
|
||||
@ -74,55 +54,23 @@ type Account struct {
|
||||
// ListRequest builds the ListAccountsGroups request
|
||||
func (a Account) ListRequest() (ListCommand, error) {
|
||||
return &ListAccounts{
|
||||
ID: a.ID,
|
||||
DomainID: a.DomainID,
|
||||
AccountType: a.AccountType,
|
||||
State: a.State,
|
||||
ID: a.ID,
|
||||
State: a.State,
|
||||
}, nil
|
||||
}
|
||||
|
||||
//go:generate go run generate/main.go -interface=Listable ListAccounts
|
||||
|
||||
// ListAccounts represents a query to display the accounts
|
||||
type ListAccounts struct {
|
||||
AccountType AccountType `json:"accounttype,omitempty" doc:"list accounts by account type. Valid account types are 1 (admin), 2 (domain-admin), and 0 (user)."`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"list only resources belonging to the domain specified"`
|
||||
ID *UUID `json:"id,omitempty" doc:"list account by account ID"`
|
||||
IsCleanUpRequired *bool `json:"iscleanuprequired,omitempty" doc:"list accounts by cleanuprequired attribute (values are true or false)"`
|
||||
IsRecursive *bool `json:"isrecursive,omitempty" doc:"defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves."`
|
||||
Keyword string `json:"keyword,omitempty" doc:"List by keyword"`
|
||||
ListAll *bool `json:"listall,omitempty" doc:"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"`
|
||||
Name string `json:"name,omitempty" doc:"list account by account name"`
|
||||
Page int `json:"page,omitempty"`
|
||||
PageSize int `json:"pagesize,omitempty"`
|
||||
State string `json:"state,omitempty" doc:"list accounts by state. Valid states are enabled, disabled, and locked."`
|
||||
_ bool `name:"listAccounts" description:"Lists accounts and provides detailed account information for listed accounts"`
|
||||
}
|
||||
|
||||
func (ListAccounts) response() interface{} {
|
||||
return new(ListAccountsResponse)
|
||||
}
|
||||
|
||||
// SetPage sets the current page
|
||||
func (ls *ListAccounts) SetPage(page int) {
|
||||
ls.Page = page
|
||||
}
|
||||
|
||||
// SetPageSize sets the page size
|
||||
func (ls *ListAccounts) SetPageSize(pageSize int) {
|
||||
ls.PageSize = pageSize
|
||||
}
|
||||
|
||||
func (ListAccounts) each(resp interface{}, callback IterateItemFunc) {
|
||||
vms, ok := resp.(*ListAccountsResponse)
|
||||
if !ok {
|
||||
callback(nil, fmt.Errorf("wrong type. ListAccountsResponse expected, got %T", resp))
|
||||
return
|
||||
}
|
||||
|
||||
for i := range vms.Account {
|
||||
if !callback(&vms.Account[i], nil) {
|
||||
break
|
||||
}
|
||||
}
|
||||
ID *UUID `json:"id,omitempty" doc:"List account by account ID"`
|
||||
IsCleanUpRequired *bool `json:"iscleanuprequired,omitempty" doc:"list accounts by cleanuprequired attribute (values are true or false)"`
|
||||
Keyword string `json:"keyword,omitempty" doc:"List by keyword"`
|
||||
Name string `json:"name,omitempty" doc:"List account by account name"`
|
||||
Page int `json:"page,omitempty"`
|
||||
PageSize int `json:"pagesize,omitempty"`
|
||||
State string `json:"state,omitempty" doc:"List accounts by state. Valid states are enabled, disabled, and locked."`
|
||||
_ bool `name:"listAccounts" description:"Lists accounts and provides detailed account information for listed accounts"`
|
||||
}
|
||||
|
||||
// ListAccountsResponse represents a list of accounts
|
||||
@ -130,32 +78,3 @@ type ListAccountsResponse struct {
|
||||
Count int `json:"count"`
|
||||
Account []Account `json:"account"`
|
||||
}
|
||||
|
||||
// EnableAccount represents the activation of an account
|
||||
type EnableAccount struct {
|
||||
Account string `json:"account,omitempty" doc:"Enables specified account."`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"Enables specified account in this domain."`
|
||||
ID *UUID `json:"id,omitempty" doc:"Account id"`
|
||||
_ bool `name:"enableAccount" description:"Enables an account"`
|
||||
}
|
||||
|
||||
func (EnableAccount) response() interface{} {
|
||||
return new(Account)
|
||||
}
|
||||
|
||||
// DisableAccount (Async) represents the deactivation of an account
|
||||
type DisableAccount struct {
|
||||
Lock *bool `json:"lock" doc:"If true, only lock the account; else disable the account"`
|
||||
Account string `json:"account,omitempty" doc:"Disables specified account."`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"Disables specified account in this domain."`
|
||||
ID *UUID `json:"id,omitempty" doc:"Account id"`
|
||||
_ bool `name:"disableAccount" description:"Disables an account"`
|
||||
}
|
||||
|
||||
func (DisableAccount) response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (DisableAccount) asyncResponse() interface{} {
|
||||
return new(Account)
|
||||
}
|
||||
|
43
vendor/github.com/exoscale/egoscale/accounts_response.go
generated
vendored
Normal file
43
vendor/github.com/exoscale/egoscale/accounts_response.go
generated
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
// code generated; DO NOT EDIT.
|
||||
|
||||
package egoscale
|
||||
|
||||
import "fmt"
|
||||
|
||||
// Response returns the struct to unmarshal
|
||||
func (ListAccounts) Response() interface{} {
|
||||
return new(ListAccountsResponse)
|
||||
}
|
||||
|
||||
// ListRequest returns itself
|
||||
func (ls *ListAccounts) ListRequest() (ListCommand, error) {
|
||||
if ls == nil {
|
||||
return nil, fmt.Errorf("%T cannot be nil", ls)
|
||||
}
|
||||
return ls, nil
|
||||
}
|
||||
|
||||
// SetPage sets the current apge
|
||||
func (ls *ListAccounts) SetPage(page int) {
|
||||
ls.Page = page
|
||||
}
|
||||
|
||||
// SetPageSize sets the page size
|
||||
func (ls *ListAccounts) SetPageSize(pageSize int) {
|
||||
ls.PageSize = pageSize
|
||||
}
|
||||
|
||||
// Each triggers the callback for each, valid answer or any non 404 issue
|
||||
func (ListAccounts) Each(resp interface{}, callback IterateItemFunc) {
|
||||
items, ok := resp.(*ListAccountsResponse)
|
||||
if !ok {
|
||||
callback(nil, fmt.Errorf("wrong type, ListAccountsResponse was expected, got %T", resp))
|
||||
return
|
||||
}
|
||||
|
||||
for i := range items.Account {
|
||||
if !callback(&items.Account[i], nil) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
16
vendor/github.com/exoscale/egoscale/accounttype_string.go
generated
vendored
16
vendor/github.com/exoscale/egoscale/accounttype_string.go
generated
vendored
@ -1,16 +0,0 @@
|
||||
// Code generated by "stringer -type AccountType"; DO NOT EDIT.
|
||||
|
||||
package egoscale
|
||||
|
||||
import "strconv"
|
||||
|
||||
const _AccountType_name = "UserAccountAdminAccountDomainAdminAccount"
|
||||
|
||||
var _AccountType_index = [...]uint8{0, 11, 23, 41}
|
||||
|
||||
func (i AccountType) String() string {
|
||||
if i < 0 || i >= AccountType(len(_AccountType_index)-1) {
|
||||
return "AccountType(" + strconv.FormatInt(int64(i), 10) + ")"
|
||||
}
|
||||
return _AccountType_name[_AccountType_index[i]:_AccountType_index[i+1]]
|
||||
}
|
83
vendor/github.com/exoscale/egoscale/addresses.go
generated
vendored
83
vendor/github.com/exoscale/egoscale/addresses.go
generated
vendored
@ -8,14 +8,10 @@ import (
|
||||
|
||||
// IPAddress represents an IP Address
|
||||
type IPAddress struct {
|
||||
Account string `json:"account,omitempty" doc:"the account the public IP address is associated with"`
|
||||
Allocated string `json:"allocated,omitempty" doc:"date the public IP address was acquired"`
|
||||
Associated string `json:"associated,omitempty" doc:"date the public IP address was associated"`
|
||||
AssociatedNetworkID *UUID `json:"associatednetworkid,omitempty" doc:"the ID of the Network associated with the IP address"`
|
||||
AssociatedNetworkName string `json:"associatednetworkname,omitempty" doc:"the name of the Network associated with the IP address"`
|
||||
Domain string `json:"domain,omitempty" doc:"the domain the public IP address is associated with"`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"the domain ID the public IP address is associated with"`
|
||||
ForDisplay bool `json:"fordisplay,omitempty" doc:"is public ip for display to the regular user"`
|
||||
ForVirtualNetwork bool `json:"forvirtualnetwork,omitempty" doc:"the virtual network for the IP address"`
|
||||
ID *UUID `json:"id,omitempty" doc:"public IP address id"`
|
||||
IPAddress net.IP `json:"ipaddress,omitempty" doc:"public IP address"`
|
||||
@ -48,9 +44,7 @@ func (IPAddress) ResourceType() string {
|
||||
// ListRequest builds the ListAdresses request
|
||||
func (ipaddress IPAddress) ListRequest() (ListCommand, error) {
|
||||
req := &ListPublicIPAddresses{
|
||||
Account: ipaddress.Account,
|
||||
AssociatedNetworkID: ipaddress.AssociatedNetworkID,
|
||||
DomainID: ipaddress.DomainID,
|
||||
ID: ipaddress.ID,
|
||||
IPAddress: ipaddress.IPAddress,
|
||||
PhysicalNetworkID: ipaddress.PhysicalNetworkID,
|
||||
@ -63,9 +57,6 @@ func (ipaddress IPAddress) ListRequest() (ListCommand, error) {
|
||||
if ipaddress.IsSourceNat {
|
||||
req.IsSourceNat = &ipaddress.IsSourceNat
|
||||
}
|
||||
if ipaddress.ForDisplay {
|
||||
req.ForDisplay = &ipaddress.ForDisplay
|
||||
}
|
||||
if ipaddress.ForVirtualNetwork {
|
||||
req.ForVirtualNetwork = &ipaddress.ForVirtualNetwork
|
||||
}
|
||||
@ -86,21 +77,19 @@ func (ipaddress IPAddress) Delete(ctx context.Context, client *Client) error {
|
||||
|
||||
// AssociateIPAddress (Async) represents the IP creation
|
||||
type AssociateIPAddress struct {
|
||||
Account string `json:"account,omitempty" doc:"the account to associate with this IP address"`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"the ID of the domain to associate with this IP address"`
|
||||
ForDisplay *bool `json:"fordisplay,omitempty" doc:"an optional field, whether to the display the ip to the end user or not"`
|
||||
IsPortable *bool `json:"isportable,omitempty" doc:"should be set to true if public IP is required to be transferable across zones, if not specified defaults to false"`
|
||||
NetworkdID *UUID `json:"networkid,omitempty" doc:"The network this ip address should be associated to."`
|
||||
RegionID int `json:"regionid,omitempty" doc:"region ID from where portable ip is to be associated."`
|
||||
ZoneID *UUID `json:"zoneid,omitempty" doc:"the ID of the availability zone you want to acquire an public IP address from"`
|
||||
_ bool `name:"associateIpAddress" description:"Acquires and associates a public IP to an account."`
|
||||
IsPortable *bool `json:"isportable,omitempty" doc:"should be set to true if public IP is required to be transferable across zones, if not specified defaults to false"`
|
||||
NetworkdID *UUID `json:"networkid,omitempty" doc:"The network this ip address should be associated to."`
|
||||
ZoneID *UUID `json:"zoneid,omitempty" doc:"the ID of the availability zone you want to acquire an public IP address from"`
|
||||
_ bool `name:"associateIpAddress" description:"Acquires and associates a public IP to an account."`
|
||||
}
|
||||
|
||||
func (AssociateIPAddress) response() interface{} {
|
||||
// Response returns the struct to unmarshal
|
||||
func (AssociateIPAddress) Response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (AssociateIPAddress) asyncResponse() interface{} {
|
||||
// AsyncResponse returns the struct to unmarshal the async job
|
||||
func (AssociateIPAddress) AsyncResponse() interface{} {
|
||||
return new(IPAddress)
|
||||
}
|
||||
|
||||
@ -110,47 +99,47 @@ type DisassociateIPAddress struct {
|
||||
_ bool `name:"disassociateIpAddress" description:"Disassociates an ip address from the account."`
|
||||
}
|
||||
|
||||
func (DisassociateIPAddress) response() interface{} {
|
||||
// Response returns the struct to unmarshal
|
||||
func (DisassociateIPAddress) Response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (DisassociateIPAddress) asyncResponse() interface{} {
|
||||
return new(booleanResponse)
|
||||
// AsyncResponse returns the struct to unmarshal the async job
|
||||
func (DisassociateIPAddress) AsyncResponse() interface{} {
|
||||
return new(BooleanResponse)
|
||||
}
|
||||
|
||||
// UpdateIPAddress (Async) represents the IP modification
|
||||
type UpdateIPAddress struct {
|
||||
ID *UUID `json:"id" doc:"the id of the public ip address to update"`
|
||||
CustomID *UUID `json:"customid,omitempty" doc:"an optional field, in case you want to set a custom id to the resource. Allowed to Root Admins only"`
|
||||
ForDisplay *bool `json:"fordisplay,omitempty" doc:"an optional field, whether to the display the ip to the end user or not"`
|
||||
_ bool `name:"updateIpAddress" description:"Updates an ip address"`
|
||||
ID *UUID `json:"id" doc:"the id of the public ip address to update"`
|
||||
CustomID *UUID `json:"customid,omitempty" doc:"an optional field, in case you want to set a custom id to the resource. Allowed to Root Admins only"`
|
||||
_ bool `name:"updateIpAddress" description:"Updates an ip address"`
|
||||
}
|
||||
|
||||
func (UpdateIPAddress) response() interface{} {
|
||||
// Response returns the struct to unmarshal
|
||||
func (UpdateIPAddress) Response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (UpdateIPAddress) asyncResponse() interface{} {
|
||||
// AsyncResponse returns the struct to unmarshal the async job
|
||||
func (UpdateIPAddress) AsyncResponse() interface{} {
|
||||
return new(IPAddress)
|
||||
}
|
||||
|
||||
//go:generate go run generate/main.go -interface=Listable ListPublicIPAddresses
|
||||
|
||||
// ListPublicIPAddresses represents a search for public IP addresses
|
||||
type ListPublicIPAddresses struct {
|
||||
Account string `json:"account,omitempty" doc:"list resources by account. Must be used with the domainId parameter."`
|
||||
AllocatedOnly *bool `json:"allocatedonly,omitempty" doc:"limits search results to allocated public IP addresses"`
|
||||
AssociatedNetworkID *UUID `json:"associatednetworkid,omitempty" doc:"lists all public IP addresses associated to the network specified"`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"list only resources belonging to the domain specified"`
|
||||
ForDisplay *bool `json:"fordisplay,omitempty" doc:"list resources by display flag; only ROOT admin is eligible to pass this parameter"`
|
||||
ForLoadBalancing *bool `json:"forloadbalancing,omitempty" doc:"list only ips used for load balancing"`
|
||||
ForVirtualNetwork *bool `json:"forvirtualnetwork,omitempty" doc:"the virtual network for the IP address"`
|
||||
ID *UUID `json:"id,omitempty" doc:"lists ip address by id"`
|
||||
IPAddress net.IP `json:"ipaddress,omitempty" doc:"lists the specified IP address"`
|
||||
IsElastic *bool `json:"iselastic,omitempty" doc:"list only elastic ip addresses"`
|
||||
IsRecursive *bool `json:"isrecursive,omitempty" doc:"defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves."`
|
||||
IsSourceNat *bool `json:"issourcenat,omitempty" doc:"list only source nat ip addresses"`
|
||||
IsStaticNat *bool `json:"isstaticnat,omitempty" doc:"list only static nat ip addresses"`
|
||||
Keyword string `json:"keyword,omitempty" doc:"List by keyword"`
|
||||
ListAll *bool `json:"listall,omitempty" doc:"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"`
|
||||
Page int `json:"page,omitempty"`
|
||||
PageSize int `json:"pagesize,omitempty"`
|
||||
PhysicalNetworkID *UUID `json:"physicalnetworkid,omitempty" doc:"lists all public IP addresses by physical network id"`
|
||||
@ -165,31 +154,3 @@ type ListPublicIPAddressesResponse struct {
|
||||
Count int `json:"count"`
|
||||
PublicIPAddress []IPAddress `json:"publicipaddress"`
|
||||
}
|
||||
|
||||
func (ListPublicIPAddresses) response() interface{} {
|
||||
return new(ListPublicIPAddressesResponse)
|
||||
}
|
||||
|
||||
// SetPage sets the current page
|
||||
func (ls *ListPublicIPAddresses) SetPage(page int) {
|
||||
ls.Page = page
|
||||
}
|
||||
|
||||
// SetPageSize sets the page size
|
||||
func (ls *ListPublicIPAddresses) SetPageSize(pageSize int) {
|
||||
ls.PageSize = pageSize
|
||||
}
|
||||
|
||||
func (ListPublicIPAddresses) each(resp interface{}, callback IterateItemFunc) {
|
||||
ips, ok := resp.(*ListPublicIPAddressesResponse)
|
||||
if !ok {
|
||||
callback(nil, fmt.Errorf("wrong type. ListPublicIPAddressesResponse expected, got %T", resp))
|
||||
return
|
||||
}
|
||||
|
||||
for i := range ips.PublicIPAddress {
|
||||
if !callback(&ips.PublicIPAddress[i], nil) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
106
vendor/github.com/exoscale/egoscale/affinity_groups.go
generated
vendored
106
vendor/github.com/exoscale/egoscale/affinity_groups.go
generated
vendored
@ -11,14 +11,12 @@ import (
|
||||
// Affinity and Anti-Affinity groups provide a way to influence where VMs should run.
|
||||
// See: http://docs.cloudstack.apache.org/projects/cloudstack-administration/en/stable/virtual_machines.html#affinity-groups
|
||||
type AffinityGroup struct {
|
||||
Account string `json:"account,omitempty" doc:"the account owning the affinity group"`
|
||||
Description string `json:"description,omitempty" doc:"the description of the affinity group"`
|
||||
Domain string `json:"domain,omitempty" doc:"the domain name of the affinity group"`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"the domain ID of the affinity group"`
|
||||
ID *UUID `json:"id,omitempty" doc:"the ID of the affinity group"`
|
||||
Name string `json:"name,omitempty" doc:"the name of the affinity group"`
|
||||
Type string `json:"type,omitempty" doc:"the type of the affinity group"`
|
||||
VirtualMachineIDs []string `json:"virtualmachineIds,omitempty" doc:"virtual machine Ids associated with this affinity group"`
|
||||
Account string `json:"account,omitempty" doc:"the account owning the affinity group"`
|
||||
Description string `json:"description,omitempty" doc:"the description of the affinity group"`
|
||||
ID *UUID `json:"id,omitempty" doc:"the ID of the affinity group"`
|
||||
Name string `json:"name,omitempty" doc:"the name of the affinity group"`
|
||||
Type string `json:"type,omitempty" doc:"the type of the affinity group"`
|
||||
VirtualMachineIDs []UUID `json:"virtualmachineIds,omitempty" doc:"virtual machine Ids associated with this affinity group"`
|
||||
}
|
||||
|
||||
// ListRequest builds the ListAffinityGroups request
|
||||
@ -35,10 +33,7 @@ func (ag AffinityGroup) Delete(ctx context.Context, client *Client) error {
|
||||
return fmt.Errorf("an Affinity Group may only be deleted using ID or Name")
|
||||
}
|
||||
|
||||
req := &DeleteAffinityGroup{
|
||||
Account: ag.Account,
|
||||
DomainID: ag.DomainID,
|
||||
}
|
||||
req := &DeleteAffinityGroup{}
|
||||
|
||||
if ag.ID != nil {
|
||||
req.ID = ag.ID
|
||||
@ -56,19 +51,27 @@ type AffinityGroupType struct {
|
||||
|
||||
// CreateAffinityGroup (Async) represents a new (anti-)affinity group
|
||||
type CreateAffinityGroup struct {
|
||||
Account string `json:"account,omitempty" doc:"an account for the affinity group. Must be used with domainId."`
|
||||
Description string `json:"description,omitempty" doc:"optional description of the affinity group"`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"domainId of the account owning the affinity group"`
|
||||
Name string `json:"name" doc:"name of the affinity group"`
|
||||
Description string `json:"description,omitempty" doc:"Optional description of the affinity group"`
|
||||
Name string `json:"name,omitempty" doc:"Name of the affinity group"`
|
||||
Type string `json:"type" doc:"Type of the affinity group from the available affinity/anti-affinity group types"`
|
||||
_ bool `name:"createAffinityGroup" description:"Creates an affinity/anti-affinity group"`
|
||||
}
|
||||
|
||||
func (CreateAffinityGroup) response() interface{} {
|
||||
func (req CreateAffinityGroup) onBeforeSend(params url.Values) error {
|
||||
// Name must be set, but can be empty
|
||||
if req.Name == "" {
|
||||
params.Set("name", "")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Response returns the struct to unmarshal
|
||||
func (CreateAffinityGroup) Response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (CreateAffinityGroup) asyncResponse() interface{} {
|
||||
// AsyncResponse returns the struct to unmarshal the async job
|
||||
func (CreateAffinityGroup) AsyncResponse() interface{} {
|
||||
return new(AffinityGroup)
|
||||
}
|
||||
|
||||
@ -88,75 +91,47 @@ func (req UpdateVMAffinityGroup) onBeforeSend(params url.Values) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (UpdateVMAffinityGroup) response() interface{} {
|
||||
// Response returns the struct to unmarshal
|
||||
func (UpdateVMAffinityGroup) Response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (UpdateVMAffinityGroup) asyncResponse() interface{} {
|
||||
// AsyncResponse returns the struct to unmarshal the async job
|
||||
func (UpdateVMAffinityGroup) AsyncResponse() interface{} {
|
||||
return new(VirtualMachine)
|
||||
}
|
||||
|
||||
// DeleteAffinityGroup (Async) represents an (anti-)affinity group to be deleted
|
||||
type DeleteAffinityGroup struct {
|
||||
Account string `json:"account,omitempty" doc:"the account of the affinity group. Must be specified with domain ID"`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"the domain ID of account owning the affinity group"`
|
||||
ID *UUID `json:"id,omitempty" doc:"The ID of the affinity group. Mutually exclusive with name parameter"`
|
||||
Name string `json:"name,omitempty" doc:"The name of the affinity group. Mutually exclusive with ID parameter"`
|
||||
_ bool `name:"deleteAffinityGroup" description:"Deletes affinity group"`
|
||||
ID *UUID `json:"id,omitempty" doc:"The ID of the affinity group. Mutually exclusive with name parameter"`
|
||||
Name string `json:"name,omitempty" doc:"The name of the affinity group. Mutually exclusive with ID parameter"`
|
||||
_ bool `name:"deleteAffinityGroup" description:"Deletes affinity group"`
|
||||
}
|
||||
|
||||
func (DeleteAffinityGroup) response() interface{} {
|
||||
// Response returns the struct to unmarshal
|
||||
func (DeleteAffinityGroup) Response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (DeleteAffinityGroup) asyncResponse() interface{} {
|
||||
return new(booleanResponse)
|
||||
// AsyncResponse returns the struct to unmarshal the async job
|
||||
func (DeleteAffinityGroup) AsyncResponse() interface{} {
|
||||
return new(BooleanResponse)
|
||||
}
|
||||
|
||||
//go:generate go run generate/main.go -interface=Listable ListAffinityGroups
|
||||
|
||||
// ListAffinityGroups represents an (anti-)affinity groups search
|
||||
type ListAffinityGroups struct {
|
||||
Account string `json:"account,omitempty" doc:"list resources by account. Must be used with the domainId parameter."`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"list only resources belonging to the domain specified"`
|
||||
ID *UUID `json:"id,omitempty" doc:"list the affinity group by the ID provided"`
|
||||
IsRecursive *bool `json:"isrecursive,omitempty" doc:"defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves."`
|
||||
ID *UUID `json:"id,omitempty" doc:"List the affinity group by the ID provided"`
|
||||
Keyword string `json:"keyword,omitempty" doc:"List by keyword"`
|
||||
ListAll *bool `json:"listall,omitempty" doc:"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"`
|
||||
Name string `json:"name,omitempty" doc:"lists affinity groups by name"`
|
||||
Name string `json:"name,omitempty" doc:"Lists affinity groups by name"`
|
||||
Page int `json:"page,omitempty"`
|
||||
PageSize int `json:"pagesize,omitempty"`
|
||||
Type string `json:"type,omitempty" doc:"lists affinity groups by type"`
|
||||
VirtualMachineID *UUID `json:"virtualmachineid,omitempty" doc:"lists affinity groups by virtual machine ID"`
|
||||
Type string `json:"type,omitempty" doc:"Lists affinity groups by type"`
|
||||
VirtualMachineID *UUID `json:"virtualmachineid,omitempty" doc:"Lists affinity groups by virtual machine ID"`
|
||||
_ bool `name:"listAffinityGroups" description:"Lists affinity groups"`
|
||||
}
|
||||
|
||||
func (ListAffinityGroups) response() interface{} {
|
||||
return new(ListAffinityGroupsResponse)
|
||||
}
|
||||
|
||||
// SetPage sets the current page
|
||||
func (ls *ListAffinityGroups) SetPage(page int) {
|
||||
ls.Page = page
|
||||
}
|
||||
|
||||
// SetPageSize sets the page size
|
||||
func (ls *ListAffinityGroups) SetPageSize(pageSize int) {
|
||||
ls.PageSize = pageSize
|
||||
}
|
||||
|
||||
func (ListAffinityGroups) each(resp interface{}, callback IterateItemFunc) {
|
||||
vms, ok := resp.(*ListAffinityGroupsResponse)
|
||||
if !ok {
|
||||
callback(nil, fmt.Errorf("wrong type. ListAffinityGroupsResponse expected, got %T", resp))
|
||||
return
|
||||
}
|
||||
|
||||
for i := range vms.AffinityGroup {
|
||||
if !callback(&vms.AffinityGroup[i], nil) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ListAffinityGroupsResponse represents a list of (anti-)affinity groups
|
||||
type ListAffinityGroupsResponse struct {
|
||||
Count int `json:"count"`
|
||||
@ -171,7 +146,8 @@ type ListAffinityGroupTypes struct {
|
||||
_ bool `name:"listAffinityGroupTypes" description:"Lists affinity group types available"`
|
||||
}
|
||||
|
||||
func (ListAffinityGroupTypes) response() interface{} {
|
||||
// Response returns the struct to unmarshal
|
||||
func (ListAffinityGroupTypes) Response() interface{} {
|
||||
return new(ListAffinityGroupTypesResponse)
|
||||
}
|
||||
|
||||
|
43
vendor/github.com/exoscale/egoscale/affinitygroups_response.go
generated
vendored
Normal file
43
vendor/github.com/exoscale/egoscale/affinitygroups_response.go
generated
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
// code generated; DO NOT EDIT.
|
||||
|
||||
package egoscale
|
||||
|
||||
import "fmt"
|
||||
|
||||
// Response returns the struct to unmarshal
|
||||
func (ListAffinityGroups) Response() interface{} {
|
||||
return new(ListAffinityGroupsResponse)
|
||||
}
|
||||
|
||||
// ListRequest returns itself
|
||||
func (ls *ListAffinityGroups) ListRequest() (ListCommand, error) {
|
||||
if ls == nil {
|
||||
return nil, fmt.Errorf("%T cannot be nil", ls)
|
||||
}
|
||||
return ls, nil
|
||||
}
|
||||
|
||||
// SetPage sets the current apge
|
||||
func (ls *ListAffinityGroups) SetPage(page int) {
|
||||
ls.Page = page
|
||||
}
|
||||
|
||||
// SetPageSize sets the page size
|
||||
func (ls *ListAffinityGroups) SetPageSize(pageSize int) {
|
||||
ls.PageSize = pageSize
|
||||
}
|
||||
|
||||
// Each triggers the callback for each, valid answer or any non 404 issue
|
||||
func (ListAffinityGroups) Each(resp interface{}, callback IterateItemFunc) {
|
||||
items, ok := resp.(*ListAffinityGroupsResponse)
|
||||
if !ok {
|
||||
callback(nil, fmt.Errorf("wrong type, ListAffinityGroupsResponse was expected, got %T", resp))
|
||||
return
|
||||
}
|
||||
|
||||
for i := range items.AffinityGroup {
|
||||
if !callback(&items.AffinityGroup[i], nil) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
5
vendor/github.com/exoscale/egoscale/apis.go
generated
vendored
5
vendor/github.com/exoscale/egoscale/apis.go
generated
vendored
@ -3,7 +3,7 @@ package egoscale
|
||||
// API represents an API service
|
||||
type API struct {
|
||||
Description string `json:"description,omitempty" doc:"description of the api"`
|
||||
IsAsync bool `json:"isasync,omitempty" doc:"true if api is asynchronous"`
|
||||
IsAsync bool `json:"isasync" doc:"true if api is asynchronous"`
|
||||
Name string `json:"name,omitempty" doc:"the name of the api command"`
|
||||
Related string `json:"related,omitempty" doc:"comma separated related apis"`
|
||||
Since string `json:"since,omitempty" doc:"version of CloudStack the api was introduced in"`
|
||||
@ -42,6 +42,7 @@ type ListAPIsResponse struct {
|
||||
API []API `json:"api"`
|
||||
}
|
||||
|
||||
func (*ListAPIs) response() interface{} {
|
||||
// Response returns the struct to unmarshal
|
||||
func (*ListAPIs) Response() interface{} {
|
||||
return new(ListAPIsResponse)
|
||||
}
|
||||
|
39
vendor/github.com/exoscale/egoscale/async_jobs.go
generated
vendored
39
vendor/github.com/exoscale/egoscale/async_jobs.go
generated
vendored
@ -10,7 +10,7 @@ type AsyncJobResult struct {
|
||||
AccountID *UUID `json:"accountid,omitempty" doc:"the account that executed the async command"`
|
||||
Cmd string `json:"cmd,omitempty" doc:"the async command executed"`
|
||||
Created string `json:"created,omitempty" doc:"the created date of the job"`
|
||||
JobID *UUID `json:"jobid,omitempty" doc:"extra field for the initial async call"`
|
||||
JobID *UUID `json:"jobid" doc:"extra field for the initial async call"`
|
||||
JobInstanceID *UUID `json:"jobinstanceid,omitempty" doc:"the unique ID of the instance/entity object related to the job"`
|
||||
JobInstanceType string `json:"jobinstancetype,omitempty" doc:"the instance/entity object related to the job"`
|
||||
JobProcStatus int `json:"jobprocstatus,omitempty" doc:"the progress information of the PENDING job"`
|
||||
@ -21,6 +21,16 @@ type AsyncJobResult struct {
|
||||
UserID *UUID `json:"userid,omitempty" doc:"the user that executed the async command"`
|
||||
}
|
||||
|
||||
// ListRequest buils the (empty) ListAsyncJobs request
|
||||
func (a AsyncJobResult) ListRequest() (ListCommand, error) {
|
||||
req := &ListAsyncJobs{
|
||||
StartDate: a.Created,
|
||||
}
|
||||
|
||||
return req, nil
|
||||
}
|
||||
|
||||
// Error builds an error message from the result
|
||||
func (a AsyncJobResult) Error() error {
|
||||
r := new(ErrorResponse)
|
||||
if e := json.Unmarshal(*a.JobResult, r); e != nil {
|
||||
@ -35,31 +45,26 @@ type QueryAsyncJobResult struct {
|
||||
_ bool `name:"queryAsyncJobResult" description:"Retrieves the current status of asynchronous job."`
|
||||
}
|
||||
|
||||
func (QueryAsyncJobResult) response() interface{} {
|
||||
// Response returns the struct to unmarshal
|
||||
func (QueryAsyncJobResult) Response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
//go:generate go run generate/main.go -interface=Listable ListAsyncJobs
|
||||
|
||||
// ListAsyncJobs list the asynchronous jobs
|
||||
type ListAsyncJobs struct {
|
||||
Account string `json:"account,omitempty" doc:"list resources by account. Must be used with the domainId parameter."`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"list only resources belonging to the domain specified"`
|
||||
IsRecursive *bool `json:"isrecursive,omitempty" doc:"defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves."`
|
||||
Keyword string `json:"keyword,omitempty" doc:"List by keyword"`
|
||||
ListAll *bool `json:"listall,omitempty" doc:"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"`
|
||||
Page int `json:"page,omitempty"`
|
||||
PageSize int `json:"pagesize,omitempty"`
|
||||
StartDate string `json:"startdate,omitempty" doc:"the start date of the async job"`
|
||||
_ bool `name:"listAsyncJobs" description:"Lists all pending asynchronous jobs for the account."`
|
||||
Keyword string `json:"keyword,omitempty" doc:"List by keyword"`
|
||||
Page int `json:"page,omitempty"`
|
||||
PageSize int `json:"pagesize,omitempty"`
|
||||
StartDate string `json:"startdate,omitempty" doc:"the start date of the async job"`
|
||||
_ bool `name:"listAsyncJobs" description:"Lists all pending asynchronous jobs for the account."`
|
||||
}
|
||||
|
||||
// ListAsyncJobsResponse represents a list of job results
|
||||
type ListAsyncJobsResponse struct {
|
||||
Count int `json:"count"`
|
||||
AsyncJobs []AsyncJobResult `json:"asyncjobs"`
|
||||
}
|
||||
|
||||
func (ListAsyncJobs) response() interface{} {
|
||||
return new(ListAsyncJobsResponse)
|
||||
Count int `json:"count"`
|
||||
AsyncJob []AsyncJobResult `json:"asyncjobs"`
|
||||
}
|
||||
|
||||
// Result unmarshals the result of an AsyncJobResult into the given interface
|
||||
|
43
vendor/github.com/exoscale/egoscale/asyncjobs_response.go
generated
vendored
Normal file
43
vendor/github.com/exoscale/egoscale/asyncjobs_response.go
generated
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
// code generated; DO NOT EDIT.
|
||||
|
||||
package egoscale
|
||||
|
||||
import "fmt"
|
||||
|
||||
// Response returns the struct to unmarshal
|
||||
func (ListAsyncJobs) Response() interface{} {
|
||||
return new(ListAsyncJobsResponse)
|
||||
}
|
||||
|
||||
// ListRequest returns itself
|
||||
func (ls *ListAsyncJobs) ListRequest() (ListCommand, error) {
|
||||
if ls == nil {
|
||||
return nil, fmt.Errorf("%T cannot be nil", ls)
|
||||
}
|
||||
return ls, nil
|
||||
}
|
||||
|
||||
// SetPage sets the current apge
|
||||
func (ls *ListAsyncJobs) SetPage(page int) {
|
||||
ls.Page = page
|
||||
}
|
||||
|
||||
// SetPageSize sets the page size
|
||||
func (ls *ListAsyncJobs) SetPageSize(pageSize int) {
|
||||
ls.PageSize = pageSize
|
||||
}
|
||||
|
||||
// Each triggers the callback for each, valid answer or any non 404 issue
|
||||
func (ListAsyncJobs) Each(resp interface{}, callback IterateItemFunc) {
|
||||
items, ok := resp.(*ListAsyncJobsResponse)
|
||||
if !ok {
|
||||
callback(nil, fmt.Errorf("wrong type, ListAsyncJobsResponse was expected, got %T", resp))
|
||||
return
|
||||
}
|
||||
|
||||
for i := range items.AsyncJob {
|
||||
if !callback(&items.AsyncJob[i], nil) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
117
vendor/github.com/exoscale/egoscale/client.go
generated
vendored
117
vendor/github.com/exoscale/egoscale/client.go
generated
vendored
@ -13,11 +13,11 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// Taggable represents a resource which can have tags attached
|
||||
// Taggable represents a resource to which tags can be attached
|
||||
//
|
||||
// This is a helper to fill the resourcetype of a CreateTags call
|
||||
type Taggable interface {
|
||||
// CloudStack resource type of the Taggable type
|
||||
// ResourceType is the name of the Taggable type
|
||||
ResourceType() string
|
||||
}
|
||||
|
||||
@ -33,16 +33,11 @@ type Listable interface {
|
||||
ListRequest() (ListCommand, error)
|
||||
}
|
||||
|
||||
// Gettable represents an Interface that can be "Get" by the client
|
||||
type Gettable interface {
|
||||
Listable
|
||||
}
|
||||
|
||||
// Client represents the CloudStack API client
|
||||
// Client represents the API client
|
||||
type Client struct {
|
||||
// HTTPClient holds the HTTP client
|
||||
HTTPClient *http.Client
|
||||
// Endpoints is CloudStack API
|
||||
// Endpoint is the HTTP URL
|
||||
Endpoint string
|
||||
// APIKey is the API identifier
|
||||
APIKey string
|
||||
@ -52,13 +47,15 @@ type Client struct {
|
||||
PageSize int
|
||||
// Timeout represents the default timeout for the async requests
|
||||
Timeout time.Duration
|
||||
// Expiration representation how long a signed payload may be used
|
||||
Expiration time.Duration
|
||||
// RetryStrategy represents the waiting strategy for polling the async requests
|
||||
RetryStrategy RetryStrategyFunc
|
||||
// Logger contains any log, plug your own
|
||||
Logger *log.Logger
|
||||
}
|
||||
|
||||
// RetryStrategyFunc represents a how much time to wait between two calls to CloudStack
|
||||
// RetryStrategyFunc represents a how much time to wait between two calls to the API
|
||||
type RetryStrategyFunc func(int64) time.Duration
|
||||
|
||||
// IterateItemFunc represents the callback to iterate a list of results, if false stops
|
||||
@ -67,11 +64,12 @@ type IterateItemFunc func(interface{}, error) bool
|
||||
// WaitAsyncJobResultFunc represents the callback to wait a results of an async request, if false stops
|
||||
type WaitAsyncJobResultFunc func(*AsyncJobResult, error) bool
|
||||
|
||||
// NewClient creates a CloudStack API client with default timeout (60)
|
||||
// NewClient creates an API client with default timeout (60)
|
||||
//
|
||||
// Timeout is set to both the HTTP client and the client itself.
|
||||
func NewClient(endpoint, apiKey, apiSecret string) *Client {
|
||||
timeout := 60 * time.Second
|
||||
expiration := 10 * time.Minute
|
||||
|
||||
httpClient := &http.Client{
|
||||
Transport: http.DefaultTransport,
|
||||
@ -84,6 +82,7 @@ func NewClient(endpoint, apiKey, apiSecret string) *Client {
|
||||
apiSecret: apiSecret,
|
||||
PageSize: 50,
|
||||
Timeout: timeout,
|
||||
Expiration: expiration,
|
||||
RetryStrategy: MonotonicRetryStrategyFunc(2),
|
||||
Logger: log.New(ioutil.Discard, "", 0),
|
||||
}
|
||||
@ -97,45 +96,52 @@ func NewClient(endpoint, apiKey, apiSecret string) *Client {
|
||||
}
|
||||
|
||||
// Get populates the given resource or fails
|
||||
func (client *Client) Get(g Gettable) error {
|
||||
func (client *Client) Get(ls Listable) (interface{}, error) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), client.Timeout)
|
||||
defer cancel()
|
||||
|
||||
return client.GetWithContext(ctx, g)
|
||||
return client.GetWithContext(ctx, ls)
|
||||
}
|
||||
|
||||
// GetWithContext populates the given resource or fails
|
||||
func (client *Client) GetWithContext(ctx context.Context, g Gettable) error {
|
||||
gs, err := client.ListWithContext(ctx, g)
|
||||
func (client *Client) GetWithContext(ctx context.Context, ls Listable) (interface{}, error) {
|
||||
gs, err := client.ListWithContext(ctx, ls)
|
||||
if err != nil {
|
||||
return err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
count := len(gs)
|
||||
if count != 1 {
|
||||
req, err := g.ListRequest()
|
||||
req, err := ls.ListRequest()
|
||||
if err != nil {
|
||||
return err
|
||||
return nil, err
|
||||
}
|
||||
params, err := client.Payload(req)
|
||||
if err != nil {
|
||||
return err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// removing sensitive/useless informations
|
||||
params.Del("expires")
|
||||
params.Del("response")
|
||||
params.Del("signature")
|
||||
params.Del("signatureversion")
|
||||
|
||||
// formatting the query string nicely
|
||||
payload := params.Encode()
|
||||
payload = strings.Replace(payload, "&", ", ", -1)
|
||||
|
||||
if count == 0 {
|
||||
return &ErrorResponse{
|
||||
ErrorCode: ParamError,
|
||||
ErrorText: fmt.Sprintf("not found, query: %s", payload),
|
||||
return nil, &ErrorResponse{
|
||||
CSErrorCode: ServerAPIException,
|
||||
ErrorCode: ParamError,
|
||||
ErrorText: fmt.Sprintf("not found, query: %s", payload),
|
||||
}
|
||||
}
|
||||
return fmt.Errorf("more than one element found: %s", payload)
|
||||
return nil, fmt.Errorf("more than one element found: %s", payload)
|
||||
}
|
||||
|
||||
return Copy(g, gs[0])
|
||||
return gs[0], nil
|
||||
}
|
||||
|
||||
// Delete removes the given resource of fails
|
||||
@ -160,18 +166,25 @@ func (client *Client) List(g Listable) ([]interface{}, error) {
|
||||
}
|
||||
|
||||
// ListWithContext lists the given resources (and paginate till the end)
|
||||
func (client *Client) ListWithContext(ctx context.Context, g Listable) ([]interface{}, error) {
|
||||
s := make([]interface{}, 0)
|
||||
func (client *Client) ListWithContext(ctx context.Context, g Listable) (s []interface{}, err error) {
|
||||
s = make([]interface{}, 0)
|
||||
|
||||
if g == nil || reflect.ValueOf(g).IsNil() {
|
||||
return s, fmt.Errorf("g Listable shouldn't be nil, got %#v", g)
|
||||
defer func() {
|
||||
if e := recover(); e != nil {
|
||||
if g == nil || reflect.ValueOf(g).IsNil() {
|
||||
err = fmt.Errorf("g Listable shouldn't be nil, got %#v", g)
|
||||
return
|
||||
}
|
||||
|
||||
panic(e)
|
||||
}
|
||||
}()
|
||||
|
||||
req, e := g.ListRequest()
|
||||
if e != nil {
|
||||
err = e
|
||||
return
|
||||
}
|
||||
|
||||
req, err := g.ListRequest()
|
||||
if err != nil {
|
||||
return s, err
|
||||
}
|
||||
|
||||
client.PaginateWithContext(ctx, req, func(item interface{}, e error) bool {
|
||||
if item != nil {
|
||||
s = append(s, item)
|
||||
@ -181,7 +194,7 @@ func (client *Client) ListWithContext(ctx context.Context, g Listable) ([]interf
|
||||
return false
|
||||
})
|
||||
|
||||
return s, err
|
||||
return
|
||||
}
|
||||
|
||||
// AsyncListWithContext lists the given resources (and paginate till the end)
|
||||
@ -227,7 +240,6 @@ func (client *Client) AsyncListWithContext(ctx context.Context, g Listable) (<-c
|
||||
errChan <- err
|
||||
return
|
||||
}
|
||||
|
||||
client.PaginateWithContext(ctx, req, func(item interface{}, e error) bool {
|
||||
if item != nil {
|
||||
outChan <- item
|
||||
@ -242,15 +254,21 @@ func (client *Client) AsyncListWithContext(ctx context.Context, g Listable) (<-c
|
||||
}
|
||||
|
||||
// Paginate runs the ListCommand and paginates
|
||||
func (client *Client) Paginate(req ListCommand, callback IterateItemFunc) {
|
||||
func (client *Client) Paginate(g Listable, callback IterateItemFunc) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), client.Timeout)
|
||||
defer cancel()
|
||||
|
||||
client.PaginateWithContext(ctx, req, callback)
|
||||
client.PaginateWithContext(ctx, g, callback)
|
||||
}
|
||||
|
||||
// PaginateWithContext runs the ListCommand as long as the ctx is valid
|
||||
func (client *Client) PaginateWithContext(ctx context.Context, req ListCommand, callback IterateItemFunc) {
|
||||
func (client *Client) PaginateWithContext(ctx context.Context, g Listable, callback IterateItemFunc) {
|
||||
req, err := g.ListRequest()
|
||||
if err != nil {
|
||||
callback(nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
pageSize := client.PageSize
|
||||
|
||||
page := 1
|
||||
@ -260,13 +278,18 @@ func (client *Client) PaginateWithContext(ctx context.Context, req ListCommand,
|
||||
req.SetPageSize(pageSize)
|
||||
resp, err := client.RequestWithContext(ctx, req)
|
||||
if err != nil {
|
||||
// in case of 431, the response is knowingly empty
|
||||
if errResponse, ok := err.(*ErrorResponse); ok && page == 1 && errResponse.ErrorCode == ParamError {
|
||||
break
|
||||
}
|
||||
|
||||
callback(nil, err)
|
||||
break
|
||||
}
|
||||
|
||||
size := 0
|
||||
didErr := false
|
||||
req.each(resp, func(element interface{}, err error) bool {
|
||||
req.Each(resp, func(element interface{}, err error) bool {
|
||||
// If the context was cancelled, kill it in flight
|
||||
if e := ctx.Err(); e != nil {
|
||||
element = nil
|
||||
@ -290,10 +313,12 @@ func (client *Client) PaginateWithContext(ctx context.Context, req ListCommand,
|
||||
}
|
||||
}
|
||||
|
||||
// APIName returns the CloudStack name of the given command
|
||||
// APIName returns the name of the given command
|
||||
func (client *Client) APIName(command Command) string {
|
||||
// This is due to a limitation of Go<=1.7
|
||||
if _, ok := command.(*AuthorizeSecurityGroupEgress); ok {
|
||||
_, ok := command.(*AuthorizeSecurityGroupEgress)
|
||||
_, okPtr := command.(AuthorizeSecurityGroupEgress)
|
||||
if ok || okPtr {
|
||||
return "authorizeSecurityGroupEgress"
|
||||
}
|
||||
|
||||
@ -304,7 +329,7 @@ func (client *Client) APIName(command Command) string {
|
||||
return info.Name
|
||||
}
|
||||
|
||||
// APIDescription returns the description of the given CloudStack command
|
||||
// APIDescription returns the description of the given command
|
||||
func (client *Client) APIDescription(command Command) string {
|
||||
info, err := info(command)
|
||||
if err != nil {
|
||||
@ -315,11 +340,11 @@ func (client *Client) APIDescription(command Command) string {
|
||||
|
||||
// Response returns the response structure of the given command
|
||||
func (client *Client) Response(command Command) interface{} {
|
||||
switch command.(type) {
|
||||
switch c := command.(type) {
|
||||
case AsyncCommand:
|
||||
return (command.(AsyncCommand)).asyncResponse()
|
||||
return c.AsyncResponse()
|
||||
default:
|
||||
return command.response()
|
||||
return command.Response()
|
||||
}
|
||||
}
|
||||
|
||||
|
37
vendor/github.com/exoscale/egoscale/copier.go
generated
vendored
37
vendor/github.com/exoscale/egoscale/copier.go
generated
vendored
@ -1,37 +0,0 @@
|
||||
package egoscale
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
)
|
||||
|
||||
// Copy copies the value from from into to. The type of "from" must be convertible into the type of "to".
|
||||
func Copy(to, from interface{}) error {
|
||||
tt := reflect.TypeOf(to)
|
||||
tv := reflect.ValueOf(to)
|
||||
|
||||
ft := reflect.TypeOf(from)
|
||||
fv := reflect.ValueOf(from)
|
||||
|
||||
if tt.Kind() != reflect.Ptr {
|
||||
return fmt.Errorf("must copy to a pointer, got %q", tt.Name())
|
||||
}
|
||||
|
||||
tt = tt.Elem()
|
||||
tv = tv.Elem()
|
||||
|
||||
for {
|
||||
if ft.ConvertibleTo(tt) {
|
||||
break
|
||||
}
|
||||
if ft.Kind() == reflect.Ptr {
|
||||
ft = ft.Elem()
|
||||
fv = fv.Elem()
|
||||
} else {
|
||||
return fmt.Errorf("cannot convert %q into %q", tt.Name(), ft.Name())
|
||||
}
|
||||
}
|
||||
|
||||
tv.Set(fv.Convert(tt))
|
||||
return nil
|
||||
}
|
45
vendor/github.com/exoscale/egoscale/dns.go
generated
vendored
45
vendor/github.com/exoscale/egoscale/dns.go
generated
vendored
@ -1,6 +1,7 @@
|
||||
package egoscale
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
@ -128,7 +129,7 @@ func (req *DNSErrorResponse) Error() string {
|
||||
}
|
||||
|
||||
// CreateDomain creates a DNS domain
|
||||
func (client *Client) CreateDomain(name string) (*DNSDomain, error) {
|
||||
func (client *Client) CreateDomain(ctx context.Context, name string) (*DNSDomain, error) {
|
||||
m, err := json.Marshal(DNSDomainResponse{
|
||||
Domain: &DNSDomain{
|
||||
Name: name,
|
||||
@ -138,7 +139,7 @@ func (client *Client) CreateDomain(name string) (*DNSDomain, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
resp, err := client.dnsRequest("/v1/domains", nil, string(m), "POST")
|
||||
resp, err := client.dnsRequest(ctx, "/v1/domains", nil, string(m), "POST")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -152,8 +153,8 @@ func (client *Client) CreateDomain(name string) (*DNSDomain, error) {
|
||||
}
|
||||
|
||||
// GetDomain gets a DNS domain
|
||||
func (client *Client) GetDomain(name string) (*DNSDomain, error) {
|
||||
resp, err := client.dnsRequest("/v1/domains/"+name, nil, "", "GET")
|
||||
func (client *Client) GetDomain(ctx context.Context, name string) (*DNSDomain, error) {
|
||||
resp, err := client.dnsRequest(ctx, "/v1/domains/"+name, nil, "", "GET")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -167,8 +168,8 @@ func (client *Client) GetDomain(name string) (*DNSDomain, error) {
|
||||
}
|
||||
|
||||
// GetDomains gets DNS domains
|
||||
func (client *Client) GetDomains() ([]DNSDomain, error) {
|
||||
resp, err := client.dnsRequest("/v1/domains", nil, "", "GET")
|
||||
func (client *Client) GetDomains(ctx context.Context) ([]DNSDomain, error) {
|
||||
resp, err := client.dnsRequest(ctx, "/v1/domains", nil, "", "GET")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -186,15 +187,15 @@ func (client *Client) GetDomains() ([]DNSDomain, error) {
|
||||
}
|
||||
|
||||
// DeleteDomain delets a DNS domain
|
||||
func (client *Client) DeleteDomain(name string) error {
|
||||
_, err := client.dnsRequest("/v1/domains/"+name, nil, "", "DELETE")
|
||||
func (client *Client) DeleteDomain(ctx context.Context, name string) error {
|
||||
_, err := client.dnsRequest(ctx, "/v1/domains/"+name, nil, "", "DELETE")
|
||||
return err
|
||||
}
|
||||
|
||||
// GetRecord returns a DNS record
|
||||
func (client *Client) GetRecord(domain string, recordID int64) (*DNSRecord, error) {
|
||||
func (client *Client) GetRecord(ctx context.Context, domain string, recordID int64) (*DNSRecord, error) {
|
||||
id := strconv.FormatInt(recordID, 10)
|
||||
resp, err := client.dnsRequest("/v1/domains/"+domain+"/records/"+id, nil, "", "GET")
|
||||
resp, err := client.dnsRequest(ctx, "/v1/domains/"+domain+"/records/"+id, nil, "", "GET")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -208,8 +209,8 @@ func (client *Client) GetRecord(domain string, recordID int64) (*DNSRecord, erro
|
||||
}
|
||||
|
||||
// GetRecords returns the DNS records
|
||||
func (client *Client) GetRecords(domain string) ([]DNSRecord, error) {
|
||||
resp, err := client.dnsRequest("/v1/domains/"+domain+"/records", nil, "", "GET")
|
||||
func (client *Client) GetRecords(ctx context.Context, domain string) ([]DNSRecord, error) {
|
||||
resp, err := client.dnsRequest(ctx, "/v1/domains/"+domain+"/records", nil, "", "GET")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -228,7 +229,7 @@ func (client *Client) GetRecords(domain string) ([]DNSRecord, error) {
|
||||
}
|
||||
|
||||
// GetRecordsWithFilters returns the DNS records (filters can be empty)
|
||||
func (client *Client) GetRecordsWithFilters(domain, name, recordType string) ([]DNSRecord, error) {
|
||||
func (client *Client) GetRecordsWithFilters(ctx context.Context, domain, name, recordType string) ([]DNSRecord, error) {
|
||||
|
||||
filters := url.Values{}
|
||||
if name != "" {
|
||||
@ -238,7 +239,7 @@ func (client *Client) GetRecordsWithFilters(domain, name, recordType string) ([]
|
||||
filters.Add("record_type", recordType)
|
||||
}
|
||||
|
||||
resp, err := client.dnsRequest("/v1/domains/"+domain+"/records", filters, "", "GET")
|
||||
resp, err := client.dnsRequest(ctx, "/v1/domains/"+domain+"/records", filters, "", "GET")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -257,7 +258,7 @@ func (client *Client) GetRecordsWithFilters(domain, name, recordType string) ([]
|
||||
}
|
||||
|
||||
// CreateRecord creates a DNS record
|
||||
func (client *Client) CreateRecord(name string, rec DNSRecord) (*DNSRecord, error) {
|
||||
func (client *Client) CreateRecord(ctx context.Context, name string, rec DNSRecord) (*DNSRecord, error) {
|
||||
body, err := json.Marshal(DNSRecordResponse{
|
||||
Record: rec,
|
||||
})
|
||||
@ -265,7 +266,7 @@ func (client *Client) CreateRecord(name string, rec DNSRecord) (*DNSRecord, erro
|
||||
return nil, err
|
||||
}
|
||||
|
||||
resp, err := client.dnsRequest("/v1/domains/"+name+"/records", nil, string(body), "POST")
|
||||
resp, err := client.dnsRequest(ctx, "/v1/domains/"+name+"/records", nil, string(body), "POST")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -279,7 +280,7 @@ func (client *Client) CreateRecord(name string, rec DNSRecord) (*DNSRecord, erro
|
||||
}
|
||||
|
||||
// UpdateRecord updates a DNS record
|
||||
func (client *Client) UpdateRecord(name string, rec UpdateDNSRecord) (*DNSRecord, error) {
|
||||
func (client *Client) UpdateRecord(ctx context.Context, name string, rec UpdateDNSRecord) (*DNSRecord, error) {
|
||||
body, err := json.Marshal(UpdateDNSRecordResponse{
|
||||
Record: rec,
|
||||
})
|
||||
@ -288,7 +289,7 @@ func (client *Client) UpdateRecord(name string, rec UpdateDNSRecord) (*DNSRecord
|
||||
}
|
||||
|
||||
id := strconv.FormatInt(rec.ID, 10)
|
||||
resp, err := client.dnsRequest("/v1/domains/"+name+"/records/"+id, nil, string(body), "PUT")
|
||||
resp, err := client.dnsRequest(ctx, "/v1/domains/"+name+"/records/"+id, nil, string(body), "PUT")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -302,14 +303,14 @@ func (client *Client) UpdateRecord(name string, rec UpdateDNSRecord) (*DNSRecord
|
||||
}
|
||||
|
||||
// DeleteRecord deletes a record
|
||||
func (client *Client) DeleteRecord(name string, recordID int64) error {
|
||||
func (client *Client) DeleteRecord(ctx context.Context, name string, recordID int64) error {
|
||||
id := strconv.FormatInt(recordID, 10)
|
||||
_, err := client.dnsRequest("/v1/domains/"+name+"/records/"+id, nil, "", "DELETE")
|
||||
_, err := client.dnsRequest(ctx, "/v1/domains/"+name+"/records/"+id, nil, "", "DELETE")
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func (client *Client) dnsRequest(uri string, urlValues url.Values, params, method string) (json.RawMessage, error) {
|
||||
func (client *Client) dnsRequest(ctx context.Context, uri string, urlValues url.Values, params, method string) (json.RawMessage, error) {
|
||||
rawURL := client.Endpoint + uri
|
||||
url, err := url.Parse(rawURL)
|
||||
if err != nil {
|
||||
@ -338,7 +339,7 @@ func (client *Client) dnsRequest(uri string, urlValues url.Values, params, metho
|
||||
}
|
||||
req.Header = hdr
|
||||
|
||||
resp, err := client.HTTPClient.Do(req)
|
||||
resp, err := client.HTTPClient.Do(req.WithContext(ctx))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
49
vendor/github.com/exoscale/egoscale/doc.go
generated
vendored
49
vendor/github.com/exoscale/egoscale/doc.go
generated
vendored
@ -1,18 +1,18 @@
|
||||
/*
|
||||
|
||||
Package egoscale is a mapping for with the CloudStack API (http://cloudstack.apache.org/api.html) from Go. It has been designed against the Exoscale (https://www.exoscale.com/) infrastructure but should fit other CloudStack services.
|
||||
Package egoscale is a mapping for the Exoscale API (https://community.exoscale.com/api/compute/).
|
||||
|
||||
Requests and Responses
|
||||
|
||||
To build a request, construct the adequate struct. This library expects a pointer for efficiency reasons only. The response is a struct corresponding to the data at stake. E.g. DeployVirtualMachine gives a VirtualMachine, as a pointer as well to avoid big copies.
|
||||
|
||||
Then everything within the struct is not a pointer. Find below some examples of how egoscale may be used to interact with a CloudStack endpoint, especially Exoscale itself. If anything feels odd or unclear, please let us know: https://github.com/exoscale/egoscale/issues
|
||||
Then everything within the struct is not a pointer. Find below some examples of how egoscale may be used. If anything feels odd or unclear, please let us know: https://github.com/exoscale/egoscale/issues
|
||||
|
||||
req := &egoscale.DeployVirtualMachine{
|
||||
Size: 10,
|
||||
ServiceOfferingID: "...",
|
||||
TemplateID: "...",
|
||||
ZoneID: "...",
|
||||
ServiceOfferingID: egoscale.MustParseUUID("..."),
|
||||
TemplateID: egoscale.MustParseUUID("..."),
|
||||
ZoneID: egoscale.MastParseUUID("..."),
|
||||
}
|
||||
|
||||
fmt.Println("Deployment started")
|
||||
@ -28,9 +28,9 @@ This example deploys a virtual machine while controlling the job status as it go
|
||||
|
||||
req := &egoscale.DeployVirtualMachine{
|
||||
Size: 10,
|
||||
ServiceOfferingID: "...",
|
||||
TemplateID: "...",
|
||||
ZoneID: "...",
|
||||
ServiceOfferingID: egoscale.MustParseUUID("..."),
|
||||
TemplateID: egoscale.MustParseUUID("..."),
|
||||
ZoneID: egoscale.MustParseUUID("..."),
|
||||
}
|
||||
vm := &egoscale.VirtualMachine{}
|
||||
|
||||
@ -63,20 +63,20 @@ Debugging and traces
|
||||
|
||||
As this library is mostly an HTTP client, you can reuse all the existing tools around it.
|
||||
|
||||
cs := egoscale.NewClient("https://api.exoscale.ch/compute", "EXO...", "...")
|
||||
cs := egoscale.NewClient("https://api.exoscale.com/compute", "EXO...", "...")
|
||||
// sets a logger on stderr
|
||||
cs.Logger = log.Newos.Stderr, "prefix", log.LstdFlags)
|
||||
cs.Logger = log.New(os.Stderr, "prefix", log.LstdFlags)
|
||||
// activates the HTTP traces
|
||||
cs.TraceOn()
|
||||
|
||||
Nota bene: when running the tests or the egoscale library via another tool, e.g. the exo cli (or the cs cli), the environment variable EXOSCALE_TRACE=prefix does the above configuration for you. As a developer using egoscale as a library, you'll find it more convenient to plug your favorite io.Writer as it's Logger.
|
||||
Nota bene: when running the tests or the egoscale library via another tool, e.g. the exo cli, the environment variable EXOSCALE_TRACE=prefix does the above configuration for you. As a developer using egoscale as a library, you'll find it more convenient to plug your favorite io.Writer as it's a Logger.
|
||||
|
||||
|
||||
APIs
|
||||
|
||||
All the available APIs on the server and provided by the API Discovery plugin
|
||||
All the available APIs on the server and provided by the API Discovery plugin.
|
||||
|
||||
cs := egoscale.NewClient("https://api.exoscale.ch/compute", "EXO...", "...")
|
||||
cs := egoscale.NewClient("https://api.exoscale.com/compute", "EXO...", "...")
|
||||
|
||||
resp, err := cs.Request(&egoscale.ListAPIs{})
|
||||
if err != nil {
|
||||
@ -96,14 +96,17 @@ Security Groups provide a way to isolate traffic to VMs. Rules are added via the
|
||||
|
||||
resp, err := cs.Request(&egoscale.CreateSecurityGroup{
|
||||
Name: "Load balancer",
|
||||
Description: "Opens HTTP/HTTPS ports from the outside world",
|
||||
Description: "Open HTTP/HTTPS ports from the outside world",
|
||||
})
|
||||
securityGroup := resp.(*egoscale.SecurityGroup)
|
||||
|
||||
resp, err = cs.Request(&egoscale.AuthorizeSecurityGroupIngress{
|
||||
Description: "SSH traffic",
|
||||
SecurityGroupID: securityGroup.ID,
|
||||
CidrList: []string{"0.0.0.0/0"},
|
||||
CidrList: []CIDR{
|
||||
*egoscale.MustParseCIDR("0.0.0.0/0"),
|
||||
*egoscale.MustParseCIDR("::/0"),
|
||||
},
|
||||
Protocol: "tcp",
|
||||
StartPort: 22,
|
||||
EndPort: 22,
|
||||
@ -117,32 +120,32 @@ Security Groups provide a way to isolate traffic to VMs. Rules are added via the
|
||||
})
|
||||
// ...
|
||||
|
||||
Security Group also implement the generic List, Get and Delete interfaces (Listable, Gettable and Deletable).
|
||||
Security Group also implement the generic List, Get and Delete interfaces (Listable and Deletable).
|
||||
|
||||
// List all Security Groups
|
||||
sgs, err := cs.List(new(egoscale.SecurityGroup))
|
||||
sgs, _ := cs.List(&egoscale.SecurityGroup{})
|
||||
for _, s := range sgs {
|
||||
sg := s.(egoscale.SecurityGroup)
|
||||
// ...
|
||||
}
|
||||
|
||||
// Get a Security Group
|
||||
sg := &egoscale.SecurityGroup{Name: "Load balancer"}
|
||||
if err := cs.Get(sg); err != nil {
|
||||
sgQuery := &egoscale.SecurityGroup{Name: "Load balancer"}
|
||||
resp, err := cs.Get(sgQuery); err != nil {
|
||||
...
|
||||
}
|
||||
// The SecurityGroup struct has been loaded with the SecurityGroup informations
|
||||
sg := resp.(*egoscale.SecurityGroup)
|
||||
|
||||
if err := cs.Delete(sg); err != nil {
|
||||
...
|
||||
}
|
||||
// The SecurityGroup has been deleted
|
||||
|
||||
See: http://docs.cloudstack.apache.org/projects/cloudstack-administration/en/stable/networking_and_traffic.html#security-groups
|
||||
See: https://community.exoscale.com/documentation/compute/security-groups/
|
||||
|
||||
Zones
|
||||
|
||||
A Zone corresponds to a Data Center. You may list them. Zone implements the Listable interface, which let you perform a list in two different ways. The first exposes the underlying CloudStack request while the second one hide them and you only manipulate the structs of your interest.
|
||||
A Zone corresponds to a Data Center. You may list them. Zone implements the Listable interface, which let you perform a list in two different ways. The first exposes the underlying request while the second one hide them and you only manipulate the structs of your interest.
|
||||
|
||||
// Using ListZones request
|
||||
req := &egoscale.ListZones{}
|
||||
@ -171,7 +174,7 @@ Elastic IPs
|
||||
|
||||
An Elastic IP is a way to attach an IP address to many Virtual Machines. The API side of the story configures the external environment, like the routing. Some work is required within the machine to properly configure the interfaces.
|
||||
|
||||
See: http://docs.cloudstack.apache.org/projects/cloudstack-administration/en/latest/networking_and_traffic.html#about-elastic-ips
|
||||
See: https://community.exoscale.com/documentation/compute/eip/
|
||||
|
||||
*/
|
||||
package egoscale
|
||||
|
62
vendor/github.com/exoscale/egoscale/events.go
generated
vendored
62
vendor/github.com/exoscale/egoscale/events.go
generated
vendored
@ -5,9 +5,7 @@ type Event struct {
|
||||
Account string `json:"account,omitempty" doc:"the account name for the account that owns the object being acted on in the event (e.g. the owner of the virtual machine, ip address, or security group)"`
|
||||
Created string `json:"created,omitempty" doc:"the date the event was created"`
|
||||
Description string `json:"description,omitempty" doc:"a brief description of the event"`
|
||||
Domain string `json:"domain,omitempty" doc:"the name of the account's domain"`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"the id of the account's domain"`
|
||||
ID *UUID `json:"id,omitempty" doc:"the ID of the event"`
|
||||
ID *UUID `json:"id" doc:"the ID of the event"`
|
||||
Level string `json:"level,omitempty" doc:"the event level (INFO, WARN, ERROR)"`
|
||||
ParentID *UUID `json:"parentid,omitempty" doc:"whether the event is parented"`
|
||||
State string `json:"state,omitempty" doc:"the state of the event"`
|
||||
@ -15,28 +13,44 @@ type Event struct {
|
||||
UserName string `json:"username,omitempty" doc:"the name of the user who performed the action (can be different from the account if an admin is performing an action for a user, e.g. starting/stopping a user's virtual machine)"`
|
||||
}
|
||||
|
||||
// ListRequest builds the ListEvents request
|
||||
func (event Event) ListRequest() (ListCommand, error) {
|
||||
req := &ListEvents{
|
||||
ID: event.ID,
|
||||
Level: event.Level,
|
||||
Type: event.Type,
|
||||
}
|
||||
|
||||
return req, nil
|
||||
}
|
||||
|
||||
// EventType represent a type of event
|
||||
type EventType struct {
|
||||
Name string `json:"name,omitempty" doc:"Event Type"`
|
||||
}
|
||||
|
||||
// ListRequest builds the ListEventTypes request
|
||||
func (EventType) ListRequest() (ListCommand, error) {
|
||||
req := &ListEventTypes{}
|
||||
|
||||
return req, nil
|
||||
}
|
||||
|
||||
//go:generate go run generate/main.go -interface=Listable ListEvents
|
||||
|
||||
// ListEvents list the events
|
||||
type ListEvents struct {
|
||||
Account string `json:"account,omitempty" doc:"list resources by account. Must be used with the domainId parameter."`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"list only resources belonging to the domain specified"`
|
||||
Duration int `json:"duration,omitempty" doc:"the duration of the event"`
|
||||
EndDate string `json:"enddate,omitempty" doc:"the end date range of the list you want to retrieve (use format \"yyyy-MM-dd\" or the new format \"yyyy-MM-dd HH:mm:ss\")"`
|
||||
EntryTime int `json:"entrytime,omitempty" doc:"the time the event was entered"`
|
||||
ID *UUID `json:"id,omitempty" doc:"the ID of the event"`
|
||||
IsRecursive *bool `json:"isrecursive,omitempty" doc:"defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves." doc:"defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves."`
|
||||
Keyword string `json:"keyword,omitempty" doc:"List by keyword"`
|
||||
Level string `json:"level,omitempty" doc:"the event level (INFO, WARN, ERROR)"`
|
||||
ListAll *bool `json:"listall,omitempty" doc:"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"`
|
||||
Page int `json:"page,omitempty" `
|
||||
PageSize int `json:"pagesize,omitempty"`
|
||||
StartDate string `json:"startdate,omitempty" doc:"the start date range of the list you want to retrieve (use format \"yyyy-MM-dd\" or the new format \"yyyy-MM-dd HH:mm:ss\")"`
|
||||
Type string `json:"type,omitempty" doc:"the event type (see event types)"`
|
||||
_ bool `name:"listEvents" description:"A command to list events."`
|
||||
Duration int `json:"duration,omitempty" doc:"the duration of the event"`
|
||||
EndDate string `json:"enddate,omitempty" doc:"the end date range of the list you want to retrieve (use format \"yyyy-MM-dd\" or the new format \"yyyy-MM-dd HH:mm:ss\")"`
|
||||
EntryTime int `json:"entrytime,omitempty" doc:"the time the event was entered"`
|
||||
ID *UUID `json:"id,omitempty" doc:"the ID of the event"`
|
||||
Keyword string `json:"keyword,omitempty" doc:"List by keyword"`
|
||||
Level string `json:"level,omitempty" doc:"the event level (INFO, WARN, ERROR)"`
|
||||
Page int `json:"page,omitempty"`
|
||||
PageSize int `json:"pagesize,omitempty"`
|
||||
StartDate string `json:"startdate,omitempty" doc:"the start date range of the list you want to retrieve (use format \"yyyy-MM-dd\" or the new format \"yyyy-MM-dd HH:mm:ss\")"`
|
||||
Type string `json:"type,omitempty" doc:"the event type (see event types)"`
|
||||
_ bool `name:"listEvents" description:"A command to list events."`
|
||||
}
|
||||
|
||||
// ListEventsResponse represents a response of a list query
|
||||
@ -45,13 +59,13 @@ type ListEventsResponse struct {
|
||||
Event []Event `json:"event"`
|
||||
}
|
||||
|
||||
func (ListEvents) response() interface{} {
|
||||
return new(ListEventsResponse)
|
||||
}
|
||||
//go:generate go run generate/main.go -interface=Listable ListEventTypes
|
||||
|
||||
// ListEventTypes list the event types
|
||||
type ListEventTypes struct {
|
||||
_ bool `name:"listEventTypes" description:"List Event Types"`
|
||||
Page int `json:"page,omitempty"` // fake
|
||||
PageSize int `json:"pagesize,omitempty"` // fake
|
||||
_ bool `name:"listEventTypes" description:"List Event Types"`
|
||||
}
|
||||
|
||||
// ListEventTypesResponse represents a response of a list query
|
||||
@ -60,7 +74,3 @@ type ListEventTypesResponse struct {
|
||||
EventType []EventType `json:"eventtype"`
|
||||
_ bool `name:"listEventTypes" description:"List Event Types"`
|
||||
}
|
||||
|
||||
func (ListEventTypes) response() interface{} {
|
||||
return new(ListEventTypesResponse)
|
||||
}
|
||||
|
43
vendor/github.com/exoscale/egoscale/events_response.go
generated
vendored
Normal file
43
vendor/github.com/exoscale/egoscale/events_response.go
generated
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
// code generated; DO NOT EDIT.
|
||||
|
||||
package egoscale
|
||||
|
||||
import "fmt"
|
||||
|
||||
// Response returns the struct to unmarshal
|
||||
func (ListEvents) Response() interface{} {
|
||||
return new(ListEventsResponse)
|
||||
}
|
||||
|
||||
// ListRequest returns itself
|
||||
func (ls *ListEvents) ListRequest() (ListCommand, error) {
|
||||
if ls == nil {
|
||||
return nil, fmt.Errorf("%T cannot be nil", ls)
|
||||
}
|
||||
return ls, nil
|
||||
}
|
||||
|
||||
// SetPage sets the current apge
|
||||
func (ls *ListEvents) SetPage(page int) {
|
||||
ls.Page = page
|
||||
}
|
||||
|
||||
// SetPageSize sets the page size
|
||||
func (ls *ListEvents) SetPageSize(pageSize int) {
|
||||
ls.PageSize = pageSize
|
||||
}
|
||||
|
||||
// Each triggers the callback for each, valid answer or any non 404 issue
|
||||
func (ListEvents) Each(resp interface{}, callback IterateItemFunc) {
|
||||
items, ok := resp.(*ListEventsResponse)
|
||||
if !ok {
|
||||
callback(nil, fmt.Errorf("wrong type, ListEventsResponse was expected, got %T", resp))
|
||||
return
|
||||
}
|
||||
|
||||
for i := range items.Event {
|
||||
if !callback(&items.Event[i], nil) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
43
vendor/github.com/exoscale/egoscale/eventtypes_response.go
generated
vendored
Normal file
43
vendor/github.com/exoscale/egoscale/eventtypes_response.go
generated
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
// code generated; DO NOT EDIT.
|
||||
|
||||
package egoscale
|
||||
|
||||
import "fmt"
|
||||
|
||||
// Response returns the struct to unmarshal
|
||||
func (ListEventTypes) Response() interface{} {
|
||||
return new(ListEventTypesResponse)
|
||||
}
|
||||
|
||||
// ListRequest returns itself
|
||||
func (ls *ListEventTypes) ListRequest() (ListCommand, error) {
|
||||
if ls == nil {
|
||||
return nil, fmt.Errorf("%T cannot be nil", ls)
|
||||
}
|
||||
return ls, nil
|
||||
}
|
||||
|
||||
// SetPage sets the current apge
|
||||
func (ls *ListEventTypes) SetPage(page int) {
|
||||
ls.Page = page
|
||||
}
|
||||
|
||||
// SetPageSize sets the page size
|
||||
func (ls *ListEventTypes) SetPageSize(pageSize int) {
|
||||
ls.PageSize = pageSize
|
||||
}
|
||||
|
||||
// Each triggers the callback for each, valid answer or any non 404 issue
|
||||
func (ListEventTypes) Each(resp interface{}, callback IterateItemFunc) {
|
||||
items, ok := resp.(*ListEventTypesResponse)
|
||||
if !ok {
|
||||
callback(nil, fmt.Errorf("wrong type, ListEventTypesResponse was expected, got %T", resp))
|
||||
return
|
||||
}
|
||||
|
||||
for i := range items.EventType {
|
||||
if !callback(&items.EventType[i], nil) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
99
vendor/github.com/exoscale/egoscale/hosts.go
generated
vendored
99
vendor/github.com/exoscale/egoscale/hosts.go
generated
vendored
@ -1,99 +0,0 @@
|
||||
package egoscale
|
||||
|
||||
import (
|
||||
"net"
|
||||
)
|
||||
|
||||
// Host represents the Hypervisor
|
||||
type Host struct {
|
||||
Capabilities string `json:"capabilities,omitempty" doc:"capabilities of the host"`
|
||||
ClusterID *UUID `json:"clusterid,omitempty" doc:"the cluster ID of the host"`
|
||||
ClusterName string `json:"clustername,omitempty" doc:"the cluster name of the host"`
|
||||
ClusterType string `json:"clustertype,omitempty" doc:"the cluster type of the cluster that host belongs to"`
|
||||
CPUAllocated int64 `json:"cpuallocated,omitempty" doc:"the amount of the host's CPU currently allocated"`
|
||||
CPUNumber int `json:"cpunumber,omitempty" doc:"the CPU number of the host"`
|
||||
CPUSockets int `json:"cpusockets,omitempty" doc:"the number of CPU sockets on the host"`
|
||||
CPUSpeed int64 `json:"cpuspeed,omitempty" doc:"the CPU speed of the host"`
|
||||
CPUUsed int64 `json:"cpuused,omitempty" doc:"the amount of the host's CPU currently used"`
|
||||
CPUWithOverProvisioning int64 `json:"cpuwithoverprovisioning,omitempty" doc:"the amount of the host's CPU after applying the cpu.overprovisioning.factor"`
|
||||
Created string `json:"created,omitempty" doc:"the date and time the host was created"`
|
||||
Disconnected string `json:"disconnected,omitempty" doc:"true if the host is disconnected. False otherwise."`
|
||||
DiskSizeAllocated int64 `json:"disksizeallocated,omitempty" doc:"the host's or host storage pool's currently allocated disk size"`
|
||||
DiskSizeTotal int64 `json:"disksizetotal,omitempty" doc:"the total disk size of the host or host storage pool"`
|
||||
DiskSizeUsed int64 `json:"disksizeused,omitempty" doc:"the host's or host storage pool's currently used disk size"`
|
||||
DiskWithOverProvisioning int64 `json:"diskwithoverprovisioning,omitempty" doc:"the total disk size of the host or host storage pool with over provisioning factor"`
|
||||
Events string `json:"events,omitempty" doc:"events available for the host"`
|
||||
HAHost *bool `json:"hahost,omitempty" doc:"true if the host is Ha host (dedicated to vms started by HA process; false otherwise"`
|
||||
HostTags string `json:"hosttags,omitempty" doc:"comma-separated list of tags for the host"`
|
||||
Hypervisor string `json:"hypervisor,omitempty" doc:"the host hypervisor"`
|
||||
HypervisorVersion string `json:"hypervisorversion,omitempty" doc:"the hypervisor version"`
|
||||
ID *UUID `json:"id,omitempty" doc:"the ID of the host"`
|
||||
IPAddress net.IP `json:"ipaddress,omitempty" doc:"the IP address of the host"`
|
||||
IsLocalstorageActive *bool `json:"islocalstorageactive,omitempty" doc:"true if local storage is active, false otherwise"`
|
||||
LastPinged string `json:"lastpinged,omitempty" doc:"the date and time the host was last pinged"`
|
||||
ManagementServerID *UUID `json:"managementserverid,omitempty" doc:"the management server ID of the host"`
|
||||
MemoryAllocated int64 `json:"memoryallocated,omitempty" doc:"the amount of VM's memory allocated onto the host"`
|
||||
MemoryPhysical int64 `json:"memoryphysical,omitempty" doc:"the total physical memory of the host"`
|
||||
MemoryReserved int64 `json:"memoryreserved,omitempty" doc:"the amount of the host's memory reserved"`
|
||||
MemoryTotal int64 `json:"memorytotal,omitempty" doc:"the total memory of the host available (must be physical - reserved)"`
|
||||
MemoryUsed int64 `json:"memoryused,omitempty" doc:"the amount of the host's memory used by running vm"`
|
||||
Name string `json:"name,omitempty" doc:"the name of the host"`
|
||||
NetworkKbsRead int64 `json:"networkkbsread,omitempty" doc:"the incoming network traffic on the host"`
|
||||
NetworkKbsWrite int64 `json:"networkkbswrite,omitempty" doc:"the outgoing network traffic on the host"`
|
||||
OSCategoryID *UUID `json:"oscategoryid,omitempty" doc:"the OS category ID of the host"`
|
||||
OSCategoryName string `json:"oscategoryname,omitempty" doc:"the OS category name of the host"`
|
||||
PCIDevices []PCIDevice `json:"pcidevices,omitempty" doc:"PCI cards present in the host"`
|
||||
PodID *UUID `json:"podid,omitempty" doc:"the Pod ID of the host"`
|
||||
PodName string `json:"podname,omitempty" doc:"the Pod name of the host"`
|
||||
Removed string `json:"removed,omitempty" doc:"the date and time the host was removed"`
|
||||
ResourceState string `json:"resourcestate,omitempty" doc:"the resource state of the host"`
|
||||
State string `json:"state,omitempty" doc:"the state of the host"`
|
||||
StorageID *UUID `json:"storageid,omitempty" doc:"the host's storage pool id"`
|
||||
Type string `json:"type,omitempty" doc:"the host type"`
|
||||
Version string `json:"version,omitempty" doc:"the host version"`
|
||||
ZoneID *UUID `json:"zoneid,omitempty" doc:"the Zone ID of the host"`
|
||||
ZoneName string `json:"zonename,omitempty" doc:"the Zone name of the host"`
|
||||
}
|
||||
|
||||
// ListHosts lists hosts
|
||||
type ListHosts struct {
|
||||
ClusterID *UUID `json:"clusterid,omitempty" doc:"lists hosts existing in particular cluster"`
|
||||
Details []string `json:"details,omitempty" doc:"comma separated list of host details requested, value can be a list of [ min, all, capacity, events, stats]"`
|
||||
HAHost *bool `json:"hahost,omitempty" doc:"if true, list only hosts dedicated to HA"`
|
||||
Hypervisor string `json:"hypervisor,omitempty" doc:"hypervisor type of host: KVM,Simulator"`
|
||||
ID *UUID `json:"id,omitempty" doc:"the id of the host"`
|
||||
Keyword string `json:"keyword,omitempty" doc:"List by keyword"`
|
||||
Name string `json:"name,omitempty" doc:"the name of the host"`
|
||||
Page int `json:"page,omitempty"`
|
||||
PageSize int `json:"pagesize,omitempty"`
|
||||
PodID *UUID `json:"podid,omitempty" doc:"the Pod ID for the host"`
|
||||
ResourceState string `json:"resourcestate,omitempty" doc:"list hosts by resource state. Resource state represents current state determined by admin of host, value can be one of [Enabled, Disabled, Unmanaged, PrepareForMaintenance, ErrorInMaintenance, Maintenance, Error]"`
|
||||
State string `json:"state,omitempty" doc:"the state of the host"`
|
||||
Type string `json:"type,omitempty" doc:"the host type"`
|
||||
ZoneID *UUID `json:"zoneid,omitempty" doc:"the Zone ID for the host"`
|
||||
_ bool `name:"listHosts" description:"Lists hosts."`
|
||||
}
|
||||
|
||||
func (ListHosts) response() interface{} {
|
||||
return new(ListHostsResponse)
|
||||
}
|
||||
|
||||
// ListHostsResponse represents a list of hosts
|
||||
type ListHostsResponse struct {
|
||||
Count int `json:"count"`
|
||||
Host []Host `json:"host"`
|
||||
}
|
||||
|
||||
// UpdateHost changes the resources state of a host
|
||||
type UpdateHost struct {
|
||||
Allocationstate string `json:"allocationstate,omitempty" doc:"Change resource state of host, valid values are [Enable, Disable]. Operation may failed if host in states not allowing Enable/Disable"`
|
||||
HostTags []string `json:"hosttags,omitempty" doc:"list of tags to be added to the host"`
|
||||
ID *UUID `json:"id" doc:"the ID of the host to update"`
|
||||
OSCategoryID *UUID `json:"oscategoryid,omitempty" doc:"the id of Os category to update the host with"`
|
||||
URL string `json:"url,omitempty" doc:"the new uri for the secondary storage: nfs://host/path"`
|
||||
_ bool `name:"updateHost" description:"Updates a host."`
|
||||
}
|
||||
|
||||
func (UpdateHost) response() interface{} {
|
||||
return new(Host)
|
||||
}
|
71
vendor/github.com/exoscale/egoscale/instance_groups.go
generated
vendored
Normal file
71
vendor/github.com/exoscale/egoscale/instance_groups.go
generated
vendored
Normal file
@ -0,0 +1,71 @@
|
||||
package egoscale
|
||||
|
||||
// InstanceGroup represents a group of VM
|
||||
type InstanceGroup struct {
|
||||
Account string `json:"account,omitempty" doc:"the account owning the instance group"`
|
||||
Created string `json:"created,omitempty" doc:"time and date the instance group was created"`
|
||||
ID *UUID `json:"id,omitempty" doc:"the id of the instance group"`
|
||||
Name string `json:"name,omitempty" doc:"the name of the instance group"`
|
||||
}
|
||||
|
||||
// ListRequest builds the ListInstanceGroups request
|
||||
func (ig InstanceGroup) ListRequest() (ListCommand, error) {
|
||||
req := &ListInstanceGroups{
|
||||
ID: ig.ID,
|
||||
Name: ig.Name,
|
||||
}
|
||||
|
||||
return req, nil
|
||||
}
|
||||
|
||||
// CreateInstanceGroup creates a VM group
|
||||
type CreateInstanceGroup struct {
|
||||
Name string `json:"name" doc:"the name of the instance group"`
|
||||
_ bool `name:"createInstanceGroup" description:"Creates a vm group"`
|
||||
}
|
||||
|
||||
// Response returns the struct to unmarshal
|
||||
func (CreateInstanceGroup) Response() interface{} {
|
||||
return new(InstanceGroup)
|
||||
}
|
||||
|
||||
// UpdateInstanceGroup updates a VM group
|
||||
type UpdateInstanceGroup struct {
|
||||
ID *UUID `json:"id" doc:"Instance group ID"`
|
||||
Name string `json:"name,omitempty" doc:"new instance group name"`
|
||||
_ bool `name:"updateInstanceGroup" description:"Updates a vm group"`
|
||||
}
|
||||
|
||||
// Response returns the struct to unmarshal
|
||||
func (UpdateInstanceGroup) Response() interface{} {
|
||||
return new(InstanceGroup)
|
||||
}
|
||||
|
||||
// DeleteInstanceGroup deletes a VM group
|
||||
type DeleteInstanceGroup struct {
|
||||
ID *UUID `json:"id" doc:"the ID of the instance group"`
|
||||
_ bool `name:"deleteInstanceGroup" description:"Deletes a vm group"`
|
||||
}
|
||||
|
||||
// Response returns the struct to unmarshal
|
||||
func (DeleteInstanceGroup) Response() interface{} {
|
||||
return new(BooleanResponse)
|
||||
}
|
||||
|
||||
//go:generate go run generate/main.go -interface=Listable ListInstanceGroups
|
||||
|
||||
// ListInstanceGroups lists VM groups
|
||||
type ListInstanceGroups struct {
|
||||
ID *UUID `json:"id,omitempty" doc:"List instance groups by ID"`
|
||||
Keyword string `json:"keyword,omitempty" doc:"List by keyword"`
|
||||
Name string `json:"name,omitempty" doc:"List instance groups by name"`
|
||||
Page int `json:"page,omitempty"`
|
||||
PageSize int `json:"pagesize,omitempty"`
|
||||
_ bool `name:"listInstanceGroups" description:"Lists vm groups"`
|
||||
}
|
||||
|
||||
// ListInstanceGroupsResponse represents a list of instance groups
|
||||
type ListInstanceGroupsResponse struct {
|
||||
Count int `json:"count"`
|
||||
InstanceGroup []InstanceGroup `json:"instancegroup"`
|
||||
}
|
43
vendor/github.com/exoscale/egoscale/instancegroups_response.go
generated
vendored
Normal file
43
vendor/github.com/exoscale/egoscale/instancegroups_response.go
generated
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
// code generated; DO NOT EDIT.
|
||||
|
||||
package egoscale
|
||||
|
||||
import "fmt"
|
||||
|
||||
// Response returns the struct to unmarshal
|
||||
func (ListInstanceGroups) Response() interface{} {
|
||||
return new(ListInstanceGroupsResponse)
|
||||
}
|
||||
|
||||
// ListRequest returns itself
|
||||
func (ls *ListInstanceGroups) ListRequest() (ListCommand, error) {
|
||||
if ls == nil {
|
||||
return nil, fmt.Errorf("%T cannot be nil", ls)
|
||||
}
|
||||
return ls, nil
|
||||
}
|
||||
|
||||
// SetPage sets the current apge
|
||||
func (ls *ListInstanceGroups) SetPage(page int) {
|
||||
ls.Page = page
|
||||
}
|
||||
|
||||
// SetPageSize sets the page size
|
||||
func (ls *ListInstanceGroups) SetPageSize(pageSize int) {
|
||||
ls.PageSize = pageSize
|
||||
}
|
||||
|
||||
// Each triggers the callback for each, valid answer or any non 404 issue
|
||||
func (ListInstanceGroups) Each(resp interface{}, callback IterateItemFunc) {
|
||||
items, ok := resp.(*ListInstanceGroupsResponse)
|
||||
if !ok {
|
||||
callback(nil, fmt.Errorf("wrong type, ListInstanceGroupsResponse was expected, got %T", resp))
|
||||
return
|
||||
}
|
||||
|
||||
for i := range items.InstanceGroup {
|
||||
if !callback(&items.InstanceGroup[i], nil) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
94
vendor/github.com/exoscale/egoscale/isos.go
generated
vendored
Normal file
94
vendor/github.com/exoscale/egoscale/isos.go
generated
vendored
Normal file
@ -0,0 +1,94 @@
|
||||
package egoscale
|
||||
|
||||
// ISO represents an attachable ISO disc
|
||||
type ISO Template
|
||||
|
||||
// ResourceType returns the type of the resource
|
||||
func (ISO) ResourceType() string {
|
||||
return "ISO"
|
||||
}
|
||||
|
||||
// ListRequest produces the ListIsos command.
|
||||
func (iso ISO) ListRequest() (ListCommand, error) {
|
||||
req := &ListISOs{
|
||||
ID: iso.ID,
|
||||
Name: iso.Name,
|
||||
ZoneID: iso.ZoneID,
|
||||
}
|
||||
if iso.Bootable {
|
||||
*req.Bootable = true
|
||||
}
|
||||
if iso.IsFeatured {
|
||||
req.IsoFilter = "featured"
|
||||
}
|
||||
if iso.IsPublic {
|
||||
*req.IsPublic = true
|
||||
}
|
||||
if iso.IsReady {
|
||||
*req.IsReady = true
|
||||
}
|
||||
|
||||
for i := range iso.Tags {
|
||||
req.Tags = append(req.Tags, iso.Tags[i])
|
||||
}
|
||||
|
||||
return req, nil
|
||||
}
|
||||
|
||||
//go:generate go run generate/main.go -interface=Listable ListISOs
|
||||
|
||||
// ListISOs represents the list all available ISO files request
|
||||
type ListISOs struct {
|
||||
_ bool `name:"listIsos" description:"Lists all available ISO files."`
|
||||
Bootable *bool `json:"bootable,omitempty" doc:"True if the ISO is bootable, false otherwise"`
|
||||
ID *UUID `json:"id,omitempty" doc:"List ISO by id"`
|
||||
IsoFilter string `json:"isofilter,omitempty" doc:"Possible values are \"featured\", \"self\", \"selfexecutable\",\"sharedexecutable\",\"executable\", and \"community\". * featured : templates that have been marked as featured and public. * self : templates that have been registered or created by the calling user. * selfexecutable : same as self, but only returns templates that can be used to deploy a new VM. * sharedexecutable : templates ready to be deployed that have been granted to the calling user by another user. * executable : templates that are owned by the calling user, or public templates, that can be used to deploy a VM. * community : templates that have been marked as public but not featured. * all : all templates (only usable by admins)."`
|
||||
IsPublic *bool `json:"ispublic,omitempty" doc:"True if the ISO is publicly available to all users, false otherwise."`
|
||||
IsReady *bool `json:"isready,omitempty" doc:"True if this ISO is ready to be deployed"`
|
||||
Keyword string `json:"keyword,omitempty" doc:"List by keyword"`
|
||||
Name string `json:"name,omitempty" doc:"List all isos by name"`
|
||||
Page int `json:"page,omitempty"`
|
||||
PageSize int `json:"pagesize,omitempty"`
|
||||
ShowRemoved *bool `json:"showremoved,omitempty" doc:"Show removed ISOs as well"`
|
||||
Tags []ResourceTag `json:"tags,omitempty" doc:"List resources by tags (key/value pairs)"`
|
||||
ZoneID *UUID `json:"zoneid,omitempty" doc:"The ID of the zone"`
|
||||
}
|
||||
|
||||
// ListISOsResponse represents a list of ISO files
|
||||
type ListISOsResponse struct {
|
||||
Count int `json:"count"`
|
||||
ISO []ISO `json:"iso"`
|
||||
}
|
||||
|
||||
// AttachISO represents the request to attach an ISO to a virtual machine.
|
||||
type AttachISO struct {
|
||||
_ bool `name:"attachIso" description:"Attaches an ISO to a virtual machine."`
|
||||
ID *UUID `json:"id" doc:"the ID of the ISO file"`
|
||||
VirtualMachineID *UUID `json:"virtualmachineid" doc:"the ID of the virtual machine"`
|
||||
}
|
||||
|
||||
// Response returns the struct to unmarshal
|
||||
func (AttachISO) Response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
// AsyncResponse returns the struct to unmarshal the async job
|
||||
func (AttachISO) AsyncResponse() interface{} {
|
||||
return new(VirtualMachine)
|
||||
}
|
||||
|
||||
// DetachISO represents the request to detach an ISO to a virtual machine.
|
||||
type DetachISO struct {
|
||||
_ bool `name:"detachIso" description:"Detaches any ISO file (if any) currently attached to a virtual machine."`
|
||||
VirtualMachineID *UUID `json:"virtualmachineid" doc:"The ID of the virtual machine"`
|
||||
}
|
||||
|
||||
// Response returns the struct to unmarshal
|
||||
func (DetachISO) Response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
// AsyncResponse returns the struct to unmarshal the async job
|
||||
func (DetachISO) AsyncResponse() interface{} {
|
||||
return new(VirtualMachine)
|
||||
}
|
43
vendor/github.com/exoscale/egoscale/isos_response.go
generated
vendored
Normal file
43
vendor/github.com/exoscale/egoscale/isos_response.go
generated
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
// code generated; DO NOT EDIT.
|
||||
|
||||
package egoscale
|
||||
|
||||
import "fmt"
|
||||
|
||||
// Response returns the struct to unmarshal
|
||||
func (ListISOs) Response() interface{} {
|
||||
return new(ListISOsResponse)
|
||||
}
|
||||
|
||||
// ListRequest returns itself
|
||||
func (ls *ListISOs) ListRequest() (ListCommand, error) {
|
||||
if ls == nil {
|
||||
return nil, fmt.Errorf("%T cannot be nil", ls)
|
||||
}
|
||||
return ls, nil
|
||||
}
|
||||
|
||||
// SetPage sets the current apge
|
||||
func (ls *ListISOs) SetPage(page int) {
|
||||
ls.Page = page
|
||||
}
|
||||
|
||||
// SetPageSize sets the page size
|
||||
func (ls *ListISOs) SetPageSize(pageSize int) {
|
||||
ls.PageSize = pageSize
|
||||
}
|
||||
|
||||
// Each triggers the callback for each, valid answer or any non 404 issue
|
||||
func (ListISOs) Each(resp interface{}, callback IterateItemFunc) {
|
||||
items, ok := resp.(*ListISOsResponse)
|
||||
if !ok {
|
||||
callback(nil, fmt.Errorf("wrong type, ListISOsResponse was expected, got %T", resp))
|
||||
return
|
||||
}
|
||||
|
||||
for i := range items.ISO {
|
||||
if !callback(&items.ISO[i], nil) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
139
vendor/github.com/exoscale/egoscale/limits.go
generated
vendored
139
vendor/github.com/exoscale/egoscale/limits.go
generated
vendored
@ -1,139 +0,0 @@
|
||||
package egoscale
|
||||
|
||||
// https://github.com/apache/cloudstack/blob/master/api/src/main/java/com/cloud/configuration/Resource.java
|
||||
|
||||
// ResourceTypeName represents the name of a resource type (for limits)
|
||||
type ResourceTypeName string
|
||||
|
||||
const (
|
||||
// VirtualMachineTypeName is the resource type name of a VM
|
||||
VirtualMachineTypeName ResourceTypeName = "user_vm"
|
||||
// IPAddressTypeName is the resource type name of an IP address
|
||||
IPAddressTypeName ResourceTypeName = "public_ip"
|
||||
// VolumeTypeName is the resource type name of a volume
|
||||
VolumeTypeName ResourceTypeName = "volume"
|
||||
// SnapshotTypeName is the resource type name of a snapshot
|
||||
SnapshotTypeName ResourceTypeName = "snapshot"
|
||||
// TemplateTypeName is the resource type name of a template
|
||||
TemplateTypeName ResourceTypeName = "template"
|
||||
// ProjectTypeName is the resource type name of a project
|
||||
ProjectTypeName ResourceTypeName = "project"
|
||||
// NetworkTypeName is the resource type name of a network
|
||||
NetworkTypeName ResourceTypeName = "network"
|
||||
// VPCTypeName is the resource type name of a VPC
|
||||
VPCTypeName ResourceTypeName = "vpc"
|
||||
// CPUTypeName is the resource type name of a CPU
|
||||
CPUTypeName ResourceTypeName = "cpu"
|
||||
// MemoryTypeName is the resource type name of Memory
|
||||
MemoryTypeName ResourceTypeName = "memory"
|
||||
// PrimaryStorageTypeName is the resource type name of primary storage
|
||||
PrimaryStorageTypeName ResourceTypeName = "primary_storage"
|
||||
// SecondaryStorageTypeName is the resource type name of secondary storage
|
||||
SecondaryStorageTypeName ResourceTypeName = "secondary_storage"
|
||||
)
|
||||
|
||||
// ResourceType represents the ID of a resource type (for limits)
|
||||
type ResourceType string
|
||||
|
||||
const (
|
||||
// VirtualMachineType is the resource type ID of a VM
|
||||
VirtualMachineType ResourceType = "0"
|
||||
// IPAddressType is the resource type ID of an IP address
|
||||
IPAddressType ResourceType = "1"
|
||||
// VolumeType is the resource type ID of a volume
|
||||
VolumeType ResourceType = "2"
|
||||
// SnapshotType is the resource type ID of a snapshot
|
||||
SnapshotType ResourceType = "3"
|
||||
// TemplateType is the resource type ID of a template
|
||||
TemplateType ResourceType = "4"
|
||||
// ProjectType is the resource type ID of a project
|
||||
ProjectType ResourceType = "5"
|
||||
// NetworkType is the resource type ID of a network
|
||||
NetworkType ResourceType = "6"
|
||||
// VPCType is the resource type ID of a VPC
|
||||
VPCType ResourceType = "7"
|
||||
// CPUType is the resource type ID of a CPU
|
||||
CPUType ResourceType = "8"
|
||||
// MemoryType is the resource type ID of Memory
|
||||
MemoryType ResourceType = "9"
|
||||
// PrimaryStorageType is the resource type ID of primary storage
|
||||
PrimaryStorageType ResourceType = "10"
|
||||
// SecondaryStorageType is the resource type ID of secondary storage
|
||||
SecondaryStorageType ResourceType = "11"
|
||||
)
|
||||
|
||||
// ResourceLimit represents the limit on a particular resource
|
||||
type ResourceLimit struct {
|
||||
Account string `json:"account,omitempty" doc:"the account of the resource limit"`
|
||||
Domain string `json:"domain,omitempty" doc:"the domain name of the resource limit"`
|
||||
DomainID string `json:"domainid,omitempty" doc:"the domain ID of the resource limit"`
|
||||
Max int64 `json:"max,omitempty" doc:"the maximum number of the resource. A -1 means the resource currently has no limit."`
|
||||
ResourceType ResourceType `json:"resourcetype,omitempty" doc:"resource type. Values include 0, 1, 2, 3, 4, 6, 7, 8, 9, 10, 11. See the resourceType parameter for more information on these values."`
|
||||
ResourceTypeName string `json:"resourcetypename,omitempty" doc:"resource type name. Values include user_vm, public_ip, volume, snapshot, template, project, network, vpc, cpu, memory, primary_storage, secondary_storage."`
|
||||
}
|
||||
|
||||
// APILimit represents the limit count
|
||||
type APILimit struct {
|
||||
Account string `json:"account,omitempty" doc:"the account name of the api remaining count"`
|
||||
Accountid string `json:"accountid,omitempty" doc:"the account uuid of the api remaining count"`
|
||||
APIAllowed int `json:"apiAllowed,omitempty" doc:"currently allowed number of apis"`
|
||||
APIIssued int `json:"apiIssued,omitempty" doc:"number of api already issued"`
|
||||
ExpireAfter int64 `json:"expireAfter,omitempty" doc:"seconds left to reset counters"`
|
||||
}
|
||||
|
||||
// ListResourceLimits lists the resource limits
|
||||
type ListResourceLimits struct {
|
||||
Account string `json:"account,omitempty" doc:"list resources by account. Must be used with the domainId parameter."`
|
||||
DomainID string `json:"domainid,omitempty" doc:"list only resources belonging to the domain specified"`
|
||||
ID int64 `json:"id,omitempty" doc:"Lists resource limits by ID."`
|
||||
IsRecursive *bool `json:"isrecursive,omitempty" doc:"defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves."`
|
||||
Keyword string `json:"keyword,omitempty" doc:"List by keyword"`
|
||||
ListAll *bool `json:"listall,omitempty" doc:"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"`
|
||||
Page int `json:"page,omitempty"`
|
||||
PageSize int `json:"pagesize,omitempty"`
|
||||
ResourceType ResourceType `json:"resourcetype,omitempty" doc:"Type of resource. Values are 0, 1, 2, 3, 4, 6, 7, 8, 9, 10 and 11. 0 - Instance. Number of instances a user can create. 1 - IP. Number of public IP addresses an account can own. 2 - Volume. Number of disk volumes an account can own. 3 - Snapshot. Number of snapshots an account can own. 4 - Template. Number of templates an account can register/create. 5 - Project. Number of projects an account can own. 6 - Network. Number of networks an account can own. 7 - VPC. Number of VPC an account can own. 8 - CPU. Number of CPU an account can allocate for his resources. 9 - Memory. Amount of RAM an account can allocate for his resources. 10 - PrimaryStorage. Total primary storage space (in GiB) a user can use. 11 - SecondaryStorage. Total secondary storage space (in GiB) a user can use. 12 - Elastic IP. Number of public elastic IP addresses an account can own. 13 - SMTP. If the account is allowed SMTP outbound traffic."`
|
||||
ResourceTypeName string `json:"resourcetypename,omitempty" doc:"Type of resource (wins over resourceType if both are provided). Values are: user_vm - Instance. Number of instances a user can create. public_ip - IP. Number of public IP addresses an account can own. volume - Volume. Number of disk volumes an account can own. snapshot - Snapshot. Number of snapshots an account can own. template - Template. Number of templates an account can register/create. project - Project. Number of projects an account can own. network - Network. Number of networks an account can own. vpc - VPC. Number of VPC an account can own. cpu - CPU. Number of CPU an account can allocate for his resources. memory - Memory. Amount of RAM an account can allocate for his resources. primary_storage - PrimaryStorage. Total primary storage space (in GiB) a user can use. secondary_storage - SecondaryStorage. Total secondary storage space (in GiB) a user can use. public_elastic_ip - IP. Number of public elastic IP addresses an account can own. smtp - SG. If the account is allowed SMTP outbound traffic."`
|
||||
_ bool `name:"listResourceLimits" description:"Lists resource limits."`
|
||||
}
|
||||
|
||||
// ListResourceLimitsResponse represents a list of resource limits
|
||||
type ListResourceLimitsResponse struct {
|
||||
Count int `json:"count"`
|
||||
ResourceLimit []ResourceLimit `json:"resourcelimit"`
|
||||
}
|
||||
|
||||
func (ListResourceLimits) response() interface{} {
|
||||
return new(ListResourceLimitsResponse)
|
||||
}
|
||||
|
||||
// UpdateResourceLimit updates the resource limit
|
||||
type UpdateResourceLimit struct {
|
||||
Account string `json:"account,omitempty" doc:"Update resource for a specified account. Must be used with the domainId parameter."`
|
||||
DomainID string `json:"domainid,omitempty" doc:"Update resource limits for all accounts in specified domain. If used with the account parameter, updates resource limits for a specified account in specified domain."`
|
||||
Max int64 `json:"max,omitempty" doc:"Maximum resource limit."`
|
||||
ResourceType ResourceType `json:"resourcetype" doc:"Type of resource to update. Values are 0, 1, 2, 3, 4, 6, 7, 8, 9, 10 and 11. 0 - Instance. Number of instances a user can create. 1 - IP. Number of public IP addresses a user can own. 2 - Volume. Number of disk volumes a user can create. 3 - Snapshot. Number of snapshots a user can create. 4 - Template. Number of templates that a user can register/create. 6 - Network. Number of guest network a user can create. 7 - VPC. Number of VPC a user can create. 8 - CPU. Total number of CPU cores a user can use. 9 - Memory. Total Memory (in MB) a user can use. 10 - PrimaryStorage. Total primary storage space (in GiB) a user can use. 11 - SecondaryStorage. Total secondary storage space (in GiB) a user can use."`
|
||||
_ bool `name:"updateResourceLimit" description:"Updates resource limits for an account or domain."`
|
||||
}
|
||||
|
||||
// UpdateResourceLimitResponse represents an updated resource limit
|
||||
type UpdateResourceLimitResponse struct {
|
||||
ResourceLimit ResourceLimit `json:"resourcelimit"`
|
||||
}
|
||||
|
||||
func (UpdateResourceLimit) response() interface{} {
|
||||
return new(UpdateResourceLimitResponse)
|
||||
}
|
||||
|
||||
// GetAPILimit gets API limit count for the caller
|
||||
type GetAPILimit struct {
|
||||
_ bool `name:"getApiLimit" description:"Get API limit count for the caller"`
|
||||
}
|
||||
|
||||
// GetAPILimitResponse represents the limits towards the API call
|
||||
type GetAPILimitResponse struct {
|
||||
APILimit APILimit `json:"apilimit"`
|
||||
}
|
||||
|
||||
func (GetAPILimit) response() interface{} {
|
||||
return new(GetAPILimitResponse)
|
||||
}
|
24
vendor/github.com/exoscale/egoscale/network_offerings.go
generated
vendored
24
vendor/github.com/exoscale/egoscale/network_offerings.go
generated
vendored
@ -25,6 +25,23 @@ type NetworkOffering struct {
|
||||
TrafficType string `json:"traffictype,omitempty" doc:"the traffic type for the network offering, supported types are Public, Management, Control, Guest, Vlan or Storage."`
|
||||
}
|
||||
|
||||
// ListRequest builds the ListNetworkOfferings request
|
||||
//
|
||||
// This doesn't take into account the IsDefault flag as the default value is true.
|
||||
func (no NetworkOffering) ListRequest() (ListCommand, error) {
|
||||
req := &ListNetworkOfferings{
|
||||
Availability: no.Availability,
|
||||
ID: no.ID,
|
||||
Name: no.Name,
|
||||
State: no.State,
|
||||
TrafficType: no.TrafficType,
|
||||
}
|
||||
|
||||
return req, nil
|
||||
}
|
||||
|
||||
//go:generate go run generate/main.go -interface=Listable ListNetworkOfferings
|
||||
|
||||
// ListNetworkOfferings represents a query for network offerings
|
||||
type ListNetworkOfferings struct {
|
||||
Availability string `json:"availability,omitempty" doc:"the availability of network offering. Default value is Required"`
|
||||
@ -55,10 +72,6 @@ type ListNetworkOfferingsResponse struct {
|
||||
NetworkOffering []NetworkOffering `json:"networkoffering"`
|
||||
}
|
||||
|
||||
func (ListNetworkOfferings) response() interface{} {
|
||||
return new(ListNetworkOfferingsResponse)
|
||||
}
|
||||
|
||||
// UpdateNetworkOffering represents a modification of a network offering
|
||||
type UpdateNetworkOffering struct {
|
||||
Availability string `json:"availability,omitempty" doc:"the availability of network offering. Default value is Required for Guest Virtual network offering; Optional for Guest Direct network offering"`
|
||||
@ -72,6 +85,7 @@ type UpdateNetworkOffering struct {
|
||||
_ bool `name:"updateNetworkOffering" description:"Updates a network offering."`
|
||||
}
|
||||
|
||||
func (UpdateNetworkOffering) response() interface{} {
|
||||
// Response returns the struct to unmarshal
|
||||
func (UpdateNetworkOffering) Response() interface{} {
|
||||
return new(NetworkOffering)
|
||||
}
|
||||
|
43
vendor/github.com/exoscale/egoscale/networkofferings_response.go
generated
vendored
Normal file
43
vendor/github.com/exoscale/egoscale/networkofferings_response.go
generated
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
// code generated; DO NOT EDIT.
|
||||
|
||||
package egoscale
|
||||
|
||||
import "fmt"
|
||||
|
||||
// Response returns the struct to unmarshal
|
||||
func (ListNetworkOfferings) Response() interface{} {
|
||||
return new(ListNetworkOfferingsResponse)
|
||||
}
|
||||
|
||||
// ListRequest returns itself
|
||||
func (ls *ListNetworkOfferings) ListRequest() (ListCommand, error) {
|
||||
if ls == nil {
|
||||
return nil, fmt.Errorf("%T cannot be nil", ls)
|
||||
}
|
||||
return ls, nil
|
||||
}
|
||||
|
||||
// SetPage sets the current apge
|
||||
func (ls *ListNetworkOfferings) SetPage(page int) {
|
||||
ls.Page = page
|
||||
}
|
||||
|
||||
// SetPageSize sets the page size
|
||||
func (ls *ListNetworkOfferings) SetPageSize(pageSize int) {
|
||||
ls.PageSize = pageSize
|
||||
}
|
||||
|
||||
// Each triggers the callback for each, valid answer or any non 404 issue
|
||||
func (ListNetworkOfferings) Each(resp interface{}, callback IterateItemFunc) {
|
||||
items, ok := resp.(*ListNetworkOfferingsResponse)
|
||||
if !ok {
|
||||
callback(nil, fmt.Errorf("wrong type, ListNetworkOfferingsResponse was expected, got %T", resp))
|
||||
return
|
||||
}
|
||||
|
||||
for i := range items.NetworkOffering {
|
||||
if !callback(&items.NetworkOffering[i], nil) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
106
vendor/github.com/exoscale/egoscale/networks.go
generated
vendored
106
vendor/github.com/exoscale/egoscale/networks.go
generated
vendored
@ -1,7 +1,6 @@
|
||||
package egoscale
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"net/url"
|
||||
)
|
||||
@ -16,12 +15,10 @@ type Network struct {
|
||||
BroadcastURI string `json:"broadcasturi,omitempty" doc:"broadcast uri of the network."`
|
||||
CanUseForDeploy bool `json:"canusefordeploy,omitempty" doc:"list networks available for vm deployment"`
|
||||
CIDR *CIDR `json:"cidr,omitempty" doc:"Cloudstack managed address space, all CloudStack managed VMs get IP address from CIDR"`
|
||||
DisplayNetwork bool `json:"displaynetwork,omitempty" doc:"an optional field, whether to the display the network to the end user or not."`
|
||||
DisplayText string `json:"displaytext,omitempty" doc:"the displaytext of the network"`
|
||||
DNS1 net.IP `json:"dns1,omitempty" doc:"the first DNS for the network"`
|
||||
DNS2 net.IP `json:"dns2,omitempty" doc:"the second DNS for the network"`
|
||||
Domain string `json:"domain,omitempty" doc:"the domain name of the network owner"`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"the domain id of the network owner"`
|
||||
EndIP net.IP `json:"endip,omitempty" doc:"the ending IP address in the network IP range. Required for managed networks."`
|
||||
Gateway net.IP `json:"gateway,omitempty" doc:"the network's gateway"`
|
||||
ID *UUID `json:"id,omitempty" doc:"the id of the network"`
|
||||
IP6CIDR *CIDR `json:"ip6cidr,omitempty" doc:"the cidr of IPv6 network"`
|
||||
@ -44,6 +41,7 @@ type Network struct {
|
||||
RestartRequired bool `json:"restartrequired,omitempty" doc:"true network requires restart"`
|
||||
Service []Service `json:"service,omitempty" doc:"the list of services"`
|
||||
SpecifyIPRanges bool `json:"specifyipranges,omitempty" doc:"true if network supports specifying ip ranges, false otherwise"`
|
||||
StartIP net.IP `json:"startip,omitempty" doc:"the beginning IP address in the network IP range. Required for managed networks."`
|
||||
State string `json:"state,omitempty" doc:"state of the network"`
|
||||
StrechedL2Subnet bool `json:"strechedl2subnet,omitempty" doc:"true if network can span multiple zones"`
|
||||
SubdomainAccess bool `json:"subdomainaccess,omitempty" doc:"true if users from subdomains can access the domain level network"`
|
||||
@ -60,9 +58,8 @@ type Network struct {
|
||||
func (network Network) ListRequest() (ListCommand, error) {
|
||||
//TODO add tags support
|
||||
req := &ListNetworks{
|
||||
Account: network.Account,
|
||||
DomainID: network.DomainID,
|
||||
ID: network.ID,
|
||||
Keyword: network.Name, // this is a hack as listNetworks doesn't support to search by name.
|
||||
PhysicalNetworkID: network.PhysicalNetworkID,
|
||||
TrafficType: network.TrafficType,
|
||||
Type: network.Type,
|
||||
@ -110,30 +107,27 @@ type ServiceProvider struct {
|
||||
|
||||
// CreateNetwork creates a network
|
||||
type CreateNetwork struct {
|
||||
Account string `json:"account,omitempty" doc:"account who will own the network"`
|
||||
DisplayNetwork *bool `json:"displaynetwork,omitempty" doc:"an optional field, whether to the display the network to the end user or not."`
|
||||
DisplayText string `json:"displaytext,omitempty" doc:"the display text of the network"` // This field is required but might be empty
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"domain ID of the account owning a network"`
|
||||
EndIP net.IP `json:"endip,omitempty" doc:"the ending IP address in the network IP range. If not specified, will be defaulted to startIP"`
|
||||
EndIP net.IP `json:"endip,omitempty" doc:"the ending IP address in the network IP range. Required for managed networks."`
|
||||
EndIpv6 net.IP `json:"endipv6,omitempty" doc:"the ending IPv6 address in the IPv6 network range"`
|
||||
Gateway net.IP `json:"gateway,omitempty" doc:"the gateway of the network. Required for Shared networks and Isolated networks when it belongs to VPC"`
|
||||
IP6CIDR *CIDR `json:"ip6cidr,omitempty" doc:"the CIDR of IPv6 network, must be at least /64"`
|
||||
IP6Gateway net.IP `json:"ip6gateway,omitempty" doc:"the gateway of the IPv6 network. Required for Shared networks and Isolated networks when it belongs to VPC"`
|
||||
IsolatedPVlan string `json:"isolatedpvlan,omitempty" doc:"the isolated private vlan for this network"`
|
||||
Name string `json:"name,omitempty" doc:"the name of the network"` // This field is required but might be empty
|
||||
Netmask net.IP `json:"netmask,omitempty" doc:"the netmask of the network. Required for Shared networks and Isolated networks when it belongs to VPC"`
|
||||
Netmask net.IP `json:"netmask,omitempty" doc:"the netmask of the network. Required for managed networks."`
|
||||
NetworkDomain string `json:"networkdomain,omitempty" doc:"network domain"`
|
||||
NetworkOfferingID *UUID `json:"networkofferingid" doc:"the network offering id"`
|
||||
PhysicalNetworkID *UUID `json:"physicalnetworkid,omitempty" doc:"the Physical Network ID the network belongs to"`
|
||||
StartIP net.IP `json:"startip,omitempty" doc:"the beginning IP address in the network IP range"`
|
||||
StartIP net.IP `json:"startip,omitempty" doc:"the beginning IP address in the network IP range. Required for managed networks."`
|
||||
StartIpv6 net.IP `json:"startipv6,omitempty" doc:"the beginning IPv6 address in the IPv6 network range"`
|
||||
SubdomainAccess *bool `json:"subdomainaccess,omitempty" doc:"Defines whether to allow subdomains to use networks dedicated to their parent domain(s). Should be used with aclType=Domain, defaulted to allow.subdomain.network.access global config if not specified"`
|
||||
Vlan string `json:"vlan,omitempty" doc:"the ID or VID of the network"`
|
||||
ZoneID *UUID `json:"zoneid" doc:"the Zone ID for the network"`
|
||||
_ bool `name:"createNetwork" description:"Creates a network"`
|
||||
}
|
||||
|
||||
func (CreateNetwork) response() interface{} {
|
||||
// Response returns the struct to unmarshal
|
||||
func (CreateNetwork) Response() interface{} {
|
||||
return new(Network)
|
||||
}
|
||||
|
||||
@ -150,23 +144,26 @@ func (req CreateNetwork) onBeforeSend(params url.Values) error {
|
||||
|
||||
// UpdateNetwork (Async) updates a network
|
||||
type UpdateNetwork struct {
|
||||
ID *UUID `json:"id" doc:"the ID of the network"`
|
||||
_ bool `name:"updateNetwork" description:"Updates a network"`
|
||||
ChangeCIDR *bool `json:"changecidr,omitempty" doc:"Force update even if cidr type is different"`
|
||||
CustomID *UUID `json:"customid,omitempty" doc:"an optional field, in case you want to set a custom id to the resource. Allowed to Root Admins only"`
|
||||
DisplayNetwork *bool `json:"displaynetwork,omitempty" doc:"an optional field, whether to the display the network to the end user or not."`
|
||||
DisplayText string `json:"displaytext,omitempty" doc:"the new display text for the network"`
|
||||
EndIP net.IP `json:"endip,omitempty" doc:"the ending IP address in the network IP range. Required for managed networks."`
|
||||
GuestVMCIDR *CIDR `json:"guestvmcidr,omitempty" doc:"CIDR for Guest VMs,Cloudstack allocates IPs to Guest VMs only from this CIDR"`
|
||||
ID *UUID `json:"id" doc:"the ID of the network"`
|
||||
Name string `json:"name,omitempty" doc:"the new name for the network"`
|
||||
Netmask net.IP `json:"netmask,omitempty" doc:"the netmask of the network. Required for managed networks."`
|
||||
NetworkDomain string `json:"networkdomain,omitempty" doc:"network domain"`
|
||||
NetworkOfferingID *UUID `json:"networkofferingid,omitempty" doc:"network offering ID"`
|
||||
_ bool `name:"updateNetwork" description:"Updates a network"`
|
||||
StartIP net.IP `json:"startip,omitempty" doc:"the beginning IP address in the network IP range. Required for managed networks."`
|
||||
}
|
||||
|
||||
func (UpdateNetwork) response() interface{} {
|
||||
// Response returns the struct to unmarshal
|
||||
func (UpdateNetwork) Response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (UpdateNetwork) asyncResponse() interface{} {
|
||||
// AsyncResponse returns the struct to unmarshal the async job
|
||||
func (UpdateNetwork) AsyncResponse() interface{} {
|
||||
return new(Network)
|
||||
}
|
||||
|
||||
@ -177,11 +174,13 @@ type RestartNetwork struct {
|
||||
_ bool `name:"restartNetwork" description:"Restarts the network; includes 1) restarting network elements - virtual routers, dhcp servers 2) reapplying all public ips 3) reapplying loadBalancing/portForwarding rules"`
|
||||
}
|
||||
|
||||
func (RestartNetwork) response() interface{} {
|
||||
// Response returns the struct to unmarshal
|
||||
func (RestartNetwork) Response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (RestartNetwork) asyncResponse() interface{} {
|
||||
// AsyncResponse returns the struct to unmarshal the async job
|
||||
func (RestartNetwork) AsyncResponse() interface{} {
|
||||
return new(Network)
|
||||
}
|
||||
|
||||
@ -192,35 +191,34 @@ type DeleteNetwork struct {
|
||||
_ bool `name:"deleteNetwork" description:"Deletes a network"`
|
||||
}
|
||||
|
||||
func (DeleteNetwork) response() interface{} {
|
||||
// Response returns the struct to unmarshal
|
||||
func (DeleteNetwork) Response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (DeleteNetwork) asyncResponse() interface{} {
|
||||
return new(booleanResponse)
|
||||
// AsyncResponse returns the struct to unmarshal the async job
|
||||
func (DeleteNetwork) AsyncResponse() interface{} {
|
||||
return new(BooleanResponse)
|
||||
}
|
||||
|
||||
//go:generate go run generate/main.go -interface=Listable ListNetworks
|
||||
|
||||
// ListNetworks represents a query to a network
|
||||
type ListNetworks struct {
|
||||
Account string `json:"account,omitempty" doc:"list resources by account. Must be used with the domainId parameter."`
|
||||
CanUseForDeploy *bool `json:"canusefordeploy,omitempty" doc:"list networks available for vm deployment"`
|
||||
DisplayNetwork *bool `json:"displaynetwork,omitempty" doc:"list resources by display flag; only ROOT admin is eligible to pass this parameter"`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"list only resources belonging to the domain specified"`
|
||||
ID *UUID `json:"id,omitempty" doc:"list networks by id"`
|
||||
IsRecursive *bool `json:"isrecursive,omitempty" doc:"defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves."`
|
||||
IsSystem *bool `json:"issystem,omitempty" doc:"true if network is system, false otherwise"`
|
||||
CanUseForDeploy *bool `json:"canusefordeploy,omitempty" doc:"List networks available for vm deployment"`
|
||||
ID *UUID `json:"id,omitempty" doc:"List networks by id"`
|
||||
IsSystem *bool `json:"issystem,omitempty" doc:"true If network is system, false otherwise"`
|
||||
Keyword string `json:"keyword,omitempty" doc:"List by keyword"`
|
||||
ListAll *bool `json:"listall,omitempty" doc:"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"`
|
||||
Page int `json:"page,omitempty"`
|
||||
PageSize int `json:"pagesize,omitempty"`
|
||||
PhysicalNetworkID *UUID `json:"physicalnetworkid,omitempty" doc:"list networks by physical network id"`
|
||||
RestartRequired *bool `json:"restartrequired,omitempty" doc:"list networks by restartRequired"`
|
||||
SpecifyIPRanges *bool `json:"specifyipranges,omitempty" doc:"true if need to list only networks which support specifying ip ranges"`
|
||||
SupportedServices []Service `json:"supportedservices,omitempty" doc:"list networks supporting certain services"`
|
||||
PhysicalNetworkID *UUID `json:"physicalnetworkid,omitempty" doc:"List networks by physical network id"`
|
||||
RestartRequired *bool `json:"restartrequired,omitempty" doc:"List networks by restartRequired"`
|
||||
SpecifyIPRanges *bool `json:"specifyipranges,omitempty" doc:"True if need to list only networks which support specifying ip ranges"`
|
||||
SupportedServices []Service `json:"supportedservices,omitempty" doc:"List networks supporting certain services"`
|
||||
Tags []ResourceTag `json:"tags,omitempty" doc:"List resources by tags (key/value pairs)"`
|
||||
TrafficType string `json:"traffictype,omitempty" doc:"type of the traffic"`
|
||||
Type string `json:"type,omitempty" doc:"the type of the network. Supported values are: Isolated and Shared"`
|
||||
ZoneID *UUID `json:"zoneid,omitempty" doc:"the Zone ID of the network"`
|
||||
TrafficType string `json:"traffictype,omitempty" doc:"Type of the traffic"`
|
||||
Type string `json:"type,omitempty" doc:"The type of the network. Supported values are: Isolated and Shared"`
|
||||
ZoneID *UUID `json:"zoneid,omitempty" doc:"The Zone ID of the network"`
|
||||
_ bool `name:"listNetworks" description:"Lists all available networks."`
|
||||
}
|
||||
|
||||
@ -229,31 +227,3 @@ type ListNetworksResponse struct {
|
||||
Count int `json:"count"`
|
||||
Network []Network `json:"network"`
|
||||
}
|
||||
|
||||
func (ListNetworks) response() interface{} {
|
||||
return new(ListNetworksResponse)
|
||||
}
|
||||
|
||||
// SetPage sets the current page
|
||||
func (listNetwork *ListNetworks) SetPage(page int) {
|
||||
listNetwork.Page = page
|
||||
}
|
||||
|
||||
// SetPageSize sets the page size
|
||||
func (listNetwork *ListNetworks) SetPageSize(pageSize int) {
|
||||
listNetwork.PageSize = pageSize
|
||||
}
|
||||
|
||||
func (ListNetworks) each(resp interface{}, callback IterateItemFunc) {
|
||||
networks, ok := resp.(*ListNetworksResponse)
|
||||
if !ok {
|
||||
callback(nil, fmt.Errorf("type error: ListNetworksResponse expected, got %T", resp))
|
||||
return
|
||||
}
|
||||
|
||||
for i := range networks.Network {
|
||||
if !callback(&networks.Network[i], nil) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
43
vendor/github.com/exoscale/egoscale/networks_response.go
generated
vendored
Normal file
43
vendor/github.com/exoscale/egoscale/networks_response.go
generated
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
// code generated; DO NOT EDIT.
|
||||
|
||||
package egoscale
|
||||
|
||||
import "fmt"
|
||||
|
||||
// Response returns the struct to unmarshal
|
||||
func (ListNetworks) Response() interface{} {
|
||||
return new(ListNetworksResponse)
|
||||
}
|
||||
|
||||
// ListRequest returns itself
|
||||
func (ls *ListNetworks) ListRequest() (ListCommand, error) {
|
||||
if ls == nil {
|
||||
return nil, fmt.Errorf("%T cannot be nil", ls)
|
||||
}
|
||||
return ls, nil
|
||||
}
|
||||
|
||||
// SetPage sets the current apge
|
||||
func (ls *ListNetworks) SetPage(page int) {
|
||||
ls.Page = page
|
||||
}
|
||||
|
||||
// SetPageSize sets the page size
|
||||
func (ls *ListNetworks) SetPageSize(pageSize int) {
|
||||
ls.PageSize = pageSize
|
||||
}
|
||||
|
||||
// Each triggers the callback for each, valid answer or any non 404 issue
|
||||
func (ListNetworks) Each(resp interface{}, callback IterateItemFunc) {
|
||||
items, ok := resp.(*ListNetworksResponse)
|
||||
if !ok {
|
||||
callback(nil, fmt.Errorf("wrong type, ListNetworksResponse was expected, got %T", resp))
|
||||
return
|
||||
}
|
||||
|
||||
for i := range items.Network {
|
||||
if !callback(&items.Network[i], nil) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
53
vendor/github.com/exoscale/egoscale/nics.go
generated
vendored
53
vendor/github.com/exoscale/egoscale/nics.go
generated
vendored
@ -1,7 +1,6 @@
|
||||
package egoscale
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net"
|
||||
)
|
||||
|
||||
@ -32,10 +31,6 @@ type Nic struct {
|
||||
|
||||
// ListRequest build a ListNics request from the given Nic
|
||||
func (nic Nic) ListRequest() (ListCommand, error) {
|
||||
if nic.VirtualMachineID == nil {
|
||||
return nil, errors.New("command ListNics requires the VirtualMachineID field to be set")
|
||||
}
|
||||
|
||||
req := &ListNics{
|
||||
VirtualMachineID: nic.VirtualMachineID,
|
||||
NicID: nic.ID,
|
||||
@ -54,15 +49,16 @@ type NicSecondaryIP struct {
|
||||
VirtualMachineID *UUID `json:"virtualmachineid,omitempty" doc:"the ID of the vm"`
|
||||
}
|
||||
|
||||
//go:generate go run generate/main.go -interface=Listable ListNics
|
||||
|
||||
// ListNics represents the NIC search
|
||||
type ListNics struct {
|
||||
ForDisplay bool `json:"fordisplay,omitempty" doc:"list resources by display flag; only ROOT admin is eligible to pass this parameter"`
|
||||
Keyword string `json:"keyword,omitempty" doc:"List by keyword"`
|
||||
NetworkID *UUID `json:"networkid,omitempty" doc:"list nic of the specific vm's network"`
|
||||
NicID *UUID `json:"nicid,omitempty" doc:"the ID of the nic to to list IPs"`
|
||||
Page int `json:"page,omitempty"`
|
||||
PageSize int `json:"pagesize,omitempty"`
|
||||
VirtualMachineID *UUID `json:"virtualmachineid" doc:"the ID of the vm"`
|
||||
VirtualMachineID *UUID `json:"virtualmachineid,omitempty" doc:"the ID of the vm"`
|
||||
_ bool `name:"listNics" description:"list the vm nics IP to NIC"`
|
||||
}
|
||||
|
||||
@ -72,29 +68,6 @@ type ListNicsResponse struct {
|
||||
Nic []Nic `json:"nic"`
|
||||
}
|
||||
|
||||
func (ListNics) response() interface{} {
|
||||
return new(ListNicsResponse)
|
||||
}
|
||||
|
||||
// SetPage sets the current page
|
||||
func (ls *ListNics) SetPage(page int) {
|
||||
ls.Page = page
|
||||
}
|
||||
|
||||
// SetPageSize sets the page size
|
||||
func (ls *ListNics) SetPageSize(pageSize int) {
|
||||
ls.PageSize = pageSize
|
||||
}
|
||||
|
||||
func (ListNics) each(resp interface{}, callback IterateItemFunc) {
|
||||
nics := resp.(*ListNicsResponse)
|
||||
for i := range nics.Nic {
|
||||
if !callback(&(nics.Nic[i]), nil) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// AddIPToNic (Async) represents the assignation of a secondary IP
|
||||
type AddIPToNic struct {
|
||||
NicID *UUID `json:"nicid" doc:"the ID of the nic to which you want to assign private IP"`
|
||||
@ -102,11 +75,13 @@ type AddIPToNic struct {
|
||||
_ bool `name:"addIpToNic" description:"Assigns secondary IP to NIC"`
|
||||
}
|
||||
|
||||
func (AddIPToNic) response() interface{} {
|
||||
// Response returns the struct to unmarshal
|
||||
func (AddIPToNic) Response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (AddIPToNic) asyncResponse() interface{} {
|
||||
// AsyncResponse returns the struct to unmarshal the async job
|
||||
func (AddIPToNic) AsyncResponse() interface{} {
|
||||
return new(NicSecondaryIP)
|
||||
}
|
||||
|
||||
@ -116,12 +91,14 @@ type RemoveIPFromNic struct {
|
||||
_ bool `name:"removeIpFromNic" description:"Removes secondary IP from the NIC."`
|
||||
}
|
||||
|
||||
func (RemoveIPFromNic) response() interface{} {
|
||||
// Response returns the struct to unmarshal
|
||||
func (RemoveIPFromNic) Response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (RemoveIPFromNic) asyncResponse() interface{} {
|
||||
return new(booleanResponse)
|
||||
// AsyncResponse returns the struct to unmarshal the async job
|
||||
func (RemoveIPFromNic) AsyncResponse() interface{} {
|
||||
return new(BooleanResponse)
|
||||
}
|
||||
|
||||
// ActivateIP6 (Async) activates the IP6 on the given NIC
|
||||
@ -132,10 +109,12 @@ type ActivateIP6 struct {
|
||||
_ bool `name:"activateIp6" description:"Activate the IPv6 on the VM's nic"`
|
||||
}
|
||||
|
||||
func (ActivateIP6) response() interface{} {
|
||||
// Response returns the struct to unmarshal
|
||||
func (ActivateIP6) Response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (ActivateIP6) asyncResponse() interface{} {
|
||||
// AsyncResponse returns the struct to unmarshal the async job
|
||||
func (ActivateIP6) AsyncResponse() interface{} {
|
||||
return new(Nic)
|
||||
}
|
||||
|
43
vendor/github.com/exoscale/egoscale/nics_response.go
generated
vendored
Normal file
43
vendor/github.com/exoscale/egoscale/nics_response.go
generated
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
// code generated; DO NOT EDIT.
|
||||
|
||||
package egoscale
|
||||
|
||||
import "fmt"
|
||||
|
||||
// Response returns the struct to unmarshal
|
||||
func (ListNics) Response() interface{} {
|
||||
return new(ListNicsResponse)
|
||||
}
|
||||
|
||||
// ListRequest returns itself
|
||||
func (ls *ListNics) ListRequest() (ListCommand, error) {
|
||||
if ls == nil {
|
||||
return nil, fmt.Errorf("%T cannot be nil", ls)
|
||||
}
|
||||
return ls, nil
|
||||
}
|
||||
|
||||
// SetPage sets the current apge
|
||||
func (ls *ListNics) SetPage(page int) {
|
||||
ls.Page = page
|
||||
}
|
||||
|
||||
// SetPageSize sets the page size
|
||||
func (ls *ListNics) SetPageSize(pageSize int) {
|
||||
ls.PageSize = pageSize
|
||||
}
|
||||
|
||||
// Each triggers the callback for each, valid answer or any non 404 issue
|
||||
func (ListNics) Each(resp interface{}, callback IterateItemFunc) {
|
||||
items, ok := resp.(*ListNicsResponse)
|
||||
if !ok {
|
||||
callback(nil, fmt.Errorf("wrong type, ListNicsResponse was expected, got %T", resp))
|
||||
return
|
||||
}
|
||||
|
||||
for i := range items.Nic {
|
||||
if !callback(&items.Nic[i], nil) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
43
vendor/github.com/exoscale/egoscale/oscategories_response.go
generated
vendored
Normal file
43
vendor/github.com/exoscale/egoscale/oscategories_response.go
generated
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
// code generated; DO NOT EDIT.
|
||||
|
||||
package egoscale
|
||||
|
||||
import "fmt"
|
||||
|
||||
// Response returns the struct to unmarshal
|
||||
func (ListOSCategories) Response() interface{} {
|
||||
return new(ListOSCategoriesResponse)
|
||||
}
|
||||
|
||||
// ListRequest returns itself
|
||||
func (ls *ListOSCategories) ListRequest() (ListCommand, error) {
|
||||
if ls == nil {
|
||||
return nil, fmt.Errorf("%T cannot be nil", ls)
|
||||
}
|
||||
return ls, nil
|
||||
}
|
||||
|
||||
// SetPage sets the current apge
|
||||
func (ls *ListOSCategories) SetPage(page int) {
|
||||
ls.Page = page
|
||||
}
|
||||
|
||||
// SetPageSize sets the page size
|
||||
func (ls *ListOSCategories) SetPageSize(pageSize int) {
|
||||
ls.PageSize = pageSize
|
||||
}
|
||||
|
||||
// Each triggers the callback for each, valid answer or any non 404 issue
|
||||
func (ListOSCategories) Each(resp interface{}, callback IterateItemFunc) {
|
||||
items, ok := resp.(*ListOSCategoriesResponse)
|
||||
if !ok {
|
||||
callback(nil, fmt.Errorf("wrong type, ListOSCategoriesResponse was expected, got %T", resp))
|
||||
return
|
||||
}
|
||||
|
||||
for i := range items.OSCategory {
|
||||
if !callback(&items.OSCategory[i], nil) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
43
vendor/github.com/exoscale/egoscale/publicipaddresses_response.go
generated
vendored
Normal file
43
vendor/github.com/exoscale/egoscale/publicipaddresses_response.go
generated
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
// code generated; DO NOT EDIT.
|
||||
|
||||
package egoscale
|
||||
|
||||
import "fmt"
|
||||
|
||||
// Response returns the struct to unmarshal
|
||||
func (ListPublicIPAddresses) Response() interface{} {
|
||||
return new(ListPublicIPAddressesResponse)
|
||||
}
|
||||
|
||||
// ListRequest returns itself
|
||||
func (ls *ListPublicIPAddresses) ListRequest() (ListCommand, error) {
|
||||
if ls == nil {
|
||||
return nil, fmt.Errorf("%T cannot be nil", ls)
|
||||
}
|
||||
return ls, nil
|
||||
}
|
||||
|
||||
// SetPage sets the current apge
|
||||
func (ls *ListPublicIPAddresses) SetPage(page int) {
|
||||
ls.Page = page
|
||||
}
|
||||
|
||||
// SetPageSize sets the page size
|
||||
func (ls *ListPublicIPAddresses) SetPageSize(pageSize int) {
|
||||
ls.PageSize = pageSize
|
||||
}
|
||||
|
||||
// Each triggers the callback for each, valid answer or any non 404 issue
|
||||
func (ListPublicIPAddresses) Each(resp interface{}, callback IterateItemFunc) {
|
||||
items, ok := resp.(*ListPublicIPAddressesResponse)
|
||||
if !ok {
|
||||
callback(nil, fmt.Errorf("wrong type, ListPublicIPAddressesResponse was expected, got %T", resp))
|
||||
return
|
||||
}
|
||||
|
||||
for i := range items.PublicIPAddress {
|
||||
if !callback(&items.PublicIPAddress[i], nil) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
48
vendor/github.com/exoscale/egoscale/request.go
generated
vendored
48
vendor/github.com/exoscale/egoscale/request.go
generated
vendored
@ -24,7 +24,7 @@ func (e ErrorResponse) Error() string {
|
||||
}
|
||||
|
||||
// Error formats a CloudStack job response into a standard error
|
||||
func (e booleanResponse) Error() error {
|
||||
func (e BooleanResponse) Error() error {
|
||||
if !e.Success {
|
||||
return fmt.Errorf("API error: %s", e.DisplayText)
|
||||
}
|
||||
@ -32,11 +32,17 @@ func (e booleanResponse) Error() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// XXX: addIpToNic, activateIp6, restorevmresponse are kind of special
|
||||
var responseKeys = map[string]string{
|
||||
"addiptonicresponse": "addiptovmnicresponse",
|
||||
"activateip6response": "activateip6nicresponse",
|
||||
"restorevirtualmachineresponse": "restorevmresponse",
|
||||
func responseKey(key string) (string, bool) {
|
||||
// XXX: addIpToNic, activateIp6, restorevmresponse are kind of special
|
||||
var responseKeys = map[string]string{
|
||||
"addiptonicresponse": "addiptovmnicresponse",
|
||||
"activateip6response": "activateip6nicresponse",
|
||||
"restorevirtualmachineresponse": "restorevmresponse",
|
||||
"updatevmaffinitygroupresponse": "updatevirtualmachineresponse",
|
||||
}
|
||||
|
||||
k, ok := responseKeys[key]
|
||||
return k, ok
|
||||
}
|
||||
|
||||
func (client *Client) parseResponse(resp *http.Response, apiName string) (json.RawMessage, error) {
|
||||
@ -59,7 +65,7 @@ func (client *Client) parseResponse(resp *http.Response, apiName string) (json.R
|
||||
|
||||
if !ok {
|
||||
// try again with the special keys
|
||||
value, ok := responseKeys[key]
|
||||
value, ok := responseKey(key)
|
||||
if ok {
|
||||
key = value
|
||||
}
|
||||
@ -67,9 +73,7 @@ func (client *Client) parseResponse(resp *http.Response, apiName string) (json.R
|
||||
response, ok = m[key]
|
||||
|
||||
if !ok {
|
||||
for k := range m {
|
||||
return nil, fmt.Errorf("malformed JSON response, %q was expected, got %q", key, k)
|
||||
}
|
||||
return nil, fmt.Errorf("malformed JSON response %d, %q was expected.\n%s", resp.StatusCode, key, b)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -110,7 +114,7 @@ func (client *Client) parseResponse(resp *http.Response, apiName string) (json.R
|
||||
func (client *Client) asyncRequest(ctx context.Context, asyncCommand AsyncCommand) (interface{}, error) {
|
||||
var err error
|
||||
|
||||
resp := asyncCommand.asyncResponse()
|
||||
resp := asyncCommand.AsyncResponse()
|
||||
client.AsyncRequestWithContext(
|
||||
ctx,
|
||||
asyncCommand,
|
||||
@ -138,8 +142,8 @@ func (client *Client) SyncRequestWithContext(ctx context.Context, command Comman
|
||||
return nil, err
|
||||
}
|
||||
|
||||
response := command.response()
|
||||
b, ok := response.(*booleanResponse)
|
||||
response := command.Response()
|
||||
b, ok := response.(*BooleanResponse)
|
||||
if ok {
|
||||
m := make(map[string]interface{})
|
||||
if errUnmarshal := json.Unmarshal(body, &m); errUnmarshal != nil {
|
||||
@ -177,7 +181,7 @@ func (client *Client) BooleanRequest(command Command) error {
|
||||
return err
|
||||
}
|
||||
|
||||
if b, ok := resp.(*booleanResponse); ok {
|
||||
if b, ok := resp.(*BooleanResponse); ok {
|
||||
return b.Error()
|
||||
}
|
||||
|
||||
@ -191,7 +195,7 @@ func (client *Client) BooleanRequestWithContext(ctx context.Context, command Com
|
||||
return err
|
||||
}
|
||||
|
||||
if b, ok := resp.(*booleanResponse); ok {
|
||||
if b, ok := resp.(*BooleanResponse); ok {
|
||||
return b.Error()
|
||||
}
|
||||
|
||||
@ -208,9 +212,9 @@ func (client *Client) Request(command Command) (interface{}, error) {
|
||||
|
||||
// RequestWithContext preforms a command with a context
|
||||
func (client *Client) RequestWithContext(ctx context.Context, command Command) (interface{}, error) {
|
||||
switch command.(type) {
|
||||
switch c := command.(type) {
|
||||
case AsyncCommand:
|
||||
return client.asyncRequest(ctx, command.(AsyncCommand))
|
||||
return client.asyncRequest(ctx, c)
|
||||
default:
|
||||
return client.SyncRequestWithContext(ctx, command)
|
||||
}
|
||||
@ -277,10 +281,9 @@ func (client *Client) AsyncRequestWithContext(ctx context.Context, asyncCommand
|
||||
|
||||
// Payload builds the HTTP request params from the given command
|
||||
func (client *Client) Payload(command Command) (url.Values, error) {
|
||||
params := url.Values{}
|
||||
err := prepareValues("", params, command)
|
||||
params, err := prepareValues("", command)
|
||||
if err != nil {
|
||||
return params, err
|
||||
return nil, err
|
||||
}
|
||||
if hookReq, ok := command.(onBeforeHook); ok {
|
||||
if err := hookReq.onBeforeSend(params); err != nil {
|
||||
@ -291,6 +294,11 @@ func (client *Client) Payload(command Command) (url.Values, error) {
|
||||
params.Set("command", client.APIName(command))
|
||||
params.Set("response", "json")
|
||||
|
||||
if params.Get("expires") == "" && client.Expiration >= 0 {
|
||||
params.Set("signatureversion", "3")
|
||||
params.Set("expires", time.Now().Add(client.Expiration).Local().Format("2006-01-02T15:04:05-0700"))
|
||||
}
|
||||
|
||||
return params, nil
|
||||
}
|
||||
|
||||
|
24
vendor/github.com/exoscale/egoscale/request_type.go
generated
vendored
24
vendor/github.com/exoscale/egoscale/request_type.go
generated
vendored
@ -4,27 +4,27 @@ import (
|
||||
"net/url"
|
||||
)
|
||||
|
||||
// Command represents a CloudStack request
|
||||
// Command represents a generic request
|
||||
type Command interface {
|
||||
response() interface{}
|
||||
Response() interface{}
|
||||
}
|
||||
|
||||
// AsyncCommand represents a async CloudStack request
|
||||
// AsyncCommand represents a async request
|
||||
type AsyncCommand interface {
|
||||
Command
|
||||
// Response interface to Unmarshal the JSON into
|
||||
asyncResponse() interface{}
|
||||
AsyncResponse() interface{}
|
||||
}
|
||||
|
||||
// ListCommand represents a CloudStack list request
|
||||
// ListCommand represents a listing request
|
||||
type ListCommand interface {
|
||||
Listable
|
||||
Command
|
||||
// SetPage defines the current pages
|
||||
SetPage(int)
|
||||
// SetPageSize defines the size of the page
|
||||
SetPageSize(int)
|
||||
// each reads the data from the response and feeds channels, and returns true if we are on the last page
|
||||
each(interface{}, IterateItemFunc)
|
||||
// Each reads the data from the response and feeds channels, and returns true if we are on the last page
|
||||
Each(interface{}, IterateItemFunc)
|
||||
}
|
||||
|
||||
// onBeforeHook represents an action to be done on the params before sending them
|
||||
@ -57,7 +57,7 @@ const (
|
||||
|
||||
// ErrorCode represents the CloudStack ApiErrorCode enum
|
||||
//
|
||||
// See: https://github.com/apache/cloudstack/blob/master/api/src/org/apache/cloudstack/api/ApiErrorCode.java
|
||||
// See: https://github.com/apache/cloudstack/blob/master/api/src/main/java/org/apache/cloudstack/api/ApiErrorCode.java
|
||||
type ErrorCode int
|
||||
|
||||
//go:generate stringer -type ErrorCode
|
||||
@ -162,7 +162,7 @@ const (
|
||||
ServerAPIException CSErrorCode = 9999
|
||||
)
|
||||
|
||||
// ErrorResponse represents the standard error response from CloudStack
|
||||
// ErrorResponse represents the standard error response
|
||||
type ErrorResponse struct {
|
||||
CSErrorCode CSErrorCode `json:"cserrorcode"`
|
||||
ErrorCode ErrorCode `json:"errorcode"`
|
||||
@ -177,8 +177,8 @@ type UUIDItem struct {
|
||||
UUID string `json:"uuid"`
|
||||
}
|
||||
|
||||
// booleanResponse represents a boolean response (usually after a deletion)
|
||||
type booleanResponse struct {
|
||||
// BooleanResponse represents a boolean response (usually after a deletion)
|
||||
type BooleanResponse struct {
|
||||
DisplayText string `json:"displaytext,omitempty"`
|
||||
Success bool `json:"success"`
|
||||
}
|
||||
|
100
vendor/github.com/exoscale/egoscale/resource_limits.go
generated
vendored
Normal file
100
vendor/github.com/exoscale/egoscale/resource_limits.go
generated
vendored
Normal file
@ -0,0 +1,100 @@
|
||||
package egoscale
|
||||
|
||||
// https://github.com/apache/cloudstack/blob/master/api/src/main/java/com/cloud/configuration/Resource.java
|
||||
|
||||
// ResourceTypeName represents the name of a resource type (for limits)
|
||||
type ResourceTypeName string
|
||||
|
||||
const (
|
||||
// VirtualMachineTypeName is the resource type name of a VM
|
||||
VirtualMachineTypeName ResourceTypeName = "user_vm"
|
||||
// IPAddressTypeName is the resource type name of an IP address
|
||||
IPAddressTypeName ResourceTypeName = "public_ip"
|
||||
// VolumeTypeName is the resource type name of a volume
|
||||
VolumeTypeName ResourceTypeName = "volume"
|
||||
// SnapshotTypeName is the resource type name of a snapshot
|
||||
SnapshotTypeName ResourceTypeName = "snapshot"
|
||||
// TemplateTypeName is the resource type name of a template
|
||||
TemplateTypeName ResourceTypeName = "template"
|
||||
// ProjectTypeName is the resource type name of a project
|
||||
ProjectTypeName ResourceTypeName = "project"
|
||||
// NetworkTypeName is the resource type name of a network
|
||||
NetworkTypeName ResourceTypeName = "network"
|
||||
// VPCTypeName is the resource type name of a VPC
|
||||
VPCTypeName ResourceTypeName = "vpc"
|
||||
// CPUTypeName is the resource type name of a CPU
|
||||
CPUTypeName ResourceTypeName = "cpu"
|
||||
// MemoryTypeName is the resource type name of Memory
|
||||
MemoryTypeName ResourceTypeName = "memory"
|
||||
// PrimaryStorageTypeName is the resource type name of primary storage
|
||||
PrimaryStorageTypeName ResourceTypeName = "primary_storage"
|
||||
// SecondaryStorageTypeName is the resource type name of secondary storage
|
||||
SecondaryStorageTypeName ResourceTypeName = "secondary_storage"
|
||||
)
|
||||
|
||||
// ResourceType represents the ID of a resource type (for limits)
|
||||
type ResourceType string
|
||||
|
||||
const (
|
||||
// VirtualMachineType is the resource type ID of a VM
|
||||
VirtualMachineType ResourceType = "0"
|
||||
// IPAddressType is the resource type ID of an IP address
|
||||
IPAddressType ResourceType = "1"
|
||||
// VolumeType is the resource type ID of a volume
|
||||
VolumeType ResourceType = "2"
|
||||
// SnapshotType is the resource type ID of a snapshot
|
||||
SnapshotType ResourceType = "3"
|
||||
// TemplateType is the resource type ID of a template
|
||||
TemplateType ResourceType = "4"
|
||||
// ProjectType is the resource type ID of a project
|
||||
ProjectType ResourceType = "5"
|
||||
// NetworkType is the resource type ID of a network
|
||||
NetworkType ResourceType = "6"
|
||||
// VPCType is the resource type ID of a VPC
|
||||
VPCType ResourceType = "7"
|
||||
// CPUType is the resource type ID of a CPU
|
||||
CPUType ResourceType = "8"
|
||||
// MemoryType is the resource type ID of Memory
|
||||
MemoryType ResourceType = "9"
|
||||
// PrimaryStorageType is the resource type ID of primary storage
|
||||
PrimaryStorageType ResourceType = "10"
|
||||
// SecondaryStorageType is the resource type ID of secondary storage
|
||||
SecondaryStorageType ResourceType = "11"
|
||||
)
|
||||
|
||||
// ResourceLimit represents the limit on a particular resource
|
||||
type ResourceLimit struct {
|
||||
Max int64 `json:"max,omitempty" doc:"the maximum number of the resource. A -1 means the resource currently has no limit."`
|
||||
ResourceType ResourceType `json:"resourcetype,omitempty" doc:"resource type. Values include 0, 1, 2, 3, 4, 6, 7, 8, 9, 10, 11. See the resourceType parameter for more information on these values."`
|
||||
ResourceTypeName string `json:"resourcetypename,omitempty" doc:"resource type name. Values include user_vm, public_ip, volume, snapshot, template, network, cpu, memory, primary_storage, secondary_storage."`
|
||||
}
|
||||
|
||||
// ListRequest builds the ListResourceLimits request
|
||||
func (limit ResourceLimit) ListRequest() (ListCommand, error) {
|
||||
req := &ListResourceLimits{
|
||||
ResourceType: limit.ResourceType,
|
||||
ResourceTypeName: limit.ResourceTypeName,
|
||||
}
|
||||
|
||||
return req, nil
|
||||
}
|
||||
|
||||
//go:generate go run generate/main.go -interface=Listable ListResourceLimits
|
||||
|
||||
// ListResourceLimits lists the resource limits
|
||||
type ListResourceLimits struct {
|
||||
ID int64 `json:"id,omitempty" doc:"Lists resource limits by ID."`
|
||||
Keyword string `json:"keyword,omitempty" doc:"List by keyword"`
|
||||
Page int `json:"page,omitempty"`
|
||||
PageSize int `json:"pagesize,omitempty"`
|
||||
ResourceType ResourceType `json:"resourcetype,omitempty" doc:"Type of resource. Values are 0, 1, 2, 3, 4, 6, 8, 9, 10, 11, 12, and 13. 0 - Instance. Number of instances a user can create. 1 - IP. Number of public IP addresses an account can own. 2 - Volume. Number of disk volumes an account can own. 3 - Snapshot. Number of snapshots an account can own. 4 - Template. Number of templates an account can register/create. 6 - Network. Number of networks an account can own. 8 - CPU. Number of CPU an account can allocate for his resources. 9 - Memory. Amount of RAM an account can allocate for his resources. 10 - PrimaryStorage. Total primary storage space (in GiB) a user can use. 11 - SecondaryStorage. Total secondary storage space (in GiB) a user can use. 12 - Elastic IP. Number of public elastic IP addresses an account can own. 13 - SMTP. If the account is allowed SMTP outbound traffic."`
|
||||
ResourceTypeName string `json:"resourcetypename,omitempty" doc:"Type of resource (wins over resourceType if both are provided). Values are: user_vm - Instance. Number of instances a user can create. public_ip - IP. Number of public IP addresses an account can own. volume - Volume. Number of disk volumes an account can own. snapshot - Snapshot. Number of snapshots an account can own. template - Template. Number of templates an account can register/create. network - Network. Number of networks an account can own. cpu - CPU. Number of CPU an account can allocate for his resources. memory - Memory. Amount of RAM an account can allocate for his resources. primary_storage - PrimaryStorage. Total primary storage space (in GiB) a user can use. secondary_storage - SecondaryStorage. Total secondary storage space (in GiB) a user can use. public_elastic_ip - IP. Number of public elastic IP addresses an account can own. smtp - SG. If the account is allowed SMTP outbound traffic."`
|
||||
|
||||
_ bool `name:"listResourceLimits" description:"Lists resource limits."`
|
||||
}
|
||||
|
||||
// ListResourceLimitsResponse represents a list of resource limits
|
||||
type ListResourceLimitsResponse struct {
|
||||
Count int `json:"count"`
|
||||
ResourceLimit []ResourceLimit `json:"resourcelimit"`
|
||||
}
|
37
vendor/github.com/exoscale/egoscale/resource_metadata.go
generated
vendored
37
vendor/github.com/exoscale/egoscale/resource_metadata.go
generated
vendored
@ -1,19 +1,36 @@
|
||||
package egoscale
|
||||
|
||||
import "fmt"
|
||||
|
||||
// ResourceDetail represents extra details
|
||||
type ResourceDetail ResourceTag
|
||||
|
||||
// ListRequest builds the ListResourceDetails request
|
||||
func (detail ResourceDetail) ListRequest() (ListCommand, error) {
|
||||
if detail.ResourceType == "" {
|
||||
return nil, fmt.Errorf("the resourcetype parameter is required")
|
||||
}
|
||||
|
||||
req := &ListResourceDetails{
|
||||
ResourceType: detail.ResourceType,
|
||||
ResourceID: detail.ResourceID,
|
||||
}
|
||||
|
||||
return req, nil
|
||||
}
|
||||
|
||||
//go:generate go run generate/main.go -interface=Listable ListResourceDetails
|
||||
|
||||
// ListResourceDetails lists the resource tag(s) (but different from listTags...)
|
||||
type ListResourceDetails struct {
|
||||
ResourceType string `json:"resourcetype" doc:"list by resource type"`
|
||||
Account string `json:"account,omitempty" doc:"list resources by account. Must be used with the domainId parameter."`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"list only resources belonging to the domain specified"`
|
||||
ForDisplay bool `json:"fordisplay,omitempty" doc:"if set to true, only details marked with display=true, are returned. False by default"`
|
||||
Key string `json:"key,omitempty" doc:"list by key"`
|
||||
Keyword string `json:"keyword,omitempty" doc:"List by keyword"`
|
||||
ListAll bool `json:"listall,omitempty" doc:"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"`
|
||||
Page int `json:"page,omitempty"`
|
||||
PageSize int `json:"pagesize,omitempty"`
|
||||
ResourceID *UUID `json:"resourceid,omitempty" doc:"list by resource id"`
|
||||
Value string `json:"value,omitempty" doc:"list by key, value. Needs to be passed only along with key"`
|
||||
IsRecursive bool `json:"isrecursive,omitempty" doc:"defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves."`
|
||||
_ bool `name:"listResourceDetails" description:"List resource detail(s)"`
|
||||
}
|
||||
|
||||
@ -22,15 +39,3 @@ type ListResourceDetailsResponse struct {
|
||||
Count int `json:"count"`
|
||||
ResourceDetail []ResourceTag `json:"resourcedetail"`
|
||||
}
|
||||
|
||||
func (*ListResourceDetails) name() string {
|
||||
return "listResourceDetails"
|
||||
}
|
||||
|
||||
func (*ListResourceDetails) description() string {
|
||||
return "List resource detail(s)"
|
||||
}
|
||||
|
||||
func (*ListResourceDetails) response() interface{} {
|
||||
return new(ListResourceDetailsResponse)
|
||||
}
|
||||
|
43
vendor/github.com/exoscale/egoscale/resourcedetails_response.go
generated
vendored
Normal file
43
vendor/github.com/exoscale/egoscale/resourcedetails_response.go
generated
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
// code generated; DO NOT EDIT.
|
||||
|
||||
package egoscale
|
||||
|
||||
import "fmt"
|
||||
|
||||
// Response returns the struct to unmarshal
|
||||
func (ListResourceDetails) Response() interface{} {
|
||||
return new(ListResourceDetailsResponse)
|
||||
}
|
||||
|
||||
// ListRequest returns itself
|
||||
func (ls *ListResourceDetails) ListRequest() (ListCommand, error) {
|
||||
if ls == nil {
|
||||
return nil, fmt.Errorf("%T cannot be nil", ls)
|
||||
}
|
||||
return ls, nil
|
||||
}
|
||||
|
||||
// SetPage sets the current apge
|
||||
func (ls *ListResourceDetails) SetPage(page int) {
|
||||
ls.Page = page
|
||||
}
|
||||
|
||||
// SetPageSize sets the page size
|
||||
func (ls *ListResourceDetails) SetPageSize(pageSize int) {
|
||||
ls.PageSize = pageSize
|
||||
}
|
||||
|
||||
// Each triggers the callback for each, valid answer or any non 404 issue
|
||||
func (ListResourceDetails) Each(resp interface{}, callback IterateItemFunc) {
|
||||
items, ok := resp.(*ListResourceDetailsResponse)
|
||||
if !ok {
|
||||
callback(nil, fmt.Errorf("wrong type, ListResourceDetailsResponse was expected, got %T", resp))
|
||||
return
|
||||
}
|
||||
|
||||
for i := range items.ResourceDetail {
|
||||
if !callback(&items.ResourceDetail[i], nil) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
43
vendor/github.com/exoscale/egoscale/resourcelimits_response.go
generated
vendored
Normal file
43
vendor/github.com/exoscale/egoscale/resourcelimits_response.go
generated
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
// code generated; DO NOT EDIT.
|
||||
|
||||
package egoscale
|
||||
|
||||
import "fmt"
|
||||
|
||||
// Response returns the struct to unmarshal
|
||||
func (ListResourceLimits) Response() interface{} {
|
||||
return new(ListResourceLimitsResponse)
|
||||
}
|
||||
|
||||
// ListRequest returns itself
|
||||
func (ls *ListResourceLimits) ListRequest() (ListCommand, error) {
|
||||
if ls == nil {
|
||||
return nil, fmt.Errorf("%T cannot be nil", ls)
|
||||
}
|
||||
return ls, nil
|
||||
}
|
||||
|
||||
// SetPage sets the current apge
|
||||
func (ls *ListResourceLimits) SetPage(page int) {
|
||||
ls.Page = page
|
||||
}
|
||||
|
||||
// SetPageSize sets the page size
|
||||
func (ls *ListResourceLimits) SetPageSize(pageSize int) {
|
||||
ls.PageSize = pageSize
|
||||
}
|
||||
|
||||
// Each triggers the callback for each, valid answer or any non 404 issue
|
||||
func (ListResourceLimits) Each(resp interface{}, callback IterateItemFunc) {
|
||||
items, ok := resp.(*ListResourceLimitsResponse)
|
||||
if !ok {
|
||||
callback(nil, fmt.Errorf("wrong type, ListResourceLimitsResponse was expected, got %T", resp))
|
||||
return
|
||||
}
|
||||
|
||||
for i := range items.ResourceLimit {
|
||||
if !callback(&items.ResourceLimit[i], nil) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
22
vendor/github.com/exoscale/egoscale/reversedns.go
generated
vendored
22
vendor/github.com/exoscale/egoscale/reversedns.go
generated
vendored
@ -20,8 +20,9 @@ type DeleteReverseDNSFromPublicIPAddress struct {
|
||||
_ bool `name:"deleteReverseDnsFromPublicIpAddress" description:"delete the PTR DNS record from the public IP address"`
|
||||
}
|
||||
|
||||
func (*DeleteReverseDNSFromPublicIPAddress) response() interface{} {
|
||||
return new(booleanResponse)
|
||||
// Response returns the struct to unmarshal
|
||||
func (*DeleteReverseDNSFromPublicIPAddress) Response() interface{} {
|
||||
return new(BooleanResponse)
|
||||
}
|
||||
|
||||
// DeleteReverseDNSFromVirtualMachine is a command to create/delete the PTR record(s) of a virtual machine
|
||||
@ -30,8 +31,9 @@ type DeleteReverseDNSFromVirtualMachine struct {
|
||||
_ bool `name:"deleteReverseDnsFromVirtualMachine" description:"Delete the PTR DNS record(s) from the virtual machine"`
|
||||
}
|
||||
|
||||
func (*DeleteReverseDNSFromVirtualMachine) response() interface{} {
|
||||
return new(booleanResponse)
|
||||
// Response returns the struct to unmarshal
|
||||
func (*DeleteReverseDNSFromVirtualMachine) Response() interface{} {
|
||||
return new(BooleanResponse)
|
||||
}
|
||||
|
||||
// QueryReverseDNSForPublicIPAddress is a command to create/query the PTR record of a public IP address
|
||||
@ -40,7 +42,8 @@ type QueryReverseDNSForPublicIPAddress struct {
|
||||
_ bool `name:"queryReverseDnsForPublicIpAddress" description:"Query the PTR DNS record for the public IP address"`
|
||||
}
|
||||
|
||||
func (*QueryReverseDNSForPublicIPAddress) response() interface{} {
|
||||
// Response returns the struct to unmarshal
|
||||
func (*QueryReverseDNSForPublicIPAddress) Response() interface{} {
|
||||
return new(IPAddress)
|
||||
}
|
||||
|
||||
@ -50,7 +53,8 @@ type QueryReverseDNSForVirtualMachine struct {
|
||||
_ bool `name:"queryReverseDnsForVirtualMachine" description:"Query the PTR DNS record(s) for the virtual machine"`
|
||||
}
|
||||
|
||||
func (*QueryReverseDNSForVirtualMachine) response() interface{} {
|
||||
// Response returns the struct to unmarshal
|
||||
func (*QueryReverseDNSForVirtualMachine) Response() interface{} {
|
||||
return new(VirtualMachine)
|
||||
}
|
||||
|
||||
@ -61,7 +65,8 @@ type UpdateReverseDNSForPublicIPAddress struct {
|
||||
_ bool `name:"updateReverseDnsForPublicIpAddress" description:"Update/create the PTR DNS record for the public IP address"`
|
||||
}
|
||||
|
||||
func (*UpdateReverseDNSForPublicIPAddress) response() interface{} {
|
||||
// Response returns the struct to unmarshal
|
||||
func (*UpdateReverseDNSForPublicIPAddress) Response() interface{} {
|
||||
return new(IPAddress)
|
||||
}
|
||||
|
||||
@ -72,6 +77,7 @@ type UpdateReverseDNSForVirtualMachine struct {
|
||||
_ bool `name:"updateReverseDnsForVirtualMachine" description:"Update/create the PTR DNS record(s) for the virtual machine"`
|
||||
}
|
||||
|
||||
func (*UpdateReverseDNSForVirtualMachine) response() interface{} {
|
||||
// Response returns the struct to unmarshal
|
||||
func (*UpdateReverseDNSForVirtualMachine) Response() interface{} {
|
||||
return new(VirtualMachine)
|
||||
}
|
||||
|
131
vendor/github.com/exoscale/egoscale/runstatus.go
generated
vendored
Normal file
131
vendor/github.com/exoscale/egoscale/runstatus.go
generated
vendored
Normal file
@ -0,0 +1,131 @@
|
||||
package egoscale
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/hmac"
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
// RunstatusValidationErrorResponse represents an error in the API
|
||||
type RunstatusValidationErrorResponse map[string][]string
|
||||
|
||||
// RunstatusErrorResponse represents the default errors
|
||||
type RunstatusErrorResponse struct {
|
||||
Detail string `json:"detail"`
|
||||
}
|
||||
|
||||
// runstatusPagesURL is the only URL that cannot be guessed
|
||||
const runstatusPagesURL = "/pages"
|
||||
|
||||
// Error formats the DNSerror into a string
|
||||
func (req RunstatusErrorResponse) Error() string {
|
||||
return fmt.Sprintf("Runstatus error: %s", req.Detail)
|
||||
}
|
||||
|
||||
// Error formats the DNSerror into a string
|
||||
func (req RunstatusValidationErrorResponse) Error() string {
|
||||
if len(req) > 0 {
|
||||
errs := []string{}
|
||||
for name, ss := range req {
|
||||
if len(ss) > 0 {
|
||||
errs = append(errs, fmt.Sprintf("%s: %s", name, strings.Join(ss, ", ")))
|
||||
}
|
||||
}
|
||||
return fmt.Sprintf("Runstatus error: %s", strings.Join(errs, "; "))
|
||||
}
|
||||
return fmt.Sprintf("Runstatus error")
|
||||
}
|
||||
|
||||
func (client *Client) runstatusRequest(ctx context.Context, uri string, structParam interface{}, method string) (json.RawMessage, error) {
|
||||
reqURL, err := url.Parse(uri)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if reqURL.Scheme == "" {
|
||||
return nil, fmt.Errorf("only absolute URI are considered valid, got %q", uri)
|
||||
}
|
||||
|
||||
var params string
|
||||
if structParam != nil {
|
||||
m, err := json.Marshal(structParam)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
params = string(m)
|
||||
}
|
||||
|
||||
req, err := http.NewRequest(method, reqURL.String(), strings.NewReader(params))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
time := time.Now().Local().Format("2006-01-02T15:04:05-0700")
|
||||
|
||||
payload := fmt.Sprintf("%s%s%s", req.URL.String(), time, params)
|
||||
|
||||
mac := hmac.New(sha256.New, []byte(client.apiSecret))
|
||||
_, err = mac.Write([]byte(payload))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
signature := hex.EncodeToString(mac.Sum(nil))
|
||||
|
||||
var hdr = make(http.Header)
|
||||
|
||||
hdr.Add("Authorization", fmt.Sprintf("Exoscale-HMAC-SHA256 %s:%s", client.APIKey, signature))
|
||||
hdr.Add("Exoscale-Date", time)
|
||||
hdr.Add("User-Agent", fmt.Sprintf("exoscale/egoscale (%v)", Version))
|
||||
hdr.Add("Accept", "application/json")
|
||||
if params != "" {
|
||||
hdr.Add("Content-Type", "application/json")
|
||||
}
|
||||
req.Header = hdr
|
||||
|
||||
req = req.WithContext(ctx)
|
||||
|
||||
resp, err := client.HTTPClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer resp.Body.Close() // nolint: errcheck
|
||||
|
||||
if resp.StatusCode == 204 {
|
||||
if method != "DELETE" {
|
||||
return nil, fmt.Errorf("only DELETE is expected to produce 204, was %q", method)
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
contentType := resp.Header.Get("content-type")
|
||||
if !strings.Contains(contentType, "application/json") {
|
||||
return nil, fmt.Errorf(`response %d content-type expected to be "application/json", got %q`, resp.StatusCode, contentType)
|
||||
}
|
||||
|
||||
b, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if resp.StatusCode >= 400 {
|
||||
rerr := new(RunstatusValidationErrorResponse)
|
||||
if err := json.Unmarshal(b, rerr); err == nil {
|
||||
return nil, rerr
|
||||
}
|
||||
rverr := new(RunstatusErrorResponse)
|
||||
if err := json.Unmarshal(b, rverr); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return nil, rverr
|
||||
}
|
||||
|
||||
return b, nil
|
||||
}
|
37
vendor/github.com/exoscale/egoscale/runstatus_event.go
generated
vendored
Normal file
37
vendor/github.com/exoscale/egoscale/runstatus_event.go
generated
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
package egoscale
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
//RunstatusEvent is a runstatus event
|
||||
type RunstatusEvent struct {
|
||||
Created *time.Time `json:"created,omitempty"`
|
||||
State string `json:"state,omitempty"`
|
||||
Status string `json:"status"`
|
||||
Text string `json:"text"`
|
||||
}
|
||||
|
||||
// UpdateRunstatusIncident create runstatus incident event
|
||||
// Events can be updates or final message with status completed.
|
||||
func (client *Client) UpdateRunstatusIncident(ctx context.Context, incident RunstatusIncident, event RunstatusEvent) error {
|
||||
if incident.EventsURL == "" {
|
||||
return fmt.Errorf("empty Events URL for %#v", incident)
|
||||
}
|
||||
|
||||
_, err := client.runstatusRequest(ctx, incident.EventsURL, event, "POST")
|
||||
return err
|
||||
}
|
||||
|
||||
// UpdateRunstatusMaintenance adds a event to a maintenance.
|
||||
// Events can be updates or final message with status completed.
|
||||
func (client *Client) UpdateRunstatusMaintenance(ctx context.Context, maintenance RunstatusMaintenance, event RunstatusEvent) error {
|
||||
if maintenance.EventsURL == "" {
|
||||
return fmt.Errorf("empty Events URL for %#v", maintenance)
|
||||
}
|
||||
|
||||
_, err := client.runstatusRequest(ctx, maintenance.EventsURL, event, "POST")
|
||||
return err
|
||||
}
|
175
vendor/github.com/exoscale/egoscale/runstatus_incident.go
generated
vendored
Normal file
175
vendor/github.com/exoscale/egoscale/runstatus_incident.go
generated
vendored
Normal file
@ -0,0 +1,175 @@
|
||||
package egoscale
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
//RunstatusIncident is a runstatus incident
|
||||
type RunstatusIncident struct {
|
||||
EndDate *time.Time `json:"end_date,omitempty"`
|
||||
Events []RunstatusEvent `json:"events,omitempty"`
|
||||
EventsURL string `json:"events_url,omitempty"`
|
||||
ID int `json:"id,omitempty"`
|
||||
PageURL string `json:"page_url,omitempty"` // fake field
|
||||
PostMortem string `json:"post_mortem,omitempty"`
|
||||
RealTime bool `json:"real_time,omitempty"`
|
||||
Services []string `json:"services"`
|
||||
StartDate *time.Time `json:"start_date,omitempty"`
|
||||
State string `json:"state"`
|
||||
Status string `json:"status"`
|
||||
StatusText string `json:"status_text"`
|
||||
Title string `json:"title"`
|
||||
URL string `json:"url,omitempty"`
|
||||
}
|
||||
|
||||
// Match returns true if the other incident has got similarities with itself
|
||||
func (incident RunstatusIncident) Match(other RunstatusIncident) bool {
|
||||
if other.Title != "" && incident.Title == other.Title {
|
||||
return true
|
||||
}
|
||||
|
||||
if other.ID > 0 && incident.ID == other.ID {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
//RunstatusIncidentList is a list of incident
|
||||
type RunstatusIncidentList struct {
|
||||
Next string `json:"next"`
|
||||
Previous string `json:"previous"`
|
||||
Incidents []RunstatusIncident `json:"results"`
|
||||
}
|
||||
|
||||
// GetRunstatusIncident retrieves the details of a specific incident.
|
||||
func (client *Client) GetRunstatusIncident(ctx context.Context, incident RunstatusIncident) (*RunstatusIncident, error) {
|
||||
if incident.URL != "" {
|
||||
return client.getRunstatusIncident(ctx, incident.URL)
|
||||
}
|
||||
|
||||
if incident.PageURL == "" {
|
||||
return nil, fmt.Errorf("empty Page URL for %#v", incident)
|
||||
}
|
||||
|
||||
page, err := client.getRunstatusPage(ctx, incident.PageURL)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for i := range page.Incidents {
|
||||
j := &page.Incidents[i]
|
||||
if j.Match(incident) {
|
||||
return j, nil
|
||||
}
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("%#v not found", incident)
|
||||
}
|
||||
|
||||
func (client *Client) getRunstatusIncident(ctx context.Context, incidentURL string) (*RunstatusIncident, error) {
|
||||
resp, err := client.runstatusRequest(ctx, incidentURL, nil, "GET")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
i := new(RunstatusIncident)
|
||||
if err := json.Unmarshal(resp, i); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return i, nil
|
||||
}
|
||||
|
||||
// ListRunstatusIncidents lists the incidents for a specific page.
|
||||
func (client *Client) ListRunstatusIncidents(ctx context.Context, page RunstatusPage) ([]RunstatusIncident, error) {
|
||||
if page.IncidentsURL == "" {
|
||||
return nil, fmt.Errorf("empty Incidents URL for %#v", page)
|
||||
}
|
||||
|
||||
results := make([]RunstatusIncident, 0)
|
||||
|
||||
var err error
|
||||
client.PaginateRunstatusIncidents(ctx, page, func(incident *RunstatusIncident, e error) bool {
|
||||
if e != nil {
|
||||
err = e
|
||||
return false
|
||||
}
|
||||
|
||||
results = append(results, *incident)
|
||||
return true
|
||||
})
|
||||
|
||||
return results, err
|
||||
}
|
||||
|
||||
// PaginateRunstatusIncidents paginate Incidents
|
||||
func (client *Client) PaginateRunstatusIncidents(ctx context.Context, page RunstatusPage, callback func(*RunstatusIncident, error) bool) {
|
||||
if page.IncidentsURL == "" {
|
||||
callback(nil, fmt.Errorf("empty Incidents URL for %#v", page))
|
||||
return
|
||||
}
|
||||
|
||||
incidentsURL := page.IncidentsURL
|
||||
for incidentsURL != "" {
|
||||
resp, err := client.runstatusRequest(ctx, incidentsURL, nil, "GET")
|
||||
if err != nil {
|
||||
callback(nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
var is *RunstatusIncidentList
|
||||
if err := json.Unmarshal(resp, &is); err != nil {
|
||||
callback(nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
for i := range is.Incidents {
|
||||
if cont := callback(&is.Incidents[i], nil); !cont {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
incidentsURL = is.Next
|
||||
}
|
||||
}
|
||||
|
||||
// CreateRunstatusIncident create runstatus incident
|
||||
func (client *Client) CreateRunstatusIncident(ctx context.Context, incident RunstatusIncident) (*RunstatusIncident, error) {
|
||||
if incident.PageURL == "" {
|
||||
return nil, fmt.Errorf("empty Page URL for %#v", incident)
|
||||
}
|
||||
|
||||
page, err := client.getRunstatusPage(ctx, incident.PageURL)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if page.IncidentsURL == "" {
|
||||
return nil, fmt.Errorf("empty Incidents URL for %#v", page)
|
||||
}
|
||||
|
||||
resp, err := client.runstatusRequest(ctx, page.IncidentsURL, incident, "POST")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
i := &RunstatusIncident{}
|
||||
if err := json.Unmarshal(resp, &i); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return i, nil
|
||||
}
|
||||
|
||||
// DeleteRunstatusIncident delete runstatus incident
|
||||
func (client *Client) DeleteRunstatusIncident(ctx context.Context, incident RunstatusIncident) error {
|
||||
if incident.URL == "" {
|
||||
return fmt.Errorf("empty URL for %#v", incident)
|
||||
}
|
||||
|
||||
_, err := client.runstatusRequest(ctx, incident.URL, nil, "DELETE")
|
||||
return err
|
||||
}
|
208
vendor/github.com/exoscale/egoscale/runstatus_maintenance.go
generated
vendored
Normal file
208
vendor/github.com/exoscale/egoscale/runstatus_maintenance.go
generated
vendored
Normal file
@ -0,0 +1,208 @@
|
||||
package egoscale
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/url"
|
||||
"path"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
// RunstatusMaintenance is a runstatus maintenance
|
||||
type RunstatusMaintenance struct {
|
||||
Created *time.Time `json:"created,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
EndDate *time.Time `json:"end_date"`
|
||||
Events []RunstatusEvent `json:"events,omitempty"`
|
||||
EventsURL string `json:"events_url,omitempty"`
|
||||
ID int `json:"id,omitempty"` // missing field
|
||||
PageURL string `json:"page_url,omitempty"` // fake field
|
||||
RealTime bool `json:"real_time,omitempty"`
|
||||
Services []string `json:"services"`
|
||||
StartDate *time.Time `json:"start_date"`
|
||||
Status string `json:"status"`
|
||||
Title string `json:"title"`
|
||||
URL string `json:"url,omitempty"`
|
||||
}
|
||||
|
||||
// Match returns true if the other maintenance has got similarities with itself
|
||||
func (maintenance RunstatusMaintenance) Match(other RunstatusMaintenance) bool {
|
||||
if other.Title != "" && maintenance.Title == other.Title {
|
||||
return true
|
||||
}
|
||||
|
||||
if other.ID > 0 && maintenance.ID == other.ID {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// FakeID fills up the ID field as it's currently missing
|
||||
func (maintenance *RunstatusMaintenance) FakeID() error {
|
||||
if maintenance.ID > 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
if maintenance.URL == "" {
|
||||
return fmt.Errorf("empty URL for %#v", maintenance)
|
||||
}
|
||||
|
||||
u, err := url.Parse(maintenance.URL)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
s := path.Base(u.Path)
|
||||
id, err := strconv.Atoi(s)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
maintenance.ID = id
|
||||
return nil
|
||||
}
|
||||
|
||||
// RunstatusMaintenanceList is a list of incident
|
||||
type RunstatusMaintenanceList struct {
|
||||
Next string `json:"next"`
|
||||
Previous string `json:"previous"`
|
||||
Maintenances []RunstatusMaintenance `json:"results"`
|
||||
}
|
||||
|
||||
// GetRunstatusMaintenance retrieves the details of a specific maintenance.
|
||||
func (client *Client) GetRunstatusMaintenance(ctx context.Context, maintenance RunstatusMaintenance) (*RunstatusMaintenance, error) {
|
||||
if maintenance.URL != "" {
|
||||
return client.getRunstatusMaintenance(ctx, maintenance.URL)
|
||||
}
|
||||
|
||||
if maintenance.PageURL == "" {
|
||||
return nil, fmt.Errorf("empty Page URL for %#v", maintenance)
|
||||
}
|
||||
|
||||
page, err := client.getRunstatusPage(ctx, maintenance.PageURL)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for i := range page.Maintenances {
|
||||
m := &page.Maintenances[i]
|
||||
if m.Match(maintenance) {
|
||||
if err := m.FakeID(); err != nil {
|
||||
log.Printf("bad fake ID for %#v, %s", m, err)
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("%#v not found", maintenance)
|
||||
}
|
||||
|
||||
func (client *Client) getRunstatusMaintenance(ctx context.Context, maintenanceURL string) (*RunstatusMaintenance, error) {
|
||||
resp, err := client.runstatusRequest(ctx, maintenanceURL, nil, "GET")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
m := new(RunstatusMaintenance)
|
||||
if err := json.Unmarshal(resp, m); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// ListRunstatusMaintenances returns the list of maintenances for the page.
|
||||
func (client *Client) ListRunstatusMaintenances(ctx context.Context, page RunstatusPage) ([]RunstatusMaintenance, error) {
|
||||
if page.MaintenancesURL == "" {
|
||||
return nil, fmt.Errorf("empty Maintenances URL for %#v", page)
|
||||
}
|
||||
|
||||
results := make([]RunstatusMaintenance, 0)
|
||||
|
||||
var err error
|
||||
client.PaginateRunstatusMaintenances(ctx, page, func(maintenance *RunstatusMaintenance, e error) bool {
|
||||
if e != nil {
|
||||
err = e
|
||||
return false
|
||||
}
|
||||
|
||||
results = append(results, *maintenance)
|
||||
return true
|
||||
})
|
||||
|
||||
return results, err
|
||||
}
|
||||
|
||||
// PaginateRunstatusMaintenances paginate Maintenances
|
||||
func (client *Client) PaginateRunstatusMaintenances(ctx context.Context, page RunstatusPage, callback func(*RunstatusMaintenance, error) bool) { // nolint: dupl
|
||||
if page.MaintenancesURL == "" {
|
||||
callback(nil, fmt.Errorf("empty Maintenances URL for %#v", page))
|
||||
return
|
||||
}
|
||||
|
||||
maintenancesURL := page.MaintenancesURL
|
||||
for maintenancesURL != "" {
|
||||
resp, err := client.runstatusRequest(ctx, maintenancesURL, nil, "GET")
|
||||
if err != nil {
|
||||
callback(nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
var ms *RunstatusMaintenanceList
|
||||
if err := json.Unmarshal(resp, &ms); err != nil {
|
||||
callback(nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
for i := range ms.Maintenances {
|
||||
if err := ms.Maintenances[i].FakeID(); err != nil {
|
||||
log.Printf("bad fake ID for %#v, %s", ms.Maintenances[i], err)
|
||||
}
|
||||
if cont := callback(&ms.Maintenances[i], nil); !cont {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
maintenancesURL = ms.Next
|
||||
}
|
||||
}
|
||||
|
||||
// CreateRunstatusMaintenance create runstatus Maintenance
|
||||
func (client *Client) CreateRunstatusMaintenance(ctx context.Context, maintenance RunstatusMaintenance) (*RunstatusMaintenance, error) {
|
||||
if maintenance.PageURL == "" {
|
||||
return nil, fmt.Errorf("empty Page URL for %#v", maintenance)
|
||||
}
|
||||
|
||||
page, err := client.getRunstatusPage(ctx, maintenance.PageURL)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
resp, err := client.runstatusRequest(ctx, page.MaintenancesURL, maintenance, "POST")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
m := &RunstatusMaintenance{}
|
||||
if err := json.Unmarshal(resp, &m); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := m.FakeID(); err != nil {
|
||||
log.Printf("bad fake ID for %#v, %s", m, err)
|
||||
}
|
||||
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// DeleteRunstatusMaintenance delete runstatus Maintenance
|
||||
func (client *Client) DeleteRunstatusMaintenance(ctx context.Context, maintenance RunstatusMaintenance) error {
|
||||
if maintenance.URL == "" {
|
||||
return fmt.Errorf("empty URL for %#v", maintenance)
|
||||
}
|
||||
|
||||
_, err := client.runstatusRequest(ctx, maintenance.URL, nil, "DELETE")
|
||||
return err
|
||||
}
|
168
vendor/github.com/exoscale/egoscale/runstatus_page.go
generated
vendored
Normal file
168
vendor/github.com/exoscale/egoscale/runstatus_page.go
generated
vendored
Normal file
@ -0,0 +1,168 @@
|
||||
package egoscale
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"time"
|
||||
)
|
||||
|
||||
// RunstatusPage runstatus page
|
||||
type RunstatusPage struct {
|
||||
Created *time.Time `json:"created,omitempty"`
|
||||
DarkTheme bool `json:"dark_theme,omitempty"`
|
||||
Domain string `json:"domain,omitempty"`
|
||||
GradientEnd string `json:"gradient_end,omitempty"`
|
||||
GradientStart string `json:"gradient_start,omitempty"`
|
||||
HeaderBackground string `json:"header_background,omitempty"`
|
||||
ID int `json:"id,omitempty"`
|
||||
Incidents []RunstatusIncident `json:"incidents,omitempty"`
|
||||
IncidentsURL string `json:"incidents_url,omitempty"`
|
||||
Logo string `json:"logo,omitempty"`
|
||||
Maintenances []RunstatusMaintenance `json:"maintenances,omitempty"`
|
||||
MaintenancesURL string `json:"maintenances_url,omitempty"`
|
||||
Name string `json:"name"` //fake field (used to post a new runstatus page)
|
||||
OkText string `json:"ok_text,omitempty"`
|
||||
Plan string `json:"plan,omitempty"`
|
||||
PublicURL string `json:"public_url,omitempty"`
|
||||
Services []RunstatusService `json:"services,omitempty"`
|
||||
ServicesURL string `json:"services_url,omitempty"`
|
||||
State string `json:"state,omitempty"`
|
||||
Subdomain string `json:"subdomain"`
|
||||
SupportEmail string `json:"support_email,omitempty"`
|
||||
TimeZone string `json:"time_zone,omitempty"`
|
||||
Title string `json:"title,omitempty"`
|
||||
TitleColor string `json:"title_color,omitempty"`
|
||||
TwitterUsername string `json:"twitter_username,omitempty"`
|
||||
URL string `json:"url,omitempty"`
|
||||
}
|
||||
|
||||
// Match returns true if the other page has got similarities with itself
|
||||
func (page RunstatusPage) Match(other RunstatusPage) bool {
|
||||
if other.Subdomain != "" && page.Subdomain == other.Subdomain {
|
||||
return true
|
||||
}
|
||||
|
||||
if other.ID > 0 && page.ID == other.ID {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// RunstatusPageList runstatus page list
|
||||
type RunstatusPageList struct {
|
||||
Next string `json:"next"`
|
||||
Previous string `json:"previous"`
|
||||
Pages []RunstatusPage `json:"results"`
|
||||
}
|
||||
|
||||
// CreateRunstatusPage create runstatus page
|
||||
func (client *Client) CreateRunstatusPage(ctx context.Context, page RunstatusPage) (*RunstatusPage, error) {
|
||||
resp, err := client.runstatusRequest(ctx, client.Endpoint+runstatusPagesURL, page, "POST")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var p *RunstatusPage
|
||||
if err := json.Unmarshal(resp, &p); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return p, nil
|
||||
}
|
||||
|
||||
// DeleteRunstatusPage delete runstatus page
|
||||
func (client *Client) DeleteRunstatusPage(ctx context.Context, page RunstatusPage) error {
|
||||
if page.URL == "" {
|
||||
return fmt.Errorf("empty URL for %#v", page)
|
||||
}
|
||||
_, err := client.runstatusRequest(ctx, page.URL, nil, "DELETE")
|
||||
return err
|
||||
}
|
||||
|
||||
// GetRunstatusPage fetches the runstatus page
|
||||
func (client *Client) GetRunstatusPage(ctx context.Context, page RunstatusPage) (*RunstatusPage, error) {
|
||||
if page.URL != "" {
|
||||
return client.getRunstatusPage(ctx, page.URL)
|
||||
}
|
||||
|
||||
ps, err := client.ListRunstatusPages(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for i := range ps {
|
||||
if ps[i].Match(page) {
|
||||
return client.getRunstatusPage(ctx, ps[i].URL)
|
||||
}
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("%#v not found", page)
|
||||
}
|
||||
|
||||
func (client *Client) getRunstatusPage(ctx context.Context, pageURL string) (*RunstatusPage, error) {
|
||||
resp, err := client.runstatusRequest(ctx, pageURL, nil, "GET")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
p := new(RunstatusPage)
|
||||
if err := json.Unmarshal(resp, p); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// NOTE: fix the missing IDs
|
||||
for i := range p.Maintenances {
|
||||
if err := p.Maintenances[i].FakeID(); err != nil {
|
||||
log.Printf("bad fake ID for %#v, %s", p.Maintenances[i], err)
|
||||
}
|
||||
}
|
||||
for i := range p.Services {
|
||||
if err := p.Services[i].FakeID(); err != nil {
|
||||
log.Printf("bad fake ID for %#v, %s", p.Services[i], err)
|
||||
}
|
||||
}
|
||||
|
||||
return p, nil
|
||||
}
|
||||
|
||||
// ListRunstatusPages list all the runstatus pages
|
||||
func (client *Client) ListRunstatusPages(ctx context.Context) ([]RunstatusPage, error) {
|
||||
resp, err := client.runstatusRequest(ctx, client.Endpoint+runstatusPagesURL, nil, "GET")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var p *RunstatusPageList
|
||||
if err := json.Unmarshal(resp, &p); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return p.Pages, nil
|
||||
}
|
||||
|
||||
//PaginateRunstatusPages paginate on runstatus pages
|
||||
func (client *Client) PaginateRunstatusPages(ctx context.Context, callback func(pages []RunstatusPage, e error) bool) {
|
||||
pageURL := client.Endpoint + runstatusPagesURL
|
||||
for pageURL != "" {
|
||||
resp, err := client.runstatusRequest(ctx, pageURL, nil, "GET")
|
||||
if err != nil {
|
||||
callback(nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
var p *RunstatusPageList
|
||||
if err := json.Unmarshal(resp, &p); err != nil {
|
||||
callback(nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
if ok := callback(p.Pages, nil); ok {
|
||||
return
|
||||
}
|
||||
|
||||
pageURL = p.Next
|
||||
}
|
||||
}
|
201
vendor/github.com/exoscale/egoscale/runstatus_service.go
generated
vendored
Normal file
201
vendor/github.com/exoscale/egoscale/runstatus_service.go
generated
vendored
Normal file
@ -0,0 +1,201 @@
|
||||
package egoscale
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/url"
|
||||
"path"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// RunstatusService is a runstatus service
|
||||
type RunstatusService struct {
|
||||
ID int `json:"id"` // missing field
|
||||
Name string `json:"name"`
|
||||
PageURL string `json:"page_url,omitempty"` // fake field
|
||||
State string `json:"state,omitempty"`
|
||||
URL string `json:"url,omitempty"`
|
||||
}
|
||||
|
||||
// FakeID fills up the ID field as it's currently missing
|
||||
func (service *RunstatusService) FakeID() error {
|
||||
if service.ID > 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
if service.URL == "" {
|
||||
return fmt.Errorf("empty URL for %#v", service)
|
||||
}
|
||||
|
||||
u, err := url.Parse(service.URL)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
s := path.Base(u.Path)
|
||||
id, err := strconv.Atoi(s)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
service.ID = id
|
||||
return nil
|
||||
}
|
||||
|
||||
// Match returns true if the other service has got similarities with itself
|
||||
func (service RunstatusService) Match(other RunstatusService) bool {
|
||||
if other.Name != "" && service.Name == other.Name {
|
||||
return true
|
||||
}
|
||||
|
||||
if other.ID > 0 && service.ID == other.ID {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// RunstatusServiceList service list
|
||||
type RunstatusServiceList struct {
|
||||
Next string `json:"next"`
|
||||
Previous string `json:"previous"`
|
||||
Services []RunstatusService `json:"results"`
|
||||
}
|
||||
|
||||
// DeleteRunstatusService delete runstatus service
|
||||
func (client *Client) DeleteRunstatusService(ctx context.Context, service RunstatusService) error {
|
||||
if service.URL == "" {
|
||||
return fmt.Errorf("empty URL for %#v", service)
|
||||
}
|
||||
|
||||
_, err := client.runstatusRequest(ctx, service.URL, nil, "DELETE")
|
||||
return err
|
||||
}
|
||||
|
||||
// CreateRunstatusService create runstatus service
|
||||
func (client *Client) CreateRunstatusService(ctx context.Context, service RunstatusService) (*RunstatusService, error) {
|
||||
if service.PageURL == "" {
|
||||
return nil, fmt.Errorf("empty Page URL for %#v", service)
|
||||
}
|
||||
|
||||
page, err := client.GetRunstatusPage(ctx, RunstatusPage{URL: service.PageURL})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
resp, err := client.runstatusRequest(ctx, page.ServicesURL, service, "POST")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
s := &RunstatusService{}
|
||||
if err := json.Unmarshal(resp, s); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return s, nil
|
||||
}
|
||||
|
||||
// GetRunstatusService displays service detail.
|
||||
func (client *Client) GetRunstatusService(ctx context.Context, service RunstatusService) (*RunstatusService, error) {
|
||||
if service.URL != "" {
|
||||
return client.getRunstatusService(ctx, service.URL)
|
||||
}
|
||||
|
||||
if service.PageURL == "" {
|
||||
return nil, fmt.Errorf("empty Page URL in %#v", service)
|
||||
}
|
||||
|
||||
page, err := client.getRunstatusPage(ctx, service.PageURL)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for i := range page.Services {
|
||||
s := &page.Services[i]
|
||||
if s.Match(service) {
|
||||
if err := s.FakeID(); err != nil {
|
||||
log.Printf("bad fake ID for %#v, %s", s, err)
|
||||
}
|
||||
return s, nil
|
||||
}
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("%#v not found", service)
|
||||
}
|
||||
|
||||
func (client *Client) getRunstatusService(ctx context.Context, serviceURL string) (*RunstatusService, error) {
|
||||
resp, err := client.runstatusRequest(ctx, serviceURL, nil, "GET")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
s := &RunstatusService{}
|
||||
if err := json.Unmarshal(resp, &s); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := s.FakeID(); err != nil {
|
||||
log.Printf("bad fake ID for %#v, %s", s, err)
|
||||
}
|
||||
|
||||
return s, nil
|
||||
}
|
||||
|
||||
// ListRunstatusServices displays the list of services.
|
||||
func (client *Client) ListRunstatusServices(ctx context.Context, page RunstatusPage) ([]RunstatusService, error) {
|
||||
if page.ServicesURL == "" {
|
||||
return nil, fmt.Errorf("empty Services URL for %#v", page)
|
||||
}
|
||||
|
||||
results := make([]RunstatusService, 0)
|
||||
|
||||
var err error
|
||||
client.PaginateRunstatusServices(ctx, page, func(service *RunstatusService, e error) bool {
|
||||
if e != nil {
|
||||
err = e
|
||||
return false
|
||||
}
|
||||
|
||||
results = append(results, *service)
|
||||
return true
|
||||
})
|
||||
|
||||
return results, err
|
||||
}
|
||||
|
||||
// PaginateRunstatusServices paginates Services
|
||||
func (client *Client) PaginateRunstatusServices(ctx context.Context, page RunstatusPage, callback func(*RunstatusService, error) bool) { // nolint: dupl
|
||||
if page.ServicesURL == "" {
|
||||
callback(nil, fmt.Errorf("empty Services URL for %#v", page))
|
||||
return
|
||||
}
|
||||
|
||||
servicesURL := page.ServicesURL
|
||||
for servicesURL != "" {
|
||||
resp, err := client.runstatusRequest(ctx, servicesURL, nil, "GET")
|
||||
if err != nil {
|
||||
callback(nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
var ss *RunstatusServiceList
|
||||
if err := json.Unmarshal(resp, &ss); err != nil {
|
||||
callback(nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
for i := range ss.Services {
|
||||
if err := ss.Services[i].FakeID(); err != nil {
|
||||
log.Printf("bad fake ID for %#v, %s", ss.Services[i], err)
|
||||
}
|
||||
|
||||
if cont := callback(&ss.Services[i], nil); !cont {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
servicesURL = ss.Next
|
||||
}
|
||||
}
|
152
vendor/github.com/exoscale/egoscale/security_groups.go
generated
vendored
152
vendor/github.com/exoscale/egoscale/security_groups.go
generated
vendored
@ -12,34 +12,22 @@ import (
|
||||
type SecurityGroup struct {
|
||||
Account string `json:"account,omitempty" doc:"the account owning the security group"`
|
||||
Description string `json:"description,omitempty" doc:"the description of the security group"`
|
||||
Domain string `json:"domain,omitempty" doc:"the domain name of the security group"`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"the domain ID of the security group"`
|
||||
EgressRule []EgressRule `json:"egressrule,omitempty" doc:"the list of egress rules associated with the security group"`
|
||||
ID *UUID `json:"id,omitempty" doc:"the ID of the security group"`
|
||||
ID *UUID `json:"id" doc:"the ID of the security group"`
|
||||
IngressRule []IngressRule `json:"ingressrule,omitempty" doc:"the list of ingress rules associated with the security group"`
|
||||
Name string `json:"name,omitempty" doc:"the name of the security group"`
|
||||
Tags []ResourceTag `json:"tags,omitempty" doc:"the list of resource tags associated with the rule"`
|
||||
}
|
||||
|
||||
// ResourceType returns the type of the resource
|
||||
func (SecurityGroup) ResourceType() string {
|
||||
return "SecurityGroup"
|
||||
}
|
||||
|
||||
// UserSecurityGroup converts a SecurityGroup to a UserSecurityGroup
|
||||
func (sg SecurityGroup) UserSecurityGroup() UserSecurityGroup {
|
||||
return UserSecurityGroup{
|
||||
Account: sg.Account,
|
||||
Group: sg.Name,
|
||||
Group: sg.Name,
|
||||
}
|
||||
}
|
||||
|
||||
// ListRequest builds the ListSecurityGroups request
|
||||
func (sg SecurityGroup) ListRequest() (ListCommand, error) {
|
||||
//TODO add tags
|
||||
req := &ListSecurityGroups{
|
||||
Account: sg.Account,
|
||||
DomainID: sg.DomainID,
|
||||
ID: sg.ID,
|
||||
SecurityGroupName: sg.Name,
|
||||
}
|
||||
@ -53,10 +41,7 @@ func (sg SecurityGroup) Delete(ctx context.Context, client *Client) error {
|
||||
return fmt.Errorf("a SecurityGroup may only be deleted using ID or Name")
|
||||
}
|
||||
|
||||
req := &DeleteSecurityGroup{
|
||||
Account: sg.Account,
|
||||
DomainID: sg.DomainID,
|
||||
}
|
||||
req := &DeleteSecurityGroup{}
|
||||
|
||||
if sg.ID != nil {
|
||||
req.ID = sg.ID
|
||||
@ -86,19 +71,15 @@ func (sg SecurityGroup) RuleByID(ruleID UUID) (*IngressRule, *EgressRule) {
|
||||
|
||||
// IngressRule represents the ingress rule
|
||||
type IngressRule struct {
|
||||
Account string `json:"account,omitempty" doc:"account owning the security group rule"`
|
||||
CIDR *CIDR `json:"cidr,omitempty" doc:"the CIDR notation for the base IP address of the security group rule"`
|
||||
Description string `json:"description,omitempty" doc:"description of the security group rule"`
|
||||
EndPort uint16 `json:"endport,omitempty" doc:"the ending port of the security group rule "`
|
||||
IcmpCode uint8 `json:"icmpcode,omitempty" doc:"the code for the ICMP message response"`
|
||||
IcmpType uint8 `json:"icmptype,omitempty" doc:"the type of the ICMP message response"`
|
||||
Protocol string `json:"protocol,omitempty" doc:"the protocol of the security group rule"`
|
||||
RuleID *UUID `json:"ruleid,omitempty" doc:"the id of the security group rule"`
|
||||
SecurityGroupID *UUID `json:"securitygroupid,omitempty"`
|
||||
SecurityGroupName string `json:"securitygroupname,omitempty" doc:"security group name"`
|
||||
StartPort uint16 `json:"startport,omitempty" doc:"the starting port of the security group rule"`
|
||||
Tags []ResourceTag `json:"tags,omitempty" doc:"the list of resource tags associated with the rule"`
|
||||
UserSecurityGroupList []UserSecurityGroup `json:"usersecuritygrouplist,omitempty"`
|
||||
CIDR *CIDR `json:"cidr,omitempty" doc:"the CIDR notation for the base IP address of the security group rule"`
|
||||
Description string `json:"description,omitempty" doc:"description of the security group rule"`
|
||||
EndPort uint16 `json:"endport,omitempty" doc:"the ending port of the security group rule "`
|
||||
IcmpCode uint8 `json:"icmpcode,omitempty" doc:"the code for the ICMP message response"`
|
||||
IcmpType uint8 `json:"icmptype,omitempty" doc:"the type of the ICMP message response"`
|
||||
Protocol string `json:"protocol,omitempty" doc:"the protocol of the security group rule"`
|
||||
RuleID *UUID `json:"ruleid" doc:"the id of the security group rule"`
|
||||
SecurityGroupName string `json:"securitygroupname,omitempty" doc:"security group name"`
|
||||
StartPort uint16 `json:"startport,omitempty" doc:"the starting port of the security group rule"`
|
||||
}
|
||||
|
||||
// EgressRule represents the ingress rule
|
||||
@ -106,8 +87,7 @@ type EgressRule IngressRule
|
||||
|
||||
// UserSecurityGroup represents the traffic of another security group
|
||||
type UserSecurityGroup struct {
|
||||
Group string `json:"group,omitempty"`
|
||||
Account string `json:"account,omitempty"`
|
||||
Group string `json:"group,omitempty"`
|
||||
}
|
||||
|
||||
// String gives the UserSecurityGroup name
|
||||
@ -118,51 +98,49 @@ func (usg UserSecurityGroup) String() string {
|
||||
// CreateSecurityGroup represents a security group creation
|
||||
type CreateSecurityGroup struct {
|
||||
Name string `json:"name" doc:"name of the security group"`
|
||||
Account string `json:"account,omitempty" doc:"an optional account for the security group. Must be used with domainId."`
|
||||
Description string `json:"description,omitempty" doc:"the description of the security group"`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"an optional domainId for the security group. If the account parameter is used, domainId must also be used."`
|
||||
_ bool `name:"createSecurityGroup" description:"Creates a security group"`
|
||||
}
|
||||
|
||||
func (CreateSecurityGroup) response() interface{} {
|
||||
// Response returns the struct to unmarshal
|
||||
func (CreateSecurityGroup) Response() interface{} {
|
||||
return new(SecurityGroup)
|
||||
}
|
||||
|
||||
// DeleteSecurityGroup represents a security group deletion
|
||||
type DeleteSecurityGroup struct {
|
||||
Account string `json:"account,omitempty" doc:"the account of the security group. Must be specified with domain ID"`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"the domain ID of account owning the security group"`
|
||||
ID *UUID `json:"id,omitempty" doc:"The ID of the security group. Mutually exclusive with name parameter"`
|
||||
Name string `json:"name,omitempty" doc:"The ID of the security group. Mutually exclusive with id parameter"`
|
||||
_ bool `name:"deleteSecurityGroup" description:"Deletes security group"`
|
||||
ID *UUID `json:"id,omitempty" doc:"The ID of the security group. Mutually exclusive with name parameter"`
|
||||
Name string `json:"name,omitempty" doc:"The ID of the security group. Mutually exclusive with id parameter"`
|
||||
_ bool `name:"deleteSecurityGroup" description:"Deletes security group"`
|
||||
}
|
||||
|
||||
func (DeleteSecurityGroup) response() interface{} {
|
||||
return new(booleanResponse)
|
||||
// Response returns the struct to unmarshal
|
||||
func (DeleteSecurityGroup) Response() interface{} {
|
||||
return new(BooleanResponse)
|
||||
}
|
||||
|
||||
// AuthorizeSecurityGroupIngress (Async) represents the ingress rule creation
|
||||
type AuthorizeSecurityGroupIngress struct {
|
||||
Account string `json:"account,omitempty" doc:"an optional account for the security group. Must be used with domainId."`
|
||||
CIDRList []CIDR `json:"cidrlist,omitempty" doc:"the cidr list associated"`
|
||||
Description string `json:"description,omitempty" doc:"the description of the ingress/egress rule"`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"an optional domainid for the security group. If the account parameter is used, domainid must also be used."`
|
||||
EndPort uint16 `json:"endport,omitempty" doc:"end port for this ingress rule"`
|
||||
EndPort uint16 `json:"endport,omitempty" doc:"end port for this ingress/egress rule"`
|
||||
IcmpCode uint8 `json:"icmpcode,omitempty" doc:"error code for this icmp message"`
|
||||
IcmpType uint8 `json:"icmptype,omitempty" doc:"type of the icmp message being sent"`
|
||||
Protocol string `json:"protocol,omitempty" doc:"TCP is default. UDP, ICMP, ICMPv6, AH, ESP, GRE are the other supported protocols"`
|
||||
Protocol string `json:"protocol,omitempty" doc:"TCP is default. UDP, ICMP, ICMPv6, AH, ESP, GRE, IPIP are the other supported protocols"`
|
||||
SecurityGroupID *UUID `json:"securitygroupid,omitempty" doc:"The ID of the security group. Mutually exclusive with securitygroupname parameter"`
|
||||
SecurityGroupName string `json:"securitygroupname,omitempty" doc:"The name of the security group. Mutually exclusive with securitygroupid parameter"`
|
||||
StartPort uint16 `json:"startport,omitempty" doc:"start port for this ingress rule"`
|
||||
StartPort uint16 `json:"startport,omitempty" doc:"start port for this ingress/egress rule"`
|
||||
UserSecurityGroupList []UserSecurityGroup `json:"usersecuritygrouplist,omitempty" doc:"user to security group mapping"`
|
||||
_ bool `name:"authorizeSecurityGroupIngress" description:"Authorizes a particular ingress/egress rule for this security group"`
|
||||
_ bool `name:"authorizeSecurityGroupIngress" description:"Authorize a particular ingress/egress rule for this security group"`
|
||||
}
|
||||
|
||||
func (AuthorizeSecurityGroupIngress) response() interface{} {
|
||||
// Response returns the struct to unmarshal
|
||||
func (AuthorizeSecurityGroupIngress) Response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (AuthorizeSecurityGroupIngress) asyncResponse() interface{} {
|
||||
// AsyncResponse returns the struct to unmarshal the async job
|
||||
func (AuthorizeSecurityGroupIngress) AsyncResponse() interface{} {
|
||||
return new(SecurityGroup)
|
||||
}
|
||||
|
||||
@ -182,11 +160,13 @@ func (req AuthorizeSecurityGroupIngress) onBeforeSend(params url.Values) error {
|
||||
// AuthorizeSecurityGroupEgress (Async) represents the egress rule creation
|
||||
type AuthorizeSecurityGroupEgress AuthorizeSecurityGroupIngress
|
||||
|
||||
func (AuthorizeSecurityGroupEgress) response() interface{} {
|
||||
// Response returns the struct to unmarshal
|
||||
func (AuthorizeSecurityGroupEgress) Response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (AuthorizeSecurityGroupEgress) asyncResponse() interface{} {
|
||||
// AsyncResponse returns the struct to unmarshal the async job
|
||||
func (AuthorizeSecurityGroupEgress) AsyncResponse() interface{} {
|
||||
return new(SecurityGroup)
|
||||
}
|
||||
|
||||
@ -200,11 +180,14 @@ type RevokeSecurityGroupIngress struct {
|
||||
_ bool `name:"revokeSecurityGroupIngress" description:"Deletes a particular ingress rule from this security group"`
|
||||
}
|
||||
|
||||
func (RevokeSecurityGroupIngress) response() interface{} {
|
||||
// Response returns the struct to unmarshal
|
||||
func (RevokeSecurityGroupIngress) Response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
func (RevokeSecurityGroupIngress) asyncResponse() interface{} {
|
||||
return new(booleanResponse)
|
||||
|
||||
// AsyncResponse returns the struct to unmarshal the async job
|
||||
func (RevokeSecurityGroupIngress) AsyncResponse() interface{} {
|
||||
return new(BooleanResponse)
|
||||
}
|
||||
|
||||
// RevokeSecurityGroupEgress (Async) represents the ingress/egress rule deletion
|
||||
@ -213,28 +196,27 @@ type RevokeSecurityGroupEgress struct {
|
||||
_ bool `name:"revokeSecurityGroupEgress" description:"Deletes a particular egress rule from this security group"`
|
||||
}
|
||||
|
||||
func (RevokeSecurityGroupEgress) response() interface{} {
|
||||
// Response returns the struct to unmarshal
|
||||
func (RevokeSecurityGroupEgress) Response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (RevokeSecurityGroupEgress) asyncResponse() interface{} {
|
||||
return new(booleanResponse)
|
||||
// AsyncResponse returns the struct to unmarshal the async job
|
||||
func (RevokeSecurityGroupEgress) AsyncResponse() interface{} {
|
||||
return new(BooleanResponse)
|
||||
}
|
||||
|
||||
//go:generate go run generate/main.go -interface=Listable ListSecurityGroups
|
||||
|
||||
// ListSecurityGroups represents a search for security groups
|
||||
type ListSecurityGroups struct {
|
||||
Account string `json:"account,omitempty" doc:"list resources by account. Must be used with the domainId parameter."`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"list only resources belonging to the domain specified"`
|
||||
ID *UUID `json:"id,omitempty" doc:"list the security group by the id provided"`
|
||||
IsRecursive *bool `json:"isrecursive,omitempty" doc:"defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves."`
|
||||
Keyword string `json:"keyword,omitempty" doc:"List by keyword"`
|
||||
ListAll *bool `json:"listall,omitempty" doc:"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"`
|
||||
Page int `json:"page,omitempty"`
|
||||
PageSize int `json:"pagesize,omitempty"`
|
||||
SecurityGroupName string `json:"securitygroupname,omitempty" doc:"lists security groups by name"`
|
||||
Tags []ResourceTag `json:"tags,omitempty" doc:"List resources by tags (key/value pairs)"`
|
||||
VirtualMachineID *UUID `json:"virtualmachineid,omitempty" doc:"lists security groups by virtual machine id"`
|
||||
_ bool `name:"listSecurityGroups" description:"Lists security groups"`
|
||||
ID *UUID `json:"id,omitempty" doc:"list the security group by the id provided"`
|
||||
Keyword string `json:"keyword,omitempty" doc:"List by keyword"`
|
||||
Page int `json:"page,omitempty"`
|
||||
PageSize int `json:"pagesize,omitempty"`
|
||||
SecurityGroupName string `json:"securitygroupname,omitempty" doc:"lists security groups by name"`
|
||||
VirtualMachineID *UUID `json:"virtualmachineid,omitempty" doc:"lists security groups by virtual machine id"`
|
||||
_ bool `name:"listSecurityGroups" description:"Lists security groups"`
|
||||
}
|
||||
|
||||
// ListSecurityGroupsResponse represents a list of security groups
|
||||
@ -242,31 +224,3 @@ type ListSecurityGroupsResponse struct {
|
||||
Count int `json:"count"`
|
||||
SecurityGroup []SecurityGroup `json:"securitygroup"`
|
||||
}
|
||||
|
||||
func (ListSecurityGroups) response() interface{} {
|
||||
return new(ListSecurityGroupsResponse)
|
||||
}
|
||||
|
||||
// SetPage sets the current page
|
||||
func (lsg *ListSecurityGroups) SetPage(page int) {
|
||||
lsg.Page = page
|
||||
}
|
||||
|
||||
// SetPageSize sets the page size
|
||||
func (lsg *ListSecurityGroups) SetPageSize(pageSize int) {
|
||||
lsg.PageSize = pageSize
|
||||
}
|
||||
|
||||
func (ListSecurityGroups) each(resp interface{}, callback IterateItemFunc) {
|
||||
sgs, ok := resp.(*ListSecurityGroupsResponse)
|
||||
if !ok {
|
||||
callback(nil, fmt.Errorf("wrong type. ListSecurityGroupsResponse expected, got %T", resp))
|
||||
return
|
||||
}
|
||||
|
||||
for i := range sgs.SecurityGroup {
|
||||
if !callback(&sgs.SecurityGroup[i], nil) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
43
vendor/github.com/exoscale/egoscale/securitygroups_response.go
generated
vendored
Normal file
43
vendor/github.com/exoscale/egoscale/securitygroups_response.go
generated
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
// code generated; DO NOT EDIT.
|
||||
|
||||
package egoscale
|
||||
|
||||
import "fmt"
|
||||
|
||||
// Response returns the struct to unmarshal
|
||||
func (ListSecurityGroups) Response() interface{} {
|
||||
return new(ListSecurityGroupsResponse)
|
||||
}
|
||||
|
||||
// ListRequest returns itself
|
||||
func (ls *ListSecurityGroups) ListRequest() (ListCommand, error) {
|
||||
if ls == nil {
|
||||
return nil, fmt.Errorf("%T cannot be nil", ls)
|
||||
}
|
||||
return ls, nil
|
||||
}
|
||||
|
||||
// SetPage sets the current apge
|
||||
func (ls *ListSecurityGroups) SetPage(page int) {
|
||||
ls.Page = page
|
||||
}
|
||||
|
||||
// SetPageSize sets the page size
|
||||
func (ls *ListSecurityGroups) SetPageSize(pageSize int) {
|
||||
ls.PageSize = pageSize
|
||||
}
|
||||
|
||||
// Each triggers the callback for each, valid answer or any non 404 issue
|
||||
func (ListSecurityGroups) Each(resp interface{}, callback IterateItemFunc) {
|
||||
items, ok := resp.(*ListSecurityGroupsResponse)
|
||||
if !ok {
|
||||
callback(nil, fmt.Errorf("wrong type, ListSecurityGroupsResponse was expected, got %T", resp))
|
||||
return
|
||||
}
|
||||
|
||||
for i := range items.SecurityGroup {
|
||||
if !callback(&items.SecurityGroup[i], nil) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
438
vendor/github.com/exoscale/egoscale/serialization.go
generated
vendored
438
vendor/github.com/exoscale/egoscale/serialization.go
generated
vendored
@ -54,7 +54,9 @@ func info(command interface{}) (*CommandInfo, error) {
|
||||
// prepareValues uses a command to build a POST request
|
||||
//
|
||||
// command is not a Command so it's easier to Test
|
||||
func prepareValues(prefix string, params url.Values, command interface{}) error {
|
||||
func prepareValues(prefix string, command interface{}) (url.Values, error) {
|
||||
params := url.Values{}
|
||||
|
||||
value := reflect.ValueOf(command)
|
||||
typeof := reflect.TypeOf(command)
|
||||
|
||||
@ -66,7 +68,7 @@ func prepareValues(prefix string, params url.Values, command interface{}) error
|
||||
|
||||
// Checking for nil commands
|
||||
if !value.IsValid() {
|
||||
return fmt.Errorf("cannot serialize the invalid value %#v", command)
|
||||
return nil, fmt.Errorf("cannot serialize the invalid value %#v", command)
|
||||
}
|
||||
|
||||
for i := 0; i < typeof.NumField(); i++ {
|
||||
@ -77,217 +79,165 @@ func prepareValues(prefix string, params url.Values, command interface{}) error
|
||||
|
||||
val := value.Field(i)
|
||||
tag := field.Tag
|
||||
|
||||
var err error
|
||||
var name string
|
||||
var value interface{}
|
||||
|
||||
if json, ok := tag.Lookup("json"); ok {
|
||||
n, required := ExtractJSONTag(field.Name, json)
|
||||
name := prefix + n
|
||||
name = prefix + n
|
||||
|
||||
switch val.Kind() {
|
||||
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
|
||||
v := val.Int()
|
||||
if v == 0 {
|
||||
if required {
|
||||
return fmt.Errorf("%s.%s (%v) is required, got 0", typeof.Name(), n, val.Kind())
|
||||
}
|
||||
} else {
|
||||
params.Set(name, strconv.FormatInt(v, 10))
|
||||
}
|
||||
value, err = prepareInt(val.Int(), required)
|
||||
|
||||
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
|
||||
v := val.Uint()
|
||||
if v == 0 {
|
||||
if required {
|
||||
return fmt.Errorf("%s.%s (%v) is required, got 0", typeof.Name(), n, val.Kind())
|
||||
}
|
||||
} else {
|
||||
params.Set(name, strconv.FormatUint(v, 10))
|
||||
}
|
||||
value, err = prepareUint(val.Uint(), required)
|
||||
|
||||
case reflect.Float32, reflect.Float64:
|
||||
v := val.Float()
|
||||
if v == 0 {
|
||||
if required {
|
||||
return fmt.Errorf("%s.%s (%v) is required, got 0", typeof.Name(), n, val.Kind())
|
||||
}
|
||||
} else {
|
||||
params.Set(name, strconv.FormatFloat(v, 'f', -1, 64))
|
||||
}
|
||||
value, err = prepareFloat(val.Float(), required)
|
||||
|
||||
case reflect.String:
|
||||
v := val.String()
|
||||
if v == "" {
|
||||
if required {
|
||||
return fmt.Errorf("%s.%s (%v) is required, got \"\"", typeof.Name(), n, val.Kind())
|
||||
}
|
||||
} else {
|
||||
params.Set(name, v)
|
||||
}
|
||||
value, err = prepareString(val.String(), required)
|
||||
|
||||
case reflect.Bool:
|
||||
v := val.Bool()
|
||||
if !v {
|
||||
if required {
|
||||
params.Set(name, "false")
|
||||
}
|
||||
} else {
|
||||
params.Set(name, "true")
|
||||
}
|
||||
case reflect.Ptr:
|
||||
if val.IsNil() {
|
||||
if required {
|
||||
return fmt.Errorf("%s.%s (%v) is required, got empty ptr", typeof.Name(), n, val.Kind())
|
||||
}
|
||||
} else {
|
||||
switch field.Type.Elem().Kind() {
|
||||
case reflect.Bool:
|
||||
params.Set(name, strconv.FormatBool(val.Elem().Bool()))
|
||||
case reflect.Struct:
|
||||
i := val.Interface()
|
||||
s, ok := i.(fmt.Stringer)
|
||||
if !ok {
|
||||
return fmt.Errorf("%s.%s (%v) is not a Stringer", typeof.Name(), field.Name, val.Kind())
|
||||
}
|
||||
if s != nil && s.String() == "" {
|
||||
if required {
|
||||
return fmt.Errorf("%s.%s (%v) is required, got empty value", typeof.Name(), field.Name, val.Kind())
|
||||
}
|
||||
} else {
|
||||
params.Set(n, s.String())
|
||||
}
|
||||
default:
|
||||
log.Printf("[SKIP] %s.%s (%v) not supported", typeof.Name(), n, field.Type.Elem().Kind())
|
||||
}
|
||||
}
|
||||
case reflect.Slice:
|
||||
switch field.Type.Elem().Kind() {
|
||||
case reflect.Uint8:
|
||||
switch field.Type {
|
||||
case reflect.TypeOf(net.IPv4zero):
|
||||
ip := (net.IP)(val.Bytes())
|
||||
if ip == nil || ip.Equal(net.IPv4zero) {
|
||||
if required {
|
||||
return fmt.Errorf("%s.%s (%v) is required, got zero IPv4 address", typeof.Name(), n, val.Kind())
|
||||
}
|
||||
} else {
|
||||
params.Set(name, ip.String())
|
||||
}
|
||||
case reflect.TypeOf(MAC48(0, 0, 0, 0, 0, 0)):
|
||||
mac := val.Interface().(MACAddress)
|
||||
s := mac.String()
|
||||
if s == "" {
|
||||
if required {
|
||||
return fmt.Errorf("%s.%s (%v) is required, got empty MAC address", typeof.Name(), field.Name, val.Kind())
|
||||
}
|
||||
} else {
|
||||
params.Set(name, s)
|
||||
}
|
||||
default:
|
||||
if val.Len() == 0 {
|
||||
if required {
|
||||
return fmt.Errorf("%s.%s (%v) is required, got empty slice", typeof.Name(), n, val.Kind())
|
||||
}
|
||||
} else {
|
||||
v := val.Bytes()
|
||||
params.Set(name, base64.StdEncoding.EncodeToString(v))
|
||||
}
|
||||
}
|
||||
case reflect.String:
|
||||
if val.Len() == 0 {
|
||||
if required {
|
||||
return fmt.Errorf("%s.%s (%v) is required, got empty slice", typeof.Name(), n, val.Kind())
|
||||
}
|
||||
} else {
|
||||
elems := make([]string, 0, val.Len())
|
||||
for i := 0; i < val.Len(); i++ {
|
||||
// XXX what if the value contains a comma? Double encode?
|
||||
s := val.Index(i).String()
|
||||
elems = append(elems, s)
|
||||
}
|
||||
params.Set(name, strings.Join(elems, ","))
|
||||
}
|
||||
default:
|
||||
switch field.Type.Elem() {
|
||||
case reflect.TypeOf(CIDR{}), reflect.TypeOf(UUID{}):
|
||||
if val.Len() == 0 {
|
||||
if required {
|
||||
return fmt.Errorf("%s.%s (%v) is required, got empty slice", typeof.Name(), n, val.Kind())
|
||||
}
|
||||
} else {
|
||||
value := reflect.ValueOf(val.Interface())
|
||||
ss := make([]string, val.Len())
|
||||
for i := 0; i < value.Len(); i++ {
|
||||
v := value.Index(i).Interface()
|
||||
s, ok := v.(fmt.Stringer)
|
||||
if !ok {
|
||||
return fmt.Errorf("not a String, %T", v)
|
||||
}
|
||||
ss[i] = s.String()
|
||||
}
|
||||
params.Set(name, strings.Join(ss, ","))
|
||||
}
|
||||
default:
|
||||
if val.Len() == 0 {
|
||||
if required {
|
||||
return fmt.Errorf("%s.%s (%v) is required, got empty slice", typeof.Name(), n, val.Kind())
|
||||
}
|
||||
} else {
|
||||
err := prepareList(name, params, val.Interface())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
value, err = prepareBool(val.Bool(), required)
|
||||
|
||||
case reflect.Map:
|
||||
if val.Len() == 0 {
|
||||
if required {
|
||||
return fmt.Errorf("%s.%s (%v) is required, got empty map", typeof.Name(), field.Name, val.Kind())
|
||||
err = fmt.Errorf("field is required, got empty map")
|
||||
}
|
||||
} else {
|
||||
err := prepareMap(name, params, val.Interface())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
value, err = prepareMap(name, val.Interface())
|
||||
}
|
||||
|
||||
case reflect.Ptr:
|
||||
value, err = preparePtr(field.Type.Elem().Kind(), val, required)
|
||||
|
||||
case reflect.Slice:
|
||||
value, err = prepareSlice(name, field.Type, val, required)
|
||||
|
||||
case reflect.Struct:
|
||||
i := val.Interface()
|
||||
s, ok := i.(fmt.Stringer)
|
||||
if !ok {
|
||||
return fmt.Errorf("%s.%s (%v) is not a Stringer", typeof.Name(), field.Name, val.Kind())
|
||||
}
|
||||
if s != nil && s.String() == "" {
|
||||
if required {
|
||||
return fmt.Errorf("%s.%s (%v) is required, got empty value", typeof.Name(), field.Name, val.Kind())
|
||||
}
|
||||
} else {
|
||||
params.Set(n, s.String())
|
||||
}
|
||||
value, err = prepareStruct(val.Interface(), required)
|
||||
|
||||
default:
|
||||
if required {
|
||||
return fmt.Errorf("unsupported type %s.%s (%v)", typeof.Name(), n, val.Kind())
|
||||
err = fmt.Errorf("unsupported type")
|
||||
}
|
||||
fmt.Printf("%s\n", val.Kind())
|
||||
}
|
||||
} else {
|
||||
log.Printf("[SKIP] %s.%s no json label found", typeof.Name(), field.Name)
|
||||
switch val.Kind() {
|
||||
case reflect.Struct:
|
||||
value, err = prepareEmbedStruct(val.Interface())
|
||||
default:
|
||||
log.Printf("[SKIP] %s.%s no json label found", typeof.Name(), field.Name)
|
||||
}
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("%s.%s (%v) %s", typeof.Name(), field.Name, val.Kind(), err)
|
||||
}
|
||||
|
||||
switch v := value.(type) {
|
||||
case *string:
|
||||
if name != "" && v != nil {
|
||||
params.Set(name, *v)
|
||||
}
|
||||
case url.Values:
|
||||
for k, xs := range v {
|
||||
for _, x := range xs {
|
||||
params.Add(k, x)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
return params, nil
|
||||
}
|
||||
|
||||
func prepareList(prefix string, params url.Values, slice interface{}) error {
|
||||
func prepareInt(v int64, required bool) (*string, error) {
|
||||
if v == 0 {
|
||||
if required {
|
||||
return nil, fmt.Errorf("field is required, got %d", v)
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
value := strconv.FormatInt(v, 10)
|
||||
return &value, nil
|
||||
}
|
||||
|
||||
func prepareUint(v uint64, required bool) (*string, error) {
|
||||
if v == 0 {
|
||||
if required {
|
||||
return nil, fmt.Errorf("field is required, got %d", v)
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
value := strconv.FormatUint(v, 10)
|
||||
return &value, nil
|
||||
}
|
||||
|
||||
func prepareFloat(v float64, required bool) (*string, error) {
|
||||
if v == 0 {
|
||||
if required {
|
||||
return nil, fmt.Errorf("field is required, got %f", v)
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
value := strconv.FormatFloat(v, 'f', -1, 64)
|
||||
return &value, nil
|
||||
}
|
||||
|
||||
func prepareString(v string, required bool) (*string, error) {
|
||||
if v == "" {
|
||||
if required {
|
||||
return nil, fmt.Errorf("field is required, got %q", v)
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
return &v, nil
|
||||
}
|
||||
|
||||
func prepareBool(v bool, required bool) (*string, error) {
|
||||
value := strconv.FormatBool(v)
|
||||
if !v {
|
||||
if required {
|
||||
return &value, nil
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
return &value, nil
|
||||
}
|
||||
|
||||
func prepareList(prefix string, slice interface{}) (url.Values, error) {
|
||||
params := url.Values{}
|
||||
value := reflect.ValueOf(slice)
|
||||
|
||||
for i := 0; i < value.Len(); i++ {
|
||||
err := prepareValues(fmt.Sprintf("%s[%d].", prefix, i), params, value.Index(i).Interface())
|
||||
ps, err := prepareValues(fmt.Sprintf("%s[%d].", prefix, i), value.Index(i).Interface())
|
||||
if err != nil {
|
||||
return err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for k, xs := range ps {
|
||||
for _, x := range xs {
|
||||
params.Add(k, x)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
return params, nil
|
||||
}
|
||||
|
||||
func prepareMap(prefix string, params url.Values, m interface{}) error {
|
||||
value := reflect.ValueOf(m)
|
||||
func prepareMap(prefix string, m interface{}) (url.Values, error) {
|
||||
value := url.Values{}
|
||||
v := reflect.ValueOf(m)
|
||||
|
||||
for i, key := range value.MapKeys() {
|
||||
for i, key := range v.MapKeys() {
|
||||
var keyName string
|
||||
var keyValue string
|
||||
|
||||
@ -295,19 +245,143 @@ func prepareMap(prefix string, params url.Values, m interface{}) error {
|
||||
case reflect.String:
|
||||
keyName = key.String()
|
||||
default:
|
||||
return fmt.Errorf("only map[string]string are supported (XXX)")
|
||||
return value, fmt.Errorf("only map[string]string are supported (XXX)")
|
||||
}
|
||||
|
||||
val := value.MapIndex(key)
|
||||
val := v.MapIndex(key)
|
||||
switch val.Kind() {
|
||||
case reflect.String:
|
||||
keyValue = val.String()
|
||||
default:
|
||||
return fmt.Errorf("only map[string]string are supported (XXX)")
|
||||
return value, fmt.Errorf("only map[string]string are supported (XXX)")
|
||||
}
|
||||
params.Set(fmt.Sprintf("%s[%d].%s", prefix, i, keyName), keyValue)
|
||||
|
||||
value.Set(fmt.Sprintf("%s[%d].%s", prefix, i, keyName), keyValue)
|
||||
}
|
||||
return nil
|
||||
|
||||
return value, nil
|
||||
}
|
||||
|
||||
func preparePtr(kind reflect.Kind, val reflect.Value, required bool) (*string, error) {
|
||||
if val.IsNil() {
|
||||
if required {
|
||||
return nil, fmt.Errorf("field is required, got empty ptr")
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
switch kind {
|
||||
case reflect.Bool:
|
||||
return prepareBool(val.Elem().Bool(), true)
|
||||
case reflect.Struct:
|
||||
return prepareStruct(val.Interface(), required)
|
||||
default:
|
||||
return nil, fmt.Errorf("kind %v is not supported as a ptr", kind)
|
||||
}
|
||||
}
|
||||
|
||||
func prepareSlice(name string, fieldType reflect.Type, val reflect.Value, required bool) (interface{}, error) {
|
||||
switch fieldType.Elem().Kind() {
|
||||
case reflect.Uint8:
|
||||
switch fieldType {
|
||||
case reflect.TypeOf(net.IPv4zero):
|
||||
ip := (net.IP)(val.Bytes())
|
||||
if ip == nil || ip.Equal(net.IP{}) {
|
||||
if required {
|
||||
return nil, fmt.Errorf("field is required, got zero IPv4 address")
|
||||
}
|
||||
} else {
|
||||
value := ip.String()
|
||||
return &value, nil
|
||||
}
|
||||
|
||||
case reflect.TypeOf(MAC48(0, 0, 0, 0, 0, 0)):
|
||||
mac := val.Interface().(MACAddress)
|
||||
s := mac.String()
|
||||
if s == "" {
|
||||
if required {
|
||||
return nil, fmt.Errorf("field is required, got empty MAC address")
|
||||
}
|
||||
} else {
|
||||
return &s, nil
|
||||
}
|
||||
default:
|
||||
if val.Len() == 0 {
|
||||
if required {
|
||||
return nil, fmt.Errorf("field is required, got empty slice")
|
||||
}
|
||||
} else {
|
||||
value := base64.StdEncoding.EncodeToString(val.Bytes())
|
||||
return &value, nil
|
||||
}
|
||||
}
|
||||
case reflect.String:
|
||||
if val.Len() == 0 {
|
||||
if required {
|
||||
return nil, fmt.Errorf("field is required, got empty slice")
|
||||
}
|
||||
} else {
|
||||
elems := make([]string, 0, val.Len())
|
||||
for i := 0; i < val.Len(); i++ {
|
||||
// XXX what if the value contains a comma? Double encode?
|
||||
s := val.Index(i).String()
|
||||
elems = append(elems, s)
|
||||
}
|
||||
value := strings.Join(elems, ",")
|
||||
return &value, nil
|
||||
}
|
||||
default:
|
||||
switch fieldType.Elem() {
|
||||
case reflect.TypeOf(CIDR{}), reflect.TypeOf(UUID{}):
|
||||
if val.Len() == 0 {
|
||||
if required {
|
||||
return nil, fmt.Errorf("field is required, got empty slice")
|
||||
}
|
||||
} else {
|
||||
v := reflect.ValueOf(val.Interface())
|
||||
ss := make([]string, val.Len())
|
||||
for i := 0; i < v.Len(); i++ {
|
||||
e := v.Index(i).Interface()
|
||||
s, ok := e.(fmt.Stringer)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("not a String, %T", e)
|
||||
}
|
||||
ss[i] = s.String()
|
||||
}
|
||||
value := strings.Join(ss, ",")
|
||||
return &value, nil
|
||||
}
|
||||
default:
|
||||
if val.Len() == 0 {
|
||||
if required {
|
||||
return nil, fmt.Errorf("field is required, got empty slice")
|
||||
}
|
||||
} else {
|
||||
return prepareList(name, val.Interface())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func prepareStruct(i interface{}, required bool) (*string, error) {
|
||||
s, ok := i.(fmt.Stringer)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("struct field not a Stringer")
|
||||
}
|
||||
|
||||
if s == nil {
|
||||
if required {
|
||||
return nil, fmt.Errorf("field is required, got %#v", s)
|
||||
}
|
||||
}
|
||||
|
||||
return prepareString(s.String(), required)
|
||||
}
|
||||
|
||||
func prepareEmbedStruct(i interface{}) (url.Values, error) {
|
||||
return prepareValues("", i)
|
||||
}
|
||||
|
||||
// ExtractJSONTag returns the variable name or defaultName as well as if the field is required (!omitempty)
|
||||
|
40
vendor/github.com/exoscale/egoscale/service_offerings.go
generated
vendored
40
vendor/github.com/exoscale/egoscale/service_offerings.go
generated
vendored
@ -1,9 +1,5 @@
|
||||
package egoscale
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// ServiceOffering corresponds to the Compute Offerings
|
||||
//
|
||||
// A service offering correspond to some hardware features (CPU, RAM).
|
||||
@ -21,11 +17,9 @@ type ServiceOffering struct {
|
||||
DiskIopsReadRate int64 `json:"diskIopsReadRate,omitempty" doc:"io requests read rate of the service offering"`
|
||||
DiskIopsWriteRate int64 `json:"diskIopsWriteRate,omitempty" doc:"io requests write rate of the service offering"`
|
||||
Displaytext string `json:"displaytext,omitempty" doc:"an alternate display text of the service offering."`
|
||||
Domain string `json:"domain,omitempty" doc:"Domain name for the offering"`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"the domain id of the service offering"`
|
||||
HostTags string `json:"hosttags,omitempty" doc:"the host tag for the service offering"`
|
||||
HypervisorSnapshotReserve int `json:"hypervisorsnapshotreserve,omitempty" doc:"Hypervisor snapshot reserve space as a percent of a volume (for managed storage using Xen or VMware)"`
|
||||
ID *UUID `json:"id,omitempty" doc:"the id of the service offering"`
|
||||
ID *UUID `json:"id" doc:"the id of the service offering"`
|
||||
IsCustomized bool `json:"iscustomized,omitempty" doc:"is true if the offering is customized"`
|
||||
IsCustomizedIops bool `json:"iscustomizediops,omitempty" doc:"true if disk offering uses custom iops, false otherwise"`
|
||||
IsSystem bool `json:"issystem,omitempty" doc:"is this a system vm offering"`
|
||||
@ -49,7 +43,6 @@ func (so ServiceOffering) ListRequest() (ListCommand, error) {
|
||||
// Restricted cannot be applied here because it really has three states
|
||||
req := &ListServiceOfferings{
|
||||
ID: so.ID,
|
||||
DomainID: so.DomainID,
|
||||
Name: so.Name,
|
||||
SystemVMType: so.SystemVMType,
|
||||
}
|
||||
@ -61,9 +54,10 @@ func (so ServiceOffering) ListRequest() (ListCommand, error) {
|
||||
return req, nil
|
||||
}
|
||||
|
||||
//go:generate go run generate/main.go -interface=Listable ListServiceOfferings
|
||||
|
||||
// ListServiceOfferings represents a query for service offerings
|
||||
type ListServiceOfferings struct {
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"the ID of the domain associated with the service offering"`
|
||||
ID *UUID `json:"id,omitempty" doc:"ID of the service offering"`
|
||||
IsSystem *bool `json:"issystem,omitempty" doc:"is this a system vm offering"`
|
||||
Keyword string `json:"keyword,omitempty" doc:"List by keyword"`
|
||||
@ -81,31 +75,3 @@ type ListServiceOfferingsResponse struct {
|
||||
Count int `json:"count"`
|
||||
ServiceOffering []ServiceOffering `json:"serviceoffering"`
|
||||
}
|
||||
|
||||
func (ListServiceOfferings) response() interface{} {
|
||||
return new(ListServiceOfferingsResponse)
|
||||
}
|
||||
|
||||
// SetPage sets the current page
|
||||
func (lso *ListServiceOfferings) SetPage(page int) {
|
||||
lso.Page = page
|
||||
}
|
||||
|
||||
// SetPageSize sets the page size
|
||||
func (lso *ListServiceOfferings) SetPageSize(pageSize int) {
|
||||
lso.PageSize = pageSize
|
||||
}
|
||||
|
||||
func (ListServiceOfferings) each(resp interface{}, callback IterateItemFunc) {
|
||||
sos, ok := resp.(*ListServiceOfferingsResponse)
|
||||
if !ok {
|
||||
callback(nil, fmt.Errorf("wrong type. ListServiceOfferingsResponse expected, got %T", resp))
|
||||
return
|
||||
}
|
||||
|
||||
for i := range sos.ServiceOffering {
|
||||
if !callback(&sos.ServiceOffering[i], nil) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
43
vendor/github.com/exoscale/egoscale/serviceofferings_response.go
generated
vendored
Normal file
43
vendor/github.com/exoscale/egoscale/serviceofferings_response.go
generated
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
// code generated; DO NOT EDIT.
|
||||
|
||||
package egoscale
|
||||
|
||||
import "fmt"
|
||||
|
||||
// Response returns the struct to unmarshal
|
||||
func (ListServiceOfferings) Response() interface{} {
|
||||
return new(ListServiceOfferingsResponse)
|
||||
}
|
||||
|
||||
// ListRequest returns itself
|
||||
func (ls *ListServiceOfferings) ListRequest() (ListCommand, error) {
|
||||
if ls == nil {
|
||||
return nil, fmt.Errorf("%T cannot be nil", ls)
|
||||
}
|
||||
return ls, nil
|
||||
}
|
||||
|
||||
// SetPage sets the current apge
|
||||
func (ls *ListServiceOfferings) SetPage(page int) {
|
||||
ls.Page = page
|
||||
}
|
||||
|
||||
// SetPageSize sets the page size
|
||||
func (ls *ListServiceOfferings) SetPageSize(pageSize int) {
|
||||
ls.PageSize = pageSize
|
||||
}
|
||||
|
||||
// Each triggers the callback for each, valid answer or any non 404 issue
|
||||
func (ListServiceOfferings) Each(resp interface{}, callback IterateItemFunc) {
|
||||
items, ok := resp.(*ListServiceOfferingsResponse)
|
||||
if !ok {
|
||||
callback(nil, fmt.Errorf("wrong type, ListServiceOfferingsResponse was expected, got %T", resp))
|
||||
return
|
||||
}
|
||||
|
||||
for i := range items.ServiceOffering {
|
||||
if !callback(&items.ServiceOffering[i], nil) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
80
vendor/github.com/exoscale/egoscale/snapshots.go
generated
vendored
80
vendor/github.com/exoscale/egoscale/snapshots.go
generated
vendored
@ -3,28 +3,27 @@ package egoscale
|
||||
// SnapshotState represents the Snapshot.State enum
|
||||
//
|
||||
// See: https://github.com/apache/cloudstack/blob/master/api/src/main/java/com/cloud/storage/Snapshot.java
|
||||
type SnapshotState int
|
||||
type SnapshotState string
|
||||
|
||||
//go:generate stringer -type SnapshotState
|
||||
const (
|
||||
// Allocated ... (TODO)
|
||||
Allocated SnapshotState = iota
|
||||
Allocated SnapshotState = "Allocated"
|
||||
// Creating ... (TODO)
|
||||
Creating
|
||||
Creating SnapshotState = "Creating"
|
||||
// CreatedOnPrimary ... (TODO)
|
||||
CreatedOnPrimary
|
||||
CreatedOnPrimary SnapshotState = "CreatedOnPrimary"
|
||||
// BackingUp ... (TODO)
|
||||
BackingUp
|
||||
BackingUp SnapshotState = "BackingUp"
|
||||
// BackedUp ... (TODO)
|
||||
BackedUp
|
||||
BackedUp SnapshotState = "BackedUp"
|
||||
// Copying ... (TODO)
|
||||
Copying
|
||||
Copying SnapshotState = "Copying"
|
||||
// Destroying ... (TODO)
|
||||
Destroying
|
||||
Destroying SnapshotState = "Destroying"
|
||||
// Destroyed ... (TODO)
|
||||
Destroyed
|
||||
Destroyed SnapshotState = "Destroyed"
|
||||
// Error is a state where the user can't see the snapshot while the snapshot may still exist on the storage
|
||||
Error
|
||||
Error SnapshotState = "Error"
|
||||
)
|
||||
|
||||
// Snapshot represents a volume snapshot
|
||||
@ -32,8 +31,6 @@ type Snapshot struct {
|
||||
Account string `json:"account,omitempty" doc:"the account associated with the snapshot"`
|
||||
AccountID *UUID `json:"accountid,omitempty" doc:"the account ID associated with the snapshot"`
|
||||
Created string `json:"created,omitempty" doc:"the date the snapshot was created"`
|
||||
Domain string `json:"domain,omitempty" doc:"the domain name of the snapshot's account"`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"the domain ID of the snapshot's account"`
|
||||
ID *UUID `json:"id,omitempty" doc:"ID of the snapshot"`
|
||||
IntervalType string `json:"intervaltype,omitempty" doc:"valid types are hourly, daily, weekly, monthy, template, and none."`
|
||||
Name string `json:"name,omitempty" doc:"name of the snapshot"`
|
||||
@ -41,7 +38,7 @@ type Snapshot struct {
|
||||
Revertable *bool `json:"revertable,omitempty" doc:"indicates whether the underlying storage supports reverting the volume to this snapshot"`
|
||||
Size int64 `json:"size,omitempty" doc:"the size of original volume"`
|
||||
SnapshotType string `json:"snapshottype,omitempty" doc:"the type of the snapshot"`
|
||||
State SnapshotState `json:"state,omitempty" doc:"the state of the snapshot. BackedUp means that snapshot is ready to be used; Creating - the snapshot is being allocated on the primary storage; BackingUp - the snapshot is being backed up on secondary storage"`
|
||||
State string `json:"state,omitempty" doc:"the state of the snapshot. BackedUp means that snapshot is ready to be used; Creating - the snapshot is being allocated on the primary storage; BackingUp - the snapshot is being backed up on secondary storage"`
|
||||
Tags []ResourceTag `json:"tags,omitempty" doc:"the list of resource tags associated with snapshot"`
|
||||
VolumeID *UUID `json:"volumeid,omitempty" doc:"ID of the disk volume"`
|
||||
VolumeName string `json:"volumename,omitempty" doc:"name of the disk volume"`
|
||||
@ -56,30 +53,43 @@ func (Snapshot) ResourceType() string {
|
||||
|
||||
// CreateSnapshot (Async) creates an instant snapshot of a volume
|
||||
type CreateSnapshot struct {
|
||||
VolumeID *UUID `json:"volumeid" doc:"The ID of the disk volume"`
|
||||
Account string `json:"account,omitempty" doc:"The account of the snapshot. The account parameter must be used with the domainId parameter."`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"The domain ID of the snapshot. If used with the account parameter, specifies a domain for the account associated with the disk volume."`
|
||||
QuiesceVM *bool `json:"quiescevm,omitempty" doc:"quiesce vm if true"`
|
||||
_ bool `name:"createSnapshot" description:"Creates an instant snapshot of a volume."`
|
||||
VolumeID *UUID `json:"volumeid" doc:"The ID of the disk volume"`
|
||||
QuiesceVM *bool `json:"quiescevm,omitempty" doc:"quiesce vm if true"`
|
||||
_ bool `name:"createSnapshot" description:"Creates an instant snapshot of a volume."`
|
||||
}
|
||||
|
||||
func (CreateSnapshot) response() interface{} {
|
||||
// Response returns the struct to unmarshal
|
||||
func (CreateSnapshot) Response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (CreateSnapshot) asyncResponse() interface{} {
|
||||
// AsyncResponse returns the struct to unmarshal the async job
|
||||
func (CreateSnapshot) AsyncResponse() interface{} {
|
||||
return new(Snapshot)
|
||||
}
|
||||
|
||||
// ListRequest builds the ListSnapshot request
|
||||
func (ss Snapshot) ListRequest() (ListCommand, error) {
|
||||
// Restricted cannot be applied here because it really has three states
|
||||
req := &ListSnapshots{
|
||||
ID: ss.ID,
|
||||
Name: ss.Name,
|
||||
VolumeID: ss.VolumeID,
|
||||
SnapshotType: ss.SnapshotType,
|
||||
ZoneID: ss.ZoneID,
|
||||
// TODO: tags
|
||||
}
|
||||
|
||||
return req, nil
|
||||
}
|
||||
|
||||
//go:generate go run generate/main.go -interface=Listable ListSnapshots
|
||||
|
||||
// ListSnapshots lists the volume snapshots
|
||||
type ListSnapshots struct {
|
||||
Account string `json:"account,omitempty" doc:"list resources by account. Must be used with the domainId parameter."`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"list only resources belonging to the domain specified"`
|
||||
ID *UUID `json:"id,omitempty" doc:"lists snapshot by snapshot ID"`
|
||||
IntervalType string `json:"intervaltype,omitempty" doc:"valid values are HOURLY, DAILY, WEEKLY, and MONTHLY."`
|
||||
IsRecursive *bool `json:"isrecursive,omitempty" doc:"defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves."`
|
||||
Keyword string `json:"keyword,omitempty" doc:"List by keyword"`
|
||||
ListAll *bool `json:"listall,omitempty" doc:"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"`
|
||||
Name string `json:"name,omitempty" doc:"lists snapshot by snapshot name"`
|
||||
Page int `json:"page,omitempty"`
|
||||
PageSize int `json:"pagesize,omitempty"`
|
||||
@ -96,22 +106,20 @@ type ListSnapshotsResponse struct {
|
||||
Snapshot []Snapshot `json:"snapshot"`
|
||||
}
|
||||
|
||||
func (ListSnapshots) response() interface{} {
|
||||
return new(ListSnapshotsResponse)
|
||||
}
|
||||
|
||||
// DeleteSnapshot (Async) deletes a snapshot of a disk volume
|
||||
type DeleteSnapshot struct {
|
||||
ID *UUID `json:"id" doc:"The ID of the snapshot"`
|
||||
_ bool `name:"deleteSnapshot" description:"Deletes a snapshot of a disk volume."`
|
||||
}
|
||||
|
||||
func (DeleteSnapshot) response() interface{} {
|
||||
// Response returns the struct to unmarshal
|
||||
func (DeleteSnapshot) Response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (DeleteSnapshot) asyncResponse() interface{} {
|
||||
return new(booleanResponse)
|
||||
// AsyncResponse returns the struct to unmarshal the async job
|
||||
func (DeleteSnapshot) AsyncResponse() interface{} {
|
||||
return new(BooleanResponse)
|
||||
}
|
||||
|
||||
// RevertSnapshot (Async) reverts a volume snapshot
|
||||
@ -120,10 +128,12 @@ type RevertSnapshot struct {
|
||||
_ bool `name:"revertSnapshot" description:"revert a volume snapshot."`
|
||||
}
|
||||
|
||||
func (RevertSnapshot) response() interface{} {
|
||||
// Response returns the struct to unmarshal
|
||||
func (RevertSnapshot) Response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (RevertSnapshot) asyncResponse() interface{} {
|
||||
return new(booleanResponse)
|
||||
// AsyncResponse returns the struct to unmarshal the async job
|
||||
func (RevertSnapshot) AsyncResponse() interface{} {
|
||||
return new(BooleanResponse)
|
||||
}
|
||||
|
43
vendor/github.com/exoscale/egoscale/snapshots_response.go
generated
vendored
Normal file
43
vendor/github.com/exoscale/egoscale/snapshots_response.go
generated
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
// code generated; DO NOT EDIT.
|
||||
|
||||
package egoscale
|
||||
|
||||
import "fmt"
|
||||
|
||||
// Response returns the struct to unmarshal
|
||||
func (ListSnapshots) Response() interface{} {
|
||||
return new(ListSnapshotsResponse)
|
||||
}
|
||||
|
||||
// ListRequest returns itself
|
||||
func (ls *ListSnapshots) ListRequest() (ListCommand, error) {
|
||||
if ls == nil {
|
||||
return nil, fmt.Errorf("%T cannot be nil", ls)
|
||||
}
|
||||
return ls, nil
|
||||
}
|
||||
|
||||
// SetPage sets the current apge
|
||||
func (ls *ListSnapshots) SetPage(page int) {
|
||||
ls.Page = page
|
||||
}
|
||||
|
||||
// SetPageSize sets the page size
|
||||
func (ls *ListSnapshots) SetPageSize(pageSize int) {
|
||||
ls.PageSize = pageSize
|
||||
}
|
||||
|
||||
// Each triggers the callback for each, valid answer or any non 404 issue
|
||||
func (ListSnapshots) Each(resp interface{}, callback IterateItemFunc) {
|
||||
items, ok := resp.(*ListSnapshotsResponse)
|
||||
if !ok {
|
||||
callback(nil, fmt.Errorf("wrong type, ListSnapshotsResponse was expected, got %T", resp))
|
||||
return
|
||||
}
|
||||
|
||||
for i := range items.Snapshot {
|
||||
if !callback(&items.Snapshot[i], nil) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
16
vendor/github.com/exoscale/egoscale/snapshotstate_string.go
generated
vendored
16
vendor/github.com/exoscale/egoscale/snapshotstate_string.go
generated
vendored
@ -1,16 +0,0 @@
|
||||
// Code generated by "stringer -type SnapshotState"; DO NOT EDIT.
|
||||
|
||||
package egoscale
|
||||
|
||||
import "strconv"
|
||||
|
||||
const _SnapshotState_name = "AllocatedCreatingCreatedOnPrimaryBackingUpBackedUpCopyingDestroyingDestroyedError"
|
||||
|
||||
var _SnapshotState_index = [...]uint8{0, 9, 17, 33, 42, 50, 57, 67, 76, 81}
|
||||
|
||||
func (i SnapshotState) String() string {
|
||||
if i < 0 || i >= SnapshotState(len(_SnapshotState_index)-1) {
|
||||
return "SnapshotState(" + strconv.FormatInt(int64(i), 10) + ")"
|
||||
}
|
||||
return _SnapshotState_name[_SnapshotState_index[i]:_SnapshotState_index[i+1]]
|
||||
}
|
73
vendor/github.com/exoscale/egoscale/ssh_keypairs.go
generated
vendored
73
vendor/github.com/exoscale/egoscale/ssh_keypairs.go
generated
vendored
@ -37,49 +37,44 @@ func (ssh SSHKeyPair) ListRequest() (ListCommand, error) {
|
||||
|
||||
// CreateSSHKeyPair represents a new keypair to be created
|
||||
type CreateSSHKeyPair struct {
|
||||
Name string `json:"name" doc:"Name of the keypair"`
|
||||
Account string `json:"account,omitempty" doc:"an optional account for the ssh key. Must be used with domainId."`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"an optional domainId for the ssh key. If the account parameter is used, domainId must also be used."`
|
||||
_ bool `name:"createSSHKeyPair" description:"Create a new keypair and returns the private key"`
|
||||
Name string `json:"name" doc:"Name of the keypair"`
|
||||
_ bool `name:"createSSHKeyPair" description:"Create a new keypair and returns the private key"`
|
||||
}
|
||||
|
||||
func (CreateSSHKeyPair) response() interface{} {
|
||||
// Response returns the struct to unmarshal
|
||||
func (CreateSSHKeyPair) Response() interface{} {
|
||||
return new(SSHKeyPair)
|
||||
}
|
||||
|
||||
// DeleteSSHKeyPair represents a new keypair to be created
|
||||
type DeleteSSHKeyPair struct {
|
||||
Name string `json:"name" doc:"Name of the keypair"`
|
||||
Account string `json:"account,omitempty" doc:"the account associated with the keypair. Must be used with the domainId parameter."`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"the domain ID associated with the keypair"`
|
||||
_ bool `name:"deleteSSHKeyPair" description:"Deletes a keypair by name"`
|
||||
Name string `json:"name" doc:"Name of the keypair"`
|
||||
_ bool `name:"deleteSSHKeyPair" description:"Deletes a keypair by name"`
|
||||
}
|
||||
|
||||
func (DeleteSSHKeyPair) response() interface{} {
|
||||
return new(booleanResponse)
|
||||
// Response returns the struct to unmarshal
|
||||
func (DeleteSSHKeyPair) Response() interface{} {
|
||||
return new(BooleanResponse)
|
||||
}
|
||||
|
||||
// RegisterSSHKeyPair represents a new registration of a public key in a keypair
|
||||
type RegisterSSHKeyPair struct {
|
||||
Name string `json:"name" doc:"Name of the keypair"`
|
||||
PublicKey string `json:"publickey" doc:"Public key material of the keypair"`
|
||||
Account string `json:"account,omitempty" doc:"an optional account for the ssh key. Must be used with domainId."`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"an optional domainId for the ssh key. If the account parameter is used, domainId must also be used."`
|
||||
_ bool `name:"registerSSHKeyPair" description:"Register a public key in a keypair under a certain name"`
|
||||
}
|
||||
|
||||
func (RegisterSSHKeyPair) response() interface{} {
|
||||
// Response returns the struct to unmarshal
|
||||
func (RegisterSSHKeyPair) Response() interface{} {
|
||||
return new(SSHKeyPair)
|
||||
}
|
||||
|
||||
//go:generate go run generate/main.go -interface=Listable ListSSHKeyPairs
|
||||
|
||||
// ListSSHKeyPairs represents a query for a list of SSH KeyPairs
|
||||
type ListSSHKeyPairs struct {
|
||||
Account string `json:"account,omitempty" doc:"list resources by account. Must be used with the domainId parameter."`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"list only resources belonging to the domain specified"`
|
||||
Fingerprint string `json:"fingerprint,omitempty" doc:"A public key fingerprint to look for"`
|
||||
IsRecursive *bool `json:"isrecursive,omitempty" doc:"defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves."`
|
||||
Keyword string `json:"keyword,omitempty" doc:"List by keyword"`
|
||||
ListAll *bool `json:"listall,omitempty" doc:"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"`
|
||||
Name string `json:"name,omitempty" doc:"A key pair name to look for"`
|
||||
Page int `json:"page,omitempty"`
|
||||
PageSize int `json:"pagesize,omitempty"`
|
||||
@ -92,47 +87,19 @@ type ListSSHKeyPairsResponse struct {
|
||||
SSHKeyPair []SSHKeyPair `json:"sshkeypair"`
|
||||
}
|
||||
|
||||
func (ListSSHKeyPairs) response() interface{} {
|
||||
return new(ListSSHKeyPairsResponse)
|
||||
}
|
||||
|
||||
// SetPage sets the current page
|
||||
func (ls *ListSSHKeyPairs) SetPage(page int) {
|
||||
ls.Page = page
|
||||
}
|
||||
|
||||
// SetPageSize sets the page size
|
||||
func (ls *ListSSHKeyPairs) SetPageSize(pageSize int) {
|
||||
ls.PageSize = pageSize
|
||||
}
|
||||
|
||||
func (ListSSHKeyPairs) each(resp interface{}, callback IterateItemFunc) {
|
||||
sshs, ok := resp.(*ListSSHKeyPairsResponse)
|
||||
if !ok {
|
||||
callback(nil, fmt.Errorf("wrong type. ListSSHKeyPairsResponse expected, got %T", resp))
|
||||
return
|
||||
}
|
||||
|
||||
for i := range sshs.SSHKeyPair {
|
||||
if !callback(&sshs.SSHKeyPair[i], nil) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ResetSSHKeyForVirtualMachine (Async) represents a change for the key pairs
|
||||
type ResetSSHKeyForVirtualMachine struct {
|
||||
ID *UUID `json:"id" doc:"The ID of the virtual machine"`
|
||||
KeyPair string `json:"keypair" doc:"name of the ssh key pair used to login to the virtual machine"`
|
||||
Account string `json:"account,omitempty" doc:"an optional account for the ssh key. Must be used with domainId."`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"an optional domainId for the virtual machine. If the account parameter is used, domainId must also be used."`
|
||||
_ bool `name:"resetSSHKeyForVirtualMachine" description:"Resets the SSH Key for virtual machine. The virtual machine must be in a \"Stopped\" state."`
|
||||
ID *UUID `json:"id" doc:"The ID of the virtual machine"`
|
||||
KeyPair string `json:"keypair" doc:"Name of the ssh key pair used to login to the virtual machine"`
|
||||
_ bool `name:"resetSSHKeyForVirtualMachine" description:"Resets the SSH Key for virtual machine. The virtual machine must be in a \"Stopped\" state."`
|
||||
}
|
||||
|
||||
func (ResetSSHKeyForVirtualMachine) response() interface{} {
|
||||
// Response returns the struct to unmarshal
|
||||
func (ResetSSHKeyForVirtualMachine) Response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (ResetSSHKeyForVirtualMachine) asyncResponse() interface{} {
|
||||
// AsyncResponse returns the struct to unmarshal the async job
|
||||
func (ResetSSHKeyForVirtualMachine) AsyncResponse() interface{} {
|
||||
return new(VirtualMachine)
|
||||
}
|
||||
|
43
vendor/github.com/exoscale/egoscale/sshkeypairs_response.go
generated
vendored
Normal file
43
vendor/github.com/exoscale/egoscale/sshkeypairs_response.go
generated
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
// code generated; DO NOT EDIT.
|
||||
|
||||
package egoscale
|
||||
|
||||
import "fmt"
|
||||
|
||||
// Response returns the struct to unmarshal
|
||||
func (ListSSHKeyPairs) Response() interface{} {
|
||||
return new(ListSSHKeyPairsResponse)
|
||||
}
|
||||
|
||||
// ListRequest returns itself
|
||||
func (ls *ListSSHKeyPairs) ListRequest() (ListCommand, error) {
|
||||
if ls == nil {
|
||||
return nil, fmt.Errorf("%T cannot be nil", ls)
|
||||
}
|
||||
return ls, nil
|
||||
}
|
||||
|
||||
// SetPage sets the current apge
|
||||
func (ls *ListSSHKeyPairs) SetPage(page int) {
|
||||
ls.Page = page
|
||||
}
|
||||
|
||||
// SetPageSize sets the page size
|
||||
func (ls *ListSSHKeyPairs) SetPageSize(pageSize int) {
|
||||
ls.PageSize = pageSize
|
||||
}
|
||||
|
||||
// Each triggers the callback for each, valid answer or any non 404 issue
|
||||
func (ListSSHKeyPairs) Each(resp interface{}, callback IterateItemFunc) {
|
||||
items, ok := resp.(*ListSSHKeyPairsResponse)
|
||||
if !ok {
|
||||
callback(nil, fmt.Errorf("wrong type, ListSSHKeyPairsResponse was expected, got %T", resp))
|
||||
return
|
||||
}
|
||||
|
||||
for i := range items.SSHKeyPair {
|
||||
if !callback(&items.SSHKeyPair[i], nil) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
43
vendor/github.com/exoscale/egoscale/tags.go
generated
vendored
43
vendor/github.com/exoscale/egoscale/tags.go
generated
vendored
@ -2,18 +2,29 @@ package egoscale
|
||||
|
||||
// ResourceTag is a tag associated with a resource
|
||||
//
|
||||
// http://docs.cloudstack.apache.org/projects/cloudstack-administration/en/4.9/management.html
|
||||
// https://community.exoscale.com/documentation/compute/instance-tags/
|
||||
type ResourceTag struct {
|
||||
Account string `json:"account,omitempty" doc:"the account associated with the tag"`
|
||||
Customer string `json:"customer,omitempty" doc:"customer associated with the tag"`
|
||||
Domain string `json:"domain,omitempty" doc:"the domain associated with the tag"`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"the ID of the domain associated with the tag"`
|
||||
Key string `json:"key,omitempty" doc:"tag key name"`
|
||||
ResourceID *UUID `json:"resourceid,omitempty" doc:"id of the resource"`
|
||||
ResourceType string `json:"resourcetype,omitempty" doc:"resource type"`
|
||||
Value string `json:"value,omitempty" doc:"tag value"`
|
||||
}
|
||||
|
||||
// ListRequest builds the ListZones request
|
||||
func (tag ResourceTag) ListRequest() (ListCommand, error) {
|
||||
req := &ListTags{
|
||||
Customer: tag.Customer,
|
||||
Key: tag.Key,
|
||||
ResourceID: tag.ResourceID,
|
||||
ResourceType: tag.ResourceType,
|
||||
Value: tag.Value,
|
||||
}
|
||||
|
||||
return req, nil
|
||||
}
|
||||
|
||||
// CreateTags (Async) creates resource tag(s)
|
||||
type CreateTags struct {
|
||||
ResourceIDs []UUID `json:"resourceids" doc:"list of resources to create the tags for"`
|
||||
@ -23,12 +34,14 @@ type CreateTags struct {
|
||||
_ bool `name:"createTags" description:"Creates resource tag(s)"`
|
||||
}
|
||||
|
||||
func (CreateTags) response() interface{} {
|
||||
// Response returns the struct to unmarshal
|
||||
func (CreateTags) Response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (CreateTags) asyncResponse() interface{} {
|
||||
return new(booleanResponse)
|
||||
// AsyncResponse returns the struct to unmarshal the async job
|
||||
func (CreateTags) AsyncResponse() interface{} {
|
||||
return new(BooleanResponse)
|
||||
}
|
||||
|
||||
// DeleteTags (Async) deletes the resource tag(s)
|
||||
@ -39,23 +52,23 @@ type DeleteTags struct {
|
||||
_ bool `name:"deleteTags" description:"Deleting resource tag(s)"`
|
||||
}
|
||||
|
||||
func (DeleteTags) response() interface{} {
|
||||
// Response returns the struct to unmarshal
|
||||
func (DeleteTags) Response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (DeleteTags) asyncResponse() interface{} {
|
||||
return new(booleanResponse)
|
||||
// AsyncResponse returns the struct to unmarshal the async job
|
||||
func (DeleteTags) AsyncResponse() interface{} {
|
||||
return new(BooleanResponse)
|
||||
}
|
||||
|
||||
//go:generate go run generate/main.go -interface=Listable ListTags
|
||||
|
||||
// ListTags list resource tag(s)
|
||||
type ListTags struct {
|
||||
Account string `json:"account,omitempty" doc:"list resources by account. Must be used with the domainId parameter."`
|
||||
Customer string `json:"customer,omitempty" doc:"list by customer name"`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"list only resources belonging to the domain specified"`
|
||||
IsRecursive *bool `json:"isrecursive,omitempty" doc:"defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves."`
|
||||
Key string `json:"key,omitempty" doc:"list by key"`
|
||||
Keyword string `json:"keyword,omitempty" doc:"List by keyword"`
|
||||
ListAll *bool `json:"listall,omitempty" doc:"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"`
|
||||
Page int `json:"page,omitempty"`
|
||||
PageSize int `json:"pagesize,omitempty"`
|
||||
ResourceID *UUID `json:"resourceid,omitempty" doc:"list by resource id"`
|
||||
@ -69,7 +82,3 @@ type ListTagsResponse struct {
|
||||
Count int `json:"count"`
|
||||
Tag []ResourceTag `json:"tag"`
|
||||
}
|
||||
|
||||
func (ListTags) response() interface{} {
|
||||
return new(ListTagsResponse)
|
||||
}
|
||||
|
43
vendor/github.com/exoscale/egoscale/tags_response.go
generated
vendored
Normal file
43
vendor/github.com/exoscale/egoscale/tags_response.go
generated
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
// code generated; DO NOT EDIT.
|
||||
|
||||
package egoscale
|
||||
|
||||
import "fmt"
|
||||
|
||||
// Response returns the struct to unmarshal
|
||||
func (ListTags) Response() interface{} {
|
||||
return new(ListTagsResponse)
|
||||
}
|
||||
|
||||
// ListRequest returns itself
|
||||
func (ls *ListTags) ListRequest() (ListCommand, error) {
|
||||
if ls == nil {
|
||||
return nil, fmt.Errorf("%T cannot be nil", ls)
|
||||
}
|
||||
return ls, nil
|
||||
}
|
||||
|
||||
// SetPage sets the current apge
|
||||
func (ls *ListTags) SetPage(page int) {
|
||||
ls.Page = page
|
||||
}
|
||||
|
||||
// SetPageSize sets the page size
|
||||
func (ls *ListTags) SetPageSize(pageSize int) {
|
||||
ls.PageSize = pageSize
|
||||
}
|
||||
|
||||
// Each triggers the callback for each, valid answer or any non 404 issue
|
||||
func (ListTags) Each(resp interface{}, callback IterateItemFunc) {
|
||||
items, ok := resp.(*ListTagsResponse)
|
||||
if !ok {
|
||||
callback(nil, fmt.Errorf("wrong type, ListTagsResponse was expected, got %T", resp))
|
||||
return
|
||||
}
|
||||
|
||||
for i := range items.Tag {
|
||||
if !callback(&items.Tag[i], nil) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
221
vendor/github.com/exoscale/egoscale/templates.go
generated
vendored
221
vendor/github.com/exoscale/egoscale/templates.go
generated
vendored
@ -1,12 +1,6 @@
|
||||
package egoscale
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// Template represents a machine to be deployed
|
||||
//
|
||||
// See: http://docs.cloudstack.apache.org/projects/cloudstack-administration/en/latest/templates.html
|
||||
// Template represents a machine to be deployed.
|
||||
type Template struct {
|
||||
Account string `json:"account,omitempty" doc:"the account name to which the template belongs"`
|
||||
AccountID *UUID `json:"accountid,omitempty" doc:"the account id to which the template belongs"`
|
||||
@ -16,12 +10,9 @@ type Template struct {
|
||||
CrossZones bool `json:"crossZones,omitempty" doc:"true if the template is managed across all Zones, false otherwise"`
|
||||
Details map[string]string `json:"details,omitempty" doc:"additional key/value details tied with template"`
|
||||
DisplayText string `json:"displaytext,omitempty" doc:"the template display text"`
|
||||
Domain string `json:"domain,omitempty" doc:"the name of the domain to which the template belongs"`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"the ID of the domain to which the template belongs"`
|
||||
Format string `json:"format,omitempty" doc:"the format of the template."`
|
||||
HostID *UUID `json:"hostid,omitempty" doc:"the ID of the secondary storage host for the template"`
|
||||
HostName string `json:"hostname,omitempty" doc:"the name of the secondary storage host for the template"`
|
||||
Hypervisor string `json:"hypervisor,omitempty" doc:"the hypervisor on which the template runs"`
|
||||
ID *UUID `json:"id,omitempty" doc:"the template ID"`
|
||||
IsDynamicallyScalable bool `json:"isdynamicallyscalable,omitempty" doc:"true if template contains XS/VMWare tools inorder to support dynamic scaling of VM cpu/memory"`
|
||||
IsExtractable bool `json:"isextractable,omitempty" doc:"true if the template is extractable, false otherwise"`
|
||||
@ -52,42 +43,39 @@ func (Template) ResourceType() string {
|
||||
}
|
||||
|
||||
// ListRequest builds the ListTemplates request
|
||||
func (temp Template) ListRequest() (ListCommand, error) {
|
||||
func (template Template) ListRequest() (ListCommand, error) {
|
||||
req := &ListTemplates{
|
||||
Name: temp.Name,
|
||||
Account: temp.Account,
|
||||
DomainID: temp.DomainID,
|
||||
ID: temp.ID,
|
||||
ZoneID: temp.ZoneID,
|
||||
Hypervisor: temp.Hypervisor,
|
||||
//TODO Tags
|
||||
ID: template.ID,
|
||||
Name: template.Name,
|
||||
ZoneID: template.ZoneID,
|
||||
}
|
||||
if temp.IsFeatured {
|
||||
if template.IsFeatured {
|
||||
req.TemplateFilter = "featured"
|
||||
}
|
||||
if temp.Removed != "" {
|
||||
if template.Removed != "" {
|
||||
*req.ShowRemoved = true
|
||||
}
|
||||
|
||||
for i := range template.Tags {
|
||||
req.Tags = append(req.Tags, template.Tags[i])
|
||||
}
|
||||
|
||||
return req, nil
|
||||
}
|
||||
|
||||
//go:generate go run generate/main.go -interface=Listable ListTemplates
|
||||
|
||||
// ListTemplates represents a template query filter
|
||||
type ListTemplates struct {
|
||||
TemplateFilter string `json:"templatefilter" doc:"possible values are \"featured\", \"self\", \"selfexecutable\",\"sharedexecutable\",\"executable\", and \"community\". * featured : templates that have been marked as featured and public. * self : templates that have been registered or created by the calling user. * selfexecutable : same as self, but only returns templates that can be used to deploy a new VM. * sharedexecutable : templates ready to be deployed that have been granted to the calling user by another user. * executable : templates that are owned by the calling user, or public templates, that can be used to deploy a VM. * community : templates that have been marked as public but not featured. * all : all templates (only usable by admins)."`
|
||||
Account string `json:"account,omitempty" doc:"list resources by account. Must be used with the domainId parameter."`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"list only resources belonging to the domain specified"`
|
||||
Hypervisor string `json:"hypervisor,omitempty" doc:"the hypervisor for which to restrict the search"`
|
||||
TemplateFilter string `json:"templatefilter" doc:"Possible values are \"featured\", \"self\", \"selfexecutable\",\"sharedexecutable\",\"executable\", and \"community\". * featured : templates that have been marked as featured and public. * self : templates that have been registered or created by the calling user. * selfexecutable : same as self, but only returns templates that can be used to deploy a new VM. * sharedexecutable : templates ready to be deployed that have been granted to the calling user by another user. * executable : templates that are owned by the calling user, or public templates, that can be used to deploy a VM. * community : templates that have been marked as public but not featured."`
|
||||
ID *UUID `json:"id,omitempty" doc:"the template ID"`
|
||||
IsRecursive *bool `json:"isrecursive,omitempty" doc:"defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves."`
|
||||
Keyword string `json:"keyword,omitempty" doc:"List by keyword"`
|
||||
ListAll *bool `json:"listall,omitempty" doc:"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"`
|
||||
Name string `json:"name,omitempty" doc:"the template name"`
|
||||
Page int `json:"page,omitempty"`
|
||||
PageSize int `json:"pagesize,omitempty"`
|
||||
ShowRemoved *bool `json:"showremoved,omitempty" doc:"show removed templates as well"`
|
||||
ShowRemoved *bool `json:"showremoved,omitempty" doc:"Show removed templates as well"`
|
||||
Tags []ResourceTag `json:"tags,omitempty" doc:"List resources by tags (key/value pairs)"`
|
||||
ZoneID *UUID `json:"zoneid,omitempty" doc:"list templates by zoneId"`
|
||||
ZoneID *UUID `json:"zoneid,omitempty" doc:"list templates by zoneid"`
|
||||
_ bool `name:"listTemplates" description:"List all public, private, and privileged templates."`
|
||||
}
|
||||
|
||||
@ -97,172 +85,27 @@ type ListTemplatesResponse struct {
|
||||
Template []Template `json:"template"`
|
||||
}
|
||||
|
||||
func (ListTemplates) response() interface{} {
|
||||
return new(ListTemplatesResponse)
|
||||
}
|
||||
|
||||
func (ListTemplates) each(resp interface{}, callback IterateItemFunc) {
|
||||
temps, ok := resp.(*ListTemplatesResponse)
|
||||
if !ok {
|
||||
callback(nil, fmt.Errorf("wrong type. ListTemplatesResponse expected, got %T", resp))
|
||||
return
|
||||
}
|
||||
|
||||
for i := range temps.Template {
|
||||
if !callback(&temps.Template[i], nil) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// SetPage sets the current page
|
||||
func (ls *ListTemplates) SetPage(page int) {
|
||||
ls.Page = page
|
||||
}
|
||||
|
||||
// SetPageSize sets the page size
|
||||
func (ls *ListTemplates) SetPageSize(pageSize int) {
|
||||
ls.PageSize = pageSize
|
||||
}
|
||||
|
||||
// CreateTemplate (Async) represents a template creation
|
||||
type CreateTemplate struct {
|
||||
Bits int `json:"bits,omitempty" doc:"32 or 64 bit"`
|
||||
Details map[string]string `json:"details,omitempty" doc:"Template details in key/value pairs."`
|
||||
DisplayText string `json:"displaytext" doc:"the display text of the template. This is usually used for display purposes."`
|
||||
IsDynamicallyScalable *bool `json:"isdynamicallyscalable,omitempty" doc:"true if template contains XS/VMWare tools inorder to support dynamic scaling of VM cpu/memory"`
|
||||
IsFeatured *bool `json:"isfeatured,omitempty" doc:"true if this template is a featured template, false otherwise"`
|
||||
IsPublic *bool `json:"ispublic,omitempty" doc:"true if this template is a public template, false otherwise"`
|
||||
Name string `json:"name" doc:"the name of the template"`
|
||||
OsTypeID *UUID `json:"ostypeid" doc:"the ID of the OS Type that best represents the OS of this template."`
|
||||
PasswordEnabled *bool `json:"passwordenabled,omitempty" doc:"true if the template supports the password reset feature; default is false"`
|
||||
RequiresHVM *bool `json:"requireshvm,omitempty" doc:"true if the template requres HVM, false otherwise"`
|
||||
SnapshotID *UUID `json:"snapshotid,omitempty" doc:"the ID of the snapshot the template is being created from. Either this parameter, or volumeId has to be passed in"`
|
||||
TemplateTag string `json:"templatetag,omitempty" doc:"the tag for this template."`
|
||||
URL string `json:"url,omitempty" doc:"Optional, only for baremetal hypervisor. The directory name where template stored on CIFS server"`
|
||||
VirtualMachineID *UUID `json:"virtualmachineid,omitempty" doc:"Optional, VM ID. If this presents, it is going to create a baremetal template for VM this ID refers to. This is only for VM whose hypervisor type is BareMetal"`
|
||||
VolumeID *UUID `json:"volumeid,omitempty" doc:"the ID of the disk volume the template is being created from. Either this parameter, or snapshotId has to be passed in"`
|
||||
_ bool `name:"createTemplate" description:"Creates a template of a virtual machine. The virtual machine must be in a STOPPED state. A template created from this command is automatically designated as a private template visible to the account that created it."`
|
||||
}
|
||||
|
||||
func (CreateTemplate) response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (CreateTemplate) asyncResponse() interface{} {
|
||||
return new(Template)
|
||||
}
|
||||
|
||||
// CopyTemplate (Async) represents a template copy
|
||||
type CopyTemplate struct {
|
||||
DestZoneID *UUID `json:"destzoneid" doc:"ID of the zone the template is being copied to."`
|
||||
ID *UUID `json:"id" doc:"Template ID."`
|
||||
SourceZoneID *UUID `json:"sourcezoneid,omitempty" doc:"ID of the zone the template is currently hosted on. If not specified and template is cross-zone, then we will sync this template to region wide image store."`
|
||||
_ bool `name:"copyTemplate" description:"Copies a template from one zone to another."`
|
||||
}
|
||||
|
||||
func (CopyTemplate) response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (CopyTemplate) asyncResponse() interface{} {
|
||||
return new(Template)
|
||||
}
|
||||
|
||||
// UpdateTemplate represents a template change
|
||||
type UpdateTemplate struct {
|
||||
Bootable *bool `json:"bootable,omitempty" doc:"true if image is bootable, false otherwise"`
|
||||
Details map[string]string `json:"details,omitempty" doc:"Details in key/value pairs."`
|
||||
DisplayText string `json:"displaytext,omitempty" doc:"the display text of the image"`
|
||||
Format string `json:"format,omitempty" doc:"the format for the image"`
|
||||
ID *UUID `json:"id" doc:"the ID of the image file"`
|
||||
IsDynamicallyScalable *bool `json:"isdynamicallyscalable,omitempty" doc:"true if template/ISO contains XS/VMWare tools inorder to support dynamic scaling of VM cpu/memory"`
|
||||
IsRouting *bool `json:"isrouting,omitempty" doc:"true if the template type is routing i.e., if template is used to deploy router"`
|
||||
Name string `json:"name,omitempty" doc:"the name of the image file"`
|
||||
OsTypeID *UUID `json:"ostypeid,omitempty" doc:"the ID of the OS type that best represents the OS of this image."`
|
||||
PasswordEnabled *bool `json:"passwordenabled,omitempty" doc:"true if the image supports the password reset feature; default is false"`
|
||||
SortKey int `json:"sortkey,omitempty" doc:"sort key of the template, integer"`
|
||||
_ bool `name:"updateTemplate" description:"Updates attributes of a template."`
|
||||
}
|
||||
|
||||
func (UpdateTemplate) response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (UpdateTemplate) asyncResponse() interface{} {
|
||||
return new(Template)
|
||||
}
|
||||
|
||||
// DeleteTemplate (Async) represents the deletion of a template
|
||||
type DeleteTemplate struct {
|
||||
ID *UUID `json:"id" doc:"the ID of the template"`
|
||||
ZoneID *UUID `json:"zoneid,omitempty" doc:"the ID of zone of the template"`
|
||||
_ bool `name:"deleteTemplate" description:"Deletes a template from the system. All virtual machines using the deleted template will not be affected."`
|
||||
}
|
||||
|
||||
func (DeleteTemplate) response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (DeleteTemplate) asyncResponse() interface{} {
|
||||
return new(booleanResponse)
|
||||
}
|
||||
|
||||
// PrepareTemplate represents a template preparation
|
||||
type PrepareTemplate struct {
|
||||
TemplateID *UUID `json:"templateid" doc:"template ID of the template to be prepared in primary storage(s)."`
|
||||
ZoneID *UUID `json:"zoneid" doc:"zone ID of the template to be prepared in primary storage(s)."`
|
||||
_ bool `name:"prepareTemplate" description:"load template into primary storage"`
|
||||
}
|
||||
|
||||
func (PrepareTemplate) response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (PrepareTemplate) asyncResponse() interface{} {
|
||||
return new(Template)
|
||||
}
|
||||
|
||||
// RegisterTemplate represents a template registration
|
||||
type RegisterTemplate struct {
|
||||
Account string `json:"account,omitempty" doc:"an optional accountName. Must be used with domainId."`
|
||||
Bits int `json:"bits,omitempty" doc:"32 or 64 bits support. 64 by default"`
|
||||
Checksum string `json:"checksum,omitempty" doc:"the MD5 checksum value of this template"`
|
||||
Details map[string]string `json:"details,omitempty" doc:"Template details in key/value pairs."`
|
||||
DisplayText string `json:"displaytext" doc:"the display text of the template. This is usually used for display purposes."`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"an optional domainId. If the account parameter is used, domainId must also be used."`
|
||||
Format string `json:"format" doc:"the format for the template. Possible values include QCOW2, RAW, and VHD."`
|
||||
Hypervisor string `json:"hypervisor" doc:"the target hypervisor for the template"`
|
||||
IsDynamicallyScalable *bool `json:"isdynamicallyscalable,omitempty" doc:"true if template contains XS/VMWare tools inorder to support dynamic scaling of VM cpu/memory"`
|
||||
IsExtractable *bool `json:"isextractable,omitempty" doc:"true if the template or its derivatives are extractable; default is false"`
|
||||
IsFeatured *bool `json:"isfeatured,omitempty" doc:"true if this template is a featured template, false otherwise"`
|
||||
IsPublic *bool `json:"ispublic,omitempty" doc:"true if the template is available to all accounts; default is true"`
|
||||
IsRouting *bool `json:"isrouting,omitempty" doc:"true if the template type is routing i.e., if template is used to deploy router"`
|
||||
IsSystem *bool `json:"issystem,omitempty" doc:"true if the template type is system i.e., if template is used to deploy system VM"`
|
||||
Name string `json:"name" doc:"the name of the template"`
|
||||
OsTypeID *UUID `json:"ostypeid" doc:"the ID of the OS Type that best represents the OS of this template."`
|
||||
PasswordEnabled *bool `json:"passwordenabled,omitempty" doc:"true if the template supports the password reset feature; default is false"`
|
||||
RequiresHVM *bool `json:"requireshvm,omitempty" doc:"true if this template requires HVM"`
|
||||
SSHKeyEnabled *bool `json:"sshkeyenabled,omitempty" doc:"true if the template supports the sshkey upload feature; default is false"`
|
||||
TemplateTag string `json:"templatetag,omitempty" doc:"the tag for this template."`
|
||||
URL string `json:"url" doc:"the URL of where the template is hosted. Possible URL include http:// and https://"`
|
||||
ZoneID *UUID `json:"zoneid" doc:"the ID of the zone the template is to be hosted on"`
|
||||
_ bool `name:"registerTemplate" description:"Registers an existing template into the CloudStack cloud."`
|
||||
}
|
||||
|
||||
func (RegisterTemplate) response() interface{} {
|
||||
return new(Template)
|
||||
}
|
||||
|
||||
// OSCategory represents an OS category
|
||||
type OSCategory struct {
|
||||
ID string `json:"id,omitempty" doc:"the ID of the OS category"`
|
||||
ID *UUID `json:"id,omitempty" doc:"the ID of the OS category"`
|
||||
Name string `json:"name,omitempty" doc:"the name of the OS category"`
|
||||
}
|
||||
|
||||
// ListRequest builds the ListOSCategories request
|
||||
func (osCat OSCategory) ListRequest() (ListCommand, error) {
|
||||
req := &ListOSCategories{
|
||||
Name: osCat.Name,
|
||||
ID: osCat.ID,
|
||||
}
|
||||
|
||||
return req, nil
|
||||
}
|
||||
|
||||
//go:generate go run generate/main.go -interface=Listable ListOSCategories
|
||||
|
||||
// ListOSCategories lists the OS categories
|
||||
type ListOSCategories struct {
|
||||
ID string `json:"id,omitempty" doc:"list Os category by id"`
|
||||
ID *UUID `json:"id,omitempty" doc:"list Os category by id"`
|
||||
Keyword string `json:"keyword,omitempty" doc:"List by keyword"`
|
||||
Name string `json:"name,omitempty" doc:"list os category by name"`
|
||||
Page int `json:"page,omitempty"`
|
||||
@ -275,7 +118,3 @@ type ListOSCategoriesResponse struct {
|
||||
Count int `json:"count"`
|
||||
OSCategory []OSCategory `json:"oscategory"`
|
||||
}
|
||||
|
||||
func (ListOSCategories) response() interface{} {
|
||||
return new(ListOSCategoriesResponse)
|
||||
}
|
||||
|
43
vendor/github.com/exoscale/egoscale/templates_response.go
generated
vendored
Normal file
43
vendor/github.com/exoscale/egoscale/templates_response.go
generated
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
// code generated; DO NOT EDIT.
|
||||
|
||||
package egoscale
|
||||
|
||||
import "fmt"
|
||||
|
||||
// Response returns the struct to unmarshal
|
||||
func (ListTemplates) Response() interface{} {
|
||||
return new(ListTemplatesResponse)
|
||||
}
|
||||
|
||||
// ListRequest returns itself
|
||||
func (ls *ListTemplates) ListRequest() (ListCommand, error) {
|
||||
if ls == nil {
|
||||
return nil, fmt.Errorf("%T cannot be nil", ls)
|
||||
}
|
||||
return ls, nil
|
||||
}
|
||||
|
||||
// SetPage sets the current apge
|
||||
func (ls *ListTemplates) SetPage(page int) {
|
||||
ls.Page = page
|
||||
}
|
||||
|
||||
// SetPageSize sets the page size
|
||||
func (ls *ListTemplates) SetPageSize(pageSize int) {
|
||||
ls.PageSize = pageSize
|
||||
}
|
||||
|
||||
// Each triggers the callback for each, valid answer or any non 404 issue
|
||||
func (ListTemplates) Each(resp interface{}, callback IterateItemFunc) {
|
||||
items, ok := resp.(*ListTemplatesResponse)
|
||||
if !ok {
|
||||
callback(nil, fmt.Errorf("wrong type, ListTemplatesResponse was expected, got %T", resp))
|
||||
return
|
||||
}
|
||||
|
||||
for i := range items.Template {
|
||||
if !callback(&items.Template[i], nil) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
118
vendor/github.com/exoscale/egoscale/users.go
generated
vendored
118
vendor/github.com/exoscale/egoscale/users.go
generated
vendored
@ -2,26 +2,32 @@ package egoscale
|
||||
|
||||
// User represents a User
|
||||
type User struct {
|
||||
APIKey string `json:"apikey,omitempty" doc:"the api key of the user"`
|
||||
Account string `json:"account,omitempty" doc:"the account name of the user"`
|
||||
AccountID *UUID `json:"accountid,omitempty" doc:"the account ID of the user"`
|
||||
AccountType int16 `json:"accounttype,omitempty" doc:"the account type of the user"`
|
||||
Created string `json:"created,omitempty" doc:"the date and time the user account was created"`
|
||||
Domain string `json:"domain,omitempty" doc:"the domain name of the user"`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"the domain ID of the user"`
|
||||
Email string `json:"email,omitempty" doc:"the user email address"`
|
||||
FirstName string `json:"firstname,omitempty" doc:"the user firstname"`
|
||||
ID *UUID `json:"id,omitempty" doc:"the user ID"`
|
||||
IsCallerChildDomain bool `json:"iscallerchilddomain,omitempty" doc:"the boolean value representing if the updating target is in caller's child domain"`
|
||||
IsDefault bool `json:"isdefault,omitempty" doc:"true if user is default, false otherwise"`
|
||||
LastName string `json:"lastname,omitempty" doc:"the user lastname"`
|
||||
RoleID *UUID `json:"roleid,omitempty" doc:"the ID of the role"`
|
||||
RoleName string `json:"rolename,omitempty" doc:"the name of the role"`
|
||||
RoleType string `json:"roletype,omitempty" doc:"the type of the role"`
|
||||
SecretKey string `json:"secretkey,omitempty" doc:"the secret key of the user"`
|
||||
State string `json:"state,omitempty" doc:"the user state"`
|
||||
Timezone string `json:"timezone,omitempty" doc:"the timezone user was created in"`
|
||||
UserName string `json:"username,omitempty" doc:"the user name"`
|
||||
APIKey string `json:"apikey,omitempty" doc:"the api key of the user"`
|
||||
Account string `json:"account,omitempty" doc:"the account name of the user"`
|
||||
AccountID *UUID `json:"accountid,omitempty" doc:"the account ID of the user"`
|
||||
Created string `json:"created,omitempty" doc:"the date and time the user account was created"`
|
||||
Email string `json:"email,omitempty" doc:"the user email address"`
|
||||
FirstName string `json:"firstname,omitempty" doc:"the user firstname"`
|
||||
ID *UUID `json:"id,omitempty" doc:"the user ID"`
|
||||
IsDefault bool `json:"isdefault,omitempty" doc:"true if user is default, false otherwise"`
|
||||
LastName string `json:"lastname,omitempty" doc:"the user lastname"`
|
||||
RoleID *UUID `json:"roleid,omitempty" doc:"the ID of the role"`
|
||||
RoleName string `json:"rolename,omitempty" doc:"the name of the role"`
|
||||
RoleType string `json:"roletype,omitempty" doc:"the type of the role"`
|
||||
SecretKey string `json:"secretkey,omitempty" doc:"the secret key of the user"`
|
||||
State string `json:"state,omitempty" doc:"the user state"`
|
||||
Timezone string `json:"timezone,omitempty" doc:"the timezone user was created in"`
|
||||
UserName string `json:"username,omitempty" doc:"the user name"`
|
||||
}
|
||||
|
||||
// ListRequest builds the ListUsers request
|
||||
func (user User) ListRequest() (ListCommand, error) {
|
||||
req := &ListUsers{
|
||||
ID: user.ID,
|
||||
UserName: user.UserName,
|
||||
}
|
||||
|
||||
return req, nil
|
||||
}
|
||||
|
||||
// RegisterUserKeys registers a new set of key of the given user
|
||||
@ -32,60 +38,22 @@ type RegisterUserKeys struct {
|
||||
_ bool `name:"registerUserKeys" description:"This command allows a user to register for the developer API, returning a secret key and an API key. This request is made through the integration API port, so it is a privileged command and must be made on behalf of a user. It is up to the implementer just how the username and password are entered, and then how that translates to an integration API request. Both secret key and API key should be returned to the user"`
|
||||
}
|
||||
|
||||
func (RegisterUserKeys) response() interface{} {
|
||||
// Response returns the struct to unmarshal
|
||||
func (RegisterUserKeys) Response() interface{} {
|
||||
return new(User)
|
||||
}
|
||||
|
||||
// CreateUser represents the creation of a User
|
||||
type CreateUser struct {
|
||||
Account string `json:"account" doc:"Creates the user under the specified account. If no account is specified, the username will be used as the account name."`
|
||||
Email string `json:"email" doc:"email"`
|
||||
FirstName string `json:"firstname" doc:"firstname"`
|
||||
LastName string `json:"lastname" doc:"lastname"`
|
||||
Password string `json:"password" doc:"Clear text password (Default hashed to SHA256SALT). If you wish to use any other hashing algorithm, you would need to write a custom authentication adapter See Docs section."`
|
||||
UserName string `json:"username" doc:"Unique username."`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"Creates the user under the specified domain. Has to be accompanied with the account parameter"`
|
||||
Timezone string `json:"timezone,omitempty" doc:"Specifies a timezone for this command. For more information on the timezone parameter, see Time Zone Format."`
|
||||
UserID *UUID `json:"userid,omitempty" doc:"User UUID, required for adding account from external provisioning system"`
|
||||
_ bool `name:"createUser" description:"Creates a user for an account that already exists"`
|
||||
}
|
||||
|
||||
func (CreateUser) response() interface{} {
|
||||
return new(User)
|
||||
}
|
||||
|
||||
// UpdateUser represents the modification of a User
|
||||
type UpdateUser struct {
|
||||
ID *UUID `json:"id" doc:"User uuid"`
|
||||
Email string `json:"email,omitempty" doc:"email"`
|
||||
FirstName string `json:"firstname,omitempty" doc:"first name"`
|
||||
LastName string `json:"lastname,omitempty" doc:"last name"`
|
||||
Password string `json:"password,omitempty" doc:"Clear text password (default hashed to SHA256SALT). If you wish to use any other hashing algorithm, you would need to write a custom authentication adapter"`
|
||||
Timezone string `json:"timezone,omitempty" doc:"Specifies a timezone for this command. For more information on the timezone parameter, see Time Zone Format."`
|
||||
UserAPIKey string `json:"userapikey,omitempty" doc:"The API key for the user. Must be specified with userSecretKey"`
|
||||
UserName string `json:"username,omitempty" doc:"Unique username"`
|
||||
UserSecretKey string `json:"usersecretkey,omitempty" doc:"The secret key for the user. Must be specified with userApiKey"`
|
||||
_ bool `name:"updateUser" description:"Updates a user account"`
|
||||
}
|
||||
|
||||
func (UpdateUser) response() interface{} {
|
||||
return new(User)
|
||||
}
|
||||
//go:generate go run generate/main.go -interface=Listable ListUsers
|
||||
|
||||
// ListUsers represents the search for Users
|
||||
type ListUsers struct {
|
||||
Account string `json:"account,omitempty" doc:"list resources by account. Must be used with the domainId parameter."`
|
||||
AccountType int64 `json:"accounttype,omitempty" doc:"List users by account type. Valid types include admin, domain-admin, read-only-admin, or user."`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"list only resources belonging to the domain specified"`
|
||||
ID *UUID `json:"id,omitempty" doc:"List user by ID."`
|
||||
IsRecursive bool `json:"isrecursive,omitempty" doc:"defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves."`
|
||||
Keyword string `json:"keyword,omitempty" doc:"List by keyword"`
|
||||
ListAll bool `json:"listall,omitempty" doc:"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"`
|
||||
Page int `json:"page,omitempty"`
|
||||
PageSize int `json:"pagesize,omitempty"`
|
||||
State string `json:"state,omitempty" doc:"List users by state of the user account."`
|
||||
Username string `json:"username,omitempty" doc:"List user by the username"`
|
||||
_ bool `name:"listUsers" description:"Lists user accounts"`
|
||||
ID *UUID `json:"id,omitempty" doc:"List user by ID."`
|
||||
Keyword string `json:"keyword,omitempty" doc:"List by keyword"`
|
||||
Page int `json:"page,omitempty"`
|
||||
PageSize int `json:"pagesize,omitempty"`
|
||||
State string `json:"state,omitempty" doc:"List users by state of the user account."`
|
||||
UserName string `json:"username,omitempty" doc:"List user by the username"`
|
||||
_ bool `name:"listUsers" description:"Lists user accounts"`
|
||||
}
|
||||
|
||||
// ListUsersResponse represents a list of users
|
||||
@ -93,17 +61,3 @@ type ListUsersResponse struct {
|
||||
Count int `json:"count"`
|
||||
User []User `json:"user"`
|
||||
}
|
||||
|
||||
func (ListUsers) response() interface{} {
|
||||
return new(ListUsersResponse)
|
||||
}
|
||||
|
||||
// DeleteUser deletes a user for an account
|
||||
type DeleteUser struct {
|
||||
ID *UUID `json:"id" doc:"id of the user to be deleted"`
|
||||
_ bool `name:"deleteUser" description:"Deletes a user for an account"`
|
||||
}
|
||||
|
||||
func (DeleteUser) response() interface{} {
|
||||
return new(booleanResponse)
|
||||
}
|
||||
|
43
vendor/github.com/exoscale/egoscale/users_response.go
generated
vendored
Normal file
43
vendor/github.com/exoscale/egoscale/users_response.go
generated
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
// code generated; DO NOT EDIT.
|
||||
|
||||
package egoscale
|
||||
|
||||
import "fmt"
|
||||
|
||||
// Response returns the struct to unmarshal
|
||||
func (ListUsers) Response() interface{} {
|
||||
return new(ListUsersResponse)
|
||||
}
|
||||
|
||||
// ListRequest returns itself
|
||||
func (ls *ListUsers) ListRequest() (ListCommand, error) {
|
||||
if ls == nil {
|
||||
return nil, fmt.Errorf("%T cannot be nil", ls)
|
||||
}
|
||||
return ls, nil
|
||||
}
|
||||
|
||||
// SetPage sets the current apge
|
||||
func (ls *ListUsers) SetPage(page int) {
|
||||
ls.Page = page
|
||||
}
|
||||
|
||||
// SetPageSize sets the page size
|
||||
func (ls *ListUsers) SetPageSize(pageSize int) {
|
||||
ls.PageSize = pageSize
|
||||
}
|
||||
|
||||
// Each triggers the callback for each, valid answer or any non 404 issue
|
||||
func (ListUsers) Each(resp interface{}, callback IterateItemFunc) {
|
||||
items, ok := resp.(*ListUsersResponse)
|
||||
if !ok {
|
||||
callback(nil, fmt.Errorf("wrong type, ListUsersResponse was expected, got %T", resp))
|
||||
return
|
||||
}
|
||||
|
||||
for i := range items.User {
|
||||
if !callback(&items.User[i], nil) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
36
vendor/github.com/exoscale/egoscale/uuid.go
generated
vendored
36
vendor/github.com/exoscale/egoscale/uuid.go
generated
vendored
@ -4,7 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"github.com/satori/go.uuid"
|
||||
uuid "github.com/satori/go.uuid"
|
||||
)
|
||||
|
||||
// UUID holds a UUID v4
|
||||
@ -12,12 +12,36 @@ type UUID struct {
|
||||
uuid.UUID
|
||||
}
|
||||
|
||||
// Equal returns true if itself is equal to other
|
||||
// DeepCopy create a true copy of the receiver.
|
||||
func (u *UUID) DeepCopy() *UUID {
|
||||
if u == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
out := [uuid.Size]byte{}
|
||||
copy(out[:], u.Bytes())
|
||||
|
||||
return &UUID{
|
||||
(uuid.UUID)(out),
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopyInto copies the receiver into out.
|
||||
//
|
||||
// In must be non nil.
|
||||
func (u *UUID) DeepCopyInto(out *UUID) {
|
||||
o := [uuid.Size]byte{}
|
||||
copy(o[:], u.Bytes())
|
||||
|
||||
out.UUID = (uuid.UUID)(o)
|
||||
}
|
||||
|
||||
// Equal returns true if itself is equal to other.
|
||||
func (u UUID) Equal(other UUID) bool {
|
||||
return uuid.Equal(u.UUID, other.UUID)
|
||||
}
|
||||
|
||||
// UnmarshalJSON unmarshals the raw JSON into the MAC address
|
||||
// UnmarshalJSON unmarshals the raw JSON into the UUID.
|
||||
func (u *UUID) UnmarshalJSON(b []byte) error {
|
||||
var s string
|
||||
if err := json.Unmarshal(b, &s); err != nil {
|
||||
@ -31,12 +55,12 @@ func (u *UUID) UnmarshalJSON(b []byte) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// MarshalJSON converts the UUID to a string representation
|
||||
// MarshalJSON converts the UUID to a string representation.
|
||||
func (u UUID) MarshalJSON() ([]byte, error) {
|
||||
return []byte(fmt.Sprintf("%q", u.String())), nil
|
||||
}
|
||||
|
||||
// ParseUUID parses a string into a UUID
|
||||
// ParseUUID parses a string into a UUID.
|
||||
func ParseUUID(s string) (*UUID, error) {
|
||||
u, err := uuid.FromString(s)
|
||||
if err != nil {
|
||||
@ -45,7 +69,7 @@ func ParseUUID(s string) (*UUID, error) {
|
||||
return &UUID{u}, nil
|
||||
}
|
||||
|
||||
// MustParseUUID acts like ParseUUID but panic in case of a failure
|
||||
// MustParseUUID acts like ParseUUID but panic in case of a failure.
|
||||
func MustParseUUID(s string) *UUID {
|
||||
u, e := ParseUUID(s)
|
||||
if e != nil {
|
||||
|
2
vendor/github.com/exoscale/egoscale/version.go
generated
vendored
2
vendor/github.com/exoscale/egoscale/version.go
generated
vendored
@ -1,4 +1,4 @@
|
||||
package egoscale
|
||||
|
||||
// Version of the library
|
||||
const Version = "0.11.3"
|
||||
const Version = "0.14.3"
|
||||
|
354
vendor/github.com/exoscale/egoscale/virtual_machines.go
generated
vendored
354
vendor/github.com/exoscale/egoscale/virtual_machines.go
generated
vendored
@ -29,8 +29,10 @@ const (
|
||||
VirtualMachineDestroyed VirtualMachineState = "Destroyed"
|
||||
// VirtualMachineExpunging "VM is being expunged
|
||||
VirtualMachineExpunging VirtualMachineState = "Expunging"
|
||||
// VirtualMachineMigrating VM is being migrated. host id holds to from host
|
||||
// VirtualMachineMigrating VM is being live migrated. host id holds destination host, last host id holds source host
|
||||
VirtualMachineMigrating VirtualMachineState = "Migrating"
|
||||
// VirtualMachineMoving VM is being migrated offline (volume is being moved).
|
||||
VirtualMachineMoving VirtualMachineState = "Moving"
|
||||
// VirtualMachineError VM is in error
|
||||
VirtualMachineError VirtualMachineState = "Error"
|
||||
// VirtualMachineUnknown VM state is unknown
|
||||
@ -43,67 +45,62 @@ const (
|
||||
//
|
||||
// See: http://docs.cloudstack.apache.org/projects/cloudstack-administration/en/stable/virtual_machines.html
|
||||
type VirtualMachine struct {
|
||||
Account string `json:"account,omitempty" doc:"the account associated with the virtual machine"`
|
||||
AccountID *UUID `json:"accountid,omitempty" doc:"the account ID associated with the virtual machine"`
|
||||
AffinityGroup []AffinityGroup `json:"affinitygroup,omitempty" doc:"list of affinity groups associated with the virtual machine"`
|
||||
ClusterID *UUID `json:"clusterid,omitempty" doc:"the ID of the vm's cluster"`
|
||||
ClusterName string `json:"clustername,omitempty" doc:"the name of the vm's cluster"`
|
||||
CPUNumber int `json:"cpunumber,omitempty" doc:"the number of cpu this virtual machine is running with"`
|
||||
CPUSpeed int `json:"cpuspeed,omitempty" doc:"the speed of each cpu"`
|
||||
CPUUsed string `json:"cpuused,omitempty" doc:"the amount of the vm's CPU currently used"`
|
||||
Created string `json:"created,omitempty" doc:"the date when this virtual machine was created"`
|
||||
Details map[string]string `json:"details,omitempty" doc:"Vm details in key/value pairs."`
|
||||
DiskIoRead int64 `json:"diskioread,omitempty" doc:"the read (io) of disk on the vm"`
|
||||
DiskIoWrite int64 `json:"diskiowrite,omitempty" doc:"the write (io) of disk on the vm"`
|
||||
DiskKbsRead int64 `json:"diskkbsread,omitempty" doc:"the read (bytes) of disk on the vm"`
|
||||
DiskKbsWrite int64 `json:"diskkbswrite,omitempty" doc:"the write (bytes) of disk on the vm"`
|
||||
DiskOfferingID *UUID `json:"diskofferingid,omitempty" doc:"the ID of the disk offering of the virtual machine"`
|
||||
DiskOfferingName string `json:"diskofferingname,omitempty" doc:"the name of the disk offering of the virtual machine"`
|
||||
DisplayName string `json:"displayname,omitempty" doc:"user generated name. The name of the virtual machine is returned if no displayname exists."`
|
||||
DisplayVM bool `json:"displayvm,omitempty" doc:"an optional field whether to the display the vm to the end user or not."`
|
||||
Domain string `json:"domain,omitempty" doc:"the name of the domain in which the virtual machine exists"`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"the ID of the domain in which the virtual machine exists"`
|
||||
ForVirtualNetwork bool `json:"forvirtualnetwork,omitempty" doc:"the virtual network for the service offering"`
|
||||
Group string `json:"group,omitempty" doc:"the group name of the virtual machine"`
|
||||
GroupID *UUID `json:"groupid,omitempty" doc:"the group ID of the virtual machine"`
|
||||
HAEnable bool `json:"haenable,omitempty" doc:"true if high-availability is enabled, false otherwise"`
|
||||
HostID *UUID `json:"hostid,omitempty" doc:"the ID of the host for the virtual machine"`
|
||||
HostName string `json:"hostname,omitempty" doc:"the name of the host for the virtual machine"`
|
||||
Hypervisor string `json:"hypervisor,omitempty" doc:"the hypervisor on which the template runs"`
|
||||
ID *UUID `json:"id,omitempty" doc:"the ID of the virtual machine"`
|
||||
InstanceName string `json:"instancename,omitempty" doc:"instance name of the user vm; this parameter is returned to the ROOT admin only"`
|
||||
IsDynamicallyScalable bool `json:"isdynamicallyscalable,omitempty" doc:"true if vm contains XS/VMWare tools inorder to support dynamic scaling of VM cpu/memory."`
|
||||
IsoDisplayText string `json:"isodisplaytext,omitempty" doc:"an alternate display text of the ISO attached to the virtual machine"`
|
||||
IsoID *UUID `json:"isoid,omitempty" doc:"the ID of the ISO attached to the virtual machine"`
|
||||
IsoName string `json:"isoname,omitempty" doc:"the name of the ISO attached to the virtual machine"`
|
||||
KeyPair string `json:"keypair,omitempty" doc:"ssh key-pair"`
|
||||
Memory int `json:"memory,omitempty" doc:"the memory allocated for the virtual machine"`
|
||||
Name string `json:"name,omitempty" doc:"the name of the virtual machine"`
|
||||
NetworkKbsRead int64 `json:"networkkbsread,omitempty" doc:"the incoming network traffic on the vm"`
|
||||
NetworkKbsWrite int64 `json:"networkkbswrite,omitempty" doc:"the outgoing network traffic on the host"`
|
||||
Nic []Nic `json:"nic,omitempty" doc:"the list of nics associated with vm"`
|
||||
OSCategoryID *UUID `json:"oscategoryid,omitempty" doc:"Os category ID of the virtual machine"`
|
||||
OSCategoryName string `json:"oscategoryname,omitempty" doc:"Os category name of the virtual machine"`
|
||||
Password string `json:"password,omitempty" doc:"the password (if exists) of the virtual machine"`
|
||||
PasswordEnabled bool `json:"passwordenabled,omitempty" doc:"true if the password rest feature is enabled, false otherwise"`
|
||||
PCIDevices []PCIDevice `json:"pcidevices,omitempty" doc:"list of PCI devices"`
|
||||
PodID *UUID `json:"podid,omitempty" doc:"the ID of the vm's pod"`
|
||||
PodName string `json:"podname,omitempty" doc:"the name of the vm's pod"`
|
||||
PublicIP string `json:"publicip,omitempty" doc:"public IP address id associated with vm via Static nat rule"`
|
||||
PublicIPID *UUID `json:"publicipid,omitempty" doc:"public IP address id associated with vm via Static nat rule"`
|
||||
RootDeviceID int64 `json:"rootdeviceid,omitempty" doc:"device ID of the root volume"`
|
||||
RootDeviceType string `json:"rootdevicetype,omitempty" doc:"device type of the root volume"`
|
||||
SecurityGroup []SecurityGroup `json:"securitygroup,omitempty" doc:"list of security groups associated with the virtual machine"`
|
||||
ServiceOfferingID *UUID `json:"serviceofferingid,omitempty" doc:"the ID of the service offering of the virtual machine"`
|
||||
ServiceOfferingName string `json:"serviceofferingname,omitempty" doc:"the name of the service offering of the virtual machine"`
|
||||
ServiceState string `json:"servicestate,omitempty" doc:"State of the Service from LB rule"`
|
||||
State string `json:"state,omitempty" doc:"the state of the virtual machine"`
|
||||
Tags []ResourceTag `json:"tags,omitempty" doc:"the list of resource tags associated with vm"`
|
||||
TemplateDisplayText string `json:"templatedisplaytext,omitempty" doc:"an alternate display text of the template for the virtual machine"`
|
||||
TemplateID *UUID `json:"templateid,omitempty" doc:"the ID of the template for the virtual machine. A -1 is returned if the virtual machine was created from an ISO file."`
|
||||
TemplateName string `json:"templatename,omitempty" doc:"the name of the template for the virtual machine"`
|
||||
ZoneID *UUID `json:"zoneid,omitempty" doc:"the ID of the availablility zone for the virtual machine"`
|
||||
ZoneName string `json:"zonename,omitempty" doc:"the name of the availability zone for the virtual machine"`
|
||||
Account string `json:"account,omitempty" doc:"the account associated with the virtual machine"`
|
||||
AccountID *UUID `json:"accountid,omitempty" doc:"the account ID associated with the virtual machine"`
|
||||
AffinityGroup []AffinityGroup `json:"affinitygroup,omitempty" doc:"list of affinity groups associated with the virtual machine"`
|
||||
ClusterID *UUID `json:"clusterid,omitempty" doc:"the ID of the vm's cluster"`
|
||||
ClusterName string `json:"clustername,omitempty" doc:"the name of the vm's cluster"`
|
||||
CPUNumber int `json:"cpunumber,omitempty" doc:"the number of cpu this virtual machine is running with"`
|
||||
CPUSpeed int `json:"cpuspeed,omitempty" doc:"the speed of each cpu"`
|
||||
CPUUsed string `json:"cpuused,omitempty" doc:"the amount of the vm's CPU currently used"`
|
||||
Created string `json:"created,omitempty" doc:"the date when this virtual machine was created"`
|
||||
Details map[string]string `json:"details,omitempty" doc:"Vm details in key/value pairs."`
|
||||
DiskIoRead int64 `json:"diskioread,omitempty" doc:"the read (io) of disk on the vm"`
|
||||
DiskIoWrite int64 `json:"diskiowrite,omitempty" doc:"the write (io) of disk on the vm"`
|
||||
DiskKbsRead int64 `json:"diskkbsread,omitempty" doc:"the read (bytes) of disk on the vm"`
|
||||
DiskKbsWrite int64 `json:"diskkbswrite,omitempty" doc:"the write (bytes) of disk on the vm"`
|
||||
DiskOfferingID *UUID `json:"diskofferingid,omitempty" doc:"the ID of the disk offering of the virtual machine"`
|
||||
DiskOfferingName string `json:"diskofferingname,omitempty" doc:"the name of the disk offering of the virtual machine"`
|
||||
DisplayName string `json:"displayname,omitempty" doc:"user generated name. The name of the virtual machine is returned if no displayname exists."`
|
||||
ForVirtualNetwork bool `json:"forvirtualnetwork,omitempty" doc:"the virtual network for the service offering"`
|
||||
Group string `json:"group,omitempty" doc:"the group name of the virtual machine"`
|
||||
GroupID *UUID `json:"groupid,omitempty" doc:"the group ID of the virtual machine"`
|
||||
HAEnable bool `json:"haenable,omitempty" doc:"true if high-availability is enabled, false otherwise"`
|
||||
HostName string `json:"hostname,omitempty" doc:"the name of the host for the virtual machine"`
|
||||
ID *UUID `json:"id,omitempty" doc:"the ID of the virtual machine"`
|
||||
InstanceName string `json:"instancename,omitempty" doc:"instance name of the user vm; this parameter is returned to the ROOT admin only"`
|
||||
IsoDisplayText string `json:"isodisplaytext,omitempty" doc:"an alternate display text of the ISO attached to the virtual machine"`
|
||||
IsoID *UUID `json:"isoid,omitempty" doc:"the ID of the ISO attached to the virtual machine"`
|
||||
IsoName string `json:"isoname,omitempty" doc:"the name of the ISO attached to the virtual machine"`
|
||||
KeyPair string `json:"keypair,omitempty" doc:"ssh key-pair"`
|
||||
Memory int `json:"memory,omitempty" doc:"the memory allocated for the virtual machine"`
|
||||
Name string `json:"name,omitempty" doc:"the name of the virtual machine"`
|
||||
NetworkKbsRead int64 `json:"networkkbsread,omitempty" doc:"the incoming network traffic on the vm"`
|
||||
NetworkKbsWrite int64 `json:"networkkbswrite,omitempty" doc:"the outgoing network traffic on the host"`
|
||||
Nic []Nic `json:"nic,omitempty" doc:"the list of nics associated with vm"`
|
||||
OSCategoryID *UUID `json:"oscategoryid,omitempty" doc:"Os category ID of the virtual machine"`
|
||||
OSCategoryName string `json:"oscategoryname,omitempty" doc:"Os category name of the virtual machine"`
|
||||
OSTypeID *UUID `json:"ostypeid,omitempty" doc:"OS type id of the vm"`
|
||||
Password string `json:"password,omitempty" doc:"the password (if exists) of the virtual machine"`
|
||||
PasswordEnabled bool `json:"passwordenabled,omitempty" doc:"true if the password rest feature is enabled, false otherwise"`
|
||||
PCIDevices []PCIDevice `json:"pcidevices,omitempty" doc:"list of PCI devices"`
|
||||
PodID *UUID `json:"podid,omitempty" doc:"the ID of the vm's pod"`
|
||||
PodName string `json:"podname,omitempty" doc:"the name of the vm's pod"`
|
||||
PublicIP string `json:"publicip,omitempty" doc:"public IP address id associated with vm via Static nat rule"`
|
||||
PublicIPID *UUID `json:"publicipid,omitempty" doc:"public IP address id associated with vm via Static nat rule"`
|
||||
RootDeviceID int64 `json:"rootdeviceid,omitempty" doc:"device ID of the root volume"`
|
||||
RootDeviceType string `json:"rootdevicetype,omitempty" doc:"device type of the root volume"`
|
||||
SecurityGroup []SecurityGroup `json:"securitygroup,omitempty" doc:"list of security groups associated with the virtual machine"`
|
||||
ServiceOfferingID *UUID `json:"serviceofferingid,omitempty" doc:"the ID of the service offering of the virtual machine"`
|
||||
ServiceOfferingName string `json:"serviceofferingname,omitempty" doc:"the name of the service offering of the virtual machine"`
|
||||
ServiceState string `json:"servicestate,omitempty" doc:"State of the Service from LB rule"`
|
||||
State string `json:"state,omitempty" doc:"the state of the virtual machine"`
|
||||
Tags []ResourceTag `json:"tags,omitempty" doc:"the list of resource tags associated with vm"`
|
||||
TemplateDisplayText string `json:"templatedisplaytext,omitempty" doc:"an alternate display text of the template for the virtual machine"`
|
||||
TemplateID *UUID `json:"templateid,omitempty" doc:"the ID of the template for the virtual machine. A -1 is returned if the virtual machine was created from an ISO file."`
|
||||
TemplateName string `json:"templatename,omitempty" doc:"the name of the template for the virtual machine"`
|
||||
ZoneID *UUID `json:"zoneid,omitempty" doc:"the ID of the availablility zone for the virtual machine"`
|
||||
ZoneName string `json:"zonename,omitempty" doc:"the name of the availability zone for the virtual machine"`
|
||||
}
|
||||
|
||||
// ResourceType returns the type of the resource
|
||||
@ -122,11 +119,9 @@ func (vm VirtualMachine) Delete(ctx context.Context, client *Client) error {
|
||||
|
||||
// ListRequest builds the ListVirtualMachines request
|
||||
func (vm VirtualMachine) ListRequest() (ListCommand, error) {
|
||||
// XXX: AffinityGroupID, SecurityGroupID, Tags
|
||||
// XXX: AffinityGroupID, SecurityGroupID
|
||||
|
||||
req := &ListVirtualMachines{
|
||||
Account: vm.Account,
|
||||
DomainID: vm.DomainID,
|
||||
GroupID: vm.GroupID,
|
||||
ID: vm.ID,
|
||||
Name: vm.Name,
|
||||
@ -140,14 +135,18 @@ func (vm VirtualMachine) ListRequest() (ListCommand, error) {
|
||||
req.IPAddress = nic.IPAddress
|
||||
}
|
||||
|
||||
for i := range vm.Tags {
|
||||
req.Tags = append(req.Tags, vm.Tags[i])
|
||||
}
|
||||
|
||||
return req, nil
|
||||
}
|
||||
|
||||
// DefaultNic returns the default nic
|
||||
func (vm VirtualMachine) DefaultNic() *Nic {
|
||||
for _, nic := range vm.Nic {
|
||||
for i, nic := range vm.Nic {
|
||||
if nic.IsDefault {
|
||||
return &nic
|
||||
return &vm.Nic[i]
|
||||
}
|
||||
}
|
||||
|
||||
@ -171,8 +170,9 @@ func (vm VirtualMachine) NicsByType(nicType string) []Nic {
|
||||
for _, nic := range vm.Nic {
|
||||
if nic.Type == nicType {
|
||||
// XXX The API forgets to specify it
|
||||
nic.VirtualMachineID = vm.ID
|
||||
nics = append(nics, nic)
|
||||
n := nic
|
||||
n.VirtualMachineID = vm.ID
|
||||
nics = append(nics, n)
|
||||
}
|
||||
}
|
||||
return nics
|
||||
@ -184,8 +184,9 @@ func (vm VirtualMachine) NicsByType(nicType string) []Nic {
|
||||
func (vm VirtualMachine) NicByNetworkID(networkID UUID) *Nic {
|
||||
for _, nic := range vm.Nic {
|
||||
if nic.NetworkID.Equal(networkID) {
|
||||
nic.VirtualMachineID = vm.ID
|
||||
return &nic
|
||||
n := nic
|
||||
n.VirtualMachineID = vm.ID
|
||||
return &n
|
||||
}
|
||||
}
|
||||
return nil
|
||||
@ -195,8 +196,9 @@ func (vm VirtualMachine) NicByNetworkID(networkID UUID) *Nic {
|
||||
func (vm VirtualMachine) NicByID(nicID UUID) *Nic {
|
||||
for _, nic := range vm.Nic {
|
||||
if nic.ID.Equal(nicID) {
|
||||
nic.VirtualMachineID = vm.ID
|
||||
return &nic
|
||||
n := nic
|
||||
n.VirtualMachineID = vm.ID
|
||||
return &n
|
||||
}
|
||||
}
|
||||
|
||||
@ -213,10 +215,10 @@ type IPToNetwork struct {
|
||||
// PCIDevice represents a PCI card present in the host
|
||||
type PCIDevice struct {
|
||||
PCIVendorName string `json:"pcivendorname,omitempty" doc:"Device vendor name of pci card"`
|
||||
DeviceID *UUID `json:"deviceid,omitempty" doc:"Device model ID of pci card"`
|
||||
DeviceID string `json:"deviceid,omitempty" doc:"Device model ID of pci card"`
|
||||
RemainingCapacity int `json:"remainingcapacity,omitempty" doc:"Remaining capacity in terms of no. of more VMs that can be deployped with this vGPU type"`
|
||||
MaxCapacity int `json:"maxcapacity,omitempty" doc:"Maximum vgpu can be created with this vgpu type on the given pci group"`
|
||||
PCIVendorID *UUID `json:"pcivendorid,omitempty" doc:"Device vendor ID of pci card"`
|
||||
PCIVendorID string `json:"pcivendorid,omitempty" doc:"Device vendor ID of pci card"`
|
||||
PCIDeviceName string `json:"pcidevicename,omitempty" doc:"Device model name of pci card"`
|
||||
}
|
||||
|
||||
@ -229,8 +231,8 @@ type Password struct {
|
||||
|
||||
// VirtualMachineUserData represents the base64 encoded user-data
|
||||
type VirtualMachineUserData struct {
|
||||
UserData string `json:"userdata,omitempty" doc:"Base 64 encoded VM user data"`
|
||||
VirtualMachineID *UUID `json:"virtualmachineid,omitempty" doc:"the ID of the virtual machine"`
|
||||
UserData string `json:"userdata" doc:"Base 64 encoded VM user data"`
|
||||
VirtualMachineID *UUID `json:"virtualmachineid" doc:"the ID of the virtual machine"`
|
||||
}
|
||||
|
||||
// Decode decodes as a readable string the content of the user-data (base64 · gzip)
|
||||
@ -260,24 +262,16 @@ func (userdata VirtualMachineUserData) Decode() (string, error) {
|
||||
//
|
||||
// Regarding the UserData field, the client is responsible to base64 (and probably gzip) it. Doing it within this library would make the integration with other tools, e.g. Terraform harder.
|
||||
type DeployVirtualMachine struct {
|
||||
Account string `json:"account,omitempty" doc:"an optional account for the virtual machine. Must be used with domainId."`
|
||||
AffinityGroupIDs []UUID `json:"affinitygroupids,omitempty" doc:"comma separated list of affinity groups id that are going to be applied to the virtual machine. Mutually exclusive with affinitygroupnames parameter"`
|
||||
AffinityGroupNames []string `json:"affinitygroupnames,omitempty" doc:"comma separated list of affinity groups names that are going to be applied to the virtual machine.Mutually exclusive with affinitygroupids parameter"`
|
||||
CustomID *UUID `json:"customid,omitempty" doc:"an optional field, in case you want to set a custom id to the resource. Allowed to Root Admins only"`
|
||||
DeploymentPlanner string `json:"deploymentplanner,omitempty" doc:"Deployment planner to use for vm allocation. Available to ROOT admin only"`
|
||||
Details map[string]string `json:"details,omitempty" doc:"used to specify the custom parameters."`
|
||||
DiskOfferingID *UUID `json:"diskofferingid,omitempty" doc:"the ID of the disk offering for the virtual machine. If the template is of ISO format, the diskOfferingId is for the root disk volume. Otherwise this parameter is used to indicate the offering for the data disk volume. If the templateId parameter passed is from a Template object, the diskOfferingId refers to a DATA Disk Volume created. If the templateId parameter passed is from an ISO object, the diskOfferingId refers to a ROOT Disk Volume created."`
|
||||
DiskOfferingID *UUID `json:"diskofferingid,omitempty" doc:"the ID of the disk offering for the virtual machine. If the template is of ISO format, the diskofferingid is for the root disk volume. Otherwise this parameter is used to indicate the offering for the data disk volume. If the templateid parameter passed is from a Template object, the diskofferingid refers to a DATA Disk Volume created. If the templateid parameter passed is from an ISO object, the diskofferingid refers to a ROOT Disk Volume created."`
|
||||
DisplayName string `json:"displayname,omitempty" doc:"an optional user generated name for the virtual machine"`
|
||||
DisplayVM *bool `json:"displayvm,omitempty" doc:"an optional field, whether to the display the vm to the end user or not."`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"an optional domainId for the virtual machine. If the account parameter is used, domainId must also be used."`
|
||||
Group string `json:"group,omitempty" doc:"an optional group for the virtual machine"`
|
||||
HostID *UUID `json:"hostid,omitempty" doc:"destination Host ID to deploy the VM to - parameter available for root admin only"`
|
||||
Hypervisor string `json:"hypervisor,omitempty" doc:"the hypervisor on which to deploy the virtual machine"`
|
||||
IP4 *bool `json:"ip4,omitempty" doc:"True to set an IPv4 to the default interface"`
|
||||
IP6 *bool `json:"ip6,omitempty" doc:"True to set an IPv6 to the default interface"`
|
||||
IP6Address net.IP `json:"ip6address,omitempty" doc:"the ipv6 address for default vm's network"`
|
||||
IPAddress net.IP `json:"ipaddress,omitempty" doc:"the ip address for default vm's network"`
|
||||
IPToNetworkList []IPToNetwork `json:"iptonetworklist,omitempty" doc:"ip to network mapping. Can't be specified with networkIds parameter. Example: iptonetworklist[0].ip=10.10.10.11&iptonetworklist[0].ipv6=fc00:1234:5678::abcd&iptonetworklist[0].networkid=uuid - requests to use ip 10.10.10.11 in network id=uuid"`
|
||||
Keyboard string `json:"keyboard,omitempty" doc:"an optional keyboard device type for the virtual machine. valid value can be one of de,de-ch,es,fi,fr,fr-be,fr-ch,is,it,jp,nl-be,no,pt,uk,us"`
|
||||
KeyPair string `json:"keypair,omitempty" doc:"name of the ssh key pair used to login to the virtual machine"`
|
||||
Name string `json:"name,omitempty" doc:"host name for the virtual machine"`
|
||||
@ -286,7 +280,7 @@ type DeployVirtualMachine struct {
|
||||
SecurityGroupIDs []UUID `json:"securitygroupids,omitempty" doc:"comma separated list of security groups id that going to be applied to the virtual machine. Should be passed only when vm is created from a zone with Basic Network support. Mutually exclusive with securitygroupnames parameter"`
|
||||
SecurityGroupNames []string `json:"securitygroupnames,omitempty" doc:"comma separated list of security groups names that going to be applied to the virtual machine. Should be passed only when vm is created from a zone with Basic Network support. Mutually exclusive with securitygroupids parameter"`
|
||||
ServiceOfferingID *UUID `json:"serviceofferingid" doc:"the ID of the service offering for the virtual machine"`
|
||||
Size int64 `json:"size,omitempty" doc:"the arbitrary size for the DATADISK volume. Mutually exclusive with diskOfferingId"`
|
||||
Size int64 `json:"size,omitempty" doc:"the arbitrary size for the DATADISK volume. Mutually exclusive with diskofferingid"`
|
||||
StartVM *bool `json:"startvm,omitempty" doc:"true if start vm after creating. Default value is true"`
|
||||
TemplateID *UUID `json:"templateid" doc:"the ID of the template for the virtual machine"`
|
||||
UserData string `json:"userdata,omitempty" doc:"an optional binary data that can be sent to the virtual machine upon a successful deployment. This binary data must be base64 encoded before adding it to the request. Using HTTP GET (via querystring), you can send up to 2KB of data after base64 encoding. Using HTTP POST(via POST body), you can send up to 32K of data after base64 encoding."`
|
||||
@ -294,7 +288,7 @@ type DeployVirtualMachine struct {
|
||||
_ bool `name:"deployVirtualMachine" description:"Creates and automatically starts a virtual machine based on a service offering, disk offering, and template."`
|
||||
}
|
||||
|
||||
func (req DeployVirtualMachine) onBeforeSend(params url.Values) error {
|
||||
func (req DeployVirtualMachine) onBeforeSend(_ url.Values) error {
|
||||
// Either AffinityGroupIDs or AffinityGroupNames must be set
|
||||
if len(req.AffinityGroupIDs) > 0 && len(req.AffinityGroupNames) > 0 {
|
||||
return fmt.Errorf("either AffinityGroupIDs or AffinityGroupNames must be set")
|
||||
@ -308,27 +302,29 @@ func (req DeployVirtualMachine) onBeforeSend(params url.Values) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (DeployVirtualMachine) response() interface{} {
|
||||
// Response returns the struct to unmarshal
|
||||
func (DeployVirtualMachine) Response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (DeployVirtualMachine) asyncResponse() interface{} {
|
||||
// AsyncResponse returns the struct to unmarshal the async job
|
||||
func (DeployVirtualMachine) AsyncResponse() interface{} {
|
||||
return new(VirtualMachine)
|
||||
}
|
||||
|
||||
// StartVirtualMachine (Async) represents the creation of the virtual machine
|
||||
type StartVirtualMachine struct {
|
||||
ID *UUID `json:"id" doc:"The ID of the virtual machine"`
|
||||
DeploymentPlanner string `json:"deploymentplanner,omitempty" doc:"Deployment planner to use for vm allocation. Available to ROOT admin only"`
|
||||
HostID *UUID `json:"hostid,omitempty" doc:"destination Host ID to deploy the VM to - parameter available for root admin only"`
|
||||
_ bool `name:"startVirtualMachine" description:"Starts a virtual machine."`
|
||||
ID *UUID `json:"id" doc:"The ID of the virtual machine"`
|
||||
_ bool `name:"startVirtualMachine" description:"Starts a virtual machine."`
|
||||
}
|
||||
|
||||
func (StartVirtualMachine) response() interface{} {
|
||||
// Response returns the struct to unmarshal
|
||||
func (StartVirtualMachine) Response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (StartVirtualMachine) asyncResponse() interface{} {
|
||||
// AsyncResponse returns the struct to unmarshal the async job
|
||||
func (StartVirtualMachine) AsyncResponse() interface{} {
|
||||
return new(VirtualMachine)
|
||||
}
|
||||
|
||||
@ -339,11 +335,13 @@ type StopVirtualMachine struct {
|
||||
_ bool `name:"stopVirtualMachine" description:"Stops a virtual machine."`
|
||||
}
|
||||
|
||||
func (StopVirtualMachine) response() interface{} {
|
||||
// Response returns the struct to unmarshal
|
||||
func (StopVirtualMachine) Response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (StopVirtualMachine) asyncResponse() interface{} {
|
||||
// AsyncResponse returns the struct to unmarshal the async job
|
||||
func (StopVirtualMachine) AsyncResponse() interface{} {
|
||||
return new(VirtualMachine)
|
||||
}
|
||||
|
||||
@ -353,11 +351,13 @@ type RebootVirtualMachine struct {
|
||||
_ bool `name:"rebootVirtualMachine" description:"Reboots a virtual machine."`
|
||||
}
|
||||
|
||||
func (RebootVirtualMachine) response() interface{} {
|
||||
// Response returns the struct to unmarshal
|
||||
func (RebootVirtualMachine) Response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (RebootVirtualMachine) asyncResponse() interface{} {
|
||||
// AsyncResponse returns the struct to unmarshal the async job
|
||||
func (RebootVirtualMachine) AsyncResponse() interface{} {
|
||||
return new(VirtualMachine)
|
||||
}
|
||||
|
||||
@ -369,11 +369,13 @@ type RestoreVirtualMachine struct {
|
||||
_ bool `name:"restoreVirtualMachine" description:"Restore a VM to original template/ISO or new template/ISO"`
|
||||
}
|
||||
|
||||
func (RestoreVirtualMachine) response() interface{} {
|
||||
// Response returns the struct to unmarshal
|
||||
func (RestoreVirtualMachine) Response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (RestoreVirtualMachine) asyncResponse() interface{} {
|
||||
// AsyncResponse returns the struct to unmarshal the async job
|
||||
func (RestoreVirtualMachine) AsyncResponse() interface{} {
|
||||
return new(VirtualMachine)
|
||||
}
|
||||
|
||||
@ -383,42 +385,41 @@ type RecoverVirtualMachine struct {
|
||||
_ bool `name:"recoverVirtualMachine" description:"Recovers a virtual machine."`
|
||||
}
|
||||
|
||||
func (RecoverVirtualMachine) response() interface{} {
|
||||
// Response returns the struct to unmarshal
|
||||
func (RecoverVirtualMachine) Response() interface{} {
|
||||
return new(VirtualMachine)
|
||||
}
|
||||
|
||||
// DestroyVirtualMachine (Async) represents the destruction of the virtual machine
|
||||
type DestroyVirtualMachine struct {
|
||||
ID *UUID `json:"id" doc:"The ID of the virtual machine"`
|
||||
Expunge *bool `json:"expunge,omitempty" doc:"If true is passed, the vm is expunged immediately. False by default."`
|
||||
_ bool `name:"destroyVirtualMachine" description:"Destroys a virtual machine."`
|
||||
ID *UUID `json:"id" doc:"The ID of the virtual machine"`
|
||||
_ bool `name:"destroyVirtualMachine" description:"Destroys a virtual machine."`
|
||||
}
|
||||
|
||||
func (DestroyVirtualMachine) response() interface{} {
|
||||
// Response returns the struct to unmarshal
|
||||
func (DestroyVirtualMachine) Response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (DestroyVirtualMachine) asyncResponse() interface{} {
|
||||
// AsyncResponse returns the struct to unmarshal the async job
|
||||
func (DestroyVirtualMachine) AsyncResponse() interface{} {
|
||||
return new(VirtualMachine)
|
||||
}
|
||||
|
||||
// UpdateVirtualMachine represents the update of the virtual machine
|
||||
type UpdateVirtualMachine struct {
|
||||
ID *UUID `json:"id" doc:"The ID of the virtual machine"`
|
||||
CustomID *UUID `json:"customid,omitempty" doc:"an optional field, in case you want to set a custom id to the resource. Allowed to Root Admins only"`
|
||||
Details map[string]string `json:"details,omitempty" doc:"Details in key/value pairs."`
|
||||
DisplayName string `json:"displayname,omitempty" doc:"user generated name"`
|
||||
DisplayVM *bool `json:"displayvm,omitempty" doc:"an optional field, whether to the display the vm to the end user or not."`
|
||||
Group string `json:"group,omitempty" doc:"group of the virtual machine"`
|
||||
HAEnable *bool `json:"haenable,omitempty" doc:"true if high-availability is enabled for the virtual machine, false otherwise"`
|
||||
IsDynamicallyScalable *bool `json:"isdynamicallyscalable,omitempty" doc:"true if VM contains XS/VMWare tools inorder to support dynamic scaling of VM cpu/memory"`
|
||||
Name string `json:"name,omitempty" doc:"new host name of the vm. The VM has to be stopped/started for this update to take affect"`
|
||||
SecurityGroupIDs []UUID `json:"securitygroupids,omitempty" doc:"list of security group ids to be applied on the virtual machine."`
|
||||
UserData string `json:"userdata,omitempty" doc:"an optional binary data that can be sent to the virtual machine upon a successful deployment. This binary data must be base64 encoded before adding it to the request. Using HTTP GET (via querystring), you can send up to 2KB of data after base64 encoding. Using HTTP POST(via POST body), you can send up to 32K of data after base64 encoding."`
|
||||
_ bool `name:"updateVirtualMachine" description:"Updates properties of a virtual machine. The VM has to be stopped and restarted for the new properties to take effect. UpdateVirtualMachine does not first check whether the VM is stopped. Therefore, stop the VM manually before issuing this call."`
|
||||
ID *UUID `json:"id" doc:"The ID of the virtual machine"`
|
||||
Details map[string]string `json:"details,omitempty" doc:"Details in key/value pairs."`
|
||||
DisplayName string `json:"displayname,omitempty" doc:"user generated name"`
|
||||
Group string `json:"group,omitempty" doc:"group of the virtual machine"`
|
||||
Name string `json:"name,omitempty" doc:"new host name of the vm. The VM has to be stopped/started for this update to take affect"`
|
||||
SecurityGroupIDs []UUID `json:"securitygroupids,omitempty" doc:"list of security group ids to be applied on the virtual machine."`
|
||||
UserData string `json:"userdata,omitempty" doc:"an optional binary data that can be sent to the virtual machine upon a successful deployment. This binary data must be base64 encoded before adding it to the request. Using HTTP GET (via querystring), you can send up to 2KB of data after base64 encoding. Using HTTP POST(via POST body), you can send up to 32K of data after base64 encoding."`
|
||||
_ bool `name:"updateVirtualMachine" description:"Updates properties of a virtual machine. The VM has to be stopped and restarted for the new properties to take effect. UpdateVirtualMachine does not first check whether the VM is stopped. Therefore, stop the VM manually before issuing this call."`
|
||||
}
|
||||
|
||||
func (UpdateVirtualMachine) response() interface{} {
|
||||
// Response returns the struct to unmarshal
|
||||
func (UpdateVirtualMachine) Response() interface{} {
|
||||
return new(VirtualMachine)
|
||||
}
|
||||
|
||||
@ -428,12 +429,14 @@ type ExpungeVirtualMachine struct {
|
||||
_ bool `name:"expungeVirtualMachine" description:"Expunge a virtual machine. Once expunged, it cannot be recoverd."`
|
||||
}
|
||||
|
||||
func (ExpungeVirtualMachine) response() interface{} {
|
||||
// Response returns the struct to unmarshal
|
||||
func (ExpungeVirtualMachine) Response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (ExpungeVirtualMachine) asyncResponse() interface{} {
|
||||
return new(booleanResponse)
|
||||
// AsyncResponse returns the struct to unmarshal the async job
|
||||
func (ExpungeVirtualMachine) AsyncResponse() interface{} {
|
||||
return new(BooleanResponse)
|
||||
}
|
||||
|
||||
// ScaleVirtualMachine (Async) scales the virtual machine to a new service offering.
|
||||
@ -447,12 +450,14 @@ type ScaleVirtualMachine struct {
|
||||
_ bool `name:"scaleVirtualMachine" description:"Scales the virtual machine to a new service offering."`
|
||||
}
|
||||
|
||||
func (ScaleVirtualMachine) response() interface{} {
|
||||
// Response returns the struct to unmarshal
|
||||
func (ScaleVirtualMachine) Response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (ScaleVirtualMachine) asyncResponse() interface{} {
|
||||
return new(booleanResponse)
|
||||
// AsyncResponse returns the struct to unmarshal the async job
|
||||
func (ScaleVirtualMachine) AsyncResponse() interface{} {
|
||||
return new(BooleanResponse)
|
||||
}
|
||||
|
||||
// ChangeServiceForVirtualMachine changes the service offering for a virtual machine. The virtual machine must be in a "Stopped" state for this command to take effect.
|
||||
@ -463,7 +468,8 @@ type ChangeServiceForVirtualMachine struct {
|
||||
_ bool `name:"changeServiceForVirtualMachine" description:"Changes the service offering for a virtual machine. The virtual machine must be in a \"Stopped\" state for this command to take effect."`
|
||||
}
|
||||
|
||||
func (ChangeServiceForVirtualMachine) response() interface{} {
|
||||
// Response returns the struct to unmarshal
|
||||
func (ChangeServiceForVirtualMachine) Response() interface{} {
|
||||
return new(VirtualMachine)
|
||||
}
|
||||
|
||||
@ -473,10 +479,13 @@ type ResetPasswordForVirtualMachine struct {
|
||||
_ bool `name:"resetPasswordForVirtualMachine" description:"Resets the password for virtual machine. The virtual machine must be in a \"Stopped\" state and the template must already support this feature for this command to take effect."`
|
||||
}
|
||||
|
||||
func (ResetPasswordForVirtualMachine) response() interface{} {
|
||||
// Response returns the struct to unmarshal
|
||||
func (ResetPasswordForVirtualMachine) Response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
func (ResetPasswordForVirtualMachine) asyncResponse() interface{} {
|
||||
|
||||
// AsyncResponse returns the struct to unmarshal the async job
|
||||
func (ResetPasswordForVirtualMachine) AsyncResponse() interface{} {
|
||||
return new(VirtualMachine)
|
||||
}
|
||||
|
||||
@ -486,28 +495,24 @@ type GetVMPassword struct {
|
||||
_ bool `name:"getVMPassword" description:"Returns an encrypted password for the VM"`
|
||||
}
|
||||
|
||||
func (GetVMPassword) response() interface{} {
|
||||
// Response returns the struct to unmarshal
|
||||
func (GetVMPassword) Response() interface{} {
|
||||
return new(Password)
|
||||
}
|
||||
|
||||
//go:generate go run generate/main.go -interface=Listable ListVirtualMachines
|
||||
|
||||
// ListVirtualMachines represents a search for a VM
|
||||
type ListVirtualMachines struct {
|
||||
Account string `json:"account,omitempty" doc:"list resources by account. Must be used with the domainId parameter."`
|
||||
AffinityGroupID *UUID `json:"affinitygroupid,omitempty" doc:"list vms by affinity group"`
|
||||
Details []string `json:"details,omitempty" doc:"comma separated list of host details requested, value can be a list of [all, group, nics, stats, secgrp, tmpl, servoff, diskoff, iso, volume, min, affgrp]. If no parameter is passed in, the details will be defaulted to all"`
|
||||
DisplayVM *bool `json:"displayvm,omitempty" doc:"list resources by display flag; only ROOT admin is eligible to pass this parameter"`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"list only resources belonging to the domain specified"`
|
||||
ForVirtualNetwork *bool `json:"forvirtualnetwork,omitempty" doc:"list by network type; true if need to list vms using Virtual Network, false otherwise"`
|
||||
GroupID *UUID `json:"groupid,omitempty" doc:"the group ID"`
|
||||
HostID *UUID `json:"hostid,omitempty" doc:"the host ID"`
|
||||
Hypervisor string `json:"hypervisor,omitempty" doc:"the target hypervisor for the template"`
|
||||
ID *UUID `json:"id,omitempty" doc:"the ID of the virtual machine"`
|
||||
IDs []string `json:"ids,omitempty" doc:"the IDs of the virtual machines, mutually exclusive with id"`
|
||||
IDs []UUID `json:"ids,omitempty" doc:"the IDs of the virtual machines, mutually exclusive with id"`
|
||||
IPAddress net.IP `json:"ipaddress,omitempty" doc:"an IP address to filter the result"`
|
||||
IsoID *UUID `json:"isoid,omitempty" doc:"list vms by iso"`
|
||||
IsRecursive *bool `json:"isrecursive,omitempty" doc:"defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves."`
|
||||
Keyword string `json:"keyword,omitempty" doc:"List by keyword"`
|
||||
ListAll *bool `json:"listall,omitempty" doc:"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"`
|
||||
Name string `json:"name,omitempty" doc:"name of the virtual machine"`
|
||||
NetworkID *UUID `json:"networkid,omitempty" doc:"list by network id"`
|
||||
Page int `json:"page,omitempty"`
|
||||
@ -526,47 +531,21 @@ type ListVirtualMachinesResponse struct {
|
||||
VirtualMachine []VirtualMachine `json:"virtualmachine"`
|
||||
}
|
||||
|
||||
func (ListVirtualMachines) response() interface{} {
|
||||
return new(ListVirtualMachinesResponse)
|
||||
}
|
||||
|
||||
// SetPage sets the current page
|
||||
func (ls *ListVirtualMachines) SetPage(page int) {
|
||||
ls.Page = page
|
||||
}
|
||||
|
||||
// SetPageSize sets the page size
|
||||
func (ls *ListVirtualMachines) SetPageSize(pageSize int) {
|
||||
ls.PageSize = pageSize
|
||||
}
|
||||
|
||||
func (ListVirtualMachines) each(resp interface{}, callback IterateItemFunc) {
|
||||
vms, ok := resp.(*ListVirtualMachinesResponse)
|
||||
if !ok {
|
||||
callback(nil, fmt.Errorf("wrong type. ListVirtualMachinesResponse expected, got %T", resp))
|
||||
return
|
||||
}
|
||||
|
||||
for i := range vms.VirtualMachine {
|
||||
if !callback(&vms.VirtualMachine[i], nil) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// AddNicToVirtualMachine (Async) adds a NIC to a VM
|
||||
type AddNicToVirtualMachine struct {
|
||||
NetworkID *UUID `json:"networkid" doc:"Network ID"`
|
||||
VirtualMachineID *UUID `json:"virtualmachineid" doc:"Virtual Machine ID"`
|
||||
IPAddress net.IP `json:"ipaddress,omitempty" doc:"IP Address for the new network"`
|
||||
IPAddress net.IP `json:"ipaddress,omitempty" doc:"Static IP address lease for the corresponding NIC and network which should be in the range defined in the network"`
|
||||
_ bool `name:"addNicToVirtualMachine" description:"Adds VM to specified network by creating a NIC"`
|
||||
}
|
||||
|
||||
func (AddNicToVirtualMachine) response() interface{} {
|
||||
// Response returns the struct to unmarshal
|
||||
func (AddNicToVirtualMachine) Response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (AddNicToVirtualMachine) asyncResponse() interface{} {
|
||||
// AsyncResponse returns the struct to unmarshal the async job
|
||||
func (AddNicToVirtualMachine) AsyncResponse() interface{} {
|
||||
return new(VirtualMachine)
|
||||
}
|
||||
|
||||
@ -577,11 +556,13 @@ type RemoveNicFromVirtualMachine struct {
|
||||
_ bool `name:"removeNicFromVirtualMachine" description:"Removes VM from specified network by deleting a NIC"`
|
||||
}
|
||||
|
||||
func (RemoveNicFromVirtualMachine) response() interface{} {
|
||||
// Response returns the struct to unmarshal
|
||||
func (RemoveNicFromVirtualMachine) Response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (RemoveNicFromVirtualMachine) asyncResponse() interface{} {
|
||||
// AsyncResponse returns the struct to unmarshal the async job
|
||||
func (RemoveNicFromVirtualMachine) AsyncResponse() interface{} {
|
||||
return new(VirtualMachine)
|
||||
}
|
||||
|
||||
@ -592,10 +573,13 @@ type UpdateDefaultNicForVirtualMachine struct {
|
||||
_ bool `name:"updateDefaultNicForVirtualMachine" description:"Changes the default NIC on a VM"`
|
||||
}
|
||||
|
||||
func (UpdateDefaultNicForVirtualMachine) response() interface{} {
|
||||
// Response returns the struct to unmarshal
|
||||
func (UpdateDefaultNicForVirtualMachine) Response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
func (UpdateDefaultNicForVirtualMachine) asyncResponse() interface{} {
|
||||
|
||||
// AsyncResponse returns the struct to unmarshal the async job
|
||||
func (UpdateDefaultNicForVirtualMachine) AsyncResponse() interface{} {
|
||||
return new(VirtualMachine)
|
||||
}
|
||||
|
||||
@ -605,24 +589,24 @@ type GetVirtualMachineUserData struct {
|
||||
_ bool `name:"getVirtualMachineUserData" description:"Returns user data associated with the VM"`
|
||||
}
|
||||
|
||||
func (GetVirtualMachineUserData) response() interface{} {
|
||||
// Response returns the struct to unmarshal
|
||||
func (GetVirtualMachineUserData) Response() interface{} {
|
||||
return new(VirtualMachineUserData)
|
||||
}
|
||||
|
||||
// Decode decodes the base64 / gzipped encoded user data
|
||||
|
||||
// MigrateVirtualMachine (Async) attempts migration of a VM to a different host or Root volume of the vm to a different storage pool
|
||||
type MigrateVirtualMachine struct {
|
||||
HostID *UUID `json:"hostid,omitempty" doc:"Destination Host ID to migrate VM to. Required for live migrating a VM from host to host"`
|
||||
StorageID *UUID `json:"storageid,omitempty" doc:"Destination storage pool ID to migrate VM volumes to. Required for migrating the root disk volume"`
|
||||
VirtualMachineID *UUID `json:"virtualmachineid" doc:"the ID of the virtual machine"`
|
||||
_ bool `name:"migrateVirtualMachine" description:"Attempts Migration of a VM to a different host or Root volume of the vm to a different storage pool"`
|
||||
// UpdateVMNicIP updates the default IP address of a VM Nic
|
||||
type UpdateVMNicIP struct {
|
||||
_ bool `name:"updateVmNicIp" description:"Update the default Ip of a VM Nic"`
|
||||
IPAddress net.IP `json:"ipaddress,omitempty" doc:"Static IP address lease for the corresponding NIC and network which should be in the range defined in the network. If absent, the call removes the lease associated with the nic."`
|
||||
NicID *UUID `json:"nicid" doc:"the ID of the nic."`
|
||||
}
|
||||
|
||||
func (MigrateVirtualMachine) response() interface{} {
|
||||
// Response returns the struct to unmarshal
|
||||
func (UpdateVMNicIP) Response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (MigrateVirtualMachine) asyncResponse() interface{} {
|
||||
// AsyncResponse returns the struct to unmarshal the async job
|
||||
func (UpdateVMNicIP) AsyncResponse() interface{} {
|
||||
return new(VirtualMachine)
|
||||
}
|
||||
|
43
vendor/github.com/exoscale/egoscale/virtualmachines_response.go
generated
vendored
Normal file
43
vendor/github.com/exoscale/egoscale/virtualmachines_response.go
generated
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
// code generated; DO NOT EDIT.
|
||||
|
||||
package egoscale
|
||||
|
||||
import "fmt"
|
||||
|
||||
// Response returns the struct to unmarshal
|
||||
func (ListVirtualMachines) Response() interface{} {
|
||||
return new(ListVirtualMachinesResponse)
|
||||
}
|
||||
|
||||
// ListRequest returns itself
|
||||
func (ls *ListVirtualMachines) ListRequest() (ListCommand, error) {
|
||||
if ls == nil {
|
||||
return nil, fmt.Errorf("%T cannot be nil", ls)
|
||||
}
|
||||
return ls, nil
|
||||
}
|
||||
|
||||
// SetPage sets the current apge
|
||||
func (ls *ListVirtualMachines) SetPage(page int) {
|
||||
ls.Page = page
|
||||
}
|
||||
|
||||
// SetPageSize sets the page size
|
||||
func (ls *ListVirtualMachines) SetPageSize(pageSize int) {
|
||||
ls.PageSize = pageSize
|
||||
}
|
||||
|
||||
// Each triggers the callback for each, valid answer or any non 404 issue
|
||||
func (ListVirtualMachines) Each(resp interface{}, callback IterateItemFunc) {
|
||||
items, ok := resp.(*ListVirtualMachinesResponse)
|
||||
if !ok {
|
||||
callback(nil, fmt.Errorf("wrong type, ListVirtualMachinesResponse was expected, got %T", resp))
|
||||
return
|
||||
}
|
||||
|
||||
for i := range items.VirtualMachine {
|
||||
if !callback(&items.VirtualMachine[i], nil) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
68
vendor/github.com/exoscale/egoscale/vm_groups.go
generated
vendored
68
vendor/github.com/exoscale/egoscale/vm_groups.go
generated
vendored
@ -1,68 +0,0 @@
|
||||
package egoscale
|
||||
|
||||
// InstanceGroup represents a group of VM
|
||||
type InstanceGroup struct {
|
||||
Account string `json:"account,omitempty" doc:"the account owning the instance group"`
|
||||
Created string `json:"created,omitempty" doc:"time and date the instance group was created"`
|
||||
Domain string `json:"domain,omitempty" doc:"the domain name of the instance group"`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"the domain ID of the instance group"`
|
||||
ID *UUID `json:"id,omitempty" doc:"the id of the instance group"`
|
||||
Name string `json:"name,omitempty" doc:"the name of the instance group"`
|
||||
}
|
||||
|
||||
// CreateInstanceGroup creates a VM group
|
||||
type CreateInstanceGroup struct {
|
||||
Name string `json:"name" doc:"the name of the instance group"`
|
||||
Account string `json:"account,omitempty" doc:"the account of the instance group. The account parameter must be used with the domainId parameter."`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"the domain ID of account owning the instance group"`
|
||||
_ bool `name:"createInstanceGroup" description:"Creates a vm group"`
|
||||
}
|
||||
|
||||
func (CreateInstanceGroup) response() interface{} {
|
||||
return new(InstanceGroup)
|
||||
}
|
||||
|
||||
// UpdateInstanceGroup updates a VM group
|
||||
type UpdateInstanceGroup struct {
|
||||
ID *UUID `json:"id" doc:"Instance group ID"`
|
||||
Name string `json:"name,omitempty" doc:"new instance group name"`
|
||||
_ bool `name:"updateInstanceGroup" description:"Updates a vm group"`
|
||||
}
|
||||
|
||||
func (UpdateInstanceGroup) response() interface{} {
|
||||
return new(InstanceGroup)
|
||||
}
|
||||
|
||||
// DeleteInstanceGroup deletes a VM group
|
||||
type DeleteInstanceGroup struct {
|
||||
ID *UUID `json:"id" doc:"the ID of the instance group"`
|
||||
_ bool `name:"deleteInstanceGroup" description:"Deletes a vm group"`
|
||||
}
|
||||
|
||||
func (DeleteInstanceGroup) response() interface{} {
|
||||
return new(booleanResponse)
|
||||
}
|
||||
|
||||
// ListInstanceGroups lists VM groups
|
||||
type ListInstanceGroups struct {
|
||||
Account string `json:"account,omitempty" doc:"list resources by account. Must be used with the domainId parameter."`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"list only resources belonging to the domain specified"`
|
||||
ID *UUID `json:"id,omitempty" doc:"list instance groups by ID"`
|
||||
IsRecursive *bool `json:"isrecursive,omitempty" doc:"defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves."`
|
||||
Keyword string `json:"keyword,omitempty" doc:"List by keyword"`
|
||||
ListAll *bool `json:"listall,omitempty" doc:"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"`
|
||||
Name string `json:"name,omitempty" doc:"list instance groups by name"`
|
||||
Page int `json:"page,omitempty"`
|
||||
PageSize int `json:"pagesize,omitempty"`
|
||||
_ bool `name:"listInstanceGroups" description:"Lists vm groups"`
|
||||
}
|
||||
|
||||
// ListInstanceGroupsResponse represents a list of instance groups
|
||||
type ListInstanceGroupsResponse struct {
|
||||
Count int `json:"count"`
|
||||
InstanceGroup []InstanceGroup `json:"instancegroup"`
|
||||
}
|
||||
|
||||
func (ListInstanceGroups) response() interface{} {
|
||||
return new(ListInstanceGroupsResponse)
|
||||
}
|
69
vendor/github.com/exoscale/egoscale/volumes.go
generated
vendored
69
vendor/github.com/exoscale/egoscale/volumes.go
generated
vendored
@ -1,9 +1,5 @@
|
||||
package egoscale
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// Volume represents a volume linked to a VM
|
||||
type Volume struct {
|
||||
Account string `json:"account,omitempty" doc:"the account associated with the disk volume"`
|
||||
@ -22,8 +18,6 @@ type Volume struct {
|
||||
DiskOfferingID *UUID `json:"diskofferingid,omitempty" doc:"ID of the disk offering"`
|
||||
DiskOfferingName string `json:"diskofferingname,omitempty" doc:"name of the disk offering"`
|
||||
DisplayVolume bool `json:"displayvolume,omitempty" doc:"an optional field whether to the display the volume to the end user or not."`
|
||||
Domain string `json:"domain,omitempty" doc:"the domain associated with the disk volume"`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"the ID of the domain associated with the disk volume"`
|
||||
Hypervisor string `json:"hypervisor,omitempty" doc:"Hypervisor the volume belongs to"`
|
||||
ID *UUID `json:"id,omitempty" doc:"ID of the disk volume"`
|
||||
IsExtractable *bool `json:"isextractable,omitempty" doc:"true if the volume is extractable, false otherwise"`
|
||||
@ -49,7 +43,7 @@ type Volume struct {
|
||||
StorageType string `json:"storagetype,omitempty" doc:"shared or local storage"`
|
||||
Tags []ResourceTag `json:"tags,omitempty" doc:"the list of resource tags associated with volume"`
|
||||
TemplateDisplayText string `json:"templatedisplaytext,omitempty" doc:"an alternate display text of the template for the virtual machine"`
|
||||
TemplateID string `json:"templateid,omitempty" doc:"the ID of the template for the virtual machine. A -1 is returned if the virtual machine was created from an ISO file."` // no *UUID because of the -1 thingy...
|
||||
TemplateID *UUID `json:"templateid,omitempty" doc:"the ID of the template for the virtual machine. A -1 is returned if the virtual machine was created from an ISO file."` // no *UUID because of the -1 thingy...
|
||||
TemplateName string `json:"templatename,omitempty" doc:"the name of the template for the virtual machine"`
|
||||
Type string `json:"type,omitempty" doc:"type of the disk volume (ROOT or DATADISK)"`
|
||||
VirtualMachineID *UUID `json:"virtualmachineid,omitempty" doc:"id of the virtual machine"`
|
||||
@ -68,8 +62,6 @@ func (Volume) ResourceType() string {
|
||||
// ListRequest builds the ListVolumes request
|
||||
func (vol Volume) ListRequest() (ListCommand, error) {
|
||||
req := &ListVolumes{
|
||||
Account: vol.Account,
|
||||
DomainID: vol.DomainID,
|
||||
Name: vol.Name,
|
||||
Type: vol.Type,
|
||||
VirtualMachineID: vol.VirtualMachineID,
|
||||
@ -83,39 +75,34 @@ func (vol Volume) ListRequest() (ListCommand, error) {
|
||||
type ResizeVolume struct {
|
||||
ID *UUID `json:"id" doc:"the ID of the disk volume"`
|
||||
DiskOfferingID *UUID `json:"diskofferingid,omitempty" doc:"new disk offering id"`
|
||||
ShrinkOk *bool `json:"shrinkok,omitempty" doc:"Verify OK to Shrink"`
|
||||
Size int64 `json:"size,omitempty" doc:"New volume size in G"`
|
||||
Size int64 `json:"size,omitempty" doc:"New volume size in G (must be larger than current size since shrinking the disk is not supported)"`
|
||||
_ bool `name:"resizeVolume" description:"Resizes a volume"`
|
||||
}
|
||||
|
||||
func (ResizeVolume) response() interface{} {
|
||||
// Response returns the struct to unmarshal
|
||||
func (ResizeVolume) Response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (ResizeVolume) asyncResponse() interface{} {
|
||||
// AsyncResponse returns the struct to unmarshal the async job
|
||||
func (ResizeVolume) AsyncResponse() interface{} {
|
||||
return new(Volume)
|
||||
}
|
||||
|
||||
//go:generate go run generate/main.go -interface=Listable ListVolumes
|
||||
|
||||
// ListVolumes represents a query listing volumes
|
||||
type ListVolumes struct {
|
||||
Account string `json:"account,omitempty" doc:"list resources by account. Must be used with the domainId parameter."`
|
||||
DiskOfferingID *UUID `json:"diskofferingid,omitempty" doc:"list volumes by disk offering"`
|
||||
DisplayVolume *bool `json:"displayvolume,omitempty" doc:"list resources by display flag; only ROOT admin is eligible to pass this parameter"`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"list only resources belonging to the domain specified"`
|
||||
HostID *UUID `json:"hostid,omitempty" doc:"list volumes on specified host"`
|
||||
ID *UUID `json:"id,omitempty" doc:"the ID of the disk volume"`
|
||||
IsRecursive *bool `json:"isrecursive,omitempty" doc:"defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves."`
|
||||
DiskOfferingID *UUID `json:"diskofferingid,omitempty" doc:"List volumes by disk offering"`
|
||||
ID *UUID `json:"id,omitempty" doc:"The ID of the disk volume"`
|
||||
Keyword string `json:"keyword,omitempty" doc:"List by keyword"`
|
||||
ListAll *bool `json:"listall,omitempty" doc:"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"`
|
||||
Name string `json:"name,omitempty" doc:"the name of the disk volume"`
|
||||
Name string `json:"name,omitempty" doc:"The name of the disk volume"`
|
||||
Page int `json:"page,omitempty"`
|
||||
PageSize int `json:"pagesize,omitempty"`
|
||||
PodID *UUID `json:"podid,omitempty" doc:"the pod id the disk volume belongs to"`
|
||||
StorageID *UUID `json:"storageid,omitempty" doc:"the ID of the storage pool, available to ROOT admin only"`
|
||||
Tags []ResourceTag `json:"tags,omitempty" doc:"List resources by tags (key/value pairs)"`
|
||||
Type string `json:"type,omitempty" doc:"the type of disk volume"`
|
||||
VirtualMachineID *UUID `json:"virtualmachineid,omitempty" doc:"the ID of the virtual machine"`
|
||||
ZoneID *UUID `json:"zoneid,omitempty" doc:"the ID of the availability zone"`
|
||||
Type string `json:"type,omitempty" doc:"The type of disk volume"`
|
||||
VirtualMachineID *UUID `json:"virtualmachineid,omitempty" doc:"The ID of the virtual machine"`
|
||||
ZoneID *UUID `json:"zoneid,omitempty" doc:"The ID of the availability zone"`
|
||||
_ bool `name:"listVolumes" description:"Lists all volumes."`
|
||||
}
|
||||
|
||||
@ -124,31 +111,3 @@ type ListVolumesResponse struct {
|
||||
Count int `json:"count"`
|
||||
Volume []Volume `json:"volume"`
|
||||
}
|
||||
|
||||
func (ListVolumes) response() interface{} {
|
||||
return new(ListVolumesResponse)
|
||||
}
|
||||
|
||||
// SetPage sets the current page
|
||||
func (ls *ListVolumes) SetPage(page int) {
|
||||
ls.Page = page
|
||||
}
|
||||
|
||||
// SetPageSize sets the page size
|
||||
func (ls *ListVolumes) SetPageSize(pageSize int) {
|
||||
ls.PageSize = pageSize
|
||||
}
|
||||
|
||||
func (ListVolumes) each(resp interface{}, callback IterateItemFunc) {
|
||||
volumes, ok := resp.(*ListVolumesResponse)
|
||||
if !ok {
|
||||
callback(nil, fmt.Errorf("wrong type. ListVolumesResponse expected, got %T", resp))
|
||||
return
|
||||
}
|
||||
|
||||
for i := range volumes.Volume {
|
||||
if !callback(&volumes.Volume[i], nil) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
43
vendor/github.com/exoscale/egoscale/volumes_response.go
generated
vendored
Normal file
43
vendor/github.com/exoscale/egoscale/volumes_response.go
generated
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
// code generated; DO NOT EDIT.
|
||||
|
||||
package egoscale
|
||||
|
||||
import "fmt"
|
||||
|
||||
// Response returns the struct to unmarshal
|
||||
func (ListVolumes) Response() interface{} {
|
||||
return new(ListVolumesResponse)
|
||||
}
|
||||
|
||||
// ListRequest returns itself
|
||||
func (ls *ListVolumes) ListRequest() (ListCommand, error) {
|
||||
if ls == nil {
|
||||
return nil, fmt.Errorf("%T cannot be nil", ls)
|
||||
}
|
||||
return ls, nil
|
||||
}
|
||||
|
||||
// SetPage sets the current apge
|
||||
func (ls *ListVolumes) SetPage(page int) {
|
||||
ls.Page = page
|
||||
}
|
||||
|
||||
// SetPageSize sets the page size
|
||||
func (ls *ListVolumes) SetPageSize(pageSize int) {
|
||||
ls.PageSize = pageSize
|
||||
}
|
||||
|
||||
// Each triggers the callback for each, valid answer or any non 404 issue
|
||||
func (ListVolumes) Each(resp interface{}, callback IterateItemFunc) {
|
||||
items, ok := resp.(*ListVolumesResponse)
|
||||
if !ok {
|
||||
callback(nil, fmt.Errorf("wrong type, ListVolumesResponse was expected, got %T", resp))
|
||||
return
|
||||
}
|
||||
|
||||
for i := range items.Volume {
|
||||
if !callback(&items.Volume[i], nil) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
40
vendor/github.com/exoscale/egoscale/zones.go
generated
vendored
40
vendor/github.com/exoscale/egoscale/zones.go
generated
vendored
@ -1,7 +1,6 @@
|
||||
package egoscale
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
)
|
||||
|
||||
@ -15,9 +14,6 @@ type Zone struct {
|
||||
DisplayText string `json:"displaytext,omitempty" doc:"the display text of the zone"`
|
||||
DNS1 net.IP `json:"dns1,omitempty" doc:"the first DNS for the Zone"`
|
||||
DNS2 net.IP `json:"dns2,omitempty" doc:"the second DNS for the Zone"`
|
||||
Domain string `json:"domain,omitempty" doc:"Network domain name for the networks in the zone"`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"the UUID of the containing domain, null for public zones"`
|
||||
DomainName string `json:"domainname,omitempty" doc:"the name of the containing domain, null for public zones"`
|
||||
GuestCIDRAddress *CIDR `json:"guestcidraddress,omitempty" doc:"the guest CIDR address for the Zone"`
|
||||
ID *UUID `json:"id,omitempty" doc:"Zone id"`
|
||||
InternalDNS1 net.IP `json:"internaldns1,omitempty" doc:"the first internal DNS for the Zone"`
|
||||
@ -37,18 +33,18 @@ type Zone struct {
|
||||
// ListRequest builds the ListZones request
|
||||
func (zone Zone) ListRequest() (ListCommand, error) {
|
||||
req := &ListZones{
|
||||
DomainID: zone.DomainID,
|
||||
ID: zone.ID,
|
||||
Name: zone.Name,
|
||||
ID: zone.ID,
|
||||
Name: zone.Name,
|
||||
}
|
||||
|
||||
return req, nil
|
||||
}
|
||||
|
||||
//go:generate go run generate/main.go -interface=Listable ListZones
|
||||
|
||||
// ListZones represents a query for zones
|
||||
type ListZones struct {
|
||||
Available *bool `json:"available,omitempty" doc:"true if you want to retrieve all available Zones. False if you only want to return the Zones from which you have at least one VM. Default is false."`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"the ID of the domain associated with the zone"`
|
||||
ID *UUID `json:"id,omitempty" doc:"the ID of the zone"`
|
||||
Keyword string `json:"keyword,omitempty" doc:"List by keyword"`
|
||||
Name string `json:"name,omitempty" doc:"the name of the zone"`
|
||||
@ -64,31 +60,3 @@ type ListZonesResponse struct {
|
||||
Count int `json:"count"`
|
||||
Zone []Zone `json:"zone"`
|
||||
}
|
||||
|
||||
func (ListZones) response() interface{} {
|
||||
return new(ListZonesResponse)
|
||||
}
|
||||
|
||||
// SetPage sets the current page
|
||||
func (ls *ListZones) SetPage(page int) {
|
||||
ls.Page = page
|
||||
}
|
||||
|
||||
// SetPageSize sets the page size
|
||||
func (ls *ListZones) SetPageSize(pageSize int) {
|
||||
ls.PageSize = pageSize
|
||||
}
|
||||
|
||||
func (ListZones) each(resp interface{}, callback IterateItemFunc) {
|
||||
zones, ok := resp.(*ListZonesResponse)
|
||||
if !ok {
|
||||
callback(nil, fmt.Errorf("wrong type. ListZonesResponse was expected, got %T", resp))
|
||||
return
|
||||
}
|
||||
|
||||
for i := range zones.Zone {
|
||||
if !callback(&zones.Zone[i], nil) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
43
vendor/github.com/exoscale/egoscale/zones_response.go
generated
vendored
Normal file
43
vendor/github.com/exoscale/egoscale/zones_response.go
generated
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
// code generated; DO NOT EDIT.
|
||||
|
||||
package egoscale
|
||||
|
||||
import "fmt"
|
||||
|
||||
// Response returns the struct to unmarshal
|
||||
func (ListZones) Response() interface{} {
|
||||
return new(ListZonesResponse)
|
||||
}
|
||||
|
||||
// ListRequest returns itself
|
||||
func (ls *ListZones) ListRequest() (ListCommand, error) {
|
||||
if ls == nil {
|
||||
return nil, fmt.Errorf("%T cannot be nil", ls)
|
||||
}
|
||||
return ls, nil
|
||||
}
|
||||
|
||||
// SetPage sets the current apge
|
||||
func (ls *ListZones) SetPage(page int) {
|
||||
ls.Page = page
|
||||
}
|
||||
|
||||
// SetPageSize sets the page size
|
||||
func (ls *ListZones) SetPageSize(pageSize int) {
|
||||
ls.PageSize = pageSize
|
||||
}
|
||||
|
||||
// Each triggers the callback for each, valid answer or any non 404 issue
|
||||
func (ListZones) Each(resp interface{}, callback IterateItemFunc) {
|
||||
items, ok := resp.(*ListZonesResponse)
|
||||
if !ok {
|
||||
callback(nil, fmt.Errorf("wrong type, ListZonesResponse was expected, got %T", resp))
|
||||
return
|
||||
}
|
||||
|
||||
for i := range items.Zone {
|
||||
if !callback(&items.Zone[i], nil) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
0
vendor/github.com/xenolf/lego/LICENSE → vendor/github.com/go-acme/lego/LICENSE
generated
vendored
0
vendor/github.com/xenolf/lego/LICENSE → vendor/github.com/go-acme/lego/LICENSE
generated
vendored
@ -5,7 +5,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/xenolf/lego/acme"
|
||||
"github.com/go-acme/lego/acme"
|
||||
)
|
||||
|
||||
type AccountService service
|
@ -11,11 +11,11 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/cenkalti/backoff"
|
||||
"github.com/xenolf/lego/acme"
|
||||
"github.com/xenolf/lego/acme/api/internal/nonces"
|
||||
"github.com/xenolf/lego/acme/api/internal/secure"
|
||||
"github.com/xenolf/lego/acme/api/internal/sender"
|
||||
"github.com/xenolf/lego/log"
|
||||
"github.com/go-acme/lego/acme"
|
||||
"github.com/go-acme/lego/acme/api/internal/nonces"
|
||||
"github.com/go-acme/lego/acme/api/internal/secure"
|
||||
"github.com/go-acme/lego/acme/api/internal/sender"
|
||||
"github.com/go-acme/lego/log"
|
||||
)
|
||||
|
||||
// Core ACME/LE core API.
|
@ -3,7 +3,7 @@ package api
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/xenolf/lego/acme"
|
||||
"github.com/go-acme/lego/acme"
|
||||
)
|
||||
|
||||
type AuthorizationService service
|
@ -7,9 +7,9 @@ import (
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
|
||||
"github.com/xenolf/lego/acme"
|
||||
"github.com/xenolf/lego/certcrypto"
|
||||
"github.com/xenolf/lego/log"
|
||||
"github.com/go-acme/lego/acme"
|
||||
"github.com/go-acme/lego/certcrypto"
|
||||
"github.com/go-acme/lego/log"
|
||||
)
|
||||
|
||||
// maxBodySize is the maximum size of body that we will read.
|
@ -3,7 +3,7 @@ package api
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/xenolf/lego/acme"
|
||||
"github.com/go-acme/lego/acme"
|
||||
)
|
||||
|
||||
type ChallengeService service
|
@ -6,7 +6,7 @@ import (
|
||||
"net/http"
|
||||
"sync"
|
||||
|
||||
"github.com/xenolf/lego/acme/api/internal/sender"
|
||||
"github.com/go-acme/lego/acme/api/internal/sender"
|
||||
)
|
||||
|
||||
// Manager Manages nonces.
|
@ -9,7 +9,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/xenolf/lego/acme/api/internal/nonces"
|
||||
"github.com/go-acme/lego/acme/api/internal/nonces"
|
||||
jose "gopkg.in/square/go-jose.v2"
|
||||
)
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/xenolf/lego/acme"
|
||||
"github.com/go-acme/lego/acme"
|
||||
)
|
||||
|
||||
type RequestOption func(*http.Request) error
|
@ -5,10 +5,10 @@ package sender
|
||||
|
||||
const (
|
||||
// ourUserAgent is the User-Agent of this underlying library package.
|
||||
ourUserAgent = "xenolf-acme/2.2.0"
|
||||
ourUserAgent = "xenolf-acme/2.3.0"
|
||||
|
||||
// ourUserAgentComment is part of the UA comment linked to the version status of this underlying library package.
|
||||
// values: detach|release
|
||||
// NOTE: Update this with each tagged release.
|
||||
ourUserAgentComment = "release"
|
||||
ourUserAgentComment = "detach"
|
||||
)
|
@ -4,7 +4,7 @@ import (
|
||||
"encoding/base64"
|
||||
"errors"
|
||||
|
||||
"github.com/xenolf/lego/acme"
|
||||
"github.com/go-acme/lego/acme"
|
||||
)
|
||||
|
||||
type OrderService service
|
@ -3,8 +3,8 @@ package certificate
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/xenolf/lego/acme"
|
||||
"github.com/xenolf/lego/log"
|
||||
"github.com/go-acme/lego/acme"
|
||||
"github.com/go-acme/lego/log"
|
||||
)
|
||||
|
||||
const (
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user