From 0ef1b7b683c85235e15bd8859e1655de5651a6e1 Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Fri, 6 Apr 2018 17:04:03 +0200 Subject: [PATCH] Fix: Add TTL and custom Timeout in DigitalOcean DNS provider --- .gitattributes | 3 +- Gopkg.lock | 56 +- Gopkg.toml | 3 +- acme/acme.go | 2 +- acme/acme_test.go | 2 +- docs/configuration/acme.md | 7 + provider/acme/provider.go | 2 +- .../AkamaiOPEN-edgegrid-golang}/LICENSE | 5 +- .../client-v1/api.go | 36 + .../client-v1/client.go | 111 + .../client-v1/errors.go | 88 + .../configdns-v1/errors.go | 125 + .../configdns-v1/record.go | 1738 ++ .../configdns-v1/service.go | 16 + .../configdns-v1/zone.go | 1557 ++ .../edgegrid/config.go | 181 + .../edgegrid/errors.go | 22 + .../edgegrid/signer.go | 195 + .../jsonhooks-v1/errors.go | 1 + .../jsonhooks-v1/jsonhooks.go | 69 + .../aws/aws-sdk-go/service/lightsail/api.go | 15975 ++++++++++++++++ .../aws/aws-sdk-go/service/lightsail/doc.go | 40 + .../aws-sdk-go/service/lightsail/errors.go | 55 + .../aws-sdk-go/service/lightsail/service.go | 95 + vendor/github.com/namedotcom/go/LICENSE | 21 + .../github.com/namedotcom/go/namecom/dns.go | 133 + .../namedotcom/go/namecom/dnssecs.go | 102 + .../namedotcom/go/namecom/domains.go | 382 + .../namedotcom/go/namecom/emailforwardings.go | 133 + .../github.com/namedotcom/go/namecom/hello.go | 31 + .../namedotcom/go/namecom/namecom.go | 729 + .../namedotcom/go/namecom/transfers.go | 108 + .../namedotcom/go/namecom/urlforwardings.go | 133 + .../go/namecom/vanitynameservers.go | 133 + .../tuvistavie/securerandom/srandom.go | 70 + .../github.com/xenolf/lego/acme/challenges.go | 16 - vendor/github.com/xenolf/lego/acme/client.go | 825 - vendor/github.com/xenolf/lego/acme/crypto.go | 347 - .../xenolf/lego/acme/dns_challenge.go | 309 - .../xenolf/lego/acme/dns_challenge_manual.go | 53 - vendor/github.com/xenolf/lego/acme/error.go | 94 - vendor/github.com/xenolf/lego/acme/http.go | 160 - .../xenolf/lego/acme/http_challenge.go | 41 - .../xenolf/lego/acme/http_challenge_server.go | 79 - vendor/github.com/xenolf/lego/acme/jws.go | 131 - .../github.com/xenolf/lego/acme/messages.go | 115 - .../xenolf/lego/acme/pop_challenge.go | 1 - .../github.com/xenolf/lego/acme/provider.go | 28 - .../xenolf/lego/acme/tls_sni_challenge.go | 67 - .../lego/acme/tls_sni_challenge_server.go | 62 - vendor/github.com/xenolf/lego/acme/utils.go | 29 - .../xenolf/lego/acmev2/challenges.go | 6 +- .../github.com/xenolf/lego/acmev2/client.go | 4 +- .../github.com/xenolf/lego/acmev2/crypto.go | 2 +- .../xenolf/lego/acmev2/dns_challenge.go | 2 +- .../lego/acmev2/dns_challenge_manual.go | 2 +- vendor/github.com/xenolf/lego/acmev2/error.go | 2 +- vendor/github.com/xenolf/lego/acmev2/http.go | 2 +- .../xenolf/lego/acmev2/http_challenge.go | 2 +- .../lego/acmev2/http_challenge_server.go | 2 +- vendor/github.com/xenolf/lego/acmev2/jws.go | 2 +- .../github.com/xenolf/lego/acmev2/messages.go | 2 +- .../xenolf/lego/acmev2/pop_challenge.go | 2 +- .../github.com/xenolf/lego/acmev2/provider.go | 2 +- vendor/github.com/xenolf/lego/acmev2/utils.go | 2 +- .../lego/providers/dns/auroradns/auroradns.go | 19 +- .../xenolf/lego/providers/dns/azure/azure.go | 18 +- .../lego/providers/dns/bluecat/bluecat.go | 419 + .../providers/dns/cloudflare/cloudflare.go | 18 +- .../lego/providers/dns/cloudxns/cloudxns.go | 16 +- .../dns/digitalocean/digitalocean.go | 25 +- .../lego/providers/dns/dns_providers.go | 31 +- .../lego/providers/dns/dnsimple/dnsimple.go | 14 +- .../providers/dns/dnsmadeeasy/dnsmadeeasy.go | 12 +- .../lego/providers/dns/dnspod/dnspod.go | 14 +- .../lego/providers/dns/duckdns/duckdns.go | 82 + .../xenolf/lego/providers/dns/dyn/dyn.go | 24 +- .../xenolf/lego/providers/dns/exec/exec.go | 72 + .../lego/providers/dns/exoscale/exoscale.go | 14 +- .../lego/providers/dns/fastdns/fastdns.go | 139 + .../xenolf/lego/providers/dns/gandi/gandi.go | 14 +- .../lego/providers/dns/gandiv5/gandiv5.go | 16 +- .../lego/providers/dns/glesys/glesys.go | 211 + .../lego/providers/dns/godaddy/godaddy.go | 15 +- .../providers/dns/googlecloud/googlecloud.go | 8 +- .../lego/providers/dns/lightsail/lightsail.go | 107 + .../lego/providers/dns/linode/linode.go | 14 +- .../lego/providers/dns/namecheap/namecheap.go | 6 +- .../providers/dns/namedotcom/namedotcom.go | 124 + .../xenolf/lego/providers/dns/ns1/ns1.go | 12 +- .../xenolf/lego/providers/dns/otc/otc.go | 12 +- .../xenolf/lego/providers/dns/ovh/ovh.go | 18 +- .../xenolf/lego/providers/dns/pdns/pdns.go | 16 +- .../lego/providers/dns/rackspace/rackspace.go | 16 +- .../lego/providers/dns/rfc2136/rfc2136.go | 14 +- .../lego/providers/dns/route53/route53.go | 14 +- .../xenolf/lego/providers/dns/vultr/vultr.go | 10 +- .../mattes/go-expand-tilde.v1/tilde.go | 46 + .../gopkg.in/square/go-jose.v1/asymmetric.go | 520 - .../square/go-jose.v1/cipher/cbc_hmac.go | 196 - .../square/go-jose.v1/cipher/concat_kdf.go | 75 - .../square/go-jose.v1/cipher/ecdh_es.go | 62 - .../square/go-jose.v1/cipher/key_wrap.go | 109 - vendor/gopkg.in/square/go-jose.v1/crypter.go | 416 - vendor/gopkg.in/square/go-jose.v1/doc.go | 26 - vendor/gopkg.in/square/go-jose.v1/encoding.go | 193 - .../gopkg.in/square/go-jose.v1/json/LICENSE | 27 - .../gopkg.in/square/go-jose.v1/json/decode.go | 1183 -- .../gopkg.in/square/go-jose.v1/json/encode.go | 1197 -- .../gopkg.in/square/go-jose.v1/json/indent.go | 141 - .../square/go-jose.v1/json/scanner.go | 623 - .../gopkg.in/square/go-jose.v1/json/stream.go | 480 - .../gopkg.in/square/go-jose.v1/json/tags.go | 44 - vendor/gopkg.in/square/go-jose.v1/jwe.go | 280 - vendor/gopkg.in/square/go-jose.v1/jwk.go | 457 - vendor/gopkg.in/square/go-jose.v1/jws.go | 272 - vendor/gopkg.in/square/go-jose.v1/shared.go | 224 - vendor/gopkg.in/square/go-jose.v1/signing.go | 258 - .../gopkg.in/square/go-jose.v1/symmetric.go | 349 - vendor/gopkg.in/square/go-jose.v1/utils.go | 74 - 120 files changed, 23764 insertions(+), 9782 deletions(-) rename vendor/{gopkg.in/square/go-jose.v1 => github.com/akamai/AkamaiOPEN-edgegrid-golang}/LICENSE (99%) create mode 100644 vendor/github.com/akamai/AkamaiOPEN-edgegrid-golang/client-v1/api.go create mode 100644 vendor/github.com/akamai/AkamaiOPEN-edgegrid-golang/client-v1/client.go create mode 100644 vendor/github.com/akamai/AkamaiOPEN-edgegrid-golang/client-v1/errors.go create mode 100644 vendor/github.com/akamai/AkamaiOPEN-edgegrid-golang/configdns-v1/errors.go create mode 100644 vendor/github.com/akamai/AkamaiOPEN-edgegrid-golang/configdns-v1/record.go create mode 100644 vendor/github.com/akamai/AkamaiOPEN-edgegrid-golang/configdns-v1/service.go create mode 100644 vendor/github.com/akamai/AkamaiOPEN-edgegrid-golang/configdns-v1/zone.go create mode 100644 vendor/github.com/akamai/AkamaiOPEN-edgegrid-golang/edgegrid/config.go create mode 100644 vendor/github.com/akamai/AkamaiOPEN-edgegrid-golang/edgegrid/errors.go create mode 100644 vendor/github.com/akamai/AkamaiOPEN-edgegrid-golang/edgegrid/signer.go create mode 100644 vendor/github.com/akamai/AkamaiOPEN-edgegrid-golang/jsonhooks-v1/errors.go create mode 100644 vendor/github.com/akamai/AkamaiOPEN-edgegrid-golang/jsonhooks-v1/jsonhooks.go create mode 100644 vendor/github.com/aws/aws-sdk-go/service/lightsail/api.go create mode 100644 vendor/github.com/aws/aws-sdk-go/service/lightsail/doc.go create mode 100644 vendor/github.com/aws/aws-sdk-go/service/lightsail/errors.go create mode 100644 vendor/github.com/aws/aws-sdk-go/service/lightsail/service.go create mode 100644 vendor/github.com/namedotcom/go/LICENSE create mode 100644 vendor/github.com/namedotcom/go/namecom/dns.go create mode 100644 vendor/github.com/namedotcom/go/namecom/dnssecs.go create mode 100644 vendor/github.com/namedotcom/go/namecom/domains.go create mode 100644 vendor/github.com/namedotcom/go/namecom/emailforwardings.go create mode 100644 vendor/github.com/namedotcom/go/namecom/hello.go create mode 100644 vendor/github.com/namedotcom/go/namecom/namecom.go create mode 100644 vendor/github.com/namedotcom/go/namecom/transfers.go create mode 100644 vendor/github.com/namedotcom/go/namecom/urlforwardings.go create mode 100644 vendor/github.com/namedotcom/go/namecom/vanitynameservers.go create mode 100644 vendor/github.com/tuvistavie/securerandom/srandom.go delete mode 100644 vendor/github.com/xenolf/lego/acme/challenges.go delete mode 100644 vendor/github.com/xenolf/lego/acme/client.go delete mode 100644 vendor/github.com/xenolf/lego/acme/crypto.go delete mode 100644 vendor/github.com/xenolf/lego/acme/dns_challenge.go delete mode 100644 vendor/github.com/xenolf/lego/acme/dns_challenge_manual.go delete mode 100644 vendor/github.com/xenolf/lego/acme/error.go delete mode 100644 vendor/github.com/xenolf/lego/acme/http.go delete mode 100644 vendor/github.com/xenolf/lego/acme/http_challenge.go delete mode 100644 vendor/github.com/xenolf/lego/acme/http_challenge_server.go delete mode 100644 vendor/github.com/xenolf/lego/acme/jws.go delete mode 100644 vendor/github.com/xenolf/lego/acme/messages.go delete mode 100644 vendor/github.com/xenolf/lego/acme/pop_challenge.go delete mode 100644 vendor/github.com/xenolf/lego/acme/provider.go delete mode 100644 vendor/github.com/xenolf/lego/acme/tls_sni_challenge.go delete mode 100644 vendor/github.com/xenolf/lego/acme/tls_sni_challenge_server.go delete mode 100644 vendor/github.com/xenolf/lego/acme/utils.go create mode 100644 vendor/github.com/xenolf/lego/providers/dns/bluecat/bluecat.go create mode 100644 vendor/github.com/xenolf/lego/providers/dns/duckdns/duckdns.go create mode 100644 vendor/github.com/xenolf/lego/providers/dns/exec/exec.go create mode 100644 vendor/github.com/xenolf/lego/providers/dns/fastdns/fastdns.go create mode 100644 vendor/github.com/xenolf/lego/providers/dns/glesys/glesys.go create mode 100644 vendor/github.com/xenolf/lego/providers/dns/lightsail/lightsail.go create mode 100644 vendor/github.com/xenolf/lego/providers/dns/namedotcom/namedotcom.go create mode 100644 vendor/gopkg.in/mattes/go-expand-tilde.v1/tilde.go delete mode 100644 vendor/gopkg.in/square/go-jose.v1/asymmetric.go delete mode 100644 vendor/gopkg.in/square/go-jose.v1/cipher/cbc_hmac.go delete mode 100644 vendor/gopkg.in/square/go-jose.v1/cipher/concat_kdf.go delete mode 100644 vendor/gopkg.in/square/go-jose.v1/cipher/ecdh_es.go delete mode 100644 vendor/gopkg.in/square/go-jose.v1/cipher/key_wrap.go delete mode 100644 vendor/gopkg.in/square/go-jose.v1/crypter.go delete mode 100644 vendor/gopkg.in/square/go-jose.v1/doc.go delete mode 100644 vendor/gopkg.in/square/go-jose.v1/encoding.go delete mode 100644 vendor/gopkg.in/square/go-jose.v1/json/LICENSE delete mode 100644 vendor/gopkg.in/square/go-jose.v1/json/decode.go delete mode 100644 vendor/gopkg.in/square/go-jose.v1/json/encode.go delete mode 100644 vendor/gopkg.in/square/go-jose.v1/json/indent.go delete mode 100644 vendor/gopkg.in/square/go-jose.v1/json/scanner.go delete mode 100644 vendor/gopkg.in/square/go-jose.v1/json/stream.go delete mode 100644 vendor/gopkg.in/square/go-jose.v1/json/tags.go delete mode 100644 vendor/gopkg.in/square/go-jose.v1/jwe.go delete mode 100644 vendor/gopkg.in/square/go-jose.v1/jwk.go delete mode 100644 vendor/gopkg.in/square/go-jose.v1/jws.go delete mode 100644 vendor/gopkg.in/square/go-jose.v1/shared.go delete mode 100644 vendor/gopkg.in/square/go-jose.v1/signing.go delete mode 100644 vendor/gopkg.in/square/go-jose.v1/symmetric.go delete mode 100644 vendor/gopkg.in/square/go-jose.v1/utils.go diff --git a/.gitattributes b/.gitattributes index b7513274c..9562349f4 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1 @@ -vendor/github.com/xenolf/lego/providers/dns/cloudxns/cloudxns.go eol=crlf - +# vendor/github.com/xenolf/lego/providers/dns/cloudxns/cloudxns.go eol=crlf diff --git a/Gopkg.lock b/Gopkg.lock index ed124f4f4..133a63b46 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -140,6 +140,17 @@ ] revision = "063d875e3c5fd734fa2aa12fac83829f62acfc70" +[[projects]] + name = "github.com/akamai/AkamaiOPEN-edgegrid-golang" + packages = [ + "client-v1", + "configdns-v1", + "edgegrid", + "jsonhooks-v1" + ] + revision = "a494eba1efa1f38338393727dff63389a6a66534" + version = "v0.6.0" + [[projects]] name = "github.com/aokoli/goutils" packages = ["."] @@ -193,6 +204,7 @@ "service/dynamodb/dynamodbiface", "service/ec2", "service/ecs", + "service/lightsail", "service/route53", "service/sts" ] @@ -745,7 +757,6 @@ version = "v1.3.7" [[projects]] - branch = "master" name = "github.com/jjcollinge/servicefabric" packages = ["."] revision = "8eebe170fa1ba25d3dfb928b3f86a7313b13b9fe" @@ -914,6 +925,12 @@ packages = ["."] revision = "db96455566f05ffe42bd6ac671f05eeb1152b45d" +[[projects]] + branch = "master" + name = "github.com/namedotcom/go" + packages = ["namecom"] + revision = "08470befbe04613bd4b44cb6978b05d50294c4d4" + [[projects]] branch = "master" name = "github.com/ogier/pflag" @@ -1120,6 +1137,12 @@ ] revision = "37e84520dcf74488f67654f9c775b9752c232dc1" +[[projects]] + branch = "master" + name = "github.com/tuvistavie/securerandom" + packages = ["."] + revision = "15512123a948d62f6361bd84818e11f2ad84059a" + [[projects]] name = "github.com/tv42/zbase32" packages = ["."] @@ -1214,28 +1237,34 @@ revision = "0c8571ac0ce161a5feb57375a9cdf148c98c0f70" [[projects]] - branch = "acmev2" + branch = "containous-fork" name = "github.com/xenolf/lego" packages = [ - "acme", "acmev2", "providers/dns", "providers/dns/auroradns", "providers/dns/azure", + "providers/dns/bluecat", "providers/dns/cloudflare", "providers/dns/cloudxns", "providers/dns/digitalocean", "providers/dns/dnsimple", "providers/dns/dnsmadeeasy", "providers/dns/dnspod", + "providers/dns/duckdns", "providers/dns/dyn", + "providers/dns/exec", "providers/dns/exoscale", + "providers/dns/fastdns", "providers/dns/gandi", "providers/dns/gandiv5", + "providers/dns/glesys", "providers/dns/godaddy", "providers/dns/googlecloud", + "providers/dns/lightsail", "providers/dns/linode", "providers/dns/namecheap", + "providers/dns/namedotcom", "providers/dns/ns1", "providers/dns/otc", "providers/dns/ovh", @@ -1245,7 +1274,8 @@ "providers/dns/route53", "providers/dns/vultr" ] - revision = "a149e7d6506feb4003da7093cbf818c6b75ed4a4" + revision = "2357607e4ddeb93d5364c9ae6571ded32b7d01f1" + source = "github.com/containous/lego" [[projects]] branch = "master" @@ -1403,6 +1433,12 @@ revision = "5b3e00af70a9484542169a976dcab8d03e601a17" version = "v1.30.0" +[[projects]] + branch = "v1" + name = "gopkg.in/mattes/go-expand-tilde.v1" + packages = ["."] + revision = "cb884138e64c9a8bf5c7d6106d74b0fca082df0c" + [[projects]] name = "gopkg.in/ns1/ns1-go.v2" packages = [ @@ -1415,16 +1451,6 @@ ] revision = "c563826f4cbef9c11bebeb9f20a3f7afe9c1e2f4" -[[projects]] - name = "gopkg.in/square/go-jose.v1" - packages = [ - ".", - "cipher", - "json" - ] - revision = "aa2e30fdd1fe9dd3394119af66451ae790d50e0d" - version = "v1.1.0" - [[projects]] name = "gopkg.in/square/go-jose.v2" packages = [ @@ -1644,6 +1670,6 @@ [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "593d67272ac35ca0fa59df7f2ac077a81ea842b3181b00acffa20553bfe6f2e0" + inputs-digest = "37f92cc9416b1449e9fe4fd1b02d999af8d9887617424db7cb334060cd362e5c" solver-name = "gps-cdcl" solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml index 1383e2927..02bf77ca8 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -181,8 +181,9 @@ name = "github.com/vulcand/oxy" [[constraint]] - branch = "acmev2" + branch = "containous-fork" name = "github.com/xenolf/lego" + source = "github.com/containous/lego" [[constraint]] name = "google.golang.org/grpc" diff --git a/acme/acme.go b/acme/acme.go index 8e8634654..74d71d1c7 100644 --- a/acme/acme.go +++ b/acme/acme.go @@ -26,7 +26,7 @@ import ( "github.com/containous/traefik/tls/generate" "github.com/containous/traefik/types" "github.com/eapache/channels" - "github.com/xenolf/lego/acmev2" + acme "github.com/xenolf/lego/acmev2" "github.com/xenolf/lego/providers/dns" ) diff --git a/acme/acme_test.go b/acme/acme_test.go index 076308c82..066929f73 100644 --- a/acme/acme_test.go +++ b/acme/acme_test.go @@ -14,7 +14,7 @@ import ( "github.com/containous/traefik/tls/generate" "github.com/containous/traefik/types" "github.com/stretchr/testify/assert" - "github.com/xenolf/lego/acmev2" + acme "github.com/xenolf/lego/acmev2" ) func TestDomainsSet(t *testing.T) { diff --git a/docs/configuration/acme.md b/docs/configuration/acme.md index d089a7409..d980a0521 100644 --- a/docs/configuration/acme.md +++ b/docs/configuration/acme.md @@ -286,21 +286,28 @@ Select the provider that matches the DNS domain that will host the challenge TXT |--------------------------------------------------------|----------------|---------------------------------------------------------------------------------------------------------------------------| | [Auroradns](https://www.pcextreme.com/aurora/dns) | `auroradns` | `AURORA_USER_ID`, `AURORA_KEY`, `AURORA_ENDPOINT` | | [Azure](https://azure.microsoft.com/services/dns/) | `azure` | `AZURE_CLIENT_ID`, `AZURE_CLIENT_SECRET`, `AZURE_SUBSCRIPTION_ID`, `AZURE_TENANT_ID`, `AZURE_RESOURCE_GROUP` | +| [Blue Cat](https://www.bluecatnetworks.com/) | `bluecat` | `BLUECAT_SERVER_URL`, `BLUECAT_USER_NAME`, `BLUECAT_PASSWORD`, `BLUECAT_CONFIG_NAME`, `BLUECAT_DNS_VIEW` | | [Cloudflare](https://www.cloudflare.com) | `cloudflare` | `CLOUDFLARE_EMAIL`, `CLOUDFLARE_API_KEY` - The Cloudflare `Global API Key` needs to be used and not the `Origin CA Key` | | [CloudXNS](https://www.cloudxns.net) | `cloudxns` | `CLOUDXNS_API_KEY`, `CLOUDXNS_SECRET_KEY` | | [DigitalOcean](https://www.digitalocean.com) | `digitalocean` | `DO_AUTH_TOKEN` | | [DNSimple](https://dnsimple.com) | `dnsimple` | `DNSIMPLE_OAUTH_TOKEN`, `DNSIMPLE_BASE_URL` | | [DNS Made Easy](https://dnsmadeeasy.com) | `dnsmadeeasy` | `DNSMADEEASY_API_KEY`, `DNSMADEEASY_API_SECRET`, `DNSMADEEASY_SANDBOX` | | [DNSPod](http://www.dnspod.net/) | `dnspod` | `DNSPOD_API_KEY` | +| [Duck DNS](https://www.duckdns.org/) | `duckdns` | `DUCKDNS_TOKEN` | | [Dyn](https://dyn.com) | `dyn` | `DYN_CUSTOMER_NAME`, `DYN_USER_NAME`, `DYN_PASSWORD` | +| External Program | `exec` | `EXEC_PATH` | | [Exoscale](https://www.exoscale.ch) | `exoscale` | `EXOSCALE_API_KEY`, `EXOSCALE_API_SECRET`, `EXOSCALE_ENDPOINT` | +| [Fast DNS](https://www.akamai.com/) | `fastdns` | `AKAMAI_CLIENT_TOKEN`, `AKAMAI_CLIENT_SECRET`, `AKAMAI_ACCESS_TOKEN` | | [Gandi](https://www.gandi.net) | `gandi` | `GANDI_API_KEY` | | [Gandi V5](http://doc.livedns.gandi.net) | `gandiv5` | `GANDIV5_API_KEY` | +| [Glesys](https://glesys.com/) | `glesys` | `GLESYS_API_USER`, `GLESYS_API_KEY`, `GLESYS_DOMAIN` | | [GoDaddy](https://godaddy.com/domains) | `godaddy` | `GODADDY_API_KEY`, `GODADDY_API_SECRET` | | [Google Cloud DNS](https://cloud.google.com/dns/docs/) | `gcloud` | `GCE_PROJECT`, `GCE_SERVICE_ACCOUNT_FILE` | +| [Lightsail](https://aws.amazon.com/lightsail/) | `lightsail` | `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, `DNS_ZONE` | | [Linode](https://www.linode.com) | `linode` | `LINODE_API_KEY` | | manual | - | none, but run Træfik interactively & turn on `acmeLogging` to see instructions & press Enter. | | [Namecheap](https://www.namecheap.com) | `namecheap` | `NAMECHEAP_API_USER`, `NAMECHEAP_API_KEY` | +| [name.com](https://www.name.com/) | `namedotcom` | `NAMECOM_USERNAME`, `NAMECOM_API_TOKEN`, `NAMECOM_SERVER` | | [Ns1](https://ns1.com/) | `ns1` | `NS1_API_KEY` | | [Open Telekom Cloud](https://cloud.telekom.de/en/) | `otc` | `OTC_DOMAIN_NAME`, `OTC_USER_NAME`, `OTC_PASSWORD`, `OTC_PROJECT_NAME`, `OTC_IDENTITY_ENDPOINT` | | [OVH](https://www.ovh.com) | `ovh` | `OVH_ENDPOINT`, `OVH_APPLICATION_KEY`, `OVH_APPLICATION_SECRET`, `OVH_CONSUMER_KEY` | diff --git a/provider/acme/provider.go b/provider/acme/provider.go index 1c8180abd..b3029de9d 100644 --- a/provider/acme/provider.go +++ b/provider/acme/provider.go @@ -23,7 +23,7 @@ import ( traefikTLS "github.com/containous/traefik/tls" "github.com/containous/traefik/types" "github.com/pkg/errors" - "github.com/xenolf/lego/acmev2" + acme "github.com/xenolf/lego/acmev2" "github.com/xenolf/lego/providers/dns" ) diff --git a/vendor/gopkg.in/square/go-jose.v1/LICENSE b/vendor/github.com/akamai/AkamaiOPEN-edgegrid-golang/LICENSE similarity index 99% rename from vendor/gopkg.in/square/go-jose.v1/LICENSE rename to vendor/github.com/akamai/AkamaiOPEN-edgegrid-golang/LICENSE index d64569567..8dada3eda 100644 --- a/vendor/gopkg.in/square/go-jose.v1/LICENSE +++ b/vendor/github.com/akamai/AkamaiOPEN-edgegrid-golang/LICENSE @@ -1,4 +1,3 @@ - Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -179,7 +178,7 @@ APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" + boilerplate notice, with the fields enclosed by brackets "{}" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a @@ -187,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [yyyy] [name of copyright owner] + Copyright {yyyy} {name of copyright owner} Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/vendor/github.com/akamai/AkamaiOPEN-edgegrid-golang/client-v1/api.go b/vendor/github.com/akamai/AkamaiOPEN-edgegrid-golang/client-v1/api.go new file mode 100644 index 000000000..d20ce434e --- /dev/null +++ b/vendor/github.com/akamai/AkamaiOPEN-edgegrid-golang/client-v1/api.go @@ -0,0 +1,36 @@ +package client + +import ( + "encoding/json" +) + +// Resource is the "base" type for all API resources +type Resource struct { + Complete chan bool `json:"-"` +} + +// Init initializes the Complete channel, if it is necessary +// need to create a resource specific Init(), make sure to +// initialize the channel. +func (resource *Resource) Init() { + resource.Complete = make(chan bool, 1) +} + +// PostUnmarshalJSON is a default implementation of the +// PostUnmarshalJSON hook that simply calls Init() and +// sends true to the Complete channel. This is overridden +// in many resources, in particular those that represent +// collections, and have to initialize sub-resources also. +func (resource *Resource) PostUnmarshalJSON() error { + resource.Init() + resource.Complete <- true + return nil +} + +// GetJSON returns the raw (indented) JSON (as []bytes) +func (resource *Resource) GetJSON() ([]byte, error) { + return json.MarshalIndent(resource, "", " ") +} + +// JSONBody is a generic struct for temporary JSON unmarshalling. +type JSONBody map[string]interface{} diff --git a/vendor/github.com/akamai/AkamaiOPEN-edgegrid-golang/client-v1/client.go b/vendor/github.com/akamai/AkamaiOPEN-edgegrid-golang/client-v1/client.go new file mode 100644 index 000000000..b02dba76a --- /dev/null +++ b/vendor/github.com/akamai/AkamaiOPEN-edgegrid-golang/client-v1/client.go @@ -0,0 +1,111 @@ +// Package client is a simple library for http.Client to sign Akamai OPEN Edgegrid API requests +package client + +import ( + "bytes" + "errors" + "io" + "io/ioutil" + "net/http" + "net/url" + "runtime" + "strings" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/edgegrid" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/jsonhooks-v1" +) + +var ( + libraryVersion = "0.6.0" + // UserAgent is the User-Agent value sent for all requests + UserAgent = "Akamai-Open-Edgegrid-golang/" + libraryVersion + " golang/" + strings.TrimPrefix(runtime.Version(), "go") + // Client is the *http.Client to use + Client = http.DefaultClient +) + +// NewRequest creates an HTTP request that can be sent to Akamai APIs. A relative URL can be provided in path, which will be resolved to the +// Host specified in Config. If body is specified, it will be sent as the request body. +func NewRequest(config edgegrid.Config, method, path string, body io.Reader) (*http.Request, error) { + var ( + baseURL *url.URL + err error + ) + + if strings.HasPrefix(config.Host, "https://") { + baseURL, err = url.Parse(config.Host) + } else { + baseURL, err = url.Parse("https://" + config.Host) + } + + if err != nil { + return nil, err + } + + rel, err := url.Parse(strings.TrimPrefix(path, "/")) + if err != nil { + return nil, err + } + + u := baseURL.ResolveReference(rel) + + req, err := http.NewRequest(method, u.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("User-Agent", UserAgent) + + return req, nil +} + +// NewJSONRequest creates an HTTP request that can be sent to the Akamai APIs with a JSON body +// The JSON body is encoded and the Content-Type/Accept headers are set automatically. +func NewJSONRequest(config edgegrid.Config, method, path string, body interface{}) (*http.Request, error) { + jsonBody, err := jsonhooks.Marshal(body) + if err != nil { + return nil, err + } + + buf := bytes.NewReader(jsonBody) + req, err := NewRequest(config, method, path, buf) + if err != nil { + return nil, err + } + + req.Header.Set("Content-Type", "application/json") + req.Header.Set("Accept", "application/json,*/*") + + return req, nil +} + +// Do performs a given HTTP Request, signed with the Akamai OPEN Edgegrid +// Authorization header. An edgegrid.Response or an error is returned. +func Do(config edgegrid.Config, req *http.Request) (*http.Response, error) { + Client.CheckRedirect = func(req *http.Request, via []*http.Request) error { + req = edgegrid.AddRequestHeader(config, req) + return nil + } + + req = edgegrid.AddRequestHeader(config, req) + res, err := Client.Do(req) + if err != nil { + return nil, err + } + + return res, nil +} + +// BodyJSON unmarshals the Response.Body into a given data structure +func BodyJSON(r *http.Response, data interface{}) error { + if data == nil { + return errors.New("You must pass in an interface{}") + } + + body, err := ioutil.ReadAll(r.Body) + if err != nil { + return err + } + err = jsonhooks.Unmarshal(body, data) + + return err +} diff --git a/vendor/github.com/akamai/AkamaiOPEN-edgegrid-golang/client-v1/errors.go b/vendor/github.com/akamai/AkamaiOPEN-edgegrid-golang/client-v1/errors.go new file mode 100644 index 000000000..c679963f4 --- /dev/null +++ b/vendor/github.com/akamai/AkamaiOPEN-edgegrid-golang/client-v1/errors.go @@ -0,0 +1,88 @@ +package client + +import ( + "fmt" + "io/ioutil" + "net/http" + "strings" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/jsonhooks-v1" +) + +// APIError exposes an Akamai OPEN Edgegrid Error +type APIError struct { + error + Type string `json:"type"` + Title string `json:"title"` + Status int `json:"status"` + Detail string `json:"detail"` + Instance string `json:"instance"` + Method string `json:"method"` + ServerIP string `json:"serverIp"` + ClientIP string `json:"clientIp"` + RequestID string `json:"requestId"` + RequestTime string `json:"requestTime"` + Response *http.Response `json:"-"` + RawBody string `json:"-"` +} + +func (error APIError) Error() string { + return strings.TrimSpace(fmt.Sprintf("API Error: %d %s %s More Info %s", error.Status, error.Title, error.Detail, error.Type)) +} + +// NewAPIError creates a new API error based on a Response, +// or http.Response-like. +func NewAPIError(response *http.Response) APIError { + // TODO: handle this error + body, _ := ioutil.ReadAll(response.Body) + + return NewAPIErrorFromBody(response, body) +} + +// NewAPIErrorFromBody creates a new API error, allowing you to pass in a body +// +// This function is intended to be used after the body has already been read for +// other purposes. +func NewAPIErrorFromBody(response *http.Response, body []byte) APIError { + error := APIError{} + + if err := jsonhooks.Unmarshal(body, &error); err == nil { + error.Status = response.StatusCode + error.Title = response.Status + } + + error.Response = response + error.RawBody = string(body) + + return error +} + +// IsInformational determines if a response was informational (1XX status) +func IsInformational(r *http.Response) bool { + return r.StatusCode > 99 && r.StatusCode < 200 +} + +// IsSuccess determines if a response was successful (2XX status) +func IsSuccess(r *http.Response) bool { + return r.StatusCode > 199 && r.StatusCode < 300 +} + +// IsRedirection determines if a response was a redirect (3XX status) +func IsRedirection(r *http.Response) bool { + return r.StatusCode > 299 && r.StatusCode < 400 +} + +// IsClientError determines if a response was a client error (4XX status) +func IsClientError(r *http.Response) bool { + return r.StatusCode > 399 && r.StatusCode < 500 +} + +// IsServerError determines if a response was a server error (5XX status) +func IsServerError(r *http.Response) bool { + return r.StatusCode > 499 && r.StatusCode < 600 +} + +// IsError determines if the response was a client or server error (4XX or 5XX status) +func IsError(r *http.Response) bool { + return r.StatusCode > 399 && r.StatusCode < 600 +} diff --git a/vendor/github.com/akamai/AkamaiOPEN-edgegrid-golang/configdns-v1/errors.go b/vendor/github.com/akamai/AkamaiOPEN-edgegrid-golang/configdns-v1/errors.go new file mode 100644 index 000000000..06eed5daa --- /dev/null +++ b/vendor/github.com/akamai/AkamaiOPEN-edgegrid-golang/configdns-v1/errors.go @@ -0,0 +1,125 @@ +package dns + +import ( + "fmt" +) + +type ConfigDNSError interface { + error + Network() bool + NotFound() bool + FailedToSave() bool + ValidationFailed() bool +} + +func IsConfigDNSError(e error) bool { + _, ok := e.(ConfigDNSError) + return ok +} + +type ZoneError struct { + zoneName string + httpErrorMessage string + apiErrorMessage string + err error +} + +func (e *ZoneError) Network() bool { + if e.httpErrorMessage != "" { + return true + } + return false +} + +func (e *ZoneError) NotFound() bool { + if e.err == nil && e.httpErrorMessage == "" && e.apiErrorMessage == "" { + return true + } + return false +} + +func (e *ZoneError) FailedToSave() bool { + return false +} + +func (e *ZoneError) ValidationFailed() bool { + if e.apiErrorMessage != "" { + return true + } + return false +} + +func (e *ZoneError) Error() string { + if e.Network() { + return fmt.Sprintf("Zone \"%s\" network error: [%s]", e.zoneName, e.httpErrorMessage) + } + + if e.NotFound() { + return fmt.Sprintf("Zone \"%s\" not found.", e.zoneName) + } + + if e.FailedToSave() { + return fmt.Sprintf("Zone \"%s\" failed to save: [%s]", e.zoneName, e.err.Error()) + } + + if e.ValidationFailed() { + return fmt.Sprintf("Zone \"%s\" validation failed: [%s]", e.zoneName, e.apiErrorMessage) + } + + if e.err != nil { + return e.err.Error() + } + + return "" +} + +type RecordError struct { + fieldName string + httpErrorMessage string + err error +} + +func (e *RecordError) Network() bool { + if e.httpErrorMessage != "" { + return true + } + return false +} + +func (e *RecordError) NotFound() bool { + return false +} + +func (e *RecordError) FailedToSave() bool { + if e.fieldName == "" { + return true + } + return false +} + +func (e *RecordError) ValidationFailed() bool { + if e.fieldName != "" { + return true + } + return false +} + +func (e *RecordError) Error() string { + if e.Network() { + return fmt.Sprintf("Record network error: [%s]", e.httpErrorMessage) + } + + if e.NotFound() { + return fmt.Sprintf("Record not found.") + } + + if e.FailedToSave() { + return fmt.Sprintf("Record failed to save: [%s]", e.err.Error()) + } + + if e.ValidationFailed() { + return fmt.Sprintf("Record validation failed for field [%s]", e.fieldName) + } + + return "" +} diff --git a/vendor/github.com/akamai/AkamaiOPEN-edgegrid-golang/configdns-v1/record.go b/vendor/github.com/akamai/AkamaiOPEN-edgegrid-golang/configdns-v1/record.go new file mode 100644 index 000000000..1c2dcb48e --- /dev/null +++ b/vendor/github.com/akamai/AkamaiOPEN-edgegrid-golang/configdns-v1/record.go @@ -0,0 +1,1738 @@ +package dns + +import ( + "strings" + "time" +) + +// All record types (below) must implement the DNSRecord interface +// This allows the record to be used dynamically in slices - see the Zone struct definition in zone.go +// +// The record types implemented and their fields are as defined here +// https://developer.akamai.com/api/luna/config-dns/data.html +type DNSRecord interface { + // Get the list of allowed fields for this type + GetAllowedFields() []string + // Set a field on the struct, which check for valid fields + SetField(name string, value interface{}) error + // Translate struct properties to a map + ToMap() map[string]interface{} +} + +type ARecord struct { + fieldMap []string `json:"-"` + Name string `json:"name,omitempty"` + TTL int `json:"ttl,omitempty"` + Active bool `json:"active,omitempty"` + Target string `json:"target,omitempty"` +} + +func NewARecord() *ARecord { + return &ARecord{ + fieldMap: []string{ + "name", + "ttl", + "active", + "target", + }, + } +} + +func (record *ARecord) GetAllowedFields() []string { + return record.fieldMap +} + +func (record *ARecord) SetField(name string, value interface{}) error { + if contains(record.fieldMap, name) { + switch name { + case "name": + v, ok := value.(string) + if ok { + record.Name = v + return nil + } + case "ttl": + v, ok := value.(int) + if ok { + record.TTL = v + return nil + } + case "active": + v, ok := value.(bool) + if ok { + record.Active = v + return nil + } + case "target": + v, ok := value.(string) + if ok { + record.Target = v + return nil + } + } + } + return &RecordError{fieldName: name} +} + +func (record *ARecord) ToMap() map[string]interface{} { + return map[string]interface{}{ + "name": record.Name, + "ttl": record.TTL, + "active": record.Active, + "target": record.Target, + } +} + +type AaaaRecord struct { + fieldMap []string `json:"-"` + Name string `json:"name,omitempty"` + TTL int `json:"ttl,omitempty"` + Active bool `json:"active,omitempty"` + Target string `json:"target,omitempty"` +} + +func NewAaaaRecord() *AaaaRecord { + return &AaaaRecord{ + fieldMap: []string{ + "name", + "ttl", + "active", + "target", + }, + } +} + +func (record *AaaaRecord) GetAllowedFields() []string { + return record.fieldMap +} + +func (record *AaaaRecord) SetField(name string, value interface{}) error { + if contains(record.fieldMap, name) { + switch name { + case "name": + v, ok := value.(string) + if ok { + record.Name = v + return nil + } + case "ttl": + v, ok := value.(int) + if ok { + record.TTL = v + return nil + } + case "active": + v, ok := value.(bool) + if ok { + record.Active = v + return nil + } + case "target": + v, ok := value.(string) + if ok { + record.Target = v + return nil + } + } + } + return &RecordError{fieldName: name} +} + +func (record *AaaaRecord) ToMap() map[string]interface{} { + return map[string]interface{}{ + "name": record.Name, + "ttl": record.TTL, + "active": record.Active, + "target": record.Target, + } +} + +type AfsdbRecord struct { + fieldMap []string `json:"-"` + Name string `json:"name,omitempty"` + TTL int `json:"ttl,omitempty"` + Active bool `json:"active,omitempty"` + Target string `json:"target,omitempty"` + Subtype int `json:"subtype,omitempty"` +} + +func NewAfsdbRecord() *AfsdbRecord { + return &AfsdbRecord{ + fieldMap: []string{ + "name", + "ttl", + "active", + "target", + "subtype", + }, + } +} + +func (record *AfsdbRecord) GetAllowedFields() []string { + return record.fieldMap +} + +func (record *AfsdbRecord) SetField(name string, value interface{}) error { + if contains(record.fieldMap, name) { + switch name { + case "name": + v, ok := value.(string) + if ok { + record.Name = v + return nil + } + case "ttl": + v, ok := value.(int) + if ok { + record.TTL = v + return nil + } + case "active": + v, ok := value.(bool) + if ok { + record.Active = v + return nil + } + case "target": + v, ok := value.(string) + if ok { + record.Target = v + return nil + } + case "subtype": + v, ok := value.(int) + if ok { + record.Subtype = v + return nil + } + } + } + return &RecordError{fieldName: name} +} + +func (record *AfsdbRecord) ToMap() map[string]interface{} { + return map[string]interface{}{ + "name": record.Name, + "ttl": record.TTL, + "active": record.Active, + "target": record.Target, + "subtype": record.Subtype, + } +} + +type CnameRecord struct { + fieldMap []string `json:"-"` + Name string `json:"name,omitempty"` + TTL int `json:"ttl,omitempty"` + Active bool `json:"active,omitempty"` + Target string `json:"target,omitempty"` +} + +func NewCnameRecord() *CnameRecord { + return &CnameRecord{ + fieldMap: []string{ + "name", + "ttl", + "active", + "target", + }, + } +} + +func (record *CnameRecord) GetAllowedFields() []string { + return record.fieldMap +} + +func (record *CnameRecord) SetField(name string, value interface{}) error { + if contains(record.fieldMap, name) { + switch name { + case "name": + v, ok := value.(string) + if ok { + record.Name = v + return nil + } + case "ttl": + v, ok := value.(int) + if ok { + record.TTL = v + return nil + } + case "active": + v, ok := value.(bool) + if ok { + record.Active = v + return nil + } + case "target": + v, ok := value.(string) + if ok { + record.Target = v + return nil + } + } + } + return &RecordError{fieldName: name} +} + +func (record *CnameRecord) ToMap() map[string]interface{} { + return map[string]interface{}{ + "name": record.Name, + "ttl": record.TTL, + "active": record.Active, + "target": record.Target, + } +} + +type DnskeyRecord struct { + fieldMap []string `json:"-"` + Name string `json:"name,omitempty"` + TTL int `json:"ttl,omitempty"` + Active bool `json:"active,omitempty"` + Flags int `json:"flags,omitempty"` + Protocol int `json:"protocol,omitempty"` + Algorithm int `json:"algorithm,omitempty"` + Key string `json:"key,omitempty"` +} + +func NewDnskeyRecord() *DnskeyRecord { + return &DnskeyRecord{ + fieldMap: []string{ + "name", + "ttl", + "active", + "flags", + "protocol", + "algorithm", + "key", + }, + } +} + +func (record *DnskeyRecord) GetAllowedFields() []string { + return record.fieldMap +} + +func (record *DnskeyRecord) SetField(name string, value interface{}) error { + if contains(record.fieldMap, name) { + switch name { + case "name": + v, ok := value.(string) + if ok { + record.Name = v + return nil + } + case "ttl": + v, ok := value.(int) + if ok { + record.TTL = v + return nil + } + case "active": + v, ok := value.(bool) + if ok { + record.Active = v + return nil + } + case "flags": + v, ok := value.(int) + if ok { + record.Flags = v + return nil + } + case "protocol": + v, ok := value.(int) + if ok { + record.Protocol = v + return nil + } + case "algorithm": + v, ok := value.(int) + if ok { + record.Algorithm = v + return nil + } + case "key": + v, ok := value.(string) + if ok { + record.Key = v + return nil + } + } + } + return &RecordError{fieldName: name} +} + +func (record *DnskeyRecord) ToMap() map[string]interface{} { + return map[string]interface{}{ + "name": record.Name, + "ttl": record.TTL, + "active": record.Active, + "flags": record.Flags, + "protocol": record.Protocol, + "algorithm": record.Algorithm, + "key": record.Key, + } +} + +type DsRecord struct { + fieldMap []string `json:"-"` + Name string `json:"name,omitempty"` + TTL int `json:"ttl,omitempty"` + Active bool `json:"active,omitempty"` + Keytag int `json:"keytag,omitempty"` + Algorithm int `json:"algorithm,omitempty"` + DigestType int `json:"digest_type,omitempty"` + Digest string `json:"digest,omitempty"` +} + +func NewDsRecord() *DsRecord { + return &DsRecord{ + fieldMap: []string{ + "name", + "ttl", + "active", + "keytag", + "algorithm", + "digesttype", + "digest", + }, + } +} + +func (record *DsRecord) GetAllowedFields() []string { + return record.fieldMap +} + +func (record *DsRecord) SetField(name string, value interface{}) error { + if contains(record.fieldMap, name) { + switch name { + case "name": + v, ok := value.(string) + if ok { + record.Name = v + return nil + } + case "ttl": + v, ok := value.(int) + if ok { + record.TTL = v + return nil + } + case "active": + v, ok := value.(bool) + if ok { + record.Active = v + return nil + } + case "keytag": + v, ok := value.(int) + if ok { + record.Keytag = v + return nil + } + case "algorithm": + v, ok := value.(int) + if ok { + record.Algorithm = v + return nil + } + case "digesttype": + v, ok := value.(int) + if ok { + record.DigestType = v + return nil + } + case "digest": + v, ok := value.(string) + if ok { + record.Digest = v + return nil + } + } + } + return &RecordError{fieldName: name} +} + +func (record *DsRecord) ToMap() map[string]interface{} { + return map[string]interface{}{ + "name": record.Name, + "ttl": record.TTL, + "active": record.Active, + "keytag": record.Keytag, + "algorithm": record.Algorithm, + "digesttype": record.DigestType, + "digest": record.DigestType, + } +} + +type HinfoRecord struct { + fieldMap []string `json:"-"` + Name string `json:"name,omitempty"` + TTL int `json:"ttl,omitempty"` + Active bool `json:"active,omitempty"` + Hardware string `json:"hardware,omitempty"` + Software string `json:"software,omitempty"` +} + +func NewHinfoRecord() *HinfoRecord { + return &HinfoRecord{ + fieldMap: []string{ + "name", + "ttl", + "active", + "hardware", + "software", + }, + } +} + +func (record *HinfoRecord) GetAllowedFields() []string { + return record.fieldMap +} + +func (record *HinfoRecord) SetField(name string, value interface{}) error { + if contains(record.fieldMap, name) { + switch name { + case "name": + v, ok := value.(string) + if ok { + record.Name = v + return nil + } + case "ttl": + v, ok := value.(int) + if ok { + record.TTL = v + return nil + } + case "active": + v, ok := value.(bool) + if ok { + record.Active = v + return nil + } + case "hardware": + v, ok := value.(string) + if ok { + record.Hardware = v + return nil + } + case "software": + v, ok := value.(string) + if ok { + record.Software = v + return nil + } + } + } + return &RecordError{fieldName: name} +} + +func (record *HinfoRecord) ToMap() map[string]interface{} { + return map[string]interface{}{ + "name": record.Name, + "ttl": record.TTL, + "active": record.Active, + "hardware": record.Hardware, + "software": record.Software, + } +} + +type LocRecord struct { + fieldMap []string `json:"-"` + Name string `json:"name,omitempty"` + TTL int `json:"ttl,omitempty"` + Active bool `json:"active,omitempty"` + Target string `json:"target,omitempty"` +} + +func NewLocRecord() *LocRecord { + return &LocRecord{ + fieldMap: []string{ + "name", + "ttl", + "active", + "target", + }, + } +} + +func (record *LocRecord) GetAllowedFields() []string { + return record.fieldMap +} + +func (record *LocRecord) SetField(name string, value interface{}) error { + if contains(record.fieldMap, name) { + switch name { + case "name": + v, ok := value.(string) + if ok { + record.Name = v + return nil + } + case "ttl": + v, ok := value.(int) + if ok { + record.TTL = v + return nil + } + case "active": + v, ok := value.(bool) + if ok { + record.Active = v + return nil + } + case "target": + v, ok := value.(string) + if ok { + record.Target = v + return nil + } + } + } + return &RecordError{fieldName: name} +} + +func (record *LocRecord) ToMap() map[string]interface{} { + return map[string]interface{}{ + "name": record.Name, + "ttl": record.TTL, + "active": record.Active, + "target": record.Target, + } +} + +type MxRecord struct { + fieldMap []string `json:"-"` + Name string `json:"name,omitempty"` + TTL int `json:"ttl,omitempty"` + Active bool `json:"active,omitempty"` + Target string `json:"target,omitempty"` + Priority int `json:"priority,omitempty"` +} + +func NewMxRecord() *MxRecord { + return &MxRecord{ + fieldMap: []string{ + "name", + "ttl", + "active", + "target", + "priority", + }, + } +} + +func (record *MxRecord) GetAllowedFields() []string { + return record.fieldMap +} + +func (record *MxRecord) SetField(name string, value interface{}) error { + if contains(record.fieldMap, name) { + switch name { + case "name": + v, ok := value.(string) + if ok { + record.Name = v + return nil + } + case "ttl": + v, ok := value.(int) + if ok { + record.TTL = v + return nil + } + case "active": + v, ok := value.(bool) + if ok { + record.Active = v + return nil + } + case "target": + v, ok := value.(string) + if ok { + record.Target = v + return nil + } + case "priority": + v, ok := value.(int) + if ok { + record.Priority = v + return nil + } + } + } + return &RecordError{fieldName: name} +} + +func (record *MxRecord) ToMap() map[string]interface{} { + return map[string]interface{}{ + "name": record.Name, + "ttl": record.TTL, + "active": record.Active, + "target": record.Target, + "priority": record.Priority, + } +} + +type NaptrRecord struct { + fieldMap []string `json:"-"` + Name string `json:"name,omitempty"` + TTL int `json:"ttl,omitempty"` + Active bool `json:"active,omitempty"` + Order uint16 `json:"order,omitempty"` + Preference uint16 `json:"preference,omitempty"` + Flags string `json:"flags,omitempty"` + Service string `json:"service,omitempty"` + Regexp string `json:"regexp,omitempty"` + Replacement string `json:"replacement,omitempty"` +} + +func NewNaptrRecord() *NaptrRecord { + return &NaptrRecord{ + fieldMap: []string{ + "name", + "ttl", + "active", + "order", + "preference", + "flags", + "service", + "regexp", + "replacement", + }, + } +} + +func (record *NaptrRecord) GetAllowedFields() []string { + return record.fieldMap +} + +func (record *NaptrRecord) SetField(name string, value interface{}) error { + if contains(record.fieldMap, name) { + switch name { + case "name": + v, ok := value.(string) + if ok { + record.Name = v + return nil + } + case "ttl": + v, ok := value.(int) + if ok { + record.TTL = v + return nil + } + case "active": + v, ok := value.(bool) + if ok { + record.Active = v + return nil + } + case "order": + v, ok := value.(uint16) + if ok { + record.Order = v + return nil + } + case "preference": + v, ok := value.(uint16) + if ok { + record.Preference = v + return nil + } + case "flags": + v, ok := value.(string) + if ok { + record.Flags = v + return nil + } + case "service": + v, ok := value.(string) + if ok { + record.Service = v + return nil + } + case "regexp": + v, ok := value.(string) + if ok { + record.Regexp = v + return nil + } + case "replacement": + v, ok := value.(string) + if ok { + record.Replacement = v + return nil + } + } + } + return &RecordError{fieldName: name} +} + +func (record *NaptrRecord) ToMap() map[string]interface{} { + return map[string]interface{}{ + "name": record.Name, + "ttl": record.TTL, + "active": record.Active, + "order": record.Order, + "preference": record.Preference, + "flags": record.Flags, + "service": record.Service, + "regexp": record.Regexp, + "replacement": record.Replacement, + } +} + +type NsRecord struct { + fieldMap []string `json:"-"` + Name string `json:"name,omitempty"` + TTL int `json:"ttl,omitempty"` + Active bool `json:"active,omitempty"` + Target string `json:"target,omitempty"` +} + +func NewNsRecord() *NsRecord { + return &NsRecord{ + fieldMap: []string{ + "name", + "ttl", + "active", + "target", + }, + } +} + +func (record *NsRecord) GetAllowedFields() []string { + return record.fieldMap +} + +func (record *NsRecord) SetField(name string, value interface{}) error { + if contains(record.fieldMap, name) { + switch name { + case "name": + v, ok := value.(string) + if ok { + record.Name = v + return nil + } + case "ttl": + v, ok := value.(int) + if ok { + record.TTL = v + return nil + } + case "active": + v, ok := value.(bool) + if ok { + record.Active = v + return nil + } + case "target": + v, ok := value.(string) + if ok { + record.Target = v + return nil + } + } + } + return &RecordError{fieldName: name} +} + +func (record *NsRecord) ToMap() map[string]interface{} { + return map[string]interface{}{ + "name": record.Name, + "ttl": record.TTL, + "active": record.Active, + "target": record.Target, + } +} + +type Nsec3Record struct { + fieldMap []string `json:"-"` + Name string `json:"name,omitempty"` + TTL int `json:"ttl,omitempty"` + Active bool `json:"active,omitempty"` + Algorithm int `json:"algorithm,omitempty"` + Flags int `json:"flags,omitempty"` + Iterations int `json:"iterations,omitempty"` + Salt string `json:"salt,omitempty"` + NextHashedOwnerName string `json:"next_hashed_owner_name,omitempty"` + TypeBitmaps string `json:"type_bitmaps,omitempty"` +} + +func NewNsec3Record() *Nsec3Record { + return &Nsec3Record{ + fieldMap: []string{ + "name", + "ttl", + "active", + "algorithm", + "flags", + "iterations", + "salt", + "nexthashedownername", + "typebitmaps", + }, + } +} + +func (record *Nsec3Record) GetAllowedFields() []string { + return record.fieldMap +} + +func (record *Nsec3Record) SetField(name string, value interface{}) error { + if contains(record.fieldMap, name) { + switch name { + case "name": + v, ok := value.(string) + if ok { + record.Name = v + return nil + } + case "ttl": + v, ok := value.(int) + if ok { + record.TTL = v + return nil + } + case "active": + v, ok := value.(bool) + if ok { + record.Active = v + return nil + } + case "algorithm": + v, ok := value.(int) + if ok { + record.Algorithm = v + return nil + } + case "flags": + v, ok := value.(int) + if ok { + record.Flags = v + return nil + } + case "iterations": + v, ok := value.(int) + if ok { + record.Iterations = v + return nil + } + case "salt": + v, ok := value.(string) + if ok { + record.Salt = v + return nil + } + case "nexthashedownername": + v, ok := value.(string) + if ok { + record.NextHashedOwnerName = v + return nil + } + case "typebitmaps": + v, ok := value.(string) + if ok { + record.TypeBitmaps = v + return nil + } + } + } + return &RecordError{fieldName: name} +} + +func (record *Nsec3Record) ToMap() map[string]interface{} { + return map[string]interface{}{ + "name": record.Name, + "ttl": record.TTL, + "active": record.Active, + "algorithm": record.Algorithm, + "flags": record.Flags, + "iterations": record.Iterations, + "salt": record.Salt, + "nexthashedownername": record.NextHashedOwnerName, + "typebitmaps": record.TypeBitmaps, + } +} + +type Nsec3paramRecord struct { + fieldMap []string `json:"-"` + Name string `json:"name,omitempty"` + TTL int `json:"ttl,omitempty"` + Active bool `json:"active,omitempty"` + Algorithm int `json:"algorithm,omitempty"` + Flags int `json:"flags,omitempty"` + Iterations int `json:"iterations,omitempty"` + Salt string `json:"salt,omitempty"` +} + +func NewNsec3paramRecord() *Nsec3paramRecord { + return &Nsec3paramRecord{ + fieldMap: []string{ + "name", + "ttl", + "active", + "algorithm", + "flags", + "iterations", + "salt", + }, + } +} + +func (record *Nsec3paramRecord) GetAllowedFields() []string { + return record.fieldMap +} + +func (record *Nsec3paramRecord) SetField(name string, value interface{}) error { + if contains(record.fieldMap, name) { + switch name { + case "name": + v, ok := value.(string) + if ok { + record.Name = v + return nil + } + case "ttl": + v, ok := value.(int) + if ok { + record.TTL = v + return nil + } + case "active": + v, ok := value.(bool) + if ok { + record.Active = v + return nil + } + case "algorithm": + v, ok := value.(int) + if ok { + record.Algorithm = v + return nil + } + case "flags": + v, ok := value.(int) + if ok { + record.Flags = v + return nil + } + case "iterations": + v, ok := value.(int) + if ok { + record.Iterations = v + return nil + } + case "salt": + v, ok := value.(string) + if ok { + record.Salt = v + return nil + } + } + } + return &RecordError{fieldName: name} +} + +func (record *Nsec3paramRecord) ToMap() map[string]interface{} { + return map[string]interface{}{ + "name": record.Name, + "ttl": record.TTL, + "active": record.Active, + "algorithm": record.Algorithm, + "flags": record.Flags, + "iterations": record.Iterations, + "salt": record.Salt, + } +} + +type PtrRecord struct { + fieldMap []string `json:"-"` + Name string `json:"name,omitempty"` + TTL int `json:"ttl,omitempty"` + Active bool `json:"active,omitempty"` + Target string `json:"target,omitempty"` +} + +func NewPtrRecord() *PtrRecord { + return &PtrRecord{ + fieldMap: []string{ + "name", + "ttl", + "active", + "target", + }, + } +} + +func (record *PtrRecord) GetAllowedFields() []string { + return record.fieldMap +} + +func (record *PtrRecord) SetField(name string, value interface{}) error { + if contains(record.fieldMap, name) { + switch name { + case "name": + v, ok := value.(string) + if ok { + record.Name = v + return nil + } + case "ttl": + v, ok := value.(int) + if ok { + record.TTL = v + return nil + } + case "active": + v, ok := value.(bool) + if ok { + record.Active = v + return nil + } + case "target": + v, ok := value.(string) + if ok { + record.Target = v + return nil + } + } + } + return &RecordError{fieldName: name} +} + +func (record *PtrRecord) ToMap() map[string]interface{} { + return map[string]interface{}{ + "name": record.Name, + "ttl": record.TTL, + "active": record.Active, + "target": record.Target, + } +} + +type RpRecord struct { + fieldMap []string `json:"-"` + Name string `json:"name,omitempty"` + TTL int `json:"ttl,omitempty"` + Active bool `json:"active,omitempty"` + Mailbox string `json:"mailbox,omitempty"` + Txt string `json:"txt,omitempty"` +} + +func NewRpRecord() *RpRecord { + return &RpRecord{ + fieldMap: []string{ + "name", + "ttl", + "active", + "mailbox", + "txt", + }, + } +} + +func (record *RpRecord) GetAllowedFields() []string { + return record.fieldMap +} + +func (record *RpRecord) SetField(name string, value interface{}) error { + if contains(record.fieldMap, name) { + switch name { + case "name": + v, ok := value.(string) + if ok { + record.Name = v + return nil + } + case "ttl": + v, ok := value.(int) + if ok { + record.TTL = v + return nil + } + case "active": + v, ok := value.(bool) + if ok { + record.Active = v + return nil + } + case "mailbox": + v, ok := value.(string) + if ok { + record.Mailbox = v + return nil + } + case "txt": + v, ok := value.(string) + if ok { + record.Txt = v + return nil + } + } + } + return &RecordError{fieldName: name} +} + +func (record *RpRecord) ToMap() map[string]interface{} { + return map[string]interface{}{ + "name": record.Name, + "ttl": record.TTL, + "active": record.Active, + "mailbox": record.Mailbox, + "txt": record.Txt, + } +} + +type RrsigRecord struct { + fieldMap []string `json:"-"` + Name string `json:"name,omitempty"` + TTL int `json:"ttl,omitempty"` + Active bool `json:"active,omitempty"` + TypeCovered string `json:"type_covered,omitempty"` + Algorithm int `json:"algorithm,omitempty"` + OriginalTTL int `json:"original_ttl,omitempty"` + Expiration string `json:"expiration,omitempty"` + Inception string `json:"inception,omitempty"` + Keytag int `json:"keytag,omitempty"` + Signer string `json:"signer,omitempty"` + Signature string `json:"signature,omitempty"` + Labels int `json:"labels,omitempty"` +} + +func NewRrsigRecord() *RrsigRecord { + return &RrsigRecord{ + fieldMap: []string{ + "name", + "ttl", + "active", + "typecovered", + "algorithm", + "originalttl", + "expiration", + "inception", + "keytag", + "signer", + "signature", + "labels", + }, + } +} + +func (record *RrsigRecord) GetAllowedFields() []string { + return record.fieldMap +} + +func (record *RrsigRecord) SetField(name string, value interface{}) error { + if contains(record.fieldMap, name) { + switch name { + case "name": + v, ok := value.(string) + if ok { + record.Name = v + return nil + } + case "ttl": + v, ok := value.(int) + if ok { + record.TTL = v + return nil + } + case "active": + v, ok := value.(bool) + if ok { + record.Active = v + return nil + } + case "typecovered": + v, ok := value.(string) + if ok { + record.TypeCovered = v + return nil + } + case "algorithm": + v, ok := value.(int) + if ok { + record.Algorithm = v + return nil + } + case "originalttl": + v, ok := value.(int) + if ok { + record.OriginalTTL = v + return nil + } + case "expiration": + v, ok := value.(string) + if ok { + record.Expiration = v + return nil + } + case "inception": + v, ok := value.(string) + if ok { + record.Inception = v + return nil + } + case "keytag": + v, ok := value.(int) + if ok { + record.Keytag = v + return nil + } + case "signer": + v, ok := value.(string) + if ok { + record.Signer = v + return nil + } + case "signature": + v, ok := value.(string) + if ok { + record.Signature = v + return nil + } + case "labels": + v, ok := value.(int) + if ok { + record.Labels = v + return nil + } + } + } + return &RecordError{fieldName: name} +} + +func (record *RrsigRecord) ToMap() map[string]interface{} { + return map[string]interface{}{ + "name": record.Name, + "ttl": record.TTL, + "active": record.Active, + "typecovered": record.TypeCovered, + "algorithm": record.Algorithm, + "originalttl": record.OriginalTTL, + "expiration": record.Expiration, + "inception": record.Inception, + "keytag": record.Keytag, + "signer": record.Signer, + "signature": record.Signature, + "labels": record.Labels, + } +} + +type SoaRecord struct { + fieldMap []string `json:"-"` + TTL int `json:"ttl,omitempty"` + Originserver string `json:"originserver,omitempty"` + Contact string `json:"contact,omitempty"` + Serial uint `json:"serial,omitempty"` + Refresh int `json:"refresh,omitempty"` + Retry int `json:"retry,omitempty"` + Expire int `json:"expire,omitempty"` + Minimum uint `json:"minimum,omitempty"` +} + +func NewSoaRecord() *SoaRecord { + r := &SoaRecord{ + fieldMap: []string{ + "ttl", + "originserver", + "contact", + "serial", + "refresh", + "retry", + "expire", + "minimum", + }, + } + r.SetField("serial", int(time.Now().Unix())) + return r +} + +func (record *SoaRecord) GetAllowedFields() []string { + return record.fieldMap +} + +func (record *SoaRecord) SetField(name string, value interface{}) error { + if contains(record.fieldMap, name) { + switch name { + case "ttl": + v, ok := value.(int) + if ok { + record.TTL = v + return nil + } + case "originserver": + v, ok := value.(string) + if ok { + record.Originserver = v + return nil + } + case "contact": + v, ok := value.(string) + if ok { + record.Contact = v + return nil + } + case "serial": + v, ok := value.(uint) + if ok { + record.Serial = v + return nil + } + case "refresh": + v, ok := value.(int) + if ok { + record.Refresh = v + return nil + } + case "retry": + v, ok := value.(int) + if ok { + record.Retry = v + return nil + } + case "expire": + v, ok := value.(int) + if ok { + record.Expire = v + return nil + } + case "minimum": + v, ok := value.(uint) + if ok { + record.Minimum = v + return nil + } + } + } + return &RecordError{fieldName: name} +} + +func (record *SoaRecord) ToMap() map[string]interface{} { + return map[string]interface{}{ + "ttl": record.TTL, + "originserver": record.Originserver, + "contact": record.Contact, + "serial": record.Serial, + "refresh": record.Refresh, + "retry": record.Retry, + "expire": record.Expire, + "minimum": record.Minimum, + } +} + +type SpfRecord struct { + fieldMap []string `json:"-"` + Name string `json:"name,omitempty"` + TTL int `json:"ttl,omitempty"` + Active bool `json:"active,omitempty"` + Target string `json:"target,omitempty"` +} + +func NewSpfRecord() *SpfRecord { + return &SpfRecord{ + fieldMap: []string{ + "name", + "ttl", + "active", + "target", + }, + } +} + +func (record *SpfRecord) GetAllowedFields() []string { + return record.fieldMap +} + +func (record *SpfRecord) SetField(name string, value interface{}) error { + if contains(record.fieldMap, name) { + switch name { + case "name": + v, ok := value.(string) + if ok { + record.Name = v + return nil + } + case "ttl": + v, ok := value.(int) + if ok { + record.TTL = v + return nil + } + case "active": + v, ok := value.(bool) + if ok { + record.Active = v + return nil + } + case "target": + v, ok := value.(string) + if ok { + record.Target = v + return nil + } + } + } + return &RecordError{fieldName: name} +} + +func (record *SpfRecord) ToMap() map[string]interface{} { + return map[string]interface{}{ + "name": record.Name, + "ttl": record.TTL, + "active": record.Active, + "target": record.Target, + } +} + +type SrvRecord struct { + fieldMap []string `json:"-"` + Name string `json:"name,omitempty"` + TTL int `json:"ttl,omitempty"` + Active bool `json:"active,omitempty"` + Target string `json:"target,omitempty"` + Priority int `json:"priority,omitempty"` + Weight uint16 `json:"weight,omitempty"` + Port uint16 `json:"port,omitempty"` +} + +func NewSrvRecord() *SrvRecord { + return &SrvRecord{ + fieldMap: []string{ + "name", + "ttl", + "active", + "target", + "priority", + "weight", + "port", + }, + } +} + +func (record *SrvRecord) GetAllowedFields() []string { + return record.fieldMap +} + +func (record *SrvRecord) SetField(name string, value interface{}) error { + if contains(record.fieldMap, name) { + switch name { + case "name": + v, ok := value.(string) + if ok { + record.Name = v + return nil + } + case "ttl": + v, ok := value.(int) + if ok { + record.TTL = v + return nil + } + case "active": + v, ok := value.(bool) + if ok { + record.Active = v + return nil + } + case "target": + v, ok := value.(string) + if ok { + record.Target = v + return nil + } + case "priority": + v, ok := value.(int) + if ok { + record.Priority = v + return nil + } + case "weight": + v, ok := value.(uint16) + if ok { + record.Weight = v + return nil + } + case "port": + v, ok := value.(uint16) + if ok { + record.Port = v + return nil + } + } + } + return &RecordError{fieldName: name} +} + +func (record *SrvRecord) ToMap() map[string]interface{} { + return map[string]interface{}{ + "name": record.Name, + "ttl": record.TTL, + "active": record.Active, + "target": record.Target, + "priority": record.Priority, + "weight": record.Weight, + "port": record.Port, + } +} + +type SshfpRecord struct { + fieldMap []string `json:"-"` + Name string `json:"name,omitempty"` + TTL int `json:"ttl,omitempty"` + Active bool `json:"active,omitempty"` + Algorithm int `json:"algorithm,omitempty"` + FingerprintType int `json:"fingerprint_type,omitempty"` + Fingerprint string `json:"fingerprint,omitempty"` +} + +func NewSshfpRecord() *SshfpRecord { + return &SshfpRecord{ + fieldMap: []string{ + "name", + "ttl", + "active", + "algorithm", + "fingerprinttype", + "fingerprint", + }, + } +} + +func (record *SshfpRecord) GetAllowedFields() []string { + return record.fieldMap +} + +func (record *SshfpRecord) SetField(name string, value interface{}) error { + if contains(record.fieldMap, name) { + switch name { + case "name": + v, ok := value.(string) + if ok { + record.Name = v + return nil + } + case "ttl": + v, ok := value.(int) + if ok { + record.TTL = v + return nil + } + case "active": + v, ok := value.(bool) + if ok { + record.Active = v + return nil + } + case "algorithm": + v, ok := value.(int) + if ok { + record.Algorithm = v + return nil + } + case "fingerprinttype": + v, ok := value.(int) + if ok { + record.FingerprintType = v + return nil + } + case "fingerprint": + v, ok := value.(string) + if ok { + record.Fingerprint = v + return nil + } + } + } + return &RecordError{fieldName: name} +} + +func (record *SshfpRecord) ToMap() map[string]interface{} { + return map[string]interface{}{ + "name": record.Name, + "ttl": record.TTL, + "active": record.Active, + "algorithm": record.Algorithm, + "fingerprinttype": record.FingerprintType, + "fingerprint": record.Fingerprint, + } +} + +type TxtRecord struct { + fieldMap []string `json:"-"` + Name string `json:"name,omitempty"` + TTL int `json:"ttl,omitempty"` + Active bool `json:"active,omitempty"` + Target string `json:"target,omitempty"` +} + +func NewTxtRecord() *TxtRecord { + return &TxtRecord{ + fieldMap: []string{ + "name", + "ttl", + "active", + "target", + }, + } +} + +func (record *TxtRecord) GetAllowedFields() []string { + return record.fieldMap +} + +func (record *TxtRecord) SetField(name string, value interface{}) error { + if contains(record.fieldMap, name) { + switch name { + case "name": + v, ok := value.(string) + if ok { + record.Name = v + return nil + } + case "ttl": + v, ok := value.(int) + if ok { + record.TTL = v + return nil + } + case "active": + v, ok := value.(bool) + if ok { + record.Active = v + return nil + } + case "target": + v, ok := value.(string) + if ok { + record.Target = v + return nil + } + } + } + return &RecordError{fieldName: name} +} + +func (record *TxtRecord) ToMap() map[string]interface{} { + return map[string]interface{}{ + "name": record.Name, + "ttl": record.TTL, + "active": record.Active, + "target": record.Target, + } +} + +func contains(fieldMap []string, field string) bool { + field = strings.ToLower(field) + + for _, r := range fieldMap { + if r == field { + return true + } + } + + return false +} diff --git a/vendor/github.com/akamai/AkamaiOPEN-edgegrid-golang/configdns-v1/service.go b/vendor/github.com/akamai/AkamaiOPEN-edgegrid-golang/configdns-v1/service.go new file mode 100644 index 000000000..7f8ff80b6 --- /dev/null +++ b/vendor/github.com/akamai/AkamaiOPEN-edgegrid-golang/configdns-v1/service.go @@ -0,0 +1,16 @@ +package dns + +import ( + "github.com/akamai/AkamaiOPEN-edgegrid-golang/edgegrid" +) + +var ( + // Config contains the Akamai OPEN Edgegrid API credentials + // for automatic signing of requests + Config edgegrid.Config +) + +// Init sets the FastDNS edgegrid Config +func Init(config edgegrid.Config) { + Config = config +} diff --git a/vendor/github.com/akamai/AkamaiOPEN-edgegrid-golang/configdns-v1/zone.go b/vendor/github.com/akamai/AkamaiOPEN-edgegrid-golang/configdns-v1/zone.go new file mode 100644 index 000000000..355f81843 --- /dev/null +++ b/vendor/github.com/akamai/AkamaiOPEN-edgegrid-golang/configdns-v1/zone.go @@ -0,0 +1,1557 @@ +package dns + +import ( + "errors" + "fmt" + "reflect" + "strings" + "sync" + "time" + + "github.com/akamai/AkamaiOPEN-edgegrid-golang/client-v1" +) + +type name struct { + recordType string + name string +} + +var ( + cnameNames []name + nonCnameNames []name + zoneWriteLock sync.Mutex +) + +// Zone represents a DNS zone +type Zone struct { + Token string `json:"token"` + Zone struct { + Name string `json:"name,omitempty"` + A []*ARecord `json:"a,omitempty"` + Aaaa []*AaaaRecord `json:"aaaa,omitempty"` + Afsdb []*AfsdbRecord `json:"afsdb,omitempty"` + Cname []*CnameRecord `json:"cname,omitempty"` + Dnskey []*DnskeyRecord `json:"dnskey,omitempty"` + Ds []*DsRecord `json:"ds,omitempty"` + Hinfo []*HinfoRecord `json:"hinfo,omitempty"` + Loc []*LocRecord `json:"loc,omitempty"` + Mx []*MxRecord `json:"mx,omitempty"` + Naptr []*NaptrRecord `json:"naptr,omitempty"` + Ns []*NsRecord `json:"ns,omitempty"` + Nsec3 []*Nsec3Record `json:"nsec3,omitempty"` + Nsec3param []*Nsec3paramRecord `json:"nsec3param,omitempty"` + Ptr []*PtrRecord `json:"ptr,omitempty"` + Rp []*RpRecord `json:"rp,omitempty"` + Rrsig []*RrsigRecord `json:"rrsig,omitempty"` + Soa *SoaRecord `json:"soa,omitempty"` + Spf []*SpfRecord `json:"spf,omitempty"` + Srv []*SrvRecord `json:"srv,omitempty"` + Sshfp []*SshfpRecord `json:"sshfp,omitempty"` + Txt []*TxtRecord `json:"txt,omitempty"` + } `json:"zone"` +} + +// NewZone creates a new Zone +func NewZone(hostname string) *Zone { + zone := &Zone{Token: "new"} + zone.Zone.Soa = NewSoaRecord() + zone.Zone.Name = hostname + return zone +} + +// GetZone retrieves a DNS Zone for a given hostname +func GetZone(hostname string) (*Zone, error) { + zone := NewZone(hostname) + req, err := client.NewRequest( + Config, + "GET", + "/config-dns/v1/zones/"+hostname, + nil, + ) + if err != nil { + return nil, err + } + + res, err := client.Do(Config, req) + if err != nil { + return nil, err + } + + if client.IsError(res) && res.StatusCode != 404 { + return nil, client.NewAPIError(res) + } else if res.StatusCode == 404 { + return nil, &ZoneError{zoneName: hostname} + } else { + err = client.BodyJSON(res, &zone) + if err != nil { + return nil, err + } + + return zone, nil + } +} + +// Save updates the Zone +func (zone *Zone) Save() error { + // This lock will restrict the concurrency of API calls + // to 1 save request at a time. This is needed for the Soa.Serial value which + // is required to be incremented for every subsequent update to a zone + // so we have to save just one request at a time to ensure this is always + // incremented properly + zoneWriteLock.Lock() + defer zoneWriteLock.Unlock() + + valid, f := zone.validateCnames() + if valid == false { + var msg string + for _, v := range f { + msg = msg + fmt.Sprintf("\n%s Record '%s' conflicts with CNAME", v.recordType, v.name) + } + return &ZoneError{ + zoneName: zone.Zone.Name, + apiErrorMessage: "All CNAMEs must be unique in the zone" + msg, + } + } + + req, err := client.NewJSONRequest( + Config, + "POST", + "/config-dns/v1/zones/"+zone.Zone.Name, + zone, + ) + if err != nil { + return err + } + + res, err := client.Do(Config, req) + + // Network error + if err != nil { + return &ZoneError{ + zoneName: zone.Zone.Name, + httpErrorMessage: err.Error(), + err: err, + } + } + + // API error + if client.IsError(res) { + err := client.NewAPIError(res) + return &ZoneError{zoneName: zone.Zone.Name, apiErrorMessage: err.Detail, err: err} + } + + for { + updatedZone, err := GetZone(zone.Zone.Name) + if err != nil { + return err + } + + if updatedZone.Token != zone.Token { + *zone = *updatedZone + break + } + time.Sleep(time.Second) + } + + return nil +} + +func (zone *Zone) Delete() error { + // remove all the records except for SOA + // which is required and save the zone + zone.Zone.A = nil + zone.Zone.Aaaa = nil + zone.Zone.Afsdb = nil + zone.Zone.Cname = nil + zone.Zone.Dnskey = nil + zone.Zone.Ds = nil + zone.Zone.Hinfo = nil + zone.Zone.Loc = nil + zone.Zone.Mx = nil + zone.Zone.Naptr = nil + zone.Zone.Ns = nil + zone.Zone.Nsec3 = nil + zone.Zone.Nsec3param = nil + zone.Zone.Ptr = nil + zone.Zone.Rp = nil + zone.Zone.Rrsig = nil + zone.Zone.Spf = nil + zone.Zone.Srv = nil + zone.Zone.Sshfp = nil + zone.Zone.Txt = nil + + return zone.Save() +} + +func (zone *Zone) AddRecord(recordPtr interface{}) error { + switch recordPtr.(type) { + case *ARecord: + zone.addARecord(recordPtr.(*ARecord)) + case *AaaaRecord: + zone.addAaaaRecord(recordPtr.(*AaaaRecord)) + case *AfsdbRecord: + zone.addAfsdbRecord(recordPtr.(*AfsdbRecord)) + case *CnameRecord: + zone.addCnameRecord(recordPtr.(*CnameRecord)) + case *DnskeyRecord: + zone.addDnskeyRecord(recordPtr.(*DnskeyRecord)) + case *DsRecord: + zone.addDsRecord(recordPtr.(*DsRecord)) + case *HinfoRecord: + zone.addHinfoRecord(recordPtr.(*HinfoRecord)) + case *LocRecord: + zone.addLocRecord(recordPtr.(*LocRecord)) + case *MxRecord: + zone.addMxRecord(recordPtr.(*MxRecord)) + case *NaptrRecord: + zone.addNaptrRecord(recordPtr.(*NaptrRecord)) + case *NsRecord: + zone.addNsRecord(recordPtr.(*NsRecord)) + case *Nsec3Record: + zone.addNsec3Record(recordPtr.(*Nsec3Record)) + case *Nsec3paramRecord: + zone.addNsec3paramRecord(recordPtr.(*Nsec3paramRecord)) + case *PtrRecord: + zone.addPtrRecord(recordPtr.(*PtrRecord)) + case *RpRecord: + zone.addRpRecord(recordPtr.(*RpRecord)) + case *RrsigRecord: + zone.addRrsigRecord(recordPtr.(*RrsigRecord)) + case *SoaRecord: + zone.addSoaRecord(recordPtr.(*SoaRecord)) + case *SpfRecord: + zone.addSpfRecord(recordPtr.(*SpfRecord)) + case *SrvRecord: + zone.addSrvRecord(recordPtr.(*SrvRecord)) + case *SshfpRecord: + zone.addSshfpRecord(recordPtr.(*SshfpRecord)) + case *TxtRecord: + zone.addTxtRecord(recordPtr.(*TxtRecord)) + } + + return nil +} + +func (zone *Zone) RemoveRecord(recordPtr interface{}) error { + switch recordPtr.(type) { + case *ARecord: + return zone.removeARecord(recordPtr.(*ARecord)) + case *AaaaRecord: + return zone.removeAaaaRecord(recordPtr.(*AaaaRecord)) + case *AfsdbRecord: + return zone.removeAfsdbRecord(recordPtr.(*AfsdbRecord)) + case *CnameRecord: + return zone.removeCnameRecord(recordPtr.(*CnameRecord)) + case *DnskeyRecord: + return zone.removeDnskeyRecord(recordPtr.(*DnskeyRecord)) + case *DsRecord: + return zone.removeDsRecord(recordPtr.(*DsRecord)) + case *HinfoRecord: + return zone.removeHinfoRecord(recordPtr.(*HinfoRecord)) + case *LocRecord: + return zone.removeLocRecord(recordPtr.(*LocRecord)) + case *MxRecord: + return zone.removeMxRecord(recordPtr.(*MxRecord)) + case *NaptrRecord: + return zone.removeNaptrRecord(recordPtr.(*NaptrRecord)) + case *NsRecord: + return zone.removeNsRecord(recordPtr.(*NsRecord)) + case *Nsec3Record: + return zone.removeNsec3Record(recordPtr.(*Nsec3Record)) + case *Nsec3paramRecord: + return zone.removeNsec3paramRecord(recordPtr.(*Nsec3paramRecord)) + case *PtrRecord: + return zone.removePtrRecord(recordPtr.(*PtrRecord)) + case *RpRecord: + return zone.removeRpRecord(recordPtr.(*RpRecord)) + case *RrsigRecord: + return zone.removeRrsigRecord(recordPtr.(*RrsigRecord)) + case *SoaRecord: + return zone.removeSoaRecord(recordPtr.(*SoaRecord)) + case *SpfRecord: + return zone.removeSpfRecord(recordPtr.(*SpfRecord)) + case *SrvRecord: + return zone.removeSrvRecord(recordPtr.(*SrvRecord)) + case *SshfpRecord: + return zone.removeSshfpRecord(recordPtr.(*SshfpRecord)) + case *TxtRecord: + return zone.removeTxtRecord(recordPtr.(*TxtRecord)) + } + + return nil +} + +func (zone *Zone) addARecord(record *ARecord) { + zone.Zone.A = append(zone.Zone.A, record) + nonCnameNames = append(nonCnameNames, name{recordType: "A", name: record.Name}) +} + +func (zone *Zone) addAaaaRecord(record *AaaaRecord) { + zone.Zone.Aaaa = append(zone.Zone.Aaaa, record) + nonCnameNames = append(nonCnameNames, name{recordType: "AAAA", name: record.Name}) +} + +func (zone *Zone) addAfsdbRecord(record *AfsdbRecord) { + zone.Zone.Afsdb = append(zone.Zone.Afsdb, record) + nonCnameNames = append(nonCnameNames, name{recordType: "AFSDB", name: record.Name}) +} + +func (zone *Zone) addCnameRecord(record *CnameRecord) { + zone.Zone.Cname = append(zone.Zone.Cname, record) + cnameNames = append(cnameNames, name{recordType: "CNAME", name: record.Name}) +} + +func (zone *Zone) addDnskeyRecord(record *DnskeyRecord) { + zone.Zone.Dnskey = append(zone.Zone.Dnskey, record) + nonCnameNames = append(nonCnameNames, name{recordType: "DNSKEY", name: record.Name}) +} + +func (zone *Zone) addDsRecord(record *DsRecord) { + zone.Zone.Ds = append(zone.Zone.Ds, record) + nonCnameNames = append(nonCnameNames, name{recordType: "DS", name: record.Name}) +} + +func (zone *Zone) addHinfoRecord(record *HinfoRecord) { + zone.Zone.Hinfo = append(zone.Zone.Hinfo, record) + nonCnameNames = append(nonCnameNames, name{recordType: "HINFO", name: record.Name}) +} + +func (zone *Zone) addLocRecord(record *LocRecord) { + zone.Zone.Loc = append(zone.Zone.Loc, record) + nonCnameNames = append(nonCnameNames, name{recordType: "LOC", name: record.Name}) +} + +func (zone *Zone) addMxRecord(record *MxRecord) { + zone.Zone.Mx = append(zone.Zone.Mx, record) + nonCnameNames = append(nonCnameNames, name{recordType: "MX", name: record.Name}) +} + +func (zone *Zone) addNaptrRecord(record *NaptrRecord) { + zone.Zone.Naptr = append(zone.Zone.Naptr, record) + nonCnameNames = append(nonCnameNames, name{recordType: "NAPTR", name: record.Name}) +} + +func (zone *Zone) addNsRecord(record *NsRecord) { + zone.Zone.Ns = append(zone.Zone.Ns, record) + nonCnameNames = append(nonCnameNames, name{recordType: "NS", name: record.Name}) +} + +func (zone *Zone) addNsec3Record(record *Nsec3Record) { + zone.Zone.Nsec3 = append(zone.Zone.Nsec3, record) + nonCnameNames = append(nonCnameNames, name{recordType: "NSEC3", name: record.Name}) +} + +func (zone *Zone) addNsec3paramRecord(record *Nsec3paramRecord) { + zone.Zone.Nsec3param = append(zone.Zone.Nsec3param, record) + nonCnameNames = append(nonCnameNames, name{recordType: "NSEC3PARAM", name: record.Name}) +} + +func (zone *Zone) addPtrRecord(record *PtrRecord) { + zone.Zone.Ptr = append(zone.Zone.Ptr, record) + nonCnameNames = append(nonCnameNames, name{recordType: "PTR", name: record.Name}) +} + +func (zone *Zone) addRpRecord(record *RpRecord) { + zone.Zone.Rp = append(zone.Zone.Rp, record) + nonCnameNames = append(nonCnameNames, name{recordType: "RP", name: record.Name}) +} + +func (zone *Zone) addRrsigRecord(record *RrsigRecord) { + zone.Zone.Rrsig = append(zone.Zone.Rrsig, record) + nonCnameNames = append(nonCnameNames, name{recordType: "RRSIG", name: record.Name}) +} + +func (zone *Zone) addSoaRecord(record *SoaRecord) { + // Only one SOA records is allowed + zone.Zone.Soa = record +} + +func (zone *Zone) addSpfRecord(record *SpfRecord) { + zone.Zone.Spf = append(zone.Zone.Spf, record) + nonCnameNames = append(nonCnameNames, name{recordType: "SPF", name: record.Name}) +} + +func (zone *Zone) addSrvRecord(record *SrvRecord) { + zone.Zone.Srv = append(zone.Zone.Srv, record) + nonCnameNames = append(nonCnameNames, name{recordType: "SRV", name: record.Name}) +} + +func (zone *Zone) addSshfpRecord(record *SshfpRecord) { + zone.Zone.Sshfp = append(zone.Zone.Sshfp, record) + nonCnameNames = append(nonCnameNames, name{recordType: "SSHFP", name: record.Name}) +} + +func (zone *Zone) addTxtRecord(record *TxtRecord) { + zone.Zone.Txt = append(zone.Zone.Txt, record) + nonCnameNames = append(nonCnameNames, name{recordType: "TXT", name: record.Name}) +} + +func (zone *Zone) removeARecord(record *ARecord) error { + for key, r := range zone.Zone.A { + if reflect.DeepEqual(r, record) { + records := zone.Zone.A[:key] + if len(zone.Zone.A) > key { + if len(zone.Zone.A) > key { + zone.Zone.A = append(records, zone.Zone.A[key+1:]...) + } else { + zone.Zone.A = records + } + } + zone.removeNonCnameName(record.Name) + + return nil + } + } + + return errors.New("A Record not found") +} + +func (zone *Zone) removeAaaaRecord(record *AaaaRecord) error { + for key, r := range zone.Zone.Aaaa { + if reflect.DeepEqual(r, record) { + records := zone.Zone.Aaaa[:key] + if len(zone.Zone.Aaaa) > key { + zone.Zone.Aaaa = append(records, zone.Zone.Aaaa[key+1:]...) + } else { + zone.Zone.Aaaa = records + } + zone.removeNonCnameName(record.Name) + + return nil + } + } + + return errors.New("AAAA Record not found") +} + +func (zone *Zone) removeAfsdbRecord(record *AfsdbRecord) error { + for key, r := range zone.Zone.Afsdb { + if reflect.DeepEqual(r, record) { + records := zone.Zone.Afsdb[:key] + if len(zone.Zone.Afsdb) > key { + zone.Zone.Afsdb = append(records, zone.Zone.Afsdb[key+1:]...) + } else { + zone.Zone.Afsdb = records + } + zone.removeNonCnameName(record.Name) + + return nil + } + } + + return errors.New("Afsdb Record not found") +} + +func (zone *Zone) removeCnameRecord(record *CnameRecord) error { + for key, r := range zone.Zone.Cname { + if reflect.DeepEqual(r, record) { + records := zone.Zone.Cname[:key] + if len(zone.Zone.Cname) > key { + zone.Zone.Cname = append(records, zone.Zone.Cname[key+1:]...) + } else { + zone.Zone.Cname = records + } + zone.removeNonCnameName(record.Name) + + return nil + } + } + + return errors.New("Cname Record not found") + + zone.removeCnameName(record.Name) + + return nil +} + +func (zone *Zone) removeDnskeyRecord(record *DnskeyRecord) error { + for key, r := range zone.Zone.Dnskey { + if reflect.DeepEqual(r, record) { + records := zone.Zone.Dnskey[:key] + if len(zone.Zone.Dnskey) > key { + zone.Zone.Dnskey = append(records, zone.Zone.Dnskey[key+1:]...) + } else { + zone.Zone.Dnskey = records + } + zone.removeNonCnameName(record.Name) + + return nil + } + } + + return errors.New("Dnskey Record not found") +} + +func (zone *Zone) removeDsRecord(record *DsRecord) error { + for key, r := range zone.Zone.Ds { + if reflect.DeepEqual(r, record) { + records := zone.Zone.Ds[:key] + if len(zone.Zone.Ds) > key { + zone.Zone.Ds = append(records, zone.Zone.Ds[key+1:]...) + } else { + zone.Zone.Ds = records + } + zone.removeNonCnameName(record.Name) + + return nil + } + } + + return errors.New("Ds Record not found") +} + +func (zone *Zone) removeHinfoRecord(record *HinfoRecord) error { + for key, r := range zone.Zone.Hinfo { + if reflect.DeepEqual(r, record) { + records := zone.Zone.Hinfo[:key] + if len(zone.Zone.Hinfo) > key { + zone.Zone.Hinfo = append(records, zone.Zone.Hinfo[key+1:]...) + } else { + zone.Zone.Hinfo = records + } + zone.removeNonCnameName(record.Name) + + return nil + } + } + + return errors.New("Hinfo Record not found") +} + +func (zone *Zone) removeLocRecord(record *LocRecord) error { + for key, r := range zone.Zone.Loc { + if reflect.DeepEqual(r, record) { + records := zone.Zone.Loc[:key] + if len(zone.Zone.Loc) > key { + zone.Zone.Loc = append(records, zone.Zone.Loc[key+1:]...) + } else { + zone.Zone.Loc = records + } + zone.removeNonCnameName(record.Name) + + return nil + } + } + + return errors.New("Loc Record not found") +} + +func (zone *Zone) removeMxRecord(record *MxRecord) error { + for key, r := range zone.Zone.Mx { + if reflect.DeepEqual(r, record) { + records := zone.Zone.Mx[:key] + if len(zone.Zone.Mx) > key { + zone.Zone.Mx = append(records, zone.Zone.Mx[key+1:]...) + } else { + zone.Zone.Mx = records + } + zone.removeNonCnameName(record.Name) + + return nil + } + } + + return errors.New("Mx Record not found") +} + +func (zone *Zone) removeNaptrRecord(record *NaptrRecord) error { + for key, r := range zone.Zone.Naptr { + if reflect.DeepEqual(r, record) { + records := zone.Zone.Naptr[:key] + if len(zone.Zone.Naptr) > key { + zone.Zone.Naptr = append(records, zone.Zone.Naptr[key+1:]...) + } else { + zone.Zone.Naptr = records + } + zone.removeNonCnameName(record.Name) + + return nil + } + } + + return errors.New("Naptr Record not found") +} + +func (zone *Zone) removeNsRecord(record *NsRecord) error { + for key, r := range zone.Zone.Ns { + if reflect.DeepEqual(r, record) { + records := zone.Zone.Ns[:key] + if len(zone.Zone.Ns) > key { + zone.Zone.Ns = append(records, zone.Zone.Ns[key+1:]...) + } else { + zone.Zone.Ns = records + } + zone.removeNonCnameName(record.Name) + + return nil + } + } + + return errors.New("Ns Record not found") +} + +func (zone *Zone) removeNsec3Record(record *Nsec3Record) error { + for key, r := range zone.Zone.Nsec3 { + if reflect.DeepEqual(r, record) { + records := zone.Zone.Nsec3[:key] + if len(zone.Zone.Nsec3) > key { + zone.Zone.Nsec3 = append(records, zone.Zone.Nsec3[key+1:]...) + } else { + zone.Zone.Nsec3 = records + } + zone.removeNonCnameName(record.Name) + + return nil + } + } + + return errors.New("Nsec3 Record not found") +} + +func (zone *Zone) removeNsec3paramRecord(record *Nsec3paramRecord) error { + for key, r := range zone.Zone.Nsec3param { + if reflect.DeepEqual(r, record) { + records := zone.Zone.Nsec3param[:key] + if len(zone.Zone.Nsec3param) > key { + zone.Zone.Nsec3param = append(records, zone.Zone.Nsec3param[key+1:]...) + } else { + zone.Zone.Nsec3param = records + } + zone.removeNonCnameName(record.Name) + + return nil + } + } + + return errors.New("Nsec3param Record not found") +} + +func (zone *Zone) removePtrRecord(record *PtrRecord) error { + for key, r := range zone.Zone.Ptr { + if reflect.DeepEqual(r, record) { + records := zone.Zone.Ptr[:key] + if len(zone.Zone.Ptr) > key { + zone.Zone.Ptr = append(records, zone.Zone.Ptr[key+1:]...) + } else { + zone.Zone.Ptr = records + } + zone.removeNonCnameName(record.Name) + + return nil + } + } + + return errors.New("Ptr Record not found") +} + +func (zone *Zone) removeRpRecord(record *RpRecord) error { + for key, r := range zone.Zone.Rp { + if reflect.DeepEqual(r, record) { + records := zone.Zone.Rp[:key] + if len(zone.Zone.Rp) > key { + zone.Zone.Rp = append(records, zone.Zone.Rp[key+1:]...) + } else { + zone.Zone.Rp = records + } + zone.removeNonCnameName(record.Name) + + return nil + } + } + + return errors.New("Rp Record not found") +} + +func (zone *Zone) removeRrsigRecord(record *RrsigRecord) error { + for key, r := range zone.Zone.Rrsig { + if reflect.DeepEqual(r, record) { + records := zone.Zone.Rrsig[:key] + if len(zone.Zone.Rrsig) > key { + zone.Zone.Rrsig = append(records, zone.Zone.Rrsig[key+1:]...) + } else { + zone.Zone.Rrsig = records + } + zone.removeNonCnameName(record.Name) + + return nil + } + } + + return errors.New("Rrsig Record not found") +} + +func (zone *Zone) removeSoaRecord(record *SoaRecord) error { + if reflect.DeepEqual(zone.Zone.Soa, record) { + zone.Zone.Soa = nil + + return nil + } + + return errors.New("SOA Record does not match") +} + +func (zone *Zone) removeSpfRecord(record *SpfRecord) error { + for key, r := range zone.Zone.Spf { + if reflect.DeepEqual(r, record) { + records := zone.Zone.Spf[:key] + if len(zone.Zone.Spf) > key { + zone.Zone.Spf = append(records, zone.Zone.Spf[key+1:]...) + } else { + zone.Zone.Spf = records + } + zone.removeNonCnameName(record.Name) + + return nil + } + } + + return errors.New("Spf Record not found") +} + +func (zone *Zone) removeSrvRecord(record *SrvRecord) error { + for key, r := range zone.Zone.Srv { + if reflect.DeepEqual(r, record) { + records := zone.Zone.Srv[:key] + if len(zone.Zone.Srv) > key { + zone.Zone.Srv = append(records, zone.Zone.Srv[key+1:]...) + } else { + zone.Zone.Srv = records + } + zone.removeNonCnameName(record.Name) + + return nil + } + } + + return errors.New("Srv Record not found") +} + +func (zone *Zone) removeSshfpRecord(record *SshfpRecord) error { + for key, r := range zone.Zone.Sshfp { + if reflect.DeepEqual(r, record) { + records := zone.Zone.Sshfp[:key] + if len(zone.Zone.Sshfp) > key { + zone.Zone.Sshfp = append(records, zone.Zone.Sshfp[key+1:]...) + } else { + zone.Zone.Sshfp = records + } + zone.removeNonCnameName(record.Name) + + return nil + } + } + + return errors.New("Sshfp Record not found") +} + +func (zone *Zone) removeTxtRecord(record *TxtRecord) error { + for key, r := range zone.Zone.Txt { + if reflect.DeepEqual(r, record) { + records := zone.Zone.Txt[:key] + if len(zone.Zone.Txt) > key { + zone.Zone.Txt = append(records, zone.Zone.Txt[key+1:]...) + } else { + zone.Zone.Txt = records + } + zone.removeNonCnameName(record.Name) + + return nil + } + } + + return errors.New("Txt Record not found") +} + +func (zone *Zone) PreMarshalJSON() error { + if zone.Zone.Soa.Serial > 0 { + zone.Zone.Soa.Serial = zone.Zone.Soa.Serial + 1 + } else { + zone.Zone.Soa.Serial = uint(time.Now().Unix()) + } + return nil +} + +func (zone *Zone) validateCnames() (bool, []name) { + var valid bool = true + var failedRecords []name + for _, v := range cnameNames { + for _, vv := range nonCnameNames { + if v.name == vv.name { + valid = false + failedRecords = append(failedRecords, vv) + } + } + } + return valid, failedRecords +} + +func (zone *Zone) removeCnameName(host string) { + for i, v := range cnameNames { + if v.name == host { + r := cnameNames[:i] + cnameNames = append(r, cnameNames[i+1:]...) + } + } +} + +func (zone *Zone) removeNonCnameName(host string) { + for i, v := range nonCnameNames { + if v.name == host { + r := nonCnameNames[:i] + nonCnameNames = append(r, nonCnameNames[i+1:]...) + } + } +} + +func (zone *Zone) FindRecords(recordType string, options map[string]interface{}) []DNSRecord { + switch strings.ToUpper(recordType) { + case "A": + return zone.findARecord(options) + case "AAAA": + return zone.findAaaaRecord(options) + case "AFSDB": + return zone.findAfsdbRecord(options) + case "CNAME": + return zone.findCnameRecord(options) + case "DNSKEY": + return zone.findDnskeyRecord(options) + case "DS": + return zone.findDsRecord(options) + case "HINFO": + return zone.findHinfoRecord(options) + case "LOC": + return zone.findLocRecord(options) + case "MX": + return zone.findMxRecord(options) + case "NAPTR": + return zone.findNaptrRecord(options) + case "NS": + return zone.findNsRecord(options) + case "NSEC3": + return zone.findNsec3Record(options) + case "NSEC3PARAM": + return zone.findNsec3paramRecord(options) + case "PTR": + return zone.findPtrRecord(options) + case "RP": + return zone.findRpRecord(options) + case "RRSIG": + return zone.findRrsigRecord(options) + case "SPF": + return zone.findSpfRecord(options) + case "SRV": + return zone.findSrvRecord(options) + case "SSHFP": + return zone.findSshfpRecord(options) + case "TXT": + return zone.findTxtRecord(options) + } + + return make([]DNSRecord, 0) +} + +func (zone *Zone) findARecord(options map[string]interface{}) []DNSRecord { + found := make([]DNSRecord, 0) + matchesNeeded := len(options) + for _, record := range zone.Zone.A { + matchCounter := 0 + if name, ok := options["name"]; ok && record.Name == name.(string) { + matchCounter++ + } + + if target, ok := options["target"]; ok && record.Target == target.(string) { + matchCounter++ + } + + if active, ok := options["active"]; ok && record.Active == active.(bool) { + matchCounter++ + } + + if ttl, ok := options["ttl"]; ok && record.TTL == ttl.(int) { + matchCounter++ + } + + if matchCounter >= matchesNeeded { + found = append(found, record) + } + } + + return found +} + +func (zone *Zone) findAaaaRecord(options map[string]interface{}) []DNSRecord { + found := make([]DNSRecord, 0) + matchesNeeded := len(options) + for _, record := range zone.Zone.Aaaa { + matchCounter := 0 + if name, ok := options["name"]; ok && record.Name == name.(string) { + matchCounter++ + } + + if target, ok := options["target"]; ok && record.Target == target.(string) { + matchCounter++ + } + + if active, ok := options["active"]; ok && record.Active == active.(bool) { + matchCounter++ + } + + if ttl, ok := options["ttl"]; ok && record.TTL == ttl.(int) { + matchCounter++ + } + + if matchCounter >= matchesNeeded { + found = append(found, record) + } + } + + return found +} + +func (zone *Zone) findAfsdbRecord(options map[string]interface{}) []DNSRecord { + found := make([]DNSRecord, 0) + matchesNeeded := len(options) + for _, record := range zone.Zone.Afsdb { + matchCounter := 0 + if name, ok := options["name"]; ok && record.Name == name.(string) { + matchCounter++ + } + + if target, ok := options["target"]; ok && record.Target == target.(string) { + matchCounter++ + } + + if active, ok := options["active"]; ok && record.Active == active.(bool) { + matchCounter++ + } + + if ttl, ok := options["ttl"]; ok && record.TTL == ttl.(int) { + matchCounter++ + } + + if subtype, ok := options["subtype"]; ok && record.Subtype == subtype.(int) { + matchCounter++ + } + + if matchCounter >= matchesNeeded { + found = append(found, record) + } + } + return found +} + +func (zone *Zone) findCnameRecord(options map[string]interface{}) []DNSRecord { + found := make([]DNSRecord, 0) + matchesNeeded := len(options) + for _, record := range zone.Zone.Cname { + matchCounter := 0 + if name, ok := options["name"]; ok && record.Name == name.(string) { + matchCounter++ + } + + if target, ok := options["target"]; ok && record.Target == target.(string) { + matchCounter++ + } + + if active, ok := options["active"]; ok && record.Active == active.(bool) { + matchCounter++ + } + + if ttl, ok := options["ttl"]; ok && record.TTL == ttl.(int) { + matchCounter++ + } + + if matchCounter >= matchesNeeded { + found = append(found, record) + } + } + return found +} + +func (zone *Zone) findDnskeyRecord(options map[string]interface{}) []DNSRecord { + found := make([]DNSRecord, 0) + matchesNeeded := len(options) + for _, record := range zone.Zone.Dnskey { + matchCounter := 0 + if name, ok := options["name"]; ok && record.Name == name.(string) { + matchCounter++ + } + + if active, ok := options["active"]; ok && record.Active == active.(bool) { + matchCounter++ + } + + if ttl, ok := options["ttl"]; ok && record.TTL == ttl.(int) { + matchCounter++ + } + + if flags, ok := options["flags"]; ok && record.Flags == flags.(int) { + matchCounter++ + } + + if protocol, ok := options["protocol"]; ok && record.Protocol == protocol.(int) { + matchCounter++ + } + + if algorithm, ok := options["algorithm"]; ok && record.Algorithm == algorithm.(int) { + matchCounter++ + } + + if key, ok := options["key"]; ok && record.Key == key.(string) { + matchCounter++ + } + + if matchCounter >= matchesNeeded { + found = append(found, record) + } + } + return found +} + +func (zone *Zone) findDsRecord(options map[string]interface{}) []DNSRecord { + found := make([]DNSRecord, 0) + matchesNeeded := len(options) + for _, record := range zone.Zone.Ds { + matchCounter := 0 + if name, ok := options["name"]; ok && record.Name == name.(string) { + matchCounter++ + } + + if active, ok := options["active"]; ok && record.Active == active.(bool) { + matchCounter++ + } + + if ttl, ok := options["ttl"]; ok && record.TTL == ttl.(int) { + matchCounter++ + } + + if keytag, ok := options["keytag"]; ok && record.Keytag == keytag.(int) { + matchCounter++ + } + + if algorithm, ok := options["algorithm"]; ok && record.Algorithm == algorithm.(int) { + matchCounter++ + } + + if digesttype, ok := options["digesttype"]; ok && record.DigestType == digesttype.(int) { + matchCounter++ + } + + if digest, ok := options["digest"]; ok && record.Digest == digest.(string) { + matchCounter++ + } + + if matchCounter >= matchesNeeded { + found = append(found, record) + } + } + return found +} + +func (zone *Zone) findHinfoRecord(options map[string]interface{}) []DNSRecord { + found := make([]DNSRecord, 0) + matchesNeeded := len(options) + for _, record := range zone.Zone.Hinfo { + matchCounter := 0 + if name, ok := options["name"]; ok && record.Name == name.(string) { + matchCounter++ + } + + if active, ok := options["active"]; ok && record.Active == active.(bool) { + matchCounter++ + } + + if ttl, ok := options["ttl"]; ok && record.TTL == ttl.(int) { + matchCounter++ + } + + if hardware, ok := options["hardware"]; ok && record.Hardware == hardware.(string) { + matchCounter++ + } + + if software, ok := options["software"]; ok && record.Software == software.(string) { + matchCounter++ + } + + if matchCounter >= matchesNeeded { + found = append(found, record) + } + } + return found +} + +func (zone *Zone) findLocRecord(options map[string]interface{}) []DNSRecord { + found := make([]DNSRecord, 0) + matchesNeeded := len(options) + for _, record := range zone.Zone.Loc { + matchCounter := 0 + if name, ok := options["name"]; ok && record.Name == name.(string) { + matchCounter++ + } + + if active, ok := options["active"]; ok && record.Active == active.(bool) { + matchCounter++ + } + + if ttl, ok := options["ttl"]; ok && record.TTL == ttl.(int) { + matchCounter++ + } + + if target, ok := options["target"]; ok && record.Target == target.(string) { + matchCounter++ + } + + if matchCounter >= matchesNeeded { + found = append(found, record) + } + } + return found +} + +func (zone *Zone) findMxRecord(options map[string]interface{}) []DNSRecord { + found := make([]DNSRecord, 0) + matchesNeeded := len(options) + for _, record := range zone.Zone.Mx { + matchCounter := 0 + if name, ok := options["name"]; ok && record.Name == name.(string) { + matchCounter++ + } + + if active, ok := options["active"]; ok && record.Active == active.(bool) { + matchCounter++ + } + + if ttl, ok := options["ttl"]; ok && record.TTL == ttl.(int) { + matchCounter++ + } + + if target, ok := options["target"]; ok && record.Target == target.(string) { + matchCounter++ + } + + if priority, ok := options["priority"]; ok && record.Priority == priority.(int) { + matchCounter++ + } + + if matchCounter >= matchesNeeded { + found = append(found, record) + } + } + return found +} + +func (zone *Zone) findNaptrRecord(options map[string]interface{}) []DNSRecord { + found := make([]DNSRecord, 0) + matchesNeeded := len(options) + for _, record := range zone.Zone.Naptr { + matchCounter := 0 + if name, ok := options["name"]; ok && record.Name == name.(string) { + matchCounter++ + } + + if active, ok := options["active"]; ok && record.Active == active.(bool) { + matchCounter++ + } + + if ttl, ok := options["ttl"]; ok && record.TTL == ttl.(int) { + matchCounter++ + } + + if order, ok := options["order"]; ok && record.Order == order.(uint16) { + matchCounter++ + } + + if preference, ok := options["preference"]; ok && record.Preference == preference.(uint16) { + matchCounter++ + } + + if flags, ok := options["flags"]; ok && record.Flags == flags.(string) { + matchCounter++ + } + + if service, ok := options["service"]; ok && record.Service == service.(string) { + matchCounter++ + } + + if regexp, ok := options["regexp"]; ok && record.Regexp == regexp.(string) { + matchCounter++ + } + + if replacement, ok := options["replacement"]; ok && record.Replacement == replacement.(string) { + matchCounter++ + } + + if matchCounter >= matchesNeeded { + found = append(found, record) + } + } + return found +} + +func (zone *Zone) findNsRecord(options map[string]interface{}) []DNSRecord { + found := make([]DNSRecord, 0) + matchesNeeded := len(options) + for _, record := range zone.Zone.Ns { + matchCounter := 0 + if name, ok := options["name"]; ok && record.Name == name.(string) { + matchCounter++ + } + + if active, ok := options["active"]; ok && record.Active == active.(bool) { + matchCounter++ + } + + if ttl, ok := options["ttl"]; ok && record.TTL == ttl.(int) { + matchCounter++ + } + + if target, ok := options["target"]; ok && record.Target == target.(string) { + matchCounter++ + } + + if matchCounter >= matchesNeeded { + found = append(found, record) + } + } + return found +} + +func (zone *Zone) findNsec3Record(options map[string]interface{}) []DNSRecord { + found := make([]DNSRecord, 0) + matchesNeeded := len(options) + for _, record := range zone.Zone.Nsec3 { + matchCounter := 0 + if name, ok := options["name"]; ok && record.Name == name.(string) { + matchCounter++ + } + + if active, ok := options["active"]; ok && record.Active == active.(bool) { + matchCounter++ + } + + if ttl, ok := options["ttl"]; ok && record.TTL == ttl.(int) { + matchCounter++ + } + + if algorithm, ok := options["algorithm"]; ok && record.Algorithm == algorithm.(int) { + matchCounter++ + } + + if flags, ok := options["flags"]; ok && record.Flags == flags.(int) { + matchCounter++ + } + + if iterations, ok := options["iterations"]; ok && record.Iterations == iterations.(int) { + matchCounter++ + } + + if salt, ok := options["salt"]; ok && record.Salt == salt.(string) { + matchCounter++ + } + + if nextHashedOwnerName, ok := options["nextHashedOwnerName"]; ok && record.NextHashedOwnerName == nextHashedOwnerName.(string) { + matchCounter++ + } + + if typeBitmaps, ok := options["typeBitmaps"]; ok && record.TypeBitmaps == typeBitmaps.(string) { + matchCounter++ + } + + if matchCounter >= matchesNeeded { + found = append(found, record) + } + } + return found +} + +func (zone *Zone) findNsec3paramRecord(options map[string]interface{}) []DNSRecord { + found := make([]DNSRecord, 0) + matchesNeeded := len(options) + for _, record := range zone.Zone.Nsec3param { + matchCounter := 0 + if name, ok := options["name"]; ok && record.Name == name.(string) { + matchCounter++ + } + + if active, ok := options["active"]; ok && record.Active == active.(bool) { + matchCounter++ + } + + if ttl, ok := options["ttl"]; ok && record.TTL == ttl.(int) { + matchCounter++ + } + + if algorithm, ok := options["algorithm"]; ok && record.Algorithm == algorithm.(int) { + matchCounter++ + } + + if flags, ok := options["flags"]; ok && record.Flags == flags.(int) { + matchCounter++ + } + + if iterations, ok := options["iterations"]; ok && record.Iterations == iterations.(int) { + matchCounter++ + } + + if salt, ok := options["salt"]; ok && record.Salt == salt.(string) { + matchCounter++ + } + + if matchCounter >= matchesNeeded { + found = append(found, record) + } + } + return found +} + +func (zone *Zone) findPtrRecord(options map[string]interface{}) []DNSRecord { + found := make([]DNSRecord, 0) + matchesNeeded := len(options) + for _, record := range zone.Zone.Ptr { + matchCounter := 0 + if name, ok := options["name"]; ok && record.Name == name.(string) { + matchCounter++ + } + + if active, ok := options["active"]; ok && record.Active == active.(bool) { + matchCounter++ + } + + if ttl, ok := options["ttl"]; ok && record.TTL == ttl.(int) { + matchCounter++ + } + + if target, ok := options["target"]; ok && record.Target == target.(string) { + matchCounter++ + } + + if matchCounter >= matchesNeeded { + found = append(found, record) + } + } + return found +} + +func (zone *Zone) findRpRecord(options map[string]interface{}) []DNSRecord { + found := make([]DNSRecord, 0) + matchesNeeded := len(options) + for _, record := range zone.Zone.Rp { + matchCounter := 0 + if name, ok := options["name"]; ok && record.Name == name.(string) { + matchCounter++ + } + + if active, ok := options["active"]; ok && record.Active == active.(bool) { + matchCounter++ + } + + if ttl, ok := options["ttl"]; ok && record.TTL == ttl.(int) { + matchCounter++ + } + + if mailbox, ok := options["mailbox"]; ok && record.Mailbox == mailbox.(string) { + matchCounter++ + } + + if txt, ok := options["txt"]; ok && record.Txt == txt.(string) { + matchCounter++ + } + + if matchCounter >= matchesNeeded { + found = append(found, record) + } + } + return found +} + +func (zone *Zone) findRrsigRecord(options map[string]interface{}) []DNSRecord { + found := make([]DNSRecord, 0) + matchesNeeded := len(options) + for _, record := range zone.Zone.Rrsig { + matchCounter := 0 + if name, ok := options["name"]; ok && record.Name == name.(string) { + matchCounter++ + } + + if active, ok := options["active"]; ok && record.Active == active.(bool) { + matchCounter++ + } + + if ttl, ok := options["ttl"]; ok && record.TTL == ttl.(int) { + matchCounter++ + } + + if typeCovered, ok := options["typeCovered"]; ok && record.TypeCovered == typeCovered.(string) { + matchCounter++ + } + + if algorithm, ok := options["algorithm"]; ok && record.Algorithm == algorithm.(int) { + matchCounter++ + } + + if originalTTL, ok := options["originalTTL"]; ok && record.OriginalTTL == originalTTL.(int) { + matchCounter++ + } + + if expiration, ok := options["expiration"]; ok && record.Expiration == expiration.(string) { + matchCounter++ + } + + if inception, ok := options["inception"]; ok && record.Inception == inception.(string) { + matchCounter++ + } + + if keytag, ok := options["keytag"]; ok && record.Keytag == keytag.(int) { + matchCounter++ + } + + if signer, ok := options["signer"]; ok && record.Signer == signer.(string) { + matchCounter++ + } + + if signature, ok := options["signature"]; ok && record.Signature == signature.(string) { + matchCounter++ + } + + if labels, ok := options["labels"]; ok && record.Labels == labels.(int) { + matchCounter++ + } + + if matchCounter >= matchesNeeded { + found = append(found, record) + } + } + return found +} + +func (zone *Zone) findSpfRecord(options map[string]interface{}) []DNSRecord { + found := make([]DNSRecord, 0) + matchesNeeded := len(options) + for _, record := range zone.Zone.Spf { + matchCounter := 0 + if name, ok := options["name"]; ok && record.Name == name.(string) { + matchCounter++ + } + + if active, ok := options["active"]; ok && record.Active == active.(bool) { + matchCounter++ + } + + if ttl, ok := options["ttl"]; ok && record.TTL == ttl.(int) { + matchCounter++ + } + + if target, ok := options["target"]; ok && record.Target == target.(string) { + matchCounter++ + } + + if matchCounter >= matchesNeeded { + found = append(found, record) + } + } + return found +} + +func (zone *Zone) findSrvRecord(options map[string]interface{}) []DNSRecord { + found := make([]DNSRecord, 0) + matchesNeeded := len(options) + for _, record := range zone.Zone.Srv { + matchCounter := 0 + if name, ok := options["name"]; ok && record.Name == name.(string) { + matchCounter++ + } + + if active, ok := options["active"]; ok && record.Active == active.(bool) { + matchCounter++ + } + + if ttl, ok := options["ttl"]; ok && record.TTL == ttl.(int) { + matchCounter++ + } + + if target, ok := options["target"]; ok && record.Target == target.(string) { + matchCounter++ + } + + if priority, ok := options["priority"]; ok && record.Priority == priority.(int) { + matchCounter++ + } + + if weight, ok := options["weight"]; ok && record.Weight == weight.(uint16) { + matchCounter++ + } + + if port, ok := options["port"]; ok && record.Port == port.(uint16) { + matchCounter++ + } + + if matchCounter >= matchesNeeded { + found = append(found, record) + } + } + return found +} + +func (zone *Zone) findSshfpRecord(options map[string]interface{}) []DNSRecord { + found := make([]DNSRecord, 0) + matchesNeeded := len(options) + for _, record := range zone.Zone.Sshfp { + matchCounter := 0 + if name, ok := options["name"]; ok && record.Name == name.(string) { + matchCounter++ + } + + if active, ok := options["active"]; ok && record.Active == active.(bool) { + matchCounter++ + } + + if ttl, ok := options["ttl"]; ok && record.TTL == ttl.(int) { + matchCounter++ + } + + if algorithm, ok := options["algorithm"]; ok && record.Algorithm == algorithm.(int) { + matchCounter++ + } + + if fingerprintType, ok := options["fingerprintType"]; ok && record.FingerprintType == fingerprintType.(int) { + matchCounter++ + } + + if fingerprint, ok := options["fingerprint"]; ok && record.Fingerprint == fingerprint.(string) { + matchCounter++ + } + + if matchCounter >= matchesNeeded { + found = append(found, record) + } + } + return found +} + +func (zone *Zone) findTxtRecord(options map[string]interface{}) []DNSRecord { + found := make([]DNSRecord, 0) + matchesNeeded := len(options) + for _, record := range zone.Zone.Txt { + matchCounter := 0 + if name, ok := options["name"]; ok && record.Name == name.(string) { + matchCounter++ + } + + if active, ok := options["active"]; ok && record.Active == active.(bool) { + matchCounter++ + } + + if ttl, ok := options["ttl"]; ok && record.TTL == ttl.(int) { + matchCounter++ + } + + if target, ok := options["target"]; ok && record.Target == target.(string) { + matchCounter++ + } + + if matchCounter >= matchesNeeded { + found = append(found, record) + } + } + return found +} diff --git a/vendor/github.com/akamai/AkamaiOPEN-edgegrid-golang/edgegrid/config.go b/vendor/github.com/akamai/AkamaiOPEN-edgegrid-golang/edgegrid/config.go new file mode 100644 index 000000000..b9f5411a5 --- /dev/null +++ b/vendor/github.com/akamai/AkamaiOPEN-edgegrid-golang/edgegrid/config.go @@ -0,0 +1,181 @@ +package edgegrid + +import ( + "fmt" + "os" + "strconv" + "strings" + + "github.com/go-ini/ini" + "gopkg.in/mattes/go-expand-tilde.v1" +) + +// Config struct provides all the necessary fields to +// create authorization header, debug is optional +type Config struct { + Host string `ini:"host"` + ClientToken string `ini:"client_token"` + ClientSecret string `ini:"client_secret"` + AccessToken string `ini:"access_token"` + HeaderToSign []string `ini:"headers_to_sign"` + MaxBody int `ini:"max_body"` + Debug bool `ini:"debug"` +} + +// Init initializes by first attempting to use ENV vars, with .edgerc as a fallback +// +// See: InitEnv() +// See: InitEdgeRc() +func Init(filepath string, section string) (Config, error) { + if section == "" { + section = defaultSection + } else { + section = strings.ToUpper(section) + } + + _, exists := os.LookupEnv("AKAMAI_" + section + "_HOST") + if !exists && section == defaultSection { + _, exists := os.LookupEnv("AKAMAI_HOST") + + if exists { + return InitEnv("") + } + } + + if exists { + return InitEnv(section) + } + + c, err := InitEdgeRc(filepath, strings.ToLower(section)) + + if err == nil { + return c, nil + } + + if section != defaultSection { + _, ok := os.LookupEnv("AKAMAI_HOST") + if ok { + return InitEnv("") + } + } + + return c, fmt.Errorf("Unable to create instance using environment or .edgerc file") +} + +// InitEdgeRc initializes using a configuration file in standard INI format +// +// By default, it uses the .edgerc found in the users home directory, and the +// "default" section. +func InitEdgeRc(filepath string, section string) (Config, error) { + var ( + c Config + requiredOptions = []string{"host", "client_token", "client_secret", "access_token"} + missing []string + ) + + // Check if filepath is empty + if filepath == "" { + filepath = "~/.edgerc" + } + + // Check if section is empty + if section == "" { + section = "default" + } + + // Tilde seems to be not working when passing ~/.edgerc as file + // Takes current user and use home dir instead + + path, err := tilde.Expand(filepath) + + if err != nil { + return c, fmt.Errorf(errorMap[ErrHomeDirNotFound], err) + } + + edgerc, err := ini.Load(path) + if err != nil { + return c, fmt.Errorf(errorMap[ErrConfigFile], err) + } + err = edgerc.Section(section).MapTo(&c) + if err != nil { + return c, fmt.Errorf(errorMap[ErrConfigFileSection], err) + } + for _, opt := range requiredOptions { + if !(edgerc.Section(section).HasKey(opt)) { + missing = append(missing, opt) + } + } + if len(missing) > 0 { + return c, fmt.Errorf(errorMap[ErrConfigMissingOptions], missing) + } + if c.MaxBody == 0 { + c.MaxBody = 131072 + } + return c, nil +} + +// InitEnv initializes using the Environment (ENV) +// +// By default, it uses AKAMAI_HOST, AKAMAI_CLIENT_TOKEN, AKAMAI_CLIENT_SECRET, +// AKAMAI_ACCESS_TOKEN, and AKAMAI_MAX_BODY variables. +// +// You can define multiple configurations by prefixing with the section name specified, e.g. +// passing "ccu" will cause it to look for AKAMAI_CCU_HOST, etc. +// +// If AKAMAI_{SECTION} does not exist, it will fall back to just AKAMAI_. +func InitEnv(section string) (Config, error) { + var ( + c Config + requiredOptions = []string{"HOST", "CLIENT_TOKEN", "CLIENT_SECRET", "ACCESS_TOKEN"} + missing []string + prefix string + ) + + // Check if section is empty + if section == "" { + section = defaultSection + } else { + section = strings.ToUpper(section) + } + + prefix = "AKAMAI_" + _, ok := os.LookupEnv("AKAMAI_" + section + "_HOST") + if ok { + prefix = "AKAMAI_" + section + "_" + } + + for _, opt := range requiredOptions { + val, ok := os.LookupEnv(prefix + opt) + if !ok { + missing = append(missing, prefix+opt) + } else { + switch { + case opt == "HOST": + c.Host = val + case opt == "CLIENT_TOKEN": + c.ClientToken = val + case opt == "CLIENT_SECRET": + c.ClientSecret = val + case opt == "ACCESS_TOKEN": + c.AccessToken = val + } + } + } + + if len(missing) > 0 { + return c, fmt.Errorf(errorMap[ErrMissingEnvVariables], missing) + } + + c.MaxBody = 0 + + val, ok := os.LookupEnv(prefix + "MAX_BODY") + if i, err := strconv.Atoi(val); err == nil { + c.MaxBody = i + } + + if !ok || c.MaxBody == 0 { + c.MaxBody = 131072 + } + + return c, nil +} diff --git a/vendor/github.com/akamai/AkamaiOPEN-edgegrid-golang/edgegrid/errors.go b/vendor/github.com/akamai/AkamaiOPEN-edgegrid-golang/edgegrid/errors.go new file mode 100644 index 000000000..d5448aeae --- /dev/null +++ b/vendor/github.com/akamai/AkamaiOPEN-edgegrid-golang/edgegrid/errors.go @@ -0,0 +1,22 @@ +package edgegrid + +// Error constants +const ( + ErrUUIDGenerateFailed = 500 + ErrHomeDirNotFound = 501 + ErrConfigFile = 502 + ErrConfigFileSection = 503 + ErrConfigMissingOptions = 504 + ErrMissingEnvVariables = 505 +) + +var ( + errorMap = map[int]string{ + ErrUUIDGenerateFailed: "Generate UUID failed: %s", + ErrHomeDirNotFound: "Fatal could not find home dir from user: %s", + ErrConfigFile: "Fatal error edgegrid file: %s", + ErrConfigFileSection: "Could not map section: %s", + ErrConfigMissingOptions: "Fatal missing required options: %s", + ErrMissingEnvVariables: "Fatal missing required environment variables: %s", + } +) diff --git a/vendor/github.com/akamai/AkamaiOPEN-edgegrid-golang/edgegrid/signer.go b/vendor/github.com/akamai/AkamaiOPEN-edgegrid-golang/edgegrid/signer.go new file mode 100644 index 000000000..b43e4149e --- /dev/null +++ b/vendor/github.com/akamai/AkamaiOPEN-edgegrid-golang/edgegrid/signer.go @@ -0,0 +1,195 @@ +// Package edgegrid allows you to sign http.Request's using the Akamai OPEN Edgegrid Signing Scheme +package edgegrid + +import ( + "bytes" + "crypto/hmac" + "crypto/sha256" + "encoding/base64" + "fmt" + "io/ioutil" + "net/http" + "sort" + "strings" + "time" + "unicode" + + log "github.com/sirupsen/logrus" + "github.com/tuvistavie/securerandom" +) + +const defaultSection = "DEFAULT" + +// AddRequestHeader sets the Authorization header to use Akamai Open API +func AddRequestHeader(config Config, req *http.Request) *http.Request { + if config.Debug { + log.SetLevel(log.DebugLevel) + } + timestamp := makeEdgeTimeStamp() + nonce := createNonce() + + if req.Header.Get("Content-Type") == "" { + req.Header.Set("Content-Type", "application/json") + } + + req.Header.Set("Authorization", createAuthHeader(config, req, timestamp, nonce)) + return req +} + +// Must be assigned the UTC time when the request is signed. +// Format of “yyyyMMddTHH:mm:ss+0000” +func makeEdgeTimeStamp() string { + local := time.FixedZone("GMT", 0) + t := time.Now().In(local) + return fmt.Sprintf("%d%02d%02dT%02d:%02d:%02d+0000", + t.Year(), t.Month(), t.Day(), t.Hour(), t.Minute(), t.Second()) +} + +// Must be assigned a nonce (number used once) for the request. +// It is a random string used to detect replayed request messages. +// A GUID is recommended. +func createNonce() string { + uuid, err := securerandom.Uuid() + if err != nil { + log.Errorf(errorMap[ErrUUIDGenerateFailed], err) + return "" + } + return uuid +} + +func stringMinifier(in string) (out string) { + white := false + for _, c := range in { + if unicode.IsSpace(c) { + if !white { + out = out + " " + } + white = true + } else { + out = out + string(c) + white = false + } + } + return +} + +func concatPathQuery(path, query string) string { + if query == "" { + return path + } + return fmt.Sprintf("%s?%s", path, query) +} + +// createSignature is the base64-encoding of the SHA–256 HMAC of the data to sign with the signing key. +func createSignature(message string, secret string) string { + key := []byte(secret) + h := hmac.New(sha256.New, key) + h.Write([]byte(message)) + return base64.StdEncoding.EncodeToString(h.Sum(nil)) +} + +func createHash(data string) string { + h := sha256.Sum256([]byte(data)) + return base64.StdEncoding.EncodeToString(h[:]) +} + +func canonicalizeHeaders(config Config, req *http.Request) string { + var unsortedHeader []string + var sortedHeader []string + for k := range req.Header { + unsortedHeader = append(unsortedHeader, k) + } + sort.Strings(unsortedHeader) + for _, k := range unsortedHeader { + for _, sign := range config.HeaderToSign { + if sign == k { + v := strings.TrimSpace(req.Header.Get(k)) + sortedHeader = append(sortedHeader, fmt.Sprintf("%s:%s", strings.ToLower(k), strings.ToLower(stringMinifier(v)))) + } + } + } + return strings.Join(sortedHeader, "\t") + +} + +// signingKey is derived from the client secret. +// The signing key is computed as the base64 encoding of the SHA–256 HMAC of the timestamp string +// (the field value included in the HTTP authorization header described above) with the client secret as the key. +func signingKey(config Config, timestamp string) string { + key := createSignature(timestamp, config.ClientSecret) + return key +} + +// The content hash is the base64-encoded SHA–256 hash of the POST body. +// For any other request methods, this field is empty. But the tac separator (\t) must be included. +// The size of the POST body must be less than or equal to the value specified by the service. +// Any request that does not meet this criteria SHOULD be rejected during the signing process, +// as the request will be rejected by EdgeGrid. +func createContentHash(config Config, req *http.Request) string { + var ( + contentHash string + preparedBody string + bodyBytes []byte + ) + if req.Body != nil { + bodyBytes, _ = ioutil.ReadAll(req.Body) + req.Body = ioutil.NopCloser(bytes.NewBuffer(bodyBytes)) + preparedBody = string(bodyBytes) + } + + log.Debugf("Body is %s", preparedBody) + if req.Method == "POST" && len(preparedBody) > 0 { + log.Debugf("Signing content: %s", preparedBody) + if len(preparedBody) > config.MaxBody { + log.Debugf("Data length %d is larger than maximum %d", + len(preparedBody), config.MaxBody) + + preparedBody = preparedBody[0:config.MaxBody] + log.Debugf("Data truncated to %d for computing the hash", len(preparedBody)) + } + contentHash = createHash(preparedBody) + } + log.Debugf("Content hash is '%s'", contentHash) + return contentHash +} + +// The data to sign includes the information from the HTTP request that is relevant to ensuring that the request is authentic. +// This data set comprised of the request data combined with the authorization header value (excluding the signature field, +// but including the ; right before the signature field). +func signingData(config Config, req *http.Request, authHeader string) string { + + dataSign := []string{ + req.Method, + req.URL.Scheme, + req.URL.Host, + concatPathQuery(req.URL.Path, req.URL.RawQuery), + canonicalizeHeaders(config, req), + createContentHash(config, req), + authHeader, + } + log.Debugf("Data to sign %s", strings.Join(dataSign, "\t")) + return strings.Join(dataSign, "\t") +} + +func signingRequest(config Config, req *http.Request, authHeader string, timestamp string) string { + return createSignature(signingData(config, req, authHeader), + signingKey(config, timestamp)) +} + +// The Authorization header starts with the signing algorithm moniker (name of the algorithm) used to sign the request. +// The moniker below identifies EdgeGrid V1, hash message authentication code, SHA–256 as the hash standard. +// This moniker is then followed by a space and an ordered list of name value pairs with each field separated by a semicolon. +func createAuthHeader(config Config, req *http.Request, timestamp string, nonce string) string { + authHeader := fmt.Sprintf("EG1-HMAC-SHA256 client_token=%s;access_token=%s;timestamp=%s;nonce=%s;", + config.ClientToken, + config.AccessToken, + timestamp, + nonce, + ) + log.Debugf("Unsigned authorization header: '%s'", authHeader) + + signedAuthHeader := fmt.Sprintf("%ssignature=%s", authHeader, signingRequest(config, req, authHeader, timestamp)) + + log.Debugf("Signed authorization header: '%s'", signedAuthHeader) + return signedAuthHeader +} diff --git a/vendor/github.com/akamai/AkamaiOPEN-edgegrid-golang/jsonhooks-v1/errors.go b/vendor/github.com/akamai/AkamaiOPEN-edgegrid-golang/jsonhooks-v1/errors.go new file mode 100644 index 000000000..594c04e41 --- /dev/null +++ b/vendor/github.com/akamai/AkamaiOPEN-edgegrid-golang/jsonhooks-v1/errors.go @@ -0,0 +1 @@ +package jsonhooks diff --git a/vendor/github.com/akamai/AkamaiOPEN-edgegrid-golang/jsonhooks-v1/jsonhooks.go b/vendor/github.com/akamai/AkamaiOPEN-edgegrid-golang/jsonhooks-v1/jsonhooks.go new file mode 100644 index 000000000..83dccd5dd --- /dev/null +++ b/vendor/github.com/akamai/AkamaiOPEN-edgegrid-golang/jsonhooks-v1/jsonhooks.go @@ -0,0 +1,69 @@ +// Package jsonhooks adds hooks that are automatically called before JSON marshaling (PreMarshalJSON) and +// after JSON unmarshaling (PostUnmarshalJSON). It does not do so recursively. +package jsonhooks + +import ( + "encoding/json" + "reflect" +) + +// Marshal wraps encoding/json.Marshal, calls v.PreMarshalJSON() if it exists +func Marshal(v interface{}) ([]byte, error) { + if ImplementsPreJSONMarshaler(v) { + err := v.(PreJSONMarshaler).PreMarshalJSON() + if err != nil { + return nil, err + } + } + + return json.Marshal(v) +} + +// Unmarshal wraps encoding/json.Unmarshal, calls v.PostUnmarshalJSON() if it exists +func Unmarshal(data []byte, v interface{}) error { + err := json.Unmarshal(data, v) + if err != nil { + return err + } + + if ImplementsPostJSONUnmarshaler(v) { + err := v.(PostJSONUnmarshaler).PostUnmarshalJSON() + if err != nil { + return err + } + } + + return nil +} + +// PreJSONMarshaler infers support for the PreMarshalJSON pre-hook +type PreJSONMarshaler interface { + PreMarshalJSON() error +} + +// ImplementsPreJSONMarshaler checks for support for the PreMarshalJSON pre-hook +func ImplementsPreJSONMarshaler(v interface{}) bool { + value := reflect.ValueOf(v) + if value.Kind() == reflect.Ptr && value.IsNil() { + return false + } + + _, ok := value.Interface().(PreJSONMarshaler) + return ok +} + +// PostJSONUnmarshaler infers support for the PostUnmarshalJSON post-hook +type PostJSONUnmarshaler interface { + PostUnmarshalJSON() error +} + +// ImplementsPostJSONUnmarshaler checks for support for the PostUnmarshalJSON post-hook +func ImplementsPostJSONUnmarshaler(v interface{}) bool { + value := reflect.ValueOf(v) + if value.Kind() == reflect.Ptr && value.IsNil() { + return false + } + + _, ok := value.Interface().(PostJSONUnmarshaler) + return ok +} diff --git a/vendor/github.com/aws/aws-sdk-go/service/lightsail/api.go b/vendor/github.com/aws/aws-sdk-go/service/lightsail/api.go new file mode 100644 index 000000000..9d3eb928d --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/service/lightsail/api.go @@ -0,0 +1,15975 @@ +// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. + +package lightsail + +import ( + "time" + + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/awsutil" + "github.com/aws/aws-sdk-go/aws/request" +) + +const opAllocateStaticIp = "AllocateStaticIp" + +// AllocateStaticIpRequest generates a "aws/request.Request" representing the +// client's request for the AllocateStaticIp operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See AllocateStaticIp for more information on using the AllocateStaticIp +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the AllocateStaticIpRequest method. +// req, resp := client.AllocateStaticIpRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/AllocateStaticIp +func (c *Lightsail) AllocateStaticIpRequest(input *AllocateStaticIpInput) (req *request.Request, output *AllocateStaticIpOutput) { + op := &request.Operation{ + Name: opAllocateStaticIp, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &AllocateStaticIpInput{} + } + + output = &AllocateStaticIpOutput{} + req = c.newRequest(op, input, output) + return +} + +// AllocateStaticIp API operation for Amazon Lightsail. +// +// Allocates a static IP address. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation AllocateStaticIp for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/AllocateStaticIp +func (c *Lightsail) AllocateStaticIp(input *AllocateStaticIpInput) (*AllocateStaticIpOutput, error) { + req, out := c.AllocateStaticIpRequest(input) + return out, req.Send() +} + +// AllocateStaticIpWithContext is the same as AllocateStaticIp with the addition of +// the ability to pass a context and additional request options. +// +// See AllocateStaticIp for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) AllocateStaticIpWithContext(ctx aws.Context, input *AllocateStaticIpInput, opts ...request.Option) (*AllocateStaticIpOutput, error) { + req, out := c.AllocateStaticIpRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opAttachDisk = "AttachDisk" + +// AttachDiskRequest generates a "aws/request.Request" representing the +// client's request for the AttachDisk operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See AttachDisk for more information on using the AttachDisk +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the AttachDiskRequest method. +// req, resp := client.AttachDiskRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/AttachDisk +func (c *Lightsail) AttachDiskRequest(input *AttachDiskInput) (req *request.Request, output *AttachDiskOutput) { + op := &request.Operation{ + Name: opAttachDisk, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &AttachDiskInput{} + } + + output = &AttachDiskOutput{} + req = c.newRequest(op, input, output) + return +} + +// AttachDisk API operation for Amazon Lightsail. +// +// Attaches a block storage disk to a running or stopped Lightsail instance +// and exposes it to the instance with the specified disk name. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation AttachDisk for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/AttachDisk +func (c *Lightsail) AttachDisk(input *AttachDiskInput) (*AttachDiskOutput, error) { + req, out := c.AttachDiskRequest(input) + return out, req.Send() +} + +// AttachDiskWithContext is the same as AttachDisk with the addition of +// the ability to pass a context and additional request options. +// +// See AttachDisk for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) AttachDiskWithContext(ctx aws.Context, input *AttachDiskInput, opts ...request.Option) (*AttachDiskOutput, error) { + req, out := c.AttachDiskRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opAttachInstancesToLoadBalancer = "AttachInstancesToLoadBalancer" + +// AttachInstancesToLoadBalancerRequest generates a "aws/request.Request" representing the +// client's request for the AttachInstancesToLoadBalancer operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See AttachInstancesToLoadBalancer for more information on using the AttachInstancesToLoadBalancer +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the AttachInstancesToLoadBalancerRequest method. +// req, resp := client.AttachInstancesToLoadBalancerRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/AttachInstancesToLoadBalancer +func (c *Lightsail) AttachInstancesToLoadBalancerRequest(input *AttachInstancesToLoadBalancerInput) (req *request.Request, output *AttachInstancesToLoadBalancerOutput) { + op := &request.Operation{ + Name: opAttachInstancesToLoadBalancer, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &AttachInstancesToLoadBalancerInput{} + } + + output = &AttachInstancesToLoadBalancerOutput{} + req = c.newRequest(op, input, output) + return +} + +// AttachInstancesToLoadBalancer API operation for Amazon Lightsail. +// +// Attaches one or more Lightsail instances to a load balancer. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation AttachInstancesToLoadBalancer for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/AttachInstancesToLoadBalancer +func (c *Lightsail) AttachInstancesToLoadBalancer(input *AttachInstancesToLoadBalancerInput) (*AttachInstancesToLoadBalancerOutput, error) { + req, out := c.AttachInstancesToLoadBalancerRequest(input) + return out, req.Send() +} + +// AttachInstancesToLoadBalancerWithContext is the same as AttachInstancesToLoadBalancer with the addition of +// the ability to pass a context and additional request options. +// +// See AttachInstancesToLoadBalancer for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) AttachInstancesToLoadBalancerWithContext(ctx aws.Context, input *AttachInstancesToLoadBalancerInput, opts ...request.Option) (*AttachInstancesToLoadBalancerOutput, error) { + req, out := c.AttachInstancesToLoadBalancerRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opAttachLoadBalancerTlsCertificate = "AttachLoadBalancerTlsCertificate" + +// AttachLoadBalancerTlsCertificateRequest generates a "aws/request.Request" representing the +// client's request for the AttachLoadBalancerTlsCertificate operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See AttachLoadBalancerTlsCertificate for more information on using the AttachLoadBalancerTlsCertificate +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the AttachLoadBalancerTlsCertificateRequest method. +// req, resp := client.AttachLoadBalancerTlsCertificateRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/AttachLoadBalancerTlsCertificate +func (c *Lightsail) AttachLoadBalancerTlsCertificateRequest(input *AttachLoadBalancerTlsCertificateInput) (req *request.Request, output *AttachLoadBalancerTlsCertificateOutput) { + op := &request.Operation{ + Name: opAttachLoadBalancerTlsCertificate, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &AttachLoadBalancerTlsCertificateInput{} + } + + output = &AttachLoadBalancerTlsCertificateOutput{} + req = c.newRequest(op, input, output) + return +} + +// AttachLoadBalancerTlsCertificate API operation for Amazon Lightsail. +// +// Attaches a Transport Layer Security (TLS) certificate to your load balancer. +// +// TLS is just an updated, more secure version of Secure Socket Layer (SSL). +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation AttachLoadBalancerTlsCertificate for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/AttachLoadBalancerTlsCertificate +func (c *Lightsail) AttachLoadBalancerTlsCertificate(input *AttachLoadBalancerTlsCertificateInput) (*AttachLoadBalancerTlsCertificateOutput, error) { + req, out := c.AttachLoadBalancerTlsCertificateRequest(input) + return out, req.Send() +} + +// AttachLoadBalancerTlsCertificateWithContext is the same as AttachLoadBalancerTlsCertificate with the addition of +// the ability to pass a context and additional request options. +// +// See AttachLoadBalancerTlsCertificate for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) AttachLoadBalancerTlsCertificateWithContext(ctx aws.Context, input *AttachLoadBalancerTlsCertificateInput, opts ...request.Option) (*AttachLoadBalancerTlsCertificateOutput, error) { + req, out := c.AttachLoadBalancerTlsCertificateRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opAttachStaticIp = "AttachStaticIp" + +// AttachStaticIpRequest generates a "aws/request.Request" representing the +// client's request for the AttachStaticIp operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See AttachStaticIp for more information on using the AttachStaticIp +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the AttachStaticIpRequest method. +// req, resp := client.AttachStaticIpRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/AttachStaticIp +func (c *Lightsail) AttachStaticIpRequest(input *AttachStaticIpInput) (req *request.Request, output *AttachStaticIpOutput) { + op := &request.Operation{ + Name: opAttachStaticIp, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &AttachStaticIpInput{} + } + + output = &AttachStaticIpOutput{} + req = c.newRequest(op, input, output) + return +} + +// AttachStaticIp API operation for Amazon Lightsail. +// +// Attaches a static IP address to a specific Amazon Lightsail instance. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation AttachStaticIp for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/AttachStaticIp +func (c *Lightsail) AttachStaticIp(input *AttachStaticIpInput) (*AttachStaticIpOutput, error) { + req, out := c.AttachStaticIpRequest(input) + return out, req.Send() +} + +// AttachStaticIpWithContext is the same as AttachStaticIp with the addition of +// the ability to pass a context and additional request options. +// +// See AttachStaticIp for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) AttachStaticIpWithContext(ctx aws.Context, input *AttachStaticIpInput, opts ...request.Option) (*AttachStaticIpOutput, error) { + req, out := c.AttachStaticIpRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opCloseInstancePublicPorts = "CloseInstancePublicPorts" + +// CloseInstancePublicPortsRequest generates a "aws/request.Request" representing the +// client's request for the CloseInstancePublicPorts operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See CloseInstancePublicPorts for more information on using the CloseInstancePublicPorts +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the CloseInstancePublicPortsRequest method. +// req, resp := client.CloseInstancePublicPortsRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/CloseInstancePublicPorts +func (c *Lightsail) CloseInstancePublicPortsRequest(input *CloseInstancePublicPortsInput) (req *request.Request, output *CloseInstancePublicPortsOutput) { + op := &request.Operation{ + Name: opCloseInstancePublicPorts, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &CloseInstancePublicPortsInput{} + } + + output = &CloseInstancePublicPortsOutput{} + req = c.newRequest(op, input, output) + return +} + +// CloseInstancePublicPorts API operation for Amazon Lightsail. +// +// Closes the public ports on a specific Amazon Lightsail instance. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation CloseInstancePublicPorts for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/CloseInstancePublicPorts +func (c *Lightsail) CloseInstancePublicPorts(input *CloseInstancePublicPortsInput) (*CloseInstancePublicPortsOutput, error) { + req, out := c.CloseInstancePublicPortsRequest(input) + return out, req.Send() +} + +// CloseInstancePublicPortsWithContext is the same as CloseInstancePublicPorts with the addition of +// the ability to pass a context and additional request options. +// +// See CloseInstancePublicPorts for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) CloseInstancePublicPortsWithContext(ctx aws.Context, input *CloseInstancePublicPortsInput, opts ...request.Option) (*CloseInstancePublicPortsOutput, error) { + req, out := c.CloseInstancePublicPortsRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opCreateDisk = "CreateDisk" + +// CreateDiskRequest generates a "aws/request.Request" representing the +// client's request for the CreateDisk operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See CreateDisk for more information on using the CreateDisk +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the CreateDiskRequest method. +// req, resp := client.CreateDiskRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/CreateDisk +func (c *Lightsail) CreateDiskRequest(input *CreateDiskInput) (req *request.Request, output *CreateDiskOutput) { + op := &request.Operation{ + Name: opCreateDisk, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &CreateDiskInput{} + } + + output = &CreateDiskOutput{} + req = c.newRequest(op, input, output) + return +} + +// CreateDisk API operation for Amazon Lightsail. +// +// Creates a block storage disk that can be attached to a Lightsail instance +// in the same Availability Zone (e.g., us-east-2a). The disk is created in +// the regional endpoint that you send the HTTP request to. For more information, +// see Regions and Availability Zones in Lightsail (https://lightsail.aws.amazon.com/ls/docs/overview/article/understanding-regions-and-availability-zones-in-amazon-lightsail). +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation CreateDisk for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/CreateDisk +func (c *Lightsail) CreateDisk(input *CreateDiskInput) (*CreateDiskOutput, error) { + req, out := c.CreateDiskRequest(input) + return out, req.Send() +} + +// CreateDiskWithContext is the same as CreateDisk with the addition of +// the ability to pass a context and additional request options. +// +// See CreateDisk for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) CreateDiskWithContext(ctx aws.Context, input *CreateDiskInput, opts ...request.Option) (*CreateDiskOutput, error) { + req, out := c.CreateDiskRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opCreateDiskFromSnapshot = "CreateDiskFromSnapshot" + +// CreateDiskFromSnapshotRequest generates a "aws/request.Request" representing the +// client's request for the CreateDiskFromSnapshot operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See CreateDiskFromSnapshot for more information on using the CreateDiskFromSnapshot +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the CreateDiskFromSnapshotRequest method. +// req, resp := client.CreateDiskFromSnapshotRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/CreateDiskFromSnapshot +func (c *Lightsail) CreateDiskFromSnapshotRequest(input *CreateDiskFromSnapshotInput) (req *request.Request, output *CreateDiskFromSnapshotOutput) { + op := &request.Operation{ + Name: opCreateDiskFromSnapshot, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &CreateDiskFromSnapshotInput{} + } + + output = &CreateDiskFromSnapshotOutput{} + req = c.newRequest(op, input, output) + return +} + +// CreateDiskFromSnapshot API operation for Amazon Lightsail. +// +// Creates a block storage disk from a disk snapshot that can be attached to +// a Lightsail instance in the same Availability Zone (e.g., us-east-2a). The +// disk is created in the regional endpoint that you send the HTTP request to. +// For more information, see Regions and Availability Zones in Lightsail (https://lightsail.aws.amazon.com/ls/docs/overview/article/understanding-regions-and-availability-zones-in-amazon-lightsail). +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation CreateDiskFromSnapshot for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/CreateDiskFromSnapshot +func (c *Lightsail) CreateDiskFromSnapshot(input *CreateDiskFromSnapshotInput) (*CreateDiskFromSnapshotOutput, error) { + req, out := c.CreateDiskFromSnapshotRequest(input) + return out, req.Send() +} + +// CreateDiskFromSnapshotWithContext is the same as CreateDiskFromSnapshot with the addition of +// the ability to pass a context and additional request options. +// +// See CreateDiskFromSnapshot for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) CreateDiskFromSnapshotWithContext(ctx aws.Context, input *CreateDiskFromSnapshotInput, opts ...request.Option) (*CreateDiskFromSnapshotOutput, error) { + req, out := c.CreateDiskFromSnapshotRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opCreateDiskSnapshot = "CreateDiskSnapshot" + +// CreateDiskSnapshotRequest generates a "aws/request.Request" representing the +// client's request for the CreateDiskSnapshot operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See CreateDiskSnapshot for more information on using the CreateDiskSnapshot +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the CreateDiskSnapshotRequest method. +// req, resp := client.CreateDiskSnapshotRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/CreateDiskSnapshot +func (c *Lightsail) CreateDiskSnapshotRequest(input *CreateDiskSnapshotInput) (req *request.Request, output *CreateDiskSnapshotOutput) { + op := &request.Operation{ + Name: opCreateDiskSnapshot, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &CreateDiskSnapshotInput{} + } + + output = &CreateDiskSnapshotOutput{} + req = c.newRequest(op, input, output) + return +} + +// CreateDiskSnapshot API operation for Amazon Lightsail. +// +// Creates a snapshot of a block storage disk. You can use snapshots for backups, +// to make copies of disks, and to save data before shutting down a Lightsail +// instance. +// +// You can take a snapshot of an attached disk that is in use; however, snapshots +// only capture data that has been written to your disk at the time the snapshot +// command is issued. This may exclude any data that has been cached by any +// applications or the operating system. If you can pause any file systems on +// the disk long enough to take a snapshot, your snapshot should be complete. +// Nevertheless, if you cannot pause all file writes to the disk, you should +// unmount the disk from within the Lightsail instance, issue the create disk +// snapshot command, and then remount the disk to ensure a consistent and complete +// snapshot. You may remount and use your disk while the snapshot status is +// pending. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation CreateDiskSnapshot for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/CreateDiskSnapshot +func (c *Lightsail) CreateDiskSnapshot(input *CreateDiskSnapshotInput) (*CreateDiskSnapshotOutput, error) { + req, out := c.CreateDiskSnapshotRequest(input) + return out, req.Send() +} + +// CreateDiskSnapshotWithContext is the same as CreateDiskSnapshot with the addition of +// the ability to pass a context and additional request options. +// +// See CreateDiskSnapshot for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) CreateDiskSnapshotWithContext(ctx aws.Context, input *CreateDiskSnapshotInput, opts ...request.Option) (*CreateDiskSnapshotOutput, error) { + req, out := c.CreateDiskSnapshotRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opCreateDomain = "CreateDomain" + +// CreateDomainRequest generates a "aws/request.Request" representing the +// client's request for the CreateDomain operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See CreateDomain for more information on using the CreateDomain +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the CreateDomainRequest method. +// req, resp := client.CreateDomainRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/CreateDomain +func (c *Lightsail) CreateDomainRequest(input *CreateDomainInput) (req *request.Request, output *CreateDomainOutput) { + op := &request.Operation{ + Name: opCreateDomain, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &CreateDomainInput{} + } + + output = &CreateDomainOutput{} + req = c.newRequest(op, input, output) + return +} + +// CreateDomain API operation for Amazon Lightsail. +// +// Creates a domain resource for the specified domain (e.g., example.com). +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation CreateDomain for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/CreateDomain +func (c *Lightsail) CreateDomain(input *CreateDomainInput) (*CreateDomainOutput, error) { + req, out := c.CreateDomainRequest(input) + return out, req.Send() +} + +// CreateDomainWithContext is the same as CreateDomain with the addition of +// the ability to pass a context and additional request options. +// +// See CreateDomain for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) CreateDomainWithContext(ctx aws.Context, input *CreateDomainInput, opts ...request.Option) (*CreateDomainOutput, error) { + req, out := c.CreateDomainRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opCreateDomainEntry = "CreateDomainEntry" + +// CreateDomainEntryRequest generates a "aws/request.Request" representing the +// client's request for the CreateDomainEntry operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See CreateDomainEntry for more information on using the CreateDomainEntry +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the CreateDomainEntryRequest method. +// req, resp := client.CreateDomainEntryRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/CreateDomainEntry +func (c *Lightsail) CreateDomainEntryRequest(input *CreateDomainEntryInput) (req *request.Request, output *CreateDomainEntryOutput) { + op := &request.Operation{ + Name: opCreateDomainEntry, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &CreateDomainEntryInput{} + } + + output = &CreateDomainEntryOutput{} + req = c.newRequest(op, input, output) + return +} + +// CreateDomainEntry API operation for Amazon Lightsail. +// +// Creates one of the following entry records associated with the domain: A +// record, CNAME record, TXT record, or MX record. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation CreateDomainEntry for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/CreateDomainEntry +func (c *Lightsail) CreateDomainEntry(input *CreateDomainEntryInput) (*CreateDomainEntryOutput, error) { + req, out := c.CreateDomainEntryRequest(input) + return out, req.Send() +} + +// CreateDomainEntryWithContext is the same as CreateDomainEntry with the addition of +// the ability to pass a context and additional request options. +// +// See CreateDomainEntry for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) CreateDomainEntryWithContext(ctx aws.Context, input *CreateDomainEntryInput, opts ...request.Option) (*CreateDomainEntryOutput, error) { + req, out := c.CreateDomainEntryRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opCreateInstanceSnapshot = "CreateInstanceSnapshot" + +// CreateInstanceSnapshotRequest generates a "aws/request.Request" representing the +// client's request for the CreateInstanceSnapshot operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See CreateInstanceSnapshot for more information on using the CreateInstanceSnapshot +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the CreateInstanceSnapshotRequest method. +// req, resp := client.CreateInstanceSnapshotRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/CreateInstanceSnapshot +func (c *Lightsail) CreateInstanceSnapshotRequest(input *CreateInstanceSnapshotInput) (req *request.Request, output *CreateInstanceSnapshotOutput) { + op := &request.Operation{ + Name: opCreateInstanceSnapshot, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &CreateInstanceSnapshotInput{} + } + + output = &CreateInstanceSnapshotOutput{} + req = c.newRequest(op, input, output) + return +} + +// CreateInstanceSnapshot API operation for Amazon Lightsail. +// +// Creates a snapshot of a specific virtual private server, or instance. You +// can use a snapshot to create a new instance that is based on that snapshot. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation CreateInstanceSnapshot for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/CreateInstanceSnapshot +func (c *Lightsail) CreateInstanceSnapshot(input *CreateInstanceSnapshotInput) (*CreateInstanceSnapshotOutput, error) { + req, out := c.CreateInstanceSnapshotRequest(input) + return out, req.Send() +} + +// CreateInstanceSnapshotWithContext is the same as CreateInstanceSnapshot with the addition of +// the ability to pass a context and additional request options. +// +// See CreateInstanceSnapshot for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) CreateInstanceSnapshotWithContext(ctx aws.Context, input *CreateInstanceSnapshotInput, opts ...request.Option) (*CreateInstanceSnapshotOutput, error) { + req, out := c.CreateInstanceSnapshotRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opCreateInstances = "CreateInstances" + +// CreateInstancesRequest generates a "aws/request.Request" representing the +// client's request for the CreateInstances operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See CreateInstances for more information on using the CreateInstances +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the CreateInstancesRequest method. +// req, resp := client.CreateInstancesRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/CreateInstances +func (c *Lightsail) CreateInstancesRequest(input *CreateInstancesInput) (req *request.Request, output *CreateInstancesOutput) { + op := &request.Operation{ + Name: opCreateInstances, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &CreateInstancesInput{} + } + + output = &CreateInstancesOutput{} + req = c.newRequest(op, input, output) + return +} + +// CreateInstances API operation for Amazon Lightsail. +// +// Creates one or more Amazon Lightsail virtual private servers, or instances. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation CreateInstances for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/CreateInstances +func (c *Lightsail) CreateInstances(input *CreateInstancesInput) (*CreateInstancesOutput, error) { + req, out := c.CreateInstancesRequest(input) + return out, req.Send() +} + +// CreateInstancesWithContext is the same as CreateInstances with the addition of +// the ability to pass a context and additional request options. +// +// See CreateInstances for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) CreateInstancesWithContext(ctx aws.Context, input *CreateInstancesInput, opts ...request.Option) (*CreateInstancesOutput, error) { + req, out := c.CreateInstancesRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opCreateInstancesFromSnapshot = "CreateInstancesFromSnapshot" + +// CreateInstancesFromSnapshotRequest generates a "aws/request.Request" representing the +// client's request for the CreateInstancesFromSnapshot operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See CreateInstancesFromSnapshot for more information on using the CreateInstancesFromSnapshot +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the CreateInstancesFromSnapshotRequest method. +// req, resp := client.CreateInstancesFromSnapshotRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/CreateInstancesFromSnapshot +func (c *Lightsail) CreateInstancesFromSnapshotRequest(input *CreateInstancesFromSnapshotInput) (req *request.Request, output *CreateInstancesFromSnapshotOutput) { + op := &request.Operation{ + Name: opCreateInstancesFromSnapshot, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &CreateInstancesFromSnapshotInput{} + } + + output = &CreateInstancesFromSnapshotOutput{} + req = c.newRequest(op, input, output) + return +} + +// CreateInstancesFromSnapshot API operation for Amazon Lightsail. +// +// Uses a specific snapshot as a blueprint for creating one or more new instances +// that are based on that identical configuration. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation CreateInstancesFromSnapshot for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/CreateInstancesFromSnapshot +func (c *Lightsail) CreateInstancesFromSnapshot(input *CreateInstancesFromSnapshotInput) (*CreateInstancesFromSnapshotOutput, error) { + req, out := c.CreateInstancesFromSnapshotRequest(input) + return out, req.Send() +} + +// CreateInstancesFromSnapshotWithContext is the same as CreateInstancesFromSnapshot with the addition of +// the ability to pass a context and additional request options. +// +// See CreateInstancesFromSnapshot for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) CreateInstancesFromSnapshotWithContext(ctx aws.Context, input *CreateInstancesFromSnapshotInput, opts ...request.Option) (*CreateInstancesFromSnapshotOutput, error) { + req, out := c.CreateInstancesFromSnapshotRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opCreateKeyPair = "CreateKeyPair" + +// CreateKeyPairRequest generates a "aws/request.Request" representing the +// client's request for the CreateKeyPair operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See CreateKeyPair for more information on using the CreateKeyPair +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the CreateKeyPairRequest method. +// req, resp := client.CreateKeyPairRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/CreateKeyPair +func (c *Lightsail) CreateKeyPairRequest(input *CreateKeyPairInput) (req *request.Request, output *CreateKeyPairOutput) { + op := &request.Operation{ + Name: opCreateKeyPair, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &CreateKeyPairInput{} + } + + output = &CreateKeyPairOutput{} + req = c.newRequest(op, input, output) + return +} + +// CreateKeyPair API operation for Amazon Lightsail. +// +// Creates sn SSH key pair. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation CreateKeyPair for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/CreateKeyPair +func (c *Lightsail) CreateKeyPair(input *CreateKeyPairInput) (*CreateKeyPairOutput, error) { + req, out := c.CreateKeyPairRequest(input) + return out, req.Send() +} + +// CreateKeyPairWithContext is the same as CreateKeyPair with the addition of +// the ability to pass a context and additional request options. +// +// See CreateKeyPair for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) CreateKeyPairWithContext(ctx aws.Context, input *CreateKeyPairInput, opts ...request.Option) (*CreateKeyPairOutput, error) { + req, out := c.CreateKeyPairRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opCreateLoadBalancer = "CreateLoadBalancer" + +// CreateLoadBalancerRequest generates a "aws/request.Request" representing the +// client's request for the CreateLoadBalancer operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See CreateLoadBalancer for more information on using the CreateLoadBalancer +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the CreateLoadBalancerRequest method. +// req, resp := client.CreateLoadBalancerRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/CreateLoadBalancer +func (c *Lightsail) CreateLoadBalancerRequest(input *CreateLoadBalancerInput) (req *request.Request, output *CreateLoadBalancerOutput) { + op := &request.Operation{ + Name: opCreateLoadBalancer, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &CreateLoadBalancerInput{} + } + + output = &CreateLoadBalancerOutput{} + req = c.newRequest(op, input, output) + return +} + +// CreateLoadBalancer API operation for Amazon Lightsail. +// +// Creates a Lightsail load balancer. +// +// When you create a load balancer, you can specify certificates and port settings. +// You can create up to 5 load balancers per AWS Region in your account. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation CreateLoadBalancer for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/CreateLoadBalancer +func (c *Lightsail) CreateLoadBalancer(input *CreateLoadBalancerInput) (*CreateLoadBalancerOutput, error) { + req, out := c.CreateLoadBalancerRequest(input) + return out, req.Send() +} + +// CreateLoadBalancerWithContext is the same as CreateLoadBalancer with the addition of +// the ability to pass a context and additional request options. +// +// See CreateLoadBalancer for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) CreateLoadBalancerWithContext(ctx aws.Context, input *CreateLoadBalancerInput, opts ...request.Option) (*CreateLoadBalancerOutput, error) { + req, out := c.CreateLoadBalancerRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opCreateLoadBalancerTlsCertificate = "CreateLoadBalancerTlsCertificate" + +// CreateLoadBalancerTlsCertificateRequest generates a "aws/request.Request" representing the +// client's request for the CreateLoadBalancerTlsCertificate operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See CreateLoadBalancerTlsCertificate for more information on using the CreateLoadBalancerTlsCertificate +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the CreateLoadBalancerTlsCertificateRequest method. +// req, resp := client.CreateLoadBalancerTlsCertificateRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/CreateLoadBalancerTlsCertificate +func (c *Lightsail) CreateLoadBalancerTlsCertificateRequest(input *CreateLoadBalancerTlsCertificateInput) (req *request.Request, output *CreateLoadBalancerTlsCertificateOutput) { + op := &request.Operation{ + Name: opCreateLoadBalancerTlsCertificate, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &CreateLoadBalancerTlsCertificateInput{} + } + + output = &CreateLoadBalancerTlsCertificateOutput{} + req = c.newRequest(op, input, output) + return +} + +// CreateLoadBalancerTlsCertificate API operation for Amazon Lightsail. +// +// Creates a Lightsail load balancer TLS certificate. +// +// TLS is just an updated, more secure version of Secure Socket Layer (SSL). +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation CreateLoadBalancerTlsCertificate for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/CreateLoadBalancerTlsCertificate +func (c *Lightsail) CreateLoadBalancerTlsCertificate(input *CreateLoadBalancerTlsCertificateInput) (*CreateLoadBalancerTlsCertificateOutput, error) { + req, out := c.CreateLoadBalancerTlsCertificateRequest(input) + return out, req.Send() +} + +// CreateLoadBalancerTlsCertificateWithContext is the same as CreateLoadBalancerTlsCertificate with the addition of +// the ability to pass a context and additional request options. +// +// See CreateLoadBalancerTlsCertificate for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) CreateLoadBalancerTlsCertificateWithContext(ctx aws.Context, input *CreateLoadBalancerTlsCertificateInput, opts ...request.Option) (*CreateLoadBalancerTlsCertificateOutput, error) { + req, out := c.CreateLoadBalancerTlsCertificateRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opDeleteDisk = "DeleteDisk" + +// DeleteDiskRequest generates a "aws/request.Request" representing the +// client's request for the DeleteDisk operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See DeleteDisk for more information on using the DeleteDisk +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the DeleteDiskRequest method. +// req, resp := client.DeleteDiskRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/DeleteDisk +func (c *Lightsail) DeleteDiskRequest(input *DeleteDiskInput) (req *request.Request, output *DeleteDiskOutput) { + op := &request.Operation{ + Name: opDeleteDisk, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &DeleteDiskInput{} + } + + output = &DeleteDiskOutput{} + req = c.newRequest(op, input, output) + return +} + +// DeleteDisk API operation for Amazon Lightsail. +// +// Deletes the specified block storage disk. The disk must be in the available +// state (not attached to a Lightsail instance). +// +// The disk may remain in the deleting state for several minutes. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation DeleteDisk for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/DeleteDisk +func (c *Lightsail) DeleteDisk(input *DeleteDiskInput) (*DeleteDiskOutput, error) { + req, out := c.DeleteDiskRequest(input) + return out, req.Send() +} + +// DeleteDiskWithContext is the same as DeleteDisk with the addition of +// the ability to pass a context and additional request options. +// +// See DeleteDisk for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) DeleteDiskWithContext(ctx aws.Context, input *DeleteDiskInput, opts ...request.Option) (*DeleteDiskOutput, error) { + req, out := c.DeleteDiskRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opDeleteDiskSnapshot = "DeleteDiskSnapshot" + +// DeleteDiskSnapshotRequest generates a "aws/request.Request" representing the +// client's request for the DeleteDiskSnapshot operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See DeleteDiskSnapshot for more information on using the DeleteDiskSnapshot +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the DeleteDiskSnapshotRequest method. +// req, resp := client.DeleteDiskSnapshotRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/DeleteDiskSnapshot +func (c *Lightsail) DeleteDiskSnapshotRequest(input *DeleteDiskSnapshotInput) (req *request.Request, output *DeleteDiskSnapshotOutput) { + op := &request.Operation{ + Name: opDeleteDiskSnapshot, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &DeleteDiskSnapshotInput{} + } + + output = &DeleteDiskSnapshotOutput{} + req = c.newRequest(op, input, output) + return +} + +// DeleteDiskSnapshot API operation for Amazon Lightsail. +// +// Deletes the specified disk snapshot. +// +// When you make periodic snapshots of a disk, the snapshots are incremental, +// and only the blocks on the device that have changed since your last snapshot +// are saved in the new snapshot. When you delete a snapshot, only the data +// not needed for any other snapshot is removed. So regardless of which prior +// snapshots have been deleted, all active snapshots will have access to all +// the information needed to restore the disk. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation DeleteDiskSnapshot for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/DeleteDiskSnapshot +func (c *Lightsail) DeleteDiskSnapshot(input *DeleteDiskSnapshotInput) (*DeleteDiskSnapshotOutput, error) { + req, out := c.DeleteDiskSnapshotRequest(input) + return out, req.Send() +} + +// DeleteDiskSnapshotWithContext is the same as DeleteDiskSnapshot with the addition of +// the ability to pass a context and additional request options. +// +// See DeleteDiskSnapshot for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) DeleteDiskSnapshotWithContext(ctx aws.Context, input *DeleteDiskSnapshotInput, opts ...request.Option) (*DeleteDiskSnapshotOutput, error) { + req, out := c.DeleteDiskSnapshotRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opDeleteDomain = "DeleteDomain" + +// DeleteDomainRequest generates a "aws/request.Request" representing the +// client's request for the DeleteDomain operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See DeleteDomain for more information on using the DeleteDomain +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the DeleteDomainRequest method. +// req, resp := client.DeleteDomainRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/DeleteDomain +func (c *Lightsail) DeleteDomainRequest(input *DeleteDomainInput) (req *request.Request, output *DeleteDomainOutput) { + op := &request.Operation{ + Name: opDeleteDomain, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &DeleteDomainInput{} + } + + output = &DeleteDomainOutput{} + req = c.newRequest(op, input, output) + return +} + +// DeleteDomain API operation for Amazon Lightsail. +// +// Deletes the specified domain recordset and all of its domain records. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation DeleteDomain for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/DeleteDomain +func (c *Lightsail) DeleteDomain(input *DeleteDomainInput) (*DeleteDomainOutput, error) { + req, out := c.DeleteDomainRequest(input) + return out, req.Send() +} + +// DeleteDomainWithContext is the same as DeleteDomain with the addition of +// the ability to pass a context and additional request options. +// +// See DeleteDomain for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) DeleteDomainWithContext(ctx aws.Context, input *DeleteDomainInput, opts ...request.Option) (*DeleteDomainOutput, error) { + req, out := c.DeleteDomainRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opDeleteDomainEntry = "DeleteDomainEntry" + +// DeleteDomainEntryRequest generates a "aws/request.Request" representing the +// client's request for the DeleteDomainEntry operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See DeleteDomainEntry for more information on using the DeleteDomainEntry +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the DeleteDomainEntryRequest method. +// req, resp := client.DeleteDomainEntryRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/DeleteDomainEntry +func (c *Lightsail) DeleteDomainEntryRequest(input *DeleteDomainEntryInput) (req *request.Request, output *DeleteDomainEntryOutput) { + op := &request.Operation{ + Name: opDeleteDomainEntry, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &DeleteDomainEntryInput{} + } + + output = &DeleteDomainEntryOutput{} + req = c.newRequest(op, input, output) + return +} + +// DeleteDomainEntry API operation for Amazon Lightsail. +// +// Deletes a specific domain entry. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation DeleteDomainEntry for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/DeleteDomainEntry +func (c *Lightsail) DeleteDomainEntry(input *DeleteDomainEntryInput) (*DeleteDomainEntryOutput, error) { + req, out := c.DeleteDomainEntryRequest(input) + return out, req.Send() +} + +// DeleteDomainEntryWithContext is the same as DeleteDomainEntry with the addition of +// the ability to pass a context and additional request options. +// +// See DeleteDomainEntry for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) DeleteDomainEntryWithContext(ctx aws.Context, input *DeleteDomainEntryInput, opts ...request.Option) (*DeleteDomainEntryOutput, error) { + req, out := c.DeleteDomainEntryRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opDeleteInstance = "DeleteInstance" + +// DeleteInstanceRequest generates a "aws/request.Request" representing the +// client's request for the DeleteInstance operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See DeleteInstance for more information on using the DeleteInstance +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the DeleteInstanceRequest method. +// req, resp := client.DeleteInstanceRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/DeleteInstance +func (c *Lightsail) DeleteInstanceRequest(input *DeleteInstanceInput) (req *request.Request, output *DeleteInstanceOutput) { + op := &request.Operation{ + Name: opDeleteInstance, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &DeleteInstanceInput{} + } + + output = &DeleteInstanceOutput{} + req = c.newRequest(op, input, output) + return +} + +// DeleteInstance API operation for Amazon Lightsail. +// +// Deletes a specific Amazon Lightsail virtual private server, or instance. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation DeleteInstance for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/DeleteInstance +func (c *Lightsail) DeleteInstance(input *DeleteInstanceInput) (*DeleteInstanceOutput, error) { + req, out := c.DeleteInstanceRequest(input) + return out, req.Send() +} + +// DeleteInstanceWithContext is the same as DeleteInstance with the addition of +// the ability to pass a context and additional request options. +// +// See DeleteInstance for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) DeleteInstanceWithContext(ctx aws.Context, input *DeleteInstanceInput, opts ...request.Option) (*DeleteInstanceOutput, error) { + req, out := c.DeleteInstanceRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opDeleteInstanceSnapshot = "DeleteInstanceSnapshot" + +// DeleteInstanceSnapshotRequest generates a "aws/request.Request" representing the +// client's request for the DeleteInstanceSnapshot operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See DeleteInstanceSnapshot for more information on using the DeleteInstanceSnapshot +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the DeleteInstanceSnapshotRequest method. +// req, resp := client.DeleteInstanceSnapshotRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/DeleteInstanceSnapshot +func (c *Lightsail) DeleteInstanceSnapshotRequest(input *DeleteInstanceSnapshotInput) (req *request.Request, output *DeleteInstanceSnapshotOutput) { + op := &request.Operation{ + Name: opDeleteInstanceSnapshot, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &DeleteInstanceSnapshotInput{} + } + + output = &DeleteInstanceSnapshotOutput{} + req = c.newRequest(op, input, output) + return +} + +// DeleteInstanceSnapshot API operation for Amazon Lightsail. +// +// Deletes a specific snapshot of a virtual private server (or instance). +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation DeleteInstanceSnapshot for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/DeleteInstanceSnapshot +func (c *Lightsail) DeleteInstanceSnapshot(input *DeleteInstanceSnapshotInput) (*DeleteInstanceSnapshotOutput, error) { + req, out := c.DeleteInstanceSnapshotRequest(input) + return out, req.Send() +} + +// DeleteInstanceSnapshotWithContext is the same as DeleteInstanceSnapshot with the addition of +// the ability to pass a context and additional request options. +// +// See DeleteInstanceSnapshot for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) DeleteInstanceSnapshotWithContext(ctx aws.Context, input *DeleteInstanceSnapshotInput, opts ...request.Option) (*DeleteInstanceSnapshotOutput, error) { + req, out := c.DeleteInstanceSnapshotRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opDeleteKeyPair = "DeleteKeyPair" + +// DeleteKeyPairRequest generates a "aws/request.Request" representing the +// client's request for the DeleteKeyPair operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See DeleteKeyPair for more information on using the DeleteKeyPair +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the DeleteKeyPairRequest method. +// req, resp := client.DeleteKeyPairRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/DeleteKeyPair +func (c *Lightsail) DeleteKeyPairRequest(input *DeleteKeyPairInput) (req *request.Request, output *DeleteKeyPairOutput) { + op := &request.Operation{ + Name: opDeleteKeyPair, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &DeleteKeyPairInput{} + } + + output = &DeleteKeyPairOutput{} + req = c.newRequest(op, input, output) + return +} + +// DeleteKeyPair API operation for Amazon Lightsail. +// +// Deletes a specific SSH key pair. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation DeleteKeyPair for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/DeleteKeyPair +func (c *Lightsail) DeleteKeyPair(input *DeleteKeyPairInput) (*DeleteKeyPairOutput, error) { + req, out := c.DeleteKeyPairRequest(input) + return out, req.Send() +} + +// DeleteKeyPairWithContext is the same as DeleteKeyPair with the addition of +// the ability to pass a context and additional request options. +// +// See DeleteKeyPair for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) DeleteKeyPairWithContext(ctx aws.Context, input *DeleteKeyPairInput, opts ...request.Option) (*DeleteKeyPairOutput, error) { + req, out := c.DeleteKeyPairRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opDeleteLoadBalancer = "DeleteLoadBalancer" + +// DeleteLoadBalancerRequest generates a "aws/request.Request" representing the +// client's request for the DeleteLoadBalancer operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See DeleteLoadBalancer for more information on using the DeleteLoadBalancer +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the DeleteLoadBalancerRequest method. +// req, resp := client.DeleteLoadBalancerRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/DeleteLoadBalancer +func (c *Lightsail) DeleteLoadBalancerRequest(input *DeleteLoadBalancerInput) (req *request.Request, output *DeleteLoadBalancerOutput) { + op := &request.Operation{ + Name: opDeleteLoadBalancer, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &DeleteLoadBalancerInput{} + } + + output = &DeleteLoadBalancerOutput{} + req = c.newRequest(op, input, output) + return +} + +// DeleteLoadBalancer API operation for Amazon Lightsail. +// +// Deletes a Lightsail load balancer. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation DeleteLoadBalancer for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/DeleteLoadBalancer +func (c *Lightsail) DeleteLoadBalancer(input *DeleteLoadBalancerInput) (*DeleteLoadBalancerOutput, error) { + req, out := c.DeleteLoadBalancerRequest(input) + return out, req.Send() +} + +// DeleteLoadBalancerWithContext is the same as DeleteLoadBalancer with the addition of +// the ability to pass a context and additional request options. +// +// See DeleteLoadBalancer for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) DeleteLoadBalancerWithContext(ctx aws.Context, input *DeleteLoadBalancerInput, opts ...request.Option) (*DeleteLoadBalancerOutput, error) { + req, out := c.DeleteLoadBalancerRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opDeleteLoadBalancerTlsCertificate = "DeleteLoadBalancerTlsCertificate" + +// DeleteLoadBalancerTlsCertificateRequest generates a "aws/request.Request" representing the +// client's request for the DeleteLoadBalancerTlsCertificate operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See DeleteLoadBalancerTlsCertificate for more information on using the DeleteLoadBalancerTlsCertificate +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the DeleteLoadBalancerTlsCertificateRequest method. +// req, resp := client.DeleteLoadBalancerTlsCertificateRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/DeleteLoadBalancerTlsCertificate +func (c *Lightsail) DeleteLoadBalancerTlsCertificateRequest(input *DeleteLoadBalancerTlsCertificateInput) (req *request.Request, output *DeleteLoadBalancerTlsCertificateOutput) { + op := &request.Operation{ + Name: opDeleteLoadBalancerTlsCertificate, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &DeleteLoadBalancerTlsCertificateInput{} + } + + output = &DeleteLoadBalancerTlsCertificateOutput{} + req = c.newRequest(op, input, output) + return +} + +// DeleteLoadBalancerTlsCertificate API operation for Amazon Lightsail. +// +// Deletes a TLS/SSL certificate associated with a Lightsail load balancer. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation DeleteLoadBalancerTlsCertificate for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/DeleteLoadBalancerTlsCertificate +func (c *Lightsail) DeleteLoadBalancerTlsCertificate(input *DeleteLoadBalancerTlsCertificateInput) (*DeleteLoadBalancerTlsCertificateOutput, error) { + req, out := c.DeleteLoadBalancerTlsCertificateRequest(input) + return out, req.Send() +} + +// DeleteLoadBalancerTlsCertificateWithContext is the same as DeleteLoadBalancerTlsCertificate with the addition of +// the ability to pass a context and additional request options. +// +// See DeleteLoadBalancerTlsCertificate for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) DeleteLoadBalancerTlsCertificateWithContext(ctx aws.Context, input *DeleteLoadBalancerTlsCertificateInput, opts ...request.Option) (*DeleteLoadBalancerTlsCertificateOutput, error) { + req, out := c.DeleteLoadBalancerTlsCertificateRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opDetachDisk = "DetachDisk" + +// DetachDiskRequest generates a "aws/request.Request" representing the +// client's request for the DetachDisk operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See DetachDisk for more information on using the DetachDisk +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the DetachDiskRequest method. +// req, resp := client.DetachDiskRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/DetachDisk +func (c *Lightsail) DetachDiskRequest(input *DetachDiskInput) (req *request.Request, output *DetachDiskOutput) { + op := &request.Operation{ + Name: opDetachDisk, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &DetachDiskInput{} + } + + output = &DetachDiskOutput{} + req = c.newRequest(op, input, output) + return +} + +// DetachDisk API operation for Amazon Lightsail. +// +// Detaches a stopped block storage disk from a Lightsail instance. Make sure +// to unmount any file systems on the device within your operating system before +// stopping the instance and detaching the disk. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation DetachDisk for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/DetachDisk +func (c *Lightsail) DetachDisk(input *DetachDiskInput) (*DetachDiskOutput, error) { + req, out := c.DetachDiskRequest(input) + return out, req.Send() +} + +// DetachDiskWithContext is the same as DetachDisk with the addition of +// the ability to pass a context and additional request options. +// +// See DetachDisk for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) DetachDiskWithContext(ctx aws.Context, input *DetachDiskInput, opts ...request.Option) (*DetachDiskOutput, error) { + req, out := c.DetachDiskRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opDetachInstancesFromLoadBalancer = "DetachInstancesFromLoadBalancer" + +// DetachInstancesFromLoadBalancerRequest generates a "aws/request.Request" representing the +// client's request for the DetachInstancesFromLoadBalancer operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See DetachInstancesFromLoadBalancer for more information on using the DetachInstancesFromLoadBalancer +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the DetachInstancesFromLoadBalancerRequest method. +// req, resp := client.DetachInstancesFromLoadBalancerRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/DetachInstancesFromLoadBalancer +func (c *Lightsail) DetachInstancesFromLoadBalancerRequest(input *DetachInstancesFromLoadBalancerInput) (req *request.Request, output *DetachInstancesFromLoadBalancerOutput) { + op := &request.Operation{ + Name: opDetachInstancesFromLoadBalancer, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &DetachInstancesFromLoadBalancerInput{} + } + + output = &DetachInstancesFromLoadBalancerOutput{} + req = c.newRequest(op, input, output) + return +} + +// DetachInstancesFromLoadBalancer API operation for Amazon Lightsail. +// +// Detaches the specified instances from a Lightsail load balancer. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation DetachInstancesFromLoadBalancer for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/DetachInstancesFromLoadBalancer +func (c *Lightsail) DetachInstancesFromLoadBalancer(input *DetachInstancesFromLoadBalancerInput) (*DetachInstancesFromLoadBalancerOutput, error) { + req, out := c.DetachInstancesFromLoadBalancerRequest(input) + return out, req.Send() +} + +// DetachInstancesFromLoadBalancerWithContext is the same as DetachInstancesFromLoadBalancer with the addition of +// the ability to pass a context and additional request options. +// +// See DetachInstancesFromLoadBalancer for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) DetachInstancesFromLoadBalancerWithContext(ctx aws.Context, input *DetachInstancesFromLoadBalancerInput, opts ...request.Option) (*DetachInstancesFromLoadBalancerOutput, error) { + req, out := c.DetachInstancesFromLoadBalancerRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opDetachStaticIp = "DetachStaticIp" + +// DetachStaticIpRequest generates a "aws/request.Request" representing the +// client's request for the DetachStaticIp operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See DetachStaticIp for more information on using the DetachStaticIp +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the DetachStaticIpRequest method. +// req, resp := client.DetachStaticIpRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/DetachStaticIp +func (c *Lightsail) DetachStaticIpRequest(input *DetachStaticIpInput) (req *request.Request, output *DetachStaticIpOutput) { + op := &request.Operation{ + Name: opDetachStaticIp, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &DetachStaticIpInput{} + } + + output = &DetachStaticIpOutput{} + req = c.newRequest(op, input, output) + return +} + +// DetachStaticIp API operation for Amazon Lightsail. +// +// Detaches a static IP from the Amazon Lightsail instance to which it is attached. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation DetachStaticIp for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/DetachStaticIp +func (c *Lightsail) DetachStaticIp(input *DetachStaticIpInput) (*DetachStaticIpOutput, error) { + req, out := c.DetachStaticIpRequest(input) + return out, req.Send() +} + +// DetachStaticIpWithContext is the same as DetachStaticIp with the addition of +// the ability to pass a context and additional request options. +// +// See DetachStaticIp for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) DetachStaticIpWithContext(ctx aws.Context, input *DetachStaticIpInput, opts ...request.Option) (*DetachStaticIpOutput, error) { + req, out := c.DetachStaticIpRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opDownloadDefaultKeyPair = "DownloadDefaultKeyPair" + +// DownloadDefaultKeyPairRequest generates a "aws/request.Request" representing the +// client's request for the DownloadDefaultKeyPair operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See DownloadDefaultKeyPair for more information on using the DownloadDefaultKeyPair +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the DownloadDefaultKeyPairRequest method. +// req, resp := client.DownloadDefaultKeyPairRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/DownloadDefaultKeyPair +func (c *Lightsail) DownloadDefaultKeyPairRequest(input *DownloadDefaultKeyPairInput) (req *request.Request, output *DownloadDefaultKeyPairOutput) { + op := &request.Operation{ + Name: opDownloadDefaultKeyPair, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &DownloadDefaultKeyPairInput{} + } + + output = &DownloadDefaultKeyPairOutput{} + req = c.newRequest(op, input, output) + return +} + +// DownloadDefaultKeyPair API operation for Amazon Lightsail. +// +// Downloads the default SSH key pair from the user's account. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation DownloadDefaultKeyPair for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/DownloadDefaultKeyPair +func (c *Lightsail) DownloadDefaultKeyPair(input *DownloadDefaultKeyPairInput) (*DownloadDefaultKeyPairOutput, error) { + req, out := c.DownloadDefaultKeyPairRequest(input) + return out, req.Send() +} + +// DownloadDefaultKeyPairWithContext is the same as DownloadDefaultKeyPair with the addition of +// the ability to pass a context and additional request options. +// +// See DownloadDefaultKeyPair for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) DownloadDefaultKeyPairWithContext(ctx aws.Context, input *DownloadDefaultKeyPairInput, opts ...request.Option) (*DownloadDefaultKeyPairOutput, error) { + req, out := c.DownloadDefaultKeyPairRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opGetActiveNames = "GetActiveNames" + +// GetActiveNamesRequest generates a "aws/request.Request" representing the +// client's request for the GetActiveNames operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See GetActiveNames for more information on using the GetActiveNames +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the GetActiveNamesRequest method. +// req, resp := client.GetActiveNamesRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/GetActiveNames +func (c *Lightsail) GetActiveNamesRequest(input *GetActiveNamesInput) (req *request.Request, output *GetActiveNamesOutput) { + op := &request.Operation{ + Name: opGetActiveNames, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &GetActiveNamesInput{} + } + + output = &GetActiveNamesOutput{} + req = c.newRequest(op, input, output) + return +} + +// GetActiveNames API operation for Amazon Lightsail. +// +// Returns the names of all active (not deleted) resources. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation GetActiveNames for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/GetActiveNames +func (c *Lightsail) GetActiveNames(input *GetActiveNamesInput) (*GetActiveNamesOutput, error) { + req, out := c.GetActiveNamesRequest(input) + return out, req.Send() +} + +// GetActiveNamesWithContext is the same as GetActiveNames with the addition of +// the ability to pass a context and additional request options. +// +// See GetActiveNames for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) GetActiveNamesWithContext(ctx aws.Context, input *GetActiveNamesInput, opts ...request.Option) (*GetActiveNamesOutput, error) { + req, out := c.GetActiveNamesRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opGetBlueprints = "GetBlueprints" + +// GetBlueprintsRequest generates a "aws/request.Request" representing the +// client's request for the GetBlueprints operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See GetBlueprints for more information on using the GetBlueprints +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the GetBlueprintsRequest method. +// req, resp := client.GetBlueprintsRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/GetBlueprints +func (c *Lightsail) GetBlueprintsRequest(input *GetBlueprintsInput) (req *request.Request, output *GetBlueprintsOutput) { + op := &request.Operation{ + Name: opGetBlueprints, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &GetBlueprintsInput{} + } + + output = &GetBlueprintsOutput{} + req = c.newRequest(op, input, output) + return +} + +// GetBlueprints API operation for Amazon Lightsail. +// +// Returns the list of available instance images, or blueprints. You can use +// a blueprint to create a new virtual private server already running a specific +// operating system, as well as a preinstalled app or development stack. The +// software each instance is running depends on the blueprint image you choose. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation GetBlueprints for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/GetBlueprints +func (c *Lightsail) GetBlueprints(input *GetBlueprintsInput) (*GetBlueprintsOutput, error) { + req, out := c.GetBlueprintsRequest(input) + return out, req.Send() +} + +// GetBlueprintsWithContext is the same as GetBlueprints with the addition of +// the ability to pass a context and additional request options. +// +// See GetBlueprints for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) GetBlueprintsWithContext(ctx aws.Context, input *GetBlueprintsInput, opts ...request.Option) (*GetBlueprintsOutput, error) { + req, out := c.GetBlueprintsRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opGetBundles = "GetBundles" + +// GetBundlesRequest generates a "aws/request.Request" representing the +// client's request for the GetBundles operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See GetBundles for more information on using the GetBundles +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the GetBundlesRequest method. +// req, resp := client.GetBundlesRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/GetBundles +func (c *Lightsail) GetBundlesRequest(input *GetBundlesInput) (req *request.Request, output *GetBundlesOutput) { + op := &request.Operation{ + Name: opGetBundles, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &GetBundlesInput{} + } + + output = &GetBundlesOutput{} + req = c.newRequest(op, input, output) + return +} + +// GetBundles API operation for Amazon Lightsail. +// +// Returns the list of bundles that are available for purchase. A bundle describes +// the specs for your virtual private server (or instance). +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation GetBundles for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/GetBundles +func (c *Lightsail) GetBundles(input *GetBundlesInput) (*GetBundlesOutput, error) { + req, out := c.GetBundlesRequest(input) + return out, req.Send() +} + +// GetBundlesWithContext is the same as GetBundles with the addition of +// the ability to pass a context and additional request options. +// +// See GetBundles for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) GetBundlesWithContext(ctx aws.Context, input *GetBundlesInput, opts ...request.Option) (*GetBundlesOutput, error) { + req, out := c.GetBundlesRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opGetDisk = "GetDisk" + +// GetDiskRequest generates a "aws/request.Request" representing the +// client's request for the GetDisk operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See GetDisk for more information on using the GetDisk +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the GetDiskRequest method. +// req, resp := client.GetDiskRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/GetDisk +func (c *Lightsail) GetDiskRequest(input *GetDiskInput) (req *request.Request, output *GetDiskOutput) { + op := &request.Operation{ + Name: opGetDisk, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &GetDiskInput{} + } + + output = &GetDiskOutput{} + req = c.newRequest(op, input, output) + return +} + +// GetDisk API operation for Amazon Lightsail. +// +// Returns information about a specific block storage disk. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation GetDisk for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/GetDisk +func (c *Lightsail) GetDisk(input *GetDiskInput) (*GetDiskOutput, error) { + req, out := c.GetDiskRequest(input) + return out, req.Send() +} + +// GetDiskWithContext is the same as GetDisk with the addition of +// the ability to pass a context and additional request options. +// +// See GetDisk for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) GetDiskWithContext(ctx aws.Context, input *GetDiskInput, opts ...request.Option) (*GetDiskOutput, error) { + req, out := c.GetDiskRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opGetDiskSnapshot = "GetDiskSnapshot" + +// GetDiskSnapshotRequest generates a "aws/request.Request" representing the +// client's request for the GetDiskSnapshot operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See GetDiskSnapshot for more information on using the GetDiskSnapshot +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the GetDiskSnapshotRequest method. +// req, resp := client.GetDiskSnapshotRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/GetDiskSnapshot +func (c *Lightsail) GetDiskSnapshotRequest(input *GetDiskSnapshotInput) (req *request.Request, output *GetDiskSnapshotOutput) { + op := &request.Operation{ + Name: opGetDiskSnapshot, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &GetDiskSnapshotInput{} + } + + output = &GetDiskSnapshotOutput{} + req = c.newRequest(op, input, output) + return +} + +// GetDiskSnapshot API operation for Amazon Lightsail. +// +// Returns information about a specific block storage disk snapshot. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation GetDiskSnapshot for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/GetDiskSnapshot +func (c *Lightsail) GetDiskSnapshot(input *GetDiskSnapshotInput) (*GetDiskSnapshotOutput, error) { + req, out := c.GetDiskSnapshotRequest(input) + return out, req.Send() +} + +// GetDiskSnapshotWithContext is the same as GetDiskSnapshot with the addition of +// the ability to pass a context and additional request options. +// +// See GetDiskSnapshot for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) GetDiskSnapshotWithContext(ctx aws.Context, input *GetDiskSnapshotInput, opts ...request.Option) (*GetDiskSnapshotOutput, error) { + req, out := c.GetDiskSnapshotRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opGetDiskSnapshots = "GetDiskSnapshots" + +// GetDiskSnapshotsRequest generates a "aws/request.Request" representing the +// client's request for the GetDiskSnapshots operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See GetDiskSnapshots for more information on using the GetDiskSnapshots +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the GetDiskSnapshotsRequest method. +// req, resp := client.GetDiskSnapshotsRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/GetDiskSnapshots +func (c *Lightsail) GetDiskSnapshotsRequest(input *GetDiskSnapshotsInput) (req *request.Request, output *GetDiskSnapshotsOutput) { + op := &request.Operation{ + Name: opGetDiskSnapshots, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &GetDiskSnapshotsInput{} + } + + output = &GetDiskSnapshotsOutput{} + req = c.newRequest(op, input, output) + return +} + +// GetDiskSnapshots API operation for Amazon Lightsail. +// +// Returns information about all block storage disk snapshots in your AWS account +// and region. +// +// If you are describing a long list of disk snapshots, you can paginate the +// output to make the list more manageable. You can use the pageToken and nextPageToken +// values to retrieve the next items in the list. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation GetDiskSnapshots for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/GetDiskSnapshots +func (c *Lightsail) GetDiskSnapshots(input *GetDiskSnapshotsInput) (*GetDiskSnapshotsOutput, error) { + req, out := c.GetDiskSnapshotsRequest(input) + return out, req.Send() +} + +// GetDiskSnapshotsWithContext is the same as GetDiskSnapshots with the addition of +// the ability to pass a context and additional request options. +// +// See GetDiskSnapshots for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) GetDiskSnapshotsWithContext(ctx aws.Context, input *GetDiskSnapshotsInput, opts ...request.Option) (*GetDiskSnapshotsOutput, error) { + req, out := c.GetDiskSnapshotsRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opGetDisks = "GetDisks" + +// GetDisksRequest generates a "aws/request.Request" representing the +// client's request for the GetDisks operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See GetDisks for more information on using the GetDisks +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the GetDisksRequest method. +// req, resp := client.GetDisksRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/GetDisks +func (c *Lightsail) GetDisksRequest(input *GetDisksInput) (req *request.Request, output *GetDisksOutput) { + op := &request.Operation{ + Name: opGetDisks, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &GetDisksInput{} + } + + output = &GetDisksOutput{} + req = c.newRequest(op, input, output) + return +} + +// GetDisks API operation for Amazon Lightsail. +// +// Returns information about all block storage disks in your AWS account and +// region. +// +// If you are describing a long list of disks, you can paginate the output to +// make the list more manageable. You can use the pageToken and nextPageToken +// values to retrieve the next items in the list. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation GetDisks for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/GetDisks +func (c *Lightsail) GetDisks(input *GetDisksInput) (*GetDisksOutput, error) { + req, out := c.GetDisksRequest(input) + return out, req.Send() +} + +// GetDisksWithContext is the same as GetDisks with the addition of +// the ability to pass a context and additional request options. +// +// See GetDisks for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) GetDisksWithContext(ctx aws.Context, input *GetDisksInput, opts ...request.Option) (*GetDisksOutput, error) { + req, out := c.GetDisksRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opGetDomain = "GetDomain" + +// GetDomainRequest generates a "aws/request.Request" representing the +// client's request for the GetDomain operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See GetDomain for more information on using the GetDomain +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the GetDomainRequest method. +// req, resp := client.GetDomainRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/GetDomain +func (c *Lightsail) GetDomainRequest(input *GetDomainInput) (req *request.Request, output *GetDomainOutput) { + op := &request.Operation{ + Name: opGetDomain, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &GetDomainInput{} + } + + output = &GetDomainOutput{} + req = c.newRequest(op, input, output) + return +} + +// GetDomain API operation for Amazon Lightsail. +// +// Returns information about a specific domain recordset. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation GetDomain for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/GetDomain +func (c *Lightsail) GetDomain(input *GetDomainInput) (*GetDomainOutput, error) { + req, out := c.GetDomainRequest(input) + return out, req.Send() +} + +// GetDomainWithContext is the same as GetDomain with the addition of +// the ability to pass a context and additional request options. +// +// See GetDomain for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) GetDomainWithContext(ctx aws.Context, input *GetDomainInput, opts ...request.Option) (*GetDomainOutput, error) { + req, out := c.GetDomainRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opGetDomains = "GetDomains" + +// GetDomainsRequest generates a "aws/request.Request" representing the +// client's request for the GetDomains operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See GetDomains for more information on using the GetDomains +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the GetDomainsRequest method. +// req, resp := client.GetDomainsRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/GetDomains +func (c *Lightsail) GetDomainsRequest(input *GetDomainsInput) (req *request.Request, output *GetDomainsOutput) { + op := &request.Operation{ + Name: opGetDomains, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &GetDomainsInput{} + } + + output = &GetDomainsOutput{} + req = c.newRequest(op, input, output) + return +} + +// GetDomains API operation for Amazon Lightsail. +// +// Returns a list of all domains in the user's account. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation GetDomains for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/GetDomains +func (c *Lightsail) GetDomains(input *GetDomainsInput) (*GetDomainsOutput, error) { + req, out := c.GetDomainsRequest(input) + return out, req.Send() +} + +// GetDomainsWithContext is the same as GetDomains with the addition of +// the ability to pass a context and additional request options. +// +// See GetDomains for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) GetDomainsWithContext(ctx aws.Context, input *GetDomainsInput, opts ...request.Option) (*GetDomainsOutput, error) { + req, out := c.GetDomainsRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opGetInstance = "GetInstance" + +// GetInstanceRequest generates a "aws/request.Request" representing the +// client's request for the GetInstance operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See GetInstance for more information on using the GetInstance +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the GetInstanceRequest method. +// req, resp := client.GetInstanceRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/GetInstance +func (c *Lightsail) GetInstanceRequest(input *GetInstanceInput) (req *request.Request, output *GetInstanceOutput) { + op := &request.Operation{ + Name: opGetInstance, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &GetInstanceInput{} + } + + output = &GetInstanceOutput{} + req = c.newRequest(op, input, output) + return +} + +// GetInstance API operation for Amazon Lightsail. +// +// Returns information about a specific Amazon Lightsail instance, which is +// a virtual private server. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation GetInstance for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/GetInstance +func (c *Lightsail) GetInstance(input *GetInstanceInput) (*GetInstanceOutput, error) { + req, out := c.GetInstanceRequest(input) + return out, req.Send() +} + +// GetInstanceWithContext is the same as GetInstance with the addition of +// the ability to pass a context and additional request options. +// +// See GetInstance for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) GetInstanceWithContext(ctx aws.Context, input *GetInstanceInput, opts ...request.Option) (*GetInstanceOutput, error) { + req, out := c.GetInstanceRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opGetInstanceAccessDetails = "GetInstanceAccessDetails" + +// GetInstanceAccessDetailsRequest generates a "aws/request.Request" representing the +// client's request for the GetInstanceAccessDetails operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See GetInstanceAccessDetails for more information on using the GetInstanceAccessDetails +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the GetInstanceAccessDetailsRequest method. +// req, resp := client.GetInstanceAccessDetailsRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/GetInstanceAccessDetails +func (c *Lightsail) GetInstanceAccessDetailsRequest(input *GetInstanceAccessDetailsInput) (req *request.Request, output *GetInstanceAccessDetailsOutput) { + op := &request.Operation{ + Name: opGetInstanceAccessDetails, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &GetInstanceAccessDetailsInput{} + } + + output = &GetInstanceAccessDetailsOutput{} + req = c.newRequest(op, input, output) + return +} + +// GetInstanceAccessDetails API operation for Amazon Lightsail. +// +// Returns temporary SSH keys you can use to connect to a specific virtual private +// server, or instance. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation GetInstanceAccessDetails for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/GetInstanceAccessDetails +func (c *Lightsail) GetInstanceAccessDetails(input *GetInstanceAccessDetailsInput) (*GetInstanceAccessDetailsOutput, error) { + req, out := c.GetInstanceAccessDetailsRequest(input) + return out, req.Send() +} + +// GetInstanceAccessDetailsWithContext is the same as GetInstanceAccessDetails with the addition of +// the ability to pass a context and additional request options. +// +// See GetInstanceAccessDetails for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) GetInstanceAccessDetailsWithContext(ctx aws.Context, input *GetInstanceAccessDetailsInput, opts ...request.Option) (*GetInstanceAccessDetailsOutput, error) { + req, out := c.GetInstanceAccessDetailsRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opGetInstanceMetricData = "GetInstanceMetricData" + +// GetInstanceMetricDataRequest generates a "aws/request.Request" representing the +// client's request for the GetInstanceMetricData operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See GetInstanceMetricData for more information on using the GetInstanceMetricData +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the GetInstanceMetricDataRequest method. +// req, resp := client.GetInstanceMetricDataRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/GetInstanceMetricData +func (c *Lightsail) GetInstanceMetricDataRequest(input *GetInstanceMetricDataInput) (req *request.Request, output *GetInstanceMetricDataOutput) { + op := &request.Operation{ + Name: opGetInstanceMetricData, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &GetInstanceMetricDataInput{} + } + + output = &GetInstanceMetricDataOutput{} + req = c.newRequest(op, input, output) + return +} + +// GetInstanceMetricData API operation for Amazon Lightsail. +// +// Returns the data points for the specified Amazon Lightsail instance metric, +// given an instance name. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation GetInstanceMetricData for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/GetInstanceMetricData +func (c *Lightsail) GetInstanceMetricData(input *GetInstanceMetricDataInput) (*GetInstanceMetricDataOutput, error) { + req, out := c.GetInstanceMetricDataRequest(input) + return out, req.Send() +} + +// GetInstanceMetricDataWithContext is the same as GetInstanceMetricData with the addition of +// the ability to pass a context and additional request options. +// +// See GetInstanceMetricData for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) GetInstanceMetricDataWithContext(ctx aws.Context, input *GetInstanceMetricDataInput, opts ...request.Option) (*GetInstanceMetricDataOutput, error) { + req, out := c.GetInstanceMetricDataRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opGetInstancePortStates = "GetInstancePortStates" + +// GetInstancePortStatesRequest generates a "aws/request.Request" representing the +// client's request for the GetInstancePortStates operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See GetInstancePortStates for more information on using the GetInstancePortStates +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the GetInstancePortStatesRequest method. +// req, resp := client.GetInstancePortStatesRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/GetInstancePortStates +func (c *Lightsail) GetInstancePortStatesRequest(input *GetInstancePortStatesInput) (req *request.Request, output *GetInstancePortStatesOutput) { + op := &request.Operation{ + Name: opGetInstancePortStates, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &GetInstancePortStatesInput{} + } + + output = &GetInstancePortStatesOutput{} + req = c.newRequest(op, input, output) + return +} + +// GetInstancePortStates API operation for Amazon Lightsail. +// +// Returns the port states for a specific virtual private server, or instance. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation GetInstancePortStates for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/GetInstancePortStates +func (c *Lightsail) GetInstancePortStates(input *GetInstancePortStatesInput) (*GetInstancePortStatesOutput, error) { + req, out := c.GetInstancePortStatesRequest(input) + return out, req.Send() +} + +// GetInstancePortStatesWithContext is the same as GetInstancePortStates with the addition of +// the ability to pass a context and additional request options. +// +// See GetInstancePortStates for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) GetInstancePortStatesWithContext(ctx aws.Context, input *GetInstancePortStatesInput, opts ...request.Option) (*GetInstancePortStatesOutput, error) { + req, out := c.GetInstancePortStatesRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opGetInstanceSnapshot = "GetInstanceSnapshot" + +// GetInstanceSnapshotRequest generates a "aws/request.Request" representing the +// client's request for the GetInstanceSnapshot operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See GetInstanceSnapshot for more information on using the GetInstanceSnapshot +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the GetInstanceSnapshotRequest method. +// req, resp := client.GetInstanceSnapshotRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/GetInstanceSnapshot +func (c *Lightsail) GetInstanceSnapshotRequest(input *GetInstanceSnapshotInput) (req *request.Request, output *GetInstanceSnapshotOutput) { + op := &request.Operation{ + Name: opGetInstanceSnapshot, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &GetInstanceSnapshotInput{} + } + + output = &GetInstanceSnapshotOutput{} + req = c.newRequest(op, input, output) + return +} + +// GetInstanceSnapshot API operation for Amazon Lightsail. +// +// Returns information about a specific instance snapshot. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation GetInstanceSnapshot for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/GetInstanceSnapshot +func (c *Lightsail) GetInstanceSnapshot(input *GetInstanceSnapshotInput) (*GetInstanceSnapshotOutput, error) { + req, out := c.GetInstanceSnapshotRequest(input) + return out, req.Send() +} + +// GetInstanceSnapshotWithContext is the same as GetInstanceSnapshot with the addition of +// the ability to pass a context and additional request options. +// +// See GetInstanceSnapshot for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) GetInstanceSnapshotWithContext(ctx aws.Context, input *GetInstanceSnapshotInput, opts ...request.Option) (*GetInstanceSnapshotOutput, error) { + req, out := c.GetInstanceSnapshotRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opGetInstanceSnapshots = "GetInstanceSnapshots" + +// GetInstanceSnapshotsRequest generates a "aws/request.Request" representing the +// client's request for the GetInstanceSnapshots operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See GetInstanceSnapshots for more information on using the GetInstanceSnapshots +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the GetInstanceSnapshotsRequest method. +// req, resp := client.GetInstanceSnapshotsRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/GetInstanceSnapshots +func (c *Lightsail) GetInstanceSnapshotsRequest(input *GetInstanceSnapshotsInput) (req *request.Request, output *GetInstanceSnapshotsOutput) { + op := &request.Operation{ + Name: opGetInstanceSnapshots, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &GetInstanceSnapshotsInput{} + } + + output = &GetInstanceSnapshotsOutput{} + req = c.newRequest(op, input, output) + return +} + +// GetInstanceSnapshots API operation for Amazon Lightsail. +// +// Returns all instance snapshots for the user's account. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation GetInstanceSnapshots for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/GetInstanceSnapshots +func (c *Lightsail) GetInstanceSnapshots(input *GetInstanceSnapshotsInput) (*GetInstanceSnapshotsOutput, error) { + req, out := c.GetInstanceSnapshotsRequest(input) + return out, req.Send() +} + +// GetInstanceSnapshotsWithContext is the same as GetInstanceSnapshots with the addition of +// the ability to pass a context and additional request options. +// +// See GetInstanceSnapshots for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) GetInstanceSnapshotsWithContext(ctx aws.Context, input *GetInstanceSnapshotsInput, opts ...request.Option) (*GetInstanceSnapshotsOutput, error) { + req, out := c.GetInstanceSnapshotsRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opGetInstanceState = "GetInstanceState" + +// GetInstanceStateRequest generates a "aws/request.Request" representing the +// client's request for the GetInstanceState operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See GetInstanceState for more information on using the GetInstanceState +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the GetInstanceStateRequest method. +// req, resp := client.GetInstanceStateRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/GetInstanceState +func (c *Lightsail) GetInstanceStateRequest(input *GetInstanceStateInput) (req *request.Request, output *GetInstanceStateOutput) { + op := &request.Operation{ + Name: opGetInstanceState, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &GetInstanceStateInput{} + } + + output = &GetInstanceStateOutput{} + req = c.newRequest(op, input, output) + return +} + +// GetInstanceState API operation for Amazon Lightsail. +// +// Returns the state of a specific instance. Works on one instance at a time. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation GetInstanceState for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/GetInstanceState +func (c *Lightsail) GetInstanceState(input *GetInstanceStateInput) (*GetInstanceStateOutput, error) { + req, out := c.GetInstanceStateRequest(input) + return out, req.Send() +} + +// GetInstanceStateWithContext is the same as GetInstanceState with the addition of +// the ability to pass a context and additional request options. +// +// See GetInstanceState for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) GetInstanceStateWithContext(ctx aws.Context, input *GetInstanceStateInput, opts ...request.Option) (*GetInstanceStateOutput, error) { + req, out := c.GetInstanceStateRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opGetInstances = "GetInstances" + +// GetInstancesRequest generates a "aws/request.Request" representing the +// client's request for the GetInstances operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See GetInstances for more information on using the GetInstances +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the GetInstancesRequest method. +// req, resp := client.GetInstancesRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/GetInstances +func (c *Lightsail) GetInstancesRequest(input *GetInstancesInput) (req *request.Request, output *GetInstancesOutput) { + op := &request.Operation{ + Name: opGetInstances, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &GetInstancesInput{} + } + + output = &GetInstancesOutput{} + req = c.newRequest(op, input, output) + return +} + +// GetInstances API operation for Amazon Lightsail. +// +// Returns information about all Amazon Lightsail virtual private servers, or +// instances. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation GetInstances for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/GetInstances +func (c *Lightsail) GetInstances(input *GetInstancesInput) (*GetInstancesOutput, error) { + req, out := c.GetInstancesRequest(input) + return out, req.Send() +} + +// GetInstancesWithContext is the same as GetInstances with the addition of +// the ability to pass a context and additional request options. +// +// See GetInstances for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) GetInstancesWithContext(ctx aws.Context, input *GetInstancesInput, opts ...request.Option) (*GetInstancesOutput, error) { + req, out := c.GetInstancesRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opGetKeyPair = "GetKeyPair" + +// GetKeyPairRequest generates a "aws/request.Request" representing the +// client's request for the GetKeyPair operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See GetKeyPair for more information on using the GetKeyPair +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the GetKeyPairRequest method. +// req, resp := client.GetKeyPairRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/GetKeyPair +func (c *Lightsail) GetKeyPairRequest(input *GetKeyPairInput) (req *request.Request, output *GetKeyPairOutput) { + op := &request.Operation{ + Name: opGetKeyPair, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &GetKeyPairInput{} + } + + output = &GetKeyPairOutput{} + req = c.newRequest(op, input, output) + return +} + +// GetKeyPair API operation for Amazon Lightsail. +// +// Returns information about a specific key pair. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation GetKeyPair for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/GetKeyPair +func (c *Lightsail) GetKeyPair(input *GetKeyPairInput) (*GetKeyPairOutput, error) { + req, out := c.GetKeyPairRequest(input) + return out, req.Send() +} + +// GetKeyPairWithContext is the same as GetKeyPair with the addition of +// the ability to pass a context and additional request options. +// +// See GetKeyPair for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) GetKeyPairWithContext(ctx aws.Context, input *GetKeyPairInput, opts ...request.Option) (*GetKeyPairOutput, error) { + req, out := c.GetKeyPairRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opGetKeyPairs = "GetKeyPairs" + +// GetKeyPairsRequest generates a "aws/request.Request" representing the +// client's request for the GetKeyPairs operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See GetKeyPairs for more information on using the GetKeyPairs +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the GetKeyPairsRequest method. +// req, resp := client.GetKeyPairsRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/GetKeyPairs +func (c *Lightsail) GetKeyPairsRequest(input *GetKeyPairsInput) (req *request.Request, output *GetKeyPairsOutput) { + op := &request.Operation{ + Name: opGetKeyPairs, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &GetKeyPairsInput{} + } + + output = &GetKeyPairsOutput{} + req = c.newRequest(op, input, output) + return +} + +// GetKeyPairs API operation for Amazon Lightsail. +// +// Returns information about all key pairs in the user's account. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation GetKeyPairs for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/GetKeyPairs +func (c *Lightsail) GetKeyPairs(input *GetKeyPairsInput) (*GetKeyPairsOutput, error) { + req, out := c.GetKeyPairsRequest(input) + return out, req.Send() +} + +// GetKeyPairsWithContext is the same as GetKeyPairs with the addition of +// the ability to pass a context and additional request options. +// +// See GetKeyPairs for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) GetKeyPairsWithContext(ctx aws.Context, input *GetKeyPairsInput, opts ...request.Option) (*GetKeyPairsOutput, error) { + req, out := c.GetKeyPairsRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opGetLoadBalancer = "GetLoadBalancer" + +// GetLoadBalancerRequest generates a "aws/request.Request" representing the +// client's request for the GetLoadBalancer operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See GetLoadBalancer for more information on using the GetLoadBalancer +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the GetLoadBalancerRequest method. +// req, resp := client.GetLoadBalancerRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/GetLoadBalancer +func (c *Lightsail) GetLoadBalancerRequest(input *GetLoadBalancerInput) (req *request.Request, output *GetLoadBalancerOutput) { + op := &request.Operation{ + Name: opGetLoadBalancer, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &GetLoadBalancerInput{} + } + + output = &GetLoadBalancerOutput{} + req = c.newRequest(op, input, output) + return +} + +// GetLoadBalancer API operation for Amazon Lightsail. +// +// Returns information about the specified Lightsail load balancer. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation GetLoadBalancer for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/GetLoadBalancer +func (c *Lightsail) GetLoadBalancer(input *GetLoadBalancerInput) (*GetLoadBalancerOutput, error) { + req, out := c.GetLoadBalancerRequest(input) + return out, req.Send() +} + +// GetLoadBalancerWithContext is the same as GetLoadBalancer with the addition of +// the ability to pass a context and additional request options. +// +// See GetLoadBalancer for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) GetLoadBalancerWithContext(ctx aws.Context, input *GetLoadBalancerInput, opts ...request.Option) (*GetLoadBalancerOutput, error) { + req, out := c.GetLoadBalancerRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opGetLoadBalancerMetricData = "GetLoadBalancerMetricData" + +// GetLoadBalancerMetricDataRequest generates a "aws/request.Request" representing the +// client's request for the GetLoadBalancerMetricData operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See GetLoadBalancerMetricData for more information on using the GetLoadBalancerMetricData +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the GetLoadBalancerMetricDataRequest method. +// req, resp := client.GetLoadBalancerMetricDataRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/GetLoadBalancerMetricData +func (c *Lightsail) GetLoadBalancerMetricDataRequest(input *GetLoadBalancerMetricDataInput) (req *request.Request, output *GetLoadBalancerMetricDataOutput) { + op := &request.Operation{ + Name: opGetLoadBalancerMetricData, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &GetLoadBalancerMetricDataInput{} + } + + output = &GetLoadBalancerMetricDataOutput{} + req = c.newRequest(op, input, output) + return +} + +// GetLoadBalancerMetricData API operation for Amazon Lightsail. +// +// Returns information about health metrics for your Lightsail load balancer. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation GetLoadBalancerMetricData for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/GetLoadBalancerMetricData +func (c *Lightsail) GetLoadBalancerMetricData(input *GetLoadBalancerMetricDataInput) (*GetLoadBalancerMetricDataOutput, error) { + req, out := c.GetLoadBalancerMetricDataRequest(input) + return out, req.Send() +} + +// GetLoadBalancerMetricDataWithContext is the same as GetLoadBalancerMetricData with the addition of +// the ability to pass a context and additional request options. +// +// See GetLoadBalancerMetricData for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) GetLoadBalancerMetricDataWithContext(ctx aws.Context, input *GetLoadBalancerMetricDataInput, opts ...request.Option) (*GetLoadBalancerMetricDataOutput, error) { + req, out := c.GetLoadBalancerMetricDataRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opGetLoadBalancerTlsCertificates = "GetLoadBalancerTlsCertificates" + +// GetLoadBalancerTlsCertificatesRequest generates a "aws/request.Request" representing the +// client's request for the GetLoadBalancerTlsCertificates operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See GetLoadBalancerTlsCertificates for more information on using the GetLoadBalancerTlsCertificates +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the GetLoadBalancerTlsCertificatesRequest method. +// req, resp := client.GetLoadBalancerTlsCertificatesRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/GetLoadBalancerTlsCertificates +func (c *Lightsail) GetLoadBalancerTlsCertificatesRequest(input *GetLoadBalancerTlsCertificatesInput) (req *request.Request, output *GetLoadBalancerTlsCertificatesOutput) { + op := &request.Operation{ + Name: opGetLoadBalancerTlsCertificates, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &GetLoadBalancerTlsCertificatesInput{} + } + + output = &GetLoadBalancerTlsCertificatesOutput{} + req = c.newRequest(op, input, output) + return +} + +// GetLoadBalancerTlsCertificates API operation for Amazon Lightsail. +// +// Returns information about the TLS certificates that are associated with the +// specified Lightsail load balancer. +// +// TLS is just an updated, more secure version of Secure Socket Layer (SSL). +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation GetLoadBalancerTlsCertificates for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/GetLoadBalancerTlsCertificates +func (c *Lightsail) GetLoadBalancerTlsCertificates(input *GetLoadBalancerTlsCertificatesInput) (*GetLoadBalancerTlsCertificatesOutput, error) { + req, out := c.GetLoadBalancerTlsCertificatesRequest(input) + return out, req.Send() +} + +// GetLoadBalancerTlsCertificatesWithContext is the same as GetLoadBalancerTlsCertificates with the addition of +// the ability to pass a context and additional request options. +// +// See GetLoadBalancerTlsCertificates for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) GetLoadBalancerTlsCertificatesWithContext(ctx aws.Context, input *GetLoadBalancerTlsCertificatesInput, opts ...request.Option) (*GetLoadBalancerTlsCertificatesOutput, error) { + req, out := c.GetLoadBalancerTlsCertificatesRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opGetLoadBalancers = "GetLoadBalancers" + +// GetLoadBalancersRequest generates a "aws/request.Request" representing the +// client's request for the GetLoadBalancers operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See GetLoadBalancers for more information on using the GetLoadBalancers +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the GetLoadBalancersRequest method. +// req, resp := client.GetLoadBalancersRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/GetLoadBalancers +func (c *Lightsail) GetLoadBalancersRequest(input *GetLoadBalancersInput) (req *request.Request, output *GetLoadBalancersOutput) { + op := &request.Operation{ + Name: opGetLoadBalancers, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &GetLoadBalancersInput{} + } + + output = &GetLoadBalancersOutput{} + req = c.newRequest(op, input, output) + return +} + +// GetLoadBalancers API operation for Amazon Lightsail. +// +// Returns information about all load balancers in an account. +// +// If you are describing a long list of load balancers, you can paginate the +// output to make the list more manageable. You can use the pageToken and nextPageToken +// values to retrieve the next items in the list. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation GetLoadBalancers for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/GetLoadBalancers +func (c *Lightsail) GetLoadBalancers(input *GetLoadBalancersInput) (*GetLoadBalancersOutput, error) { + req, out := c.GetLoadBalancersRequest(input) + return out, req.Send() +} + +// GetLoadBalancersWithContext is the same as GetLoadBalancers with the addition of +// the ability to pass a context and additional request options. +// +// See GetLoadBalancers for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) GetLoadBalancersWithContext(ctx aws.Context, input *GetLoadBalancersInput, opts ...request.Option) (*GetLoadBalancersOutput, error) { + req, out := c.GetLoadBalancersRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opGetOperation = "GetOperation" + +// GetOperationRequest generates a "aws/request.Request" representing the +// client's request for the GetOperation operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See GetOperation for more information on using the GetOperation +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the GetOperationRequest method. +// req, resp := client.GetOperationRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/GetOperation +func (c *Lightsail) GetOperationRequest(input *GetOperationInput) (req *request.Request, output *GetOperationOutput) { + op := &request.Operation{ + Name: opGetOperation, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &GetOperationInput{} + } + + output = &GetOperationOutput{} + req = c.newRequest(op, input, output) + return +} + +// GetOperation API operation for Amazon Lightsail. +// +// Returns information about a specific operation. Operations include events +// such as when you create an instance, allocate a static IP, attach a static +// IP, and so on. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation GetOperation for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/GetOperation +func (c *Lightsail) GetOperation(input *GetOperationInput) (*GetOperationOutput, error) { + req, out := c.GetOperationRequest(input) + return out, req.Send() +} + +// GetOperationWithContext is the same as GetOperation with the addition of +// the ability to pass a context and additional request options. +// +// See GetOperation for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) GetOperationWithContext(ctx aws.Context, input *GetOperationInput, opts ...request.Option) (*GetOperationOutput, error) { + req, out := c.GetOperationRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opGetOperations = "GetOperations" + +// GetOperationsRequest generates a "aws/request.Request" representing the +// client's request for the GetOperations operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See GetOperations for more information on using the GetOperations +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the GetOperationsRequest method. +// req, resp := client.GetOperationsRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/GetOperations +func (c *Lightsail) GetOperationsRequest(input *GetOperationsInput) (req *request.Request, output *GetOperationsOutput) { + op := &request.Operation{ + Name: opGetOperations, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &GetOperationsInput{} + } + + output = &GetOperationsOutput{} + req = c.newRequest(op, input, output) + return +} + +// GetOperations API operation for Amazon Lightsail. +// +// Returns information about all operations. +// +// Results are returned from oldest to newest, up to a maximum of 200. Results +// can be paged by making each subsequent call to GetOperations use the maximum +// (last) statusChangedAt value from the previous request. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation GetOperations for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/GetOperations +func (c *Lightsail) GetOperations(input *GetOperationsInput) (*GetOperationsOutput, error) { + req, out := c.GetOperationsRequest(input) + return out, req.Send() +} + +// GetOperationsWithContext is the same as GetOperations with the addition of +// the ability to pass a context and additional request options. +// +// See GetOperations for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) GetOperationsWithContext(ctx aws.Context, input *GetOperationsInput, opts ...request.Option) (*GetOperationsOutput, error) { + req, out := c.GetOperationsRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opGetOperationsForResource = "GetOperationsForResource" + +// GetOperationsForResourceRequest generates a "aws/request.Request" representing the +// client's request for the GetOperationsForResource operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See GetOperationsForResource for more information on using the GetOperationsForResource +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the GetOperationsForResourceRequest method. +// req, resp := client.GetOperationsForResourceRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/GetOperationsForResource +func (c *Lightsail) GetOperationsForResourceRequest(input *GetOperationsForResourceInput) (req *request.Request, output *GetOperationsForResourceOutput) { + op := &request.Operation{ + Name: opGetOperationsForResource, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &GetOperationsForResourceInput{} + } + + output = &GetOperationsForResourceOutput{} + req = c.newRequest(op, input, output) + return +} + +// GetOperationsForResource API operation for Amazon Lightsail. +// +// Gets operations for a specific resource (e.g., an instance or a static IP). +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation GetOperationsForResource for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/GetOperationsForResource +func (c *Lightsail) GetOperationsForResource(input *GetOperationsForResourceInput) (*GetOperationsForResourceOutput, error) { + req, out := c.GetOperationsForResourceRequest(input) + return out, req.Send() +} + +// GetOperationsForResourceWithContext is the same as GetOperationsForResource with the addition of +// the ability to pass a context and additional request options. +// +// See GetOperationsForResource for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) GetOperationsForResourceWithContext(ctx aws.Context, input *GetOperationsForResourceInput, opts ...request.Option) (*GetOperationsForResourceOutput, error) { + req, out := c.GetOperationsForResourceRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opGetRegions = "GetRegions" + +// GetRegionsRequest generates a "aws/request.Request" representing the +// client's request for the GetRegions operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See GetRegions for more information on using the GetRegions +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the GetRegionsRequest method. +// req, resp := client.GetRegionsRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/GetRegions +func (c *Lightsail) GetRegionsRequest(input *GetRegionsInput) (req *request.Request, output *GetRegionsOutput) { + op := &request.Operation{ + Name: opGetRegions, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &GetRegionsInput{} + } + + output = &GetRegionsOutput{} + req = c.newRequest(op, input, output) + return +} + +// GetRegions API operation for Amazon Lightsail. +// +// Returns a list of all valid regions for Amazon Lightsail. Use the include +// availability zones parameter to also return the availability zones in a region. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation GetRegions for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/GetRegions +func (c *Lightsail) GetRegions(input *GetRegionsInput) (*GetRegionsOutput, error) { + req, out := c.GetRegionsRequest(input) + return out, req.Send() +} + +// GetRegionsWithContext is the same as GetRegions with the addition of +// the ability to pass a context and additional request options. +// +// See GetRegions for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) GetRegionsWithContext(ctx aws.Context, input *GetRegionsInput, opts ...request.Option) (*GetRegionsOutput, error) { + req, out := c.GetRegionsRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opGetStaticIp = "GetStaticIp" + +// GetStaticIpRequest generates a "aws/request.Request" representing the +// client's request for the GetStaticIp operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See GetStaticIp for more information on using the GetStaticIp +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the GetStaticIpRequest method. +// req, resp := client.GetStaticIpRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/GetStaticIp +func (c *Lightsail) GetStaticIpRequest(input *GetStaticIpInput) (req *request.Request, output *GetStaticIpOutput) { + op := &request.Operation{ + Name: opGetStaticIp, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &GetStaticIpInput{} + } + + output = &GetStaticIpOutput{} + req = c.newRequest(op, input, output) + return +} + +// GetStaticIp API operation for Amazon Lightsail. +// +// Returns information about a specific static IP. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation GetStaticIp for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/GetStaticIp +func (c *Lightsail) GetStaticIp(input *GetStaticIpInput) (*GetStaticIpOutput, error) { + req, out := c.GetStaticIpRequest(input) + return out, req.Send() +} + +// GetStaticIpWithContext is the same as GetStaticIp with the addition of +// the ability to pass a context and additional request options. +// +// See GetStaticIp for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) GetStaticIpWithContext(ctx aws.Context, input *GetStaticIpInput, opts ...request.Option) (*GetStaticIpOutput, error) { + req, out := c.GetStaticIpRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opGetStaticIps = "GetStaticIps" + +// GetStaticIpsRequest generates a "aws/request.Request" representing the +// client's request for the GetStaticIps operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See GetStaticIps for more information on using the GetStaticIps +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the GetStaticIpsRequest method. +// req, resp := client.GetStaticIpsRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/GetStaticIps +func (c *Lightsail) GetStaticIpsRequest(input *GetStaticIpsInput) (req *request.Request, output *GetStaticIpsOutput) { + op := &request.Operation{ + Name: opGetStaticIps, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &GetStaticIpsInput{} + } + + output = &GetStaticIpsOutput{} + req = c.newRequest(op, input, output) + return +} + +// GetStaticIps API operation for Amazon Lightsail. +// +// Returns information about all static IPs in the user's account. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation GetStaticIps for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/GetStaticIps +func (c *Lightsail) GetStaticIps(input *GetStaticIpsInput) (*GetStaticIpsOutput, error) { + req, out := c.GetStaticIpsRequest(input) + return out, req.Send() +} + +// GetStaticIpsWithContext is the same as GetStaticIps with the addition of +// the ability to pass a context and additional request options. +// +// See GetStaticIps for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) GetStaticIpsWithContext(ctx aws.Context, input *GetStaticIpsInput, opts ...request.Option) (*GetStaticIpsOutput, error) { + req, out := c.GetStaticIpsRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opImportKeyPair = "ImportKeyPair" + +// ImportKeyPairRequest generates a "aws/request.Request" representing the +// client's request for the ImportKeyPair operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See ImportKeyPair for more information on using the ImportKeyPair +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the ImportKeyPairRequest method. +// req, resp := client.ImportKeyPairRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/ImportKeyPair +func (c *Lightsail) ImportKeyPairRequest(input *ImportKeyPairInput) (req *request.Request, output *ImportKeyPairOutput) { + op := &request.Operation{ + Name: opImportKeyPair, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &ImportKeyPairInput{} + } + + output = &ImportKeyPairOutput{} + req = c.newRequest(op, input, output) + return +} + +// ImportKeyPair API operation for Amazon Lightsail. +// +// Imports a public SSH key from a specific key pair. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation ImportKeyPair for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/ImportKeyPair +func (c *Lightsail) ImportKeyPair(input *ImportKeyPairInput) (*ImportKeyPairOutput, error) { + req, out := c.ImportKeyPairRequest(input) + return out, req.Send() +} + +// ImportKeyPairWithContext is the same as ImportKeyPair with the addition of +// the ability to pass a context and additional request options. +// +// See ImportKeyPair for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) ImportKeyPairWithContext(ctx aws.Context, input *ImportKeyPairInput, opts ...request.Option) (*ImportKeyPairOutput, error) { + req, out := c.ImportKeyPairRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opIsVpcPeered = "IsVpcPeered" + +// IsVpcPeeredRequest generates a "aws/request.Request" representing the +// client's request for the IsVpcPeered operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See IsVpcPeered for more information on using the IsVpcPeered +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the IsVpcPeeredRequest method. +// req, resp := client.IsVpcPeeredRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/IsVpcPeered +func (c *Lightsail) IsVpcPeeredRequest(input *IsVpcPeeredInput) (req *request.Request, output *IsVpcPeeredOutput) { + op := &request.Operation{ + Name: opIsVpcPeered, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &IsVpcPeeredInput{} + } + + output = &IsVpcPeeredOutput{} + req = c.newRequest(op, input, output) + return +} + +// IsVpcPeered API operation for Amazon Lightsail. +// +// Returns a Boolean value indicating whether your Lightsail VPC is peered. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation IsVpcPeered for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/IsVpcPeered +func (c *Lightsail) IsVpcPeered(input *IsVpcPeeredInput) (*IsVpcPeeredOutput, error) { + req, out := c.IsVpcPeeredRequest(input) + return out, req.Send() +} + +// IsVpcPeeredWithContext is the same as IsVpcPeered with the addition of +// the ability to pass a context and additional request options. +// +// See IsVpcPeered for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) IsVpcPeeredWithContext(ctx aws.Context, input *IsVpcPeeredInput, opts ...request.Option) (*IsVpcPeeredOutput, error) { + req, out := c.IsVpcPeeredRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opOpenInstancePublicPorts = "OpenInstancePublicPorts" + +// OpenInstancePublicPortsRequest generates a "aws/request.Request" representing the +// client's request for the OpenInstancePublicPorts operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See OpenInstancePublicPorts for more information on using the OpenInstancePublicPorts +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the OpenInstancePublicPortsRequest method. +// req, resp := client.OpenInstancePublicPortsRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/OpenInstancePublicPorts +func (c *Lightsail) OpenInstancePublicPortsRequest(input *OpenInstancePublicPortsInput) (req *request.Request, output *OpenInstancePublicPortsOutput) { + op := &request.Operation{ + Name: opOpenInstancePublicPorts, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &OpenInstancePublicPortsInput{} + } + + output = &OpenInstancePublicPortsOutput{} + req = c.newRequest(op, input, output) + return +} + +// OpenInstancePublicPorts API operation for Amazon Lightsail. +// +// Adds public ports to an Amazon Lightsail instance. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation OpenInstancePublicPorts for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/OpenInstancePublicPorts +func (c *Lightsail) OpenInstancePublicPorts(input *OpenInstancePublicPortsInput) (*OpenInstancePublicPortsOutput, error) { + req, out := c.OpenInstancePublicPortsRequest(input) + return out, req.Send() +} + +// OpenInstancePublicPortsWithContext is the same as OpenInstancePublicPorts with the addition of +// the ability to pass a context and additional request options. +// +// See OpenInstancePublicPorts for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) OpenInstancePublicPortsWithContext(ctx aws.Context, input *OpenInstancePublicPortsInput, opts ...request.Option) (*OpenInstancePublicPortsOutput, error) { + req, out := c.OpenInstancePublicPortsRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opPeerVpc = "PeerVpc" + +// PeerVpcRequest generates a "aws/request.Request" representing the +// client's request for the PeerVpc operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See PeerVpc for more information on using the PeerVpc +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the PeerVpcRequest method. +// req, resp := client.PeerVpcRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/PeerVpc +func (c *Lightsail) PeerVpcRequest(input *PeerVpcInput) (req *request.Request, output *PeerVpcOutput) { + op := &request.Operation{ + Name: opPeerVpc, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &PeerVpcInput{} + } + + output = &PeerVpcOutput{} + req = c.newRequest(op, input, output) + return +} + +// PeerVpc API operation for Amazon Lightsail. +// +// Tries to peer the Lightsail VPC with the user's default VPC. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation PeerVpc for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/PeerVpc +func (c *Lightsail) PeerVpc(input *PeerVpcInput) (*PeerVpcOutput, error) { + req, out := c.PeerVpcRequest(input) + return out, req.Send() +} + +// PeerVpcWithContext is the same as PeerVpc with the addition of +// the ability to pass a context and additional request options. +// +// See PeerVpc for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) PeerVpcWithContext(ctx aws.Context, input *PeerVpcInput, opts ...request.Option) (*PeerVpcOutput, error) { + req, out := c.PeerVpcRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opPutInstancePublicPorts = "PutInstancePublicPorts" + +// PutInstancePublicPortsRequest generates a "aws/request.Request" representing the +// client's request for the PutInstancePublicPorts operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See PutInstancePublicPorts for more information on using the PutInstancePublicPorts +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the PutInstancePublicPortsRequest method. +// req, resp := client.PutInstancePublicPortsRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/PutInstancePublicPorts +func (c *Lightsail) PutInstancePublicPortsRequest(input *PutInstancePublicPortsInput) (req *request.Request, output *PutInstancePublicPortsOutput) { + op := &request.Operation{ + Name: opPutInstancePublicPorts, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &PutInstancePublicPortsInput{} + } + + output = &PutInstancePublicPortsOutput{} + req = c.newRequest(op, input, output) + return +} + +// PutInstancePublicPorts API operation for Amazon Lightsail. +// +// Sets the specified open ports for an Amazon Lightsail instance, and closes +// all ports for every protocol not included in the current request. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation PutInstancePublicPorts for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/PutInstancePublicPorts +func (c *Lightsail) PutInstancePublicPorts(input *PutInstancePublicPortsInput) (*PutInstancePublicPortsOutput, error) { + req, out := c.PutInstancePublicPortsRequest(input) + return out, req.Send() +} + +// PutInstancePublicPortsWithContext is the same as PutInstancePublicPorts with the addition of +// the ability to pass a context and additional request options. +// +// See PutInstancePublicPorts for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) PutInstancePublicPortsWithContext(ctx aws.Context, input *PutInstancePublicPortsInput, opts ...request.Option) (*PutInstancePublicPortsOutput, error) { + req, out := c.PutInstancePublicPortsRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opRebootInstance = "RebootInstance" + +// RebootInstanceRequest generates a "aws/request.Request" representing the +// client's request for the RebootInstance operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See RebootInstance for more information on using the RebootInstance +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the RebootInstanceRequest method. +// req, resp := client.RebootInstanceRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/RebootInstance +func (c *Lightsail) RebootInstanceRequest(input *RebootInstanceInput) (req *request.Request, output *RebootInstanceOutput) { + op := &request.Operation{ + Name: opRebootInstance, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &RebootInstanceInput{} + } + + output = &RebootInstanceOutput{} + req = c.newRequest(op, input, output) + return +} + +// RebootInstance API operation for Amazon Lightsail. +// +// Restarts a specific instance. When your Amazon Lightsail instance is finished +// rebooting, Lightsail assigns a new public IP address. To use the same IP +// address after restarting, create a static IP address and attach it to the +// instance. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation RebootInstance for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/RebootInstance +func (c *Lightsail) RebootInstance(input *RebootInstanceInput) (*RebootInstanceOutput, error) { + req, out := c.RebootInstanceRequest(input) + return out, req.Send() +} + +// RebootInstanceWithContext is the same as RebootInstance with the addition of +// the ability to pass a context and additional request options. +// +// See RebootInstance for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) RebootInstanceWithContext(ctx aws.Context, input *RebootInstanceInput, opts ...request.Option) (*RebootInstanceOutput, error) { + req, out := c.RebootInstanceRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opReleaseStaticIp = "ReleaseStaticIp" + +// ReleaseStaticIpRequest generates a "aws/request.Request" representing the +// client's request for the ReleaseStaticIp operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See ReleaseStaticIp for more information on using the ReleaseStaticIp +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the ReleaseStaticIpRequest method. +// req, resp := client.ReleaseStaticIpRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/ReleaseStaticIp +func (c *Lightsail) ReleaseStaticIpRequest(input *ReleaseStaticIpInput) (req *request.Request, output *ReleaseStaticIpOutput) { + op := &request.Operation{ + Name: opReleaseStaticIp, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &ReleaseStaticIpInput{} + } + + output = &ReleaseStaticIpOutput{} + req = c.newRequest(op, input, output) + return +} + +// ReleaseStaticIp API operation for Amazon Lightsail. +// +// Deletes a specific static IP from your account. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation ReleaseStaticIp for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/ReleaseStaticIp +func (c *Lightsail) ReleaseStaticIp(input *ReleaseStaticIpInput) (*ReleaseStaticIpOutput, error) { + req, out := c.ReleaseStaticIpRequest(input) + return out, req.Send() +} + +// ReleaseStaticIpWithContext is the same as ReleaseStaticIp with the addition of +// the ability to pass a context and additional request options. +// +// See ReleaseStaticIp for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) ReleaseStaticIpWithContext(ctx aws.Context, input *ReleaseStaticIpInput, opts ...request.Option) (*ReleaseStaticIpOutput, error) { + req, out := c.ReleaseStaticIpRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opStartInstance = "StartInstance" + +// StartInstanceRequest generates a "aws/request.Request" representing the +// client's request for the StartInstance operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See StartInstance for more information on using the StartInstance +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the StartInstanceRequest method. +// req, resp := client.StartInstanceRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/StartInstance +func (c *Lightsail) StartInstanceRequest(input *StartInstanceInput) (req *request.Request, output *StartInstanceOutput) { + op := &request.Operation{ + Name: opStartInstance, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &StartInstanceInput{} + } + + output = &StartInstanceOutput{} + req = c.newRequest(op, input, output) + return +} + +// StartInstance API operation for Amazon Lightsail. +// +// Starts a specific Amazon Lightsail instance from a stopped state. To restart +// an instance, use the reboot instance operation. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation StartInstance for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/StartInstance +func (c *Lightsail) StartInstance(input *StartInstanceInput) (*StartInstanceOutput, error) { + req, out := c.StartInstanceRequest(input) + return out, req.Send() +} + +// StartInstanceWithContext is the same as StartInstance with the addition of +// the ability to pass a context and additional request options. +// +// See StartInstance for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) StartInstanceWithContext(ctx aws.Context, input *StartInstanceInput, opts ...request.Option) (*StartInstanceOutput, error) { + req, out := c.StartInstanceRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opStopInstance = "StopInstance" + +// StopInstanceRequest generates a "aws/request.Request" representing the +// client's request for the StopInstance operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See StopInstance for more information on using the StopInstance +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the StopInstanceRequest method. +// req, resp := client.StopInstanceRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/StopInstance +func (c *Lightsail) StopInstanceRequest(input *StopInstanceInput) (req *request.Request, output *StopInstanceOutput) { + op := &request.Operation{ + Name: opStopInstance, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &StopInstanceInput{} + } + + output = &StopInstanceOutput{} + req = c.newRequest(op, input, output) + return +} + +// StopInstance API operation for Amazon Lightsail. +// +// Stops a specific Amazon Lightsail instance that is currently running. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation StopInstance for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/StopInstance +func (c *Lightsail) StopInstance(input *StopInstanceInput) (*StopInstanceOutput, error) { + req, out := c.StopInstanceRequest(input) + return out, req.Send() +} + +// StopInstanceWithContext is the same as StopInstance with the addition of +// the ability to pass a context and additional request options. +// +// See StopInstance for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) StopInstanceWithContext(ctx aws.Context, input *StopInstanceInput, opts ...request.Option) (*StopInstanceOutput, error) { + req, out := c.StopInstanceRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opUnpeerVpc = "UnpeerVpc" + +// UnpeerVpcRequest generates a "aws/request.Request" representing the +// client's request for the UnpeerVpc operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See UnpeerVpc for more information on using the UnpeerVpc +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the UnpeerVpcRequest method. +// req, resp := client.UnpeerVpcRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/UnpeerVpc +func (c *Lightsail) UnpeerVpcRequest(input *UnpeerVpcInput) (req *request.Request, output *UnpeerVpcOutput) { + op := &request.Operation{ + Name: opUnpeerVpc, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &UnpeerVpcInput{} + } + + output = &UnpeerVpcOutput{} + req = c.newRequest(op, input, output) + return +} + +// UnpeerVpc API operation for Amazon Lightsail. +// +// Attempts to unpeer the Lightsail VPC from the user's default VPC. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation UnpeerVpc for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/UnpeerVpc +func (c *Lightsail) UnpeerVpc(input *UnpeerVpcInput) (*UnpeerVpcOutput, error) { + req, out := c.UnpeerVpcRequest(input) + return out, req.Send() +} + +// UnpeerVpcWithContext is the same as UnpeerVpc with the addition of +// the ability to pass a context and additional request options. +// +// See UnpeerVpc for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) UnpeerVpcWithContext(ctx aws.Context, input *UnpeerVpcInput, opts ...request.Option) (*UnpeerVpcOutput, error) { + req, out := c.UnpeerVpcRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opUpdateDomainEntry = "UpdateDomainEntry" + +// UpdateDomainEntryRequest generates a "aws/request.Request" representing the +// client's request for the UpdateDomainEntry operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See UpdateDomainEntry for more information on using the UpdateDomainEntry +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the UpdateDomainEntryRequest method. +// req, resp := client.UpdateDomainEntryRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/UpdateDomainEntry +func (c *Lightsail) UpdateDomainEntryRequest(input *UpdateDomainEntryInput) (req *request.Request, output *UpdateDomainEntryOutput) { + op := &request.Operation{ + Name: opUpdateDomainEntry, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &UpdateDomainEntryInput{} + } + + output = &UpdateDomainEntryOutput{} + req = c.newRequest(op, input, output) + return +} + +// UpdateDomainEntry API operation for Amazon Lightsail. +// +// Updates a domain recordset after it is created. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation UpdateDomainEntry for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/UpdateDomainEntry +func (c *Lightsail) UpdateDomainEntry(input *UpdateDomainEntryInput) (*UpdateDomainEntryOutput, error) { + req, out := c.UpdateDomainEntryRequest(input) + return out, req.Send() +} + +// UpdateDomainEntryWithContext is the same as UpdateDomainEntry with the addition of +// the ability to pass a context and additional request options. +// +// See UpdateDomainEntry for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) UpdateDomainEntryWithContext(ctx aws.Context, input *UpdateDomainEntryInput, opts ...request.Option) (*UpdateDomainEntryOutput, error) { + req, out := c.UpdateDomainEntryRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +const opUpdateLoadBalancerAttribute = "UpdateLoadBalancerAttribute" + +// UpdateLoadBalancerAttributeRequest generates a "aws/request.Request" representing the +// client's request for the UpdateLoadBalancerAttribute operation. The "output" return +// value will be populated with the request's response once the request complets +// successfuly. +// +// Use "Send" method on the returned Request to send the API call to the service. +// the "output" return value is not valid until after Send returns without error. +// +// See UpdateLoadBalancerAttribute for more information on using the UpdateLoadBalancerAttribute +// API call, and error handling. +// +// This method is useful when you want to inject custom logic or configuration +// into the SDK's request lifecycle. Such as custom headers, or retry logic. +// +// +// // Example sending a request using the UpdateLoadBalancerAttributeRequest method. +// req, resp := client.UpdateLoadBalancerAttributeRequest(params) +// +// err := req.Send() +// if err == nil { // resp is now filled +// fmt.Println(resp) +// } +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/UpdateLoadBalancerAttribute +func (c *Lightsail) UpdateLoadBalancerAttributeRequest(input *UpdateLoadBalancerAttributeInput) (req *request.Request, output *UpdateLoadBalancerAttributeOutput) { + op := &request.Operation{ + Name: opUpdateLoadBalancerAttribute, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &UpdateLoadBalancerAttributeInput{} + } + + output = &UpdateLoadBalancerAttributeOutput{} + req = c.newRequest(op, input, output) + return +} + +// UpdateLoadBalancerAttribute API operation for Amazon Lightsail. +// +// Updates the specified attribute for a load balancer. +// +// Returns awserr.Error for service API and SDK errors. Use runtime type assertions +// with awserr.Error's Code and Message methods to get detailed information about +// the error. +// +// See the AWS API reference guide for Amazon Lightsail's +// API operation UpdateLoadBalancerAttribute for usage and error information. +// +// Returned Error Codes: +// * ErrCodeServiceException "ServiceException" +// A general service exception. +// +// * ErrCodeInvalidInputException "InvalidInputException" +// Lightsail throws this exception when user input does not conform to the validation +// rules of an input field. +// +// Domain-related APIs are only available in the N. Virginia (us-east-1) Region. +// Please set your Region configuration to us-east-1 to create, view, or edit +// these resources. +// +// * ErrCodeNotFoundException "NotFoundException" +// Lightsail throws this exception when it cannot find a resource. +// +// * ErrCodeOperationFailureException "OperationFailureException" +// Lightsail throws this exception when an operation fails to execute. +// +// * ErrCodeAccessDeniedException "AccessDeniedException" +// Lightsail throws this exception when the user cannot be authenticated or +// uses invalid credentials to access a resource. +// +// * ErrCodeAccountSetupInProgressException "AccountSetupInProgressException" +// Lightsail throws this exception when an account is still in the setup in +// progress state. +// +// * ErrCodeUnauthenticatedException "UnauthenticatedException" +// Lightsail throws this exception when the user has not been authenticated. +// +// See also, https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28/UpdateLoadBalancerAttribute +func (c *Lightsail) UpdateLoadBalancerAttribute(input *UpdateLoadBalancerAttributeInput) (*UpdateLoadBalancerAttributeOutput, error) { + req, out := c.UpdateLoadBalancerAttributeRequest(input) + return out, req.Send() +} + +// UpdateLoadBalancerAttributeWithContext is the same as UpdateLoadBalancerAttribute with the addition of +// the ability to pass a context and additional request options. +// +// See UpdateLoadBalancerAttribute for details on how to use this API operation. +// +// The context must be non-nil and will be used for request cancellation. If +// the context is nil a panic will occur. In the future the SDK may create +// sub-contexts for http.Requests. See https://golang.org/pkg/context/ +// for more information on using Contexts. +func (c *Lightsail) UpdateLoadBalancerAttributeWithContext(ctx aws.Context, input *UpdateLoadBalancerAttributeInput, opts ...request.Option) (*UpdateLoadBalancerAttributeOutput, error) { + req, out := c.UpdateLoadBalancerAttributeRequest(input) + req.SetContext(ctx) + req.ApplyOptions(opts...) + return out, req.Send() +} + +type AllocateStaticIpInput struct { + _ struct{} `type:"structure"` + + // The name of the static IP address. + // + // StaticIpName is a required field + StaticIpName *string `locationName:"staticIpName" type:"string" required:"true"` +} + +// String returns the string representation +func (s AllocateStaticIpInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s AllocateStaticIpInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *AllocateStaticIpInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "AllocateStaticIpInput"} + if s.StaticIpName == nil { + invalidParams.Add(request.NewErrParamRequired("StaticIpName")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetStaticIpName sets the StaticIpName field's value. +func (s *AllocateStaticIpInput) SetStaticIpName(v string) *AllocateStaticIpInput { + s.StaticIpName = &v + return s +} + +type AllocateStaticIpOutput struct { + _ struct{} `type:"structure"` + + // An array of key-value pairs containing information about the static IP address + // you allocated. + Operations []*Operation `locationName:"operations" type:"list"` +} + +// String returns the string representation +func (s AllocateStaticIpOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s AllocateStaticIpOutput) GoString() string { + return s.String() +} + +// SetOperations sets the Operations field's value. +func (s *AllocateStaticIpOutput) SetOperations(v []*Operation) *AllocateStaticIpOutput { + s.Operations = v + return s +} + +type AttachDiskInput struct { + _ struct{} `type:"structure"` + + // The unique Lightsail disk name (e.g., my-disk). + // + // DiskName is a required field + DiskName *string `locationName:"diskName" type:"string" required:"true"` + + // The disk path to expose to the instance (e.g., /dev/xvdf). + // + // DiskPath is a required field + DiskPath *string `locationName:"diskPath" type:"string" required:"true"` + + // The name of the Lightsail instance where you want to utilize the storage + // disk. + // + // InstanceName is a required field + InstanceName *string `locationName:"instanceName" type:"string" required:"true"` +} + +// String returns the string representation +func (s AttachDiskInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s AttachDiskInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *AttachDiskInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "AttachDiskInput"} + if s.DiskName == nil { + invalidParams.Add(request.NewErrParamRequired("DiskName")) + } + if s.DiskPath == nil { + invalidParams.Add(request.NewErrParamRequired("DiskPath")) + } + if s.InstanceName == nil { + invalidParams.Add(request.NewErrParamRequired("InstanceName")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetDiskName sets the DiskName field's value. +func (s *AttachDiskInput) SetDiskName(v string) *AttachDiskInput { + s.DiskName = &v + return s +} + +// SetDiskPath sets the DiskPath field's value. +func (s *AttachDiskInput) SetDiskPath(v string) *AttachDiskInput { + s.DiskPath = &v + return s +} + +// SetInstanceName sets the InstanceName field's value. +func (s *AttachDiskInput) SetInstanceName(v string) *AttachDiskInput { + s.InstanceName = &v + return s +} + +type AttachDiskOutput struct { + _ struct{} `type:"structure"` + + // An object describing the API operations. + Operations []*Operation `locationName:"operations" type:"list"` +} + +// String returns the string representation +func (s AttachDiskOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s AttachDiskOutput) GoString() string { + return s.String() +} + +// SetOperations sets the Operations field's value. +func (s *AttachDiskOutput) SetOperations(v []*Operation) *AttachDiskOutput { + s.Operations = v + return s +} + +type AttachInstancesToLoadBalancerInput struct { + _ struct{} `type:"structure"` + + // An array of strings representing the instance name(s) you want to attach + // to your load balancer. + // + // InstanceNames is a required field + InstanceNames []*string `locationName:"instanceNames" type:"list" required:"true"` + + // The name of the load balancer. + // + // LoadBalancerName is a required field + LoadBalancerName *string `locationName:"loadBalancerName" type:"string" required:"true"` +} + +// String returns the string representation +func (s AttachInstancesToLoadBalancerInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s AttachInstancesToLoadBalancerInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *AttachInstancesToLoadBalancerInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "AttachInstancesToLoadBalancerInput"} + if s.InstanceNames == nil { + invalidParams.Add(request.NewErrParamRequired("InstanceNames")) + } + if s.LoadBalancerName == nil { + invalidParams.Add(request.NewErrParamRequired("LoadBalancerName")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetInstanceNames sets the InstanceNames field's value. +func (s *AttachInstancesToLoadBalancerInput) SetInstanceNames(v []*string) *AttachInstancesToLoadBalancerInput { + s.InstanceNames = v + return s +} + +// SetLoadBalancerName sets the LoadBalancerName field's value. +func (s *AttachInstancesToLoadBalancerInput) SetLoadBalancerName(v string) *AttachInstancesToLoadBalancerInput { + s.LoadBalancerName = &v + return s +} + +type AttachInstancesToLoadBalancerOutput struct { + _ struct{} `type:"structure"` + + // An object representing the API operations. + Operations []*Operation `locationName:"operations" type:"list"` +} + +// String returns the string representation +func (s AttachInstancesToLoadBalancerOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s AttachInstancesToLoadBalancerOutput) GoString() string { + return s.String() +} + +// SetOperations sets the Operations field's value. +func (s *AttachInstancesToLoadBalancerOutput) SetOperations(v []*Operation) *AttachInstancesToLoadBalancerOutput { + s.Operations = v + return s +} + +type AttachLoadBalancerTlsCertificateInput struct { + _ struct{} `type:"structure"` + + // The name of your TLS/SSL certificate. + // + // CertificateName is a required field + CertificateName *string `locationName:"certificateName" type:"string" required:"true"` + + // The name of the load balancer to which you want to associate the TLS/SSL + // certificate. + // + // LoadBalancerName is a required field + LoadBalancerName *string `locationName:"loadBalancerName" type:"string" required:"true"` +} + +// String returns the string representation +func (s AttachLoadBalancerTlsCertificateInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s AttachLoadBalancerTlsCertificateInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *AttachLoadBalancerTlsCertificateInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "AttachLoadBalancerTlsCertificateInput"} + if s.CertificateName == nil { + invalidParams.Add(request.NewErrParamRequired("CertificateName")) + } + if s.LoadBalancerName == nil { + invalidParams.Add(request.NewErrParamRequired("LoadBalancerName")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetCertificateName sets the CertificateName field's value. +func (s *AttachLoadBalancerTlsCertificateInput) SetCertificateName(v string) *AttachLoadBalancerTlsCertificateInput { + s.CertificateName = &v + return s +} + +// SetLoadBalancerName sets the LoadBalancerName field's value. +func (s *AttachLoadBalancerTlsCertificateInput) SetLoadBalancerName(v string) *AttachLoadBalancerTlsCertificateInput { + s.LoadBalancerName = &v + return s +} + +type AttachLoadBalancerTlsCertificateOutput struct { + _ struct{} `type:"structure"` + + // An object representing the API operations. + Operations []*Operation `locationName:"operations" type:"list"` +} + +// String returns the string representation +func (s AttachLoadBalancerTlsCertificateOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s AttachLoadBalancerTlsCertificateOutput) GoString() string { + return s.String() +} + +// SetOperations sets the Operations field's value. +func (s *AttachLoadBalancerTlsCertificateOutput) SetOperations(v []*Operation) *AttachLoadBalancerTlsCertificateOutput { + s.Operations = v + return s +} + +type AttachStaticIpInput struct { + _ struct{} `type:"structure"` + + // The instance name to which you want to attach the static IP address. + // + // InstanceName is a required field + InstanceName *string `locationName:"instanceName" type:"string" required:"true"` + + // The name of the static IP. + // + // StaticIpName is a required field + StaticIpName *string `locationName:"staticIpName" type:"string" required:"true"` +} + +// String returns the string representation +func (s AttachStaticIpInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s AttachStaticIpInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *AttachStaticIpInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "AttachStaticIpInput"} + if s.InstanceName == nil { + invalidParams.Add(request.NewErrParamRequired("InstanceName")) + } + if s.StaticIpName == nil { + invalidParams.Add(request.NewErrParamRequired("StaticIpName")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetInstanceName sets the InstanceName field's value. +func (s *AttachStaticIpInput) SetInstanceName(v string) *AttachStaticIpInput { + s.InstanceName = &v + return s +} + +// SetStaticIpName sets the StaticIpName field's value. +func (s *AttachStaticIpInput) SetStaticIpName(v string) *AttachStaticIpInput { + s.StaticIpName = &v + return s +} + +type AttachStaticIpOutput struct { + _ struct{} `type:"structure"` + + // An array of key-value pairs containing information about your API operations. + Operations []*Operation `locationName:"operations" type:"list"` +} + +// String returns the string representation +func (s AttachStaticIpOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s AttachStaticIpOutput) GoString() string { + return s.String() +} + +// SetOperations sets the Operations field's value. +func (s *AttachStaticIpOutput) SetOperations(v []*Operation) *AttachStaticIpOutput { + s.Operations = v + return s +} + +// Describes an Availability Zone. +type AvailabilityZone struct { + _ struct{} `type:"structure"` + + // The state of the Availability Zone. + State *string `locationName:"state" type:"string"` + + // The name of the Availability Zone. The format is us-east-2a (case-sensitive). + ZoneName *string `locationName:"zoneName" type:"string"` +} + +// String returns the string representation +func (s AvailabilityZone) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s AvailabilityZone) GoString() string { + return s.String() +} + +// SetState sets the State field's value. +func (s *AvailabilityZone) SetState(v string) *AvailabilityZone { + s.State = &v + return s +} + +// SetZoneName sets the ZoneName field's value. +func (s *AvailabilityZone) SetZoneName(v string) *AvailabilityZone { + s.ZoneName = &v + return s +} + +// Describes a blueprint (a virtual private server image). +type Blueprint struct { + _ struct{} `type:"structure"` + + // The ID for the virtual private server image (e.g., app_wordpress_4_4 or app_lamp_7_0). + BlueprintId *string `locationName:"blueprintId" type:"string"` + + // The description of the blueprint. + Description *string `locationName:"description" type:"string"` + + // The group name of the blueprint (e.g., amazon-linux). + Group *string `locationName:"group" type:"string"` + + // A Boolean value indicating whether the blueprint is active. When you update + // your blueprints, you will inactivate old blueprints and keep the most recent + // versions active. + IsActive *bool `locationName:"isActive" type:"boolean"` + + // The end-user license agreement URL for the image or blueprint. + LicenseUrl *string `locationName:"licenseUrl" type:"string"` + + // The minimum bundle power required to run this blueprint. For example, you + // need a bundle with a power value of 500 or more to create an instance that + // uses a blueprint with a minimum power value of 500. 0 indicates that the + // blueprint runs on all instance sizes. + MinPower *int64 `locationName:"minPower" type:"integer"` + + // The friendly name of the blueprint (e.g., Amazon Linux). + Name *string `locationName:"name" type:"string"` + + // The operating system platform (either Linux/Unix-based or Windows Server-based) + // of the blueprint. + Platform *string `locationName:"platform" type:"string" enum:"InstancePlatform"` + + // The product URL to learn more about the image or blueprint. + ProductUrl *string `locationName:"productUrl" type:"string"` + + // The type of the blueprint (e.g., os or app). + Type *string `locationName:"type" type:"string" enum:"BlueprintType"` + + // The version number of the operating system, application, or stack (e.g., + // 2016.03.0). + Version *string `locationName:"version" type:"string"` + + // The version code. + VersionCode *string `locationName:"versionCode" type:"string"` +} + +// String returns the string representation +func (s Blueprint) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s Blueprint) GoString() string { + return s.String() +} + +// SetBlueprintId sets the BlueprintId field's value. +func (s *Blueprint) SetBlueprintId(v string) *Blueprint { + s.BlueprintId = &v + return s +} + +// SetDescription sets the Description field's value. +func (s *Blueprint) SetDescription(v string) *Blueprint { + s.Description = &v + return s +} + +// SetGroup sets the Group field's value. +func (s *Blueprint) SetGroup(v string) *Blueprint { + s.Group = &v + return s +} + +// SetIsActive sets the IsActive field's value. +func (s *Blueprint) SetIsActive(v bool) *Blueprint { + s.IsActive = &v + return s +} + +// SetLicenseUrl sets the LicenseUrl field's value. +func (s *Blueprint) SetLicenseUrl(v string) *Blueprint { + s.LicenseUrl = &v + return s +} + +// SetMinPower sets the MinPower field's value. +func (s *Blueprint) SetMinPower(v int64) *Blueprint { + s.MinPower = &v + return s +} + +// SetName sets the Name field's value. +func (s *Blueprint) SetName(v string) *Blueprint { + s.Name = &v + return s +} + +// SetPlatform sets the Platform field's value. +func (s *Blueprint) SetPlatform(v string) *Blueprint { + s.Platform = &v + return s +} + +// SetProductUrl sets the ProductUrl field's value. +func (s *Blueprint) SetProductUrl(v string) *Blueprint { + s.ProductUrl = &v + return s +} + +// SetType sets the Type field's value. +func (s *Blueprint) SetType(v string) *Blueprint { + s.Type = &v + return s +} + +// SetVersion sets the Version field's value. +func (s *Blueprint) SetVersion(v string) *Blueprint { + s.Version = &v + return s +} + +// SetVersionCode sets the VersionCode field's value. +func (s *Blueprint) SetVersionCode(v string) *Blueprint { + s.VersionCode = &v + return s +} + +// Describes a bundle, which is a set of specs describing your virtual private +// server (or instance). +type Bundle struct { + _ struct{} `type:"structure"` + + // The bundle ID (e.g., micro_1_0). + BundleId *string `locationName:"bundleId" type:"string"` + + // The number of vCPUs included in the bundle (e.g., 2). + CpuCount *int64 `locationName:"cpuCount" type:"integer"` + + // The size of the SSD (e.g., 30). + DiskSizeInGb *int64 `locationName:"diskSizeInGb" type:"integer"` + + // The Amazon EC2 instance type (e.g., t2.micro). + InstanceType *string `locationName:"instanceType" type:"string"` + + // A Boolean value indicating whether the bundle is active. + IsActive *bool `locationName:"isActive" type:"boolean"` + + // A friendly name for the bundle (e.g., Micro). + Name *string `locationName:"name" type:"string"` + + // A numeric value that represents the power of the bundle (e.g., 500). You + // can use the bundle's power value in conjunction with a blueprint's minimum + // power value to determine whether the blueprint will run on the bundle. For + // example, you need a bundle with a power value of 500 or more to create an + // instance that uses a blueprint with a minimum power value of 500. + Power *int64 `locationName:"power" type:"integer"` + + // The price in US dollars (e.g., 5.0). + Price *float64 `locationName:"price" type:"float"` + + // The amount of RAM in GB (e.g., 2.0). + RamSizeInGb *float64 `locationName:"ramSizeInGb" type:"float"` + + // The operating system platform (Linux/Unix-based or Windows Server-based) + // that the bundle supports. You can only launch a WINDOWS bundle on a blueprint + // that supports the WINDOWS platform. LINUX_UNIX blueprints require a LINUX_UNIX + // bundle. + SupportedPlatforms []*string `locationName:"supportedPlatforms" type:"list"` + + // The data transfer rate per month in GB (e.g., 2000). + TransferPerMonthInGb *int64 `locationName:"transferPerMonthInGb" type:"integer"` +} + +// String returns the string representation +func (s Bundle) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s Bundle) GoString() string { + return s.String() +} + +// SetBundleId sets the BundleId field's value. +func (s *Bundle) SetBundleId(v string) *Bundle { + s.BundleId = &v + return s +} + +// SetCpuCount sets the CpuCount field's value. +func (s *Bundle) SetCpuCount(v int64) *Bundle { + s.CpuCount = &v + return s +} + +// SetDiskSizeInGb sets the DiskSizeInGb field's value. +func (s *Bundle) SetDiskSizeInGb(v int64) *Bundle { + s.DiskSizeInGb = &v + return s +} + +// SetInstanceType sets the InstanceType field's value. +func (s *Bundle) SetInstanceType(v string) *Bundle { + s.InstanceType = &v + return s +} + +// SetIsActive sets the IsActive field's value. +func (s *Bundle) SetIsActive(v bool) *Bundle { + s.IsActive = &v + return s +} + +// SetName sets the Name field's value. +func (s *Bundle) SetName(v string) *Bundle { + s.Name = &v + return s +} + +// SetPower sets the Power field's value. +func (s *Bundle) SetPower(v int64) *Bundle { + s.Power = &v + return s +} + +// SetPrice sets the Price field's value. +func (s *Bundle) SetPrice(v float64) *Bundle { + s.Price = &v + return s +} + +// SetRamSizeInGb sets the RamSizeInGb field's value. +func (s *Bundle) SetRamSizeInGb(v float64) *Bundle { + s.RamSizeInGb = &v + return s +} + +// SetSupportedPlatforms sets the SupportedPlatforms field's value. +func (s *Bundle) SetSupportedPlatforms(v []*string) *Bundle { + s.SupportedPlatforms = v + return s +} + +// SetTransferPerMonthInGb sets the TransferPerMonthInGb field's value. +func (s *Bundle) SetTransferPerMonthInGb(v int64) *Bundle { + s.TransferPerMonthInGb = &v + return s +} + +type CloseInstancePublicPortsInput struct { + _ struct{} `type:"structure"` + + // The name of the instance on which you're attempting to close the public ports. + // + // InstanceName is a required field + InstanceName *string `locationName:"instanceName" type:"string" required:"true"` + + // Information about the public port you are trying to close. + // + // PortInfo is a required field + PortInfo *PortInfo `locationName:"portInfo" type:"structure" required:"true"` +} + +// String returns the string representation +func (s CloseInstancePublicPortsInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CloseInstancePublicPortsInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *CloseInstancePublicPortsInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "CloseInstancePublicPortsInput"} + if s.InstanceName == nil { + invalidParams.Add(request.NewErrParamRequired("InstanceName")) + } + if s.PortInfo == nil { + invalidParams.Add(request.NewErrParamRequired("PortInfo")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetInstanceName sets the InstanceName field's value. +func (s *CloseInstancePublicPortsInput) SetInstanceName(v string) *CloseInstancePublicPortsInput { + s.InstanceName = &v + return s +} + +// SetPortInfo sets the PortInfo field's value. +func (s *CloseInstancePublicPortsInput) SetPortInfo(v *PortInfo) *CloseInstancePublicPortsInput { + s.PortInfo = v + return s +} + +type CloseInstancePublicPortsOutput struct { + _ struct{} `type:"structure"` + + // An array of key-value pairs that contains information about the operation. + Operation *Operation `locationName:"operation" type:"structure"` +} + +// String returns the string representation +func (s CloseInstancePublicPortsOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CloseInstancePublicPortsOutput) GoString() string { + return s.String() +} + +// SetOperation sets the Operation field's value. +func (s *CloseInstancePublicPortsOutput) SetOperation(v *Operation) *CloseInstancePublicPortsOutput { + s.Operation = v + return s +} + +type CreateDiskFromSnapshotInput struct { + _ struct{} `type:"structure"` + + // The Availability Zone where you want to create the disk (e.g., us-east-2a). + // Choose the same Availability Zone as the Lightsail instance where you want + // to create the disk. + // + // Use the GetRegions operation to list the Availability Zones where Lightsail + // is currently available. + // + // AvailabilityZone is a required field + AvailabilityZone *string `locationName:"availabilityZone" type:"string" required:"true"` + + // The unique Lightsail disk name (e.g., my-disk). + // + // DiskName is a required field + DiskName *string `locationName:"diskName" type:"string" required:"true"` + + // The name of the disk snapshot (e.g., my-snapshot) from which to create the + // new storage disk. + // + // DiskSnapshotName is a required field + DiskSnapshotName *string `locationName:"diskSnapshotName" type:"string" required:"true"` + + // The size of the disk in GB (e.g., 32). + // + // SizeInGb is a required field + SizeInGb *int64 `locationName:"sizeInGb" type:"integer" required:"true"` +} + +// String returns the string representation +func (s CreateDiskFromSnapshotInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CreateDiskFromSnapshotInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *CreateDiskFromSnapshotInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "CreateDiskFromSnapshotInput"} + if s.AvailabilityZone == nil { + invalidParams.Add(request.NewErrParamRequired("AvailabilityZone")) + } + if s.DiskName == nil { + invalidParams.Add(request.NewErrParamRequired("DiskName")) + } + if s.DiskSnapshotName == nil { + invalidParams.Add(request.NewErrParamRequired("DiskSnapshotName")) + } + if s.SizeInGb == nil { + invalidParams.Add(request.NewErrParamRequired("SizeInGb")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetAvailabilityZone sets the AvailabilityZone field's value. +func (s *CreateDiskFromSnapshotInput) SetAvailabilityZone(v string) *CreateDiskFromSnapshotInput { + s.AvailabilityZone = &v + return s +} + +// SetDiskName sets the DiskName field's value. +func (s *CreateDiskFromSnapshotInput) SetDiskName(v string) *CreateDiskFromSnapshotInput { + s.DiskName = &v + return s +} + +// SetDiskSnapshotName sets the DiskSnapshotName field's value. +func (s *CreateDiskFromSnapshotInput) SetDiskSnapshotName(v string) *CreateDiskFromSnapshotInput { + s.DiskSnapshotName = &v + return s +} + +// SetSizeInGb sets the SizeInGb field's value. +func (s *CreateDiskFromSnapshotInput) SetSizeInGb(v int64) *CreateDiskFromSnapshotInput { + s.SizeInGb = &v + return s +} + +type CreateDiskFromSnapshotOutput struct { + _ struct{} `type:"structure"` + + // An object describing the API operations. + Operations []*Operation `locationName:"operations" type:"list"` +} + +// String returns the string representation +func (s CreateDiskFromSnapshotOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CreateDiskFromSnapshotOutput) GoString() string { + return s.String() +} + +// SetOperations sets the Operations field's value. +func (s *CreateDiskFromSnapshotOutput) SetOperations(v []*Operation) *CreateDiskFromSnapshotOutput { + s.Operations = v + return s +} + +type CreateDiskInput struct { + _ struct{} `type:"structure"` + + // The Availability Zone where you want to create the disk (e.g., us-east-2a). + // Choose the same Availability Zone as the Lightsail instance where you want + // to create the disk. + // + // Use the GetRegions operation to list the Availability Zones where Lightsail + // is currently available. + // + // AvailabilityZone is a required field + AvailabilityZone *string `locationName:"availabilityZone" type:"string" required:"true"` + + // The unique Lightsail disk name (e.g., my-disk). + // + // DiskName is a required field + DiskName *string `locationName:"diskName" type:"string" required:"true"` + + // The size of the disk in GB (e.g., 32). + // + // SizeInGb is a required field + SizeInGb *int64 `locationName:"sizeInGb" type:"integer" required:"true"` +} + +// String returns the string representation +func (s CreateDiskInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CreateDiskInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *CreateDiskInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "CreateDiskInput"} + if s.AvailabilityZone == nil { + invalidParams.Add(request.NewErrParamRequired("AvailabilityZone")) + } + if s.DiskName == nil { + invalidParams.Add(request.NewErrParamRequired("DiskName")) + } + if s.SizeInGb == nil { + invalidParams.Add(request.NewErrParamRequired("SizeInGb")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetAvailabilityZone sets the AvailabilityZone field's value. +func (s *CreateDiskInput) SetAvailabilityZone(v string) *CreateDiskInput { + s.AvailabilityZone = &v + return s +} + +// SetDiskName sets the DiskName field's value. +func (s *CreateDiskInput) SetDiskName(v string) *CreateDiskInput { + s.DiskName = &v + return s +} + +// SetSizeInGb sets the SizeInGb field's value. +func (s *CreateDiskInput) SetSizeInGb(v int64) *CreateDiskInput { + s.SizeInGb = &v + return s +} + +type CreateDiskOutput struct { + _ struct{} `type:"structure"` + + // An object describing the API operations. + Operations []*Operation `locationName:"operations" type:"list"` +} + +// String returns the string representation +func (s CreateDiskOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CreateDiskOutput) GoString() string { + return s.String() +} + +// SetOperations sets the Operations field's value. +func (s *CreateDiskOutput) SetOperations(v []*Operation) *CreateDiskOutput { + s.Operations = v + return s +} + +type CreateDiskSnapshotInput struct { + _ struct{} `type:"structure"` + + // The unique name of the source disk (e.g., my-source-disk). + // + // DiskName is a required field + DiskName *string `locationName:"diskName" type:"string" required:"true"` + + // The name of the destination disk snapshot (e.g., my-disk-snapshot) based + // on the source disk. + // + // DiskSnapshotName is a required field + DiskSnapshotName *string `locationName:"diskSnapshotName" type:"string" required:"true"` +} + +// String returns the string representation +func (s CreateDiskSnapshotInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CreateDiskSnapshotInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *CreateDiskSnapshotInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "CreateDiskSnapshotInput"} + if s.DiskName == nil { + invalidParams.Add(request.NewErrParamRequired("DiskName")) + } + if s.DiskSnapshotName == nil { + invalidParams.Add(request.NewErrParamRequired("DiskSnapshotName")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetDiskName sets the DiskName field's value. +func (s *CreateDiskSnapshotInput) SetDiskName(v string) *CreateDiskSnapshotInput { + s.DiskName = &v + return s +} + +// SetDiskSnapshotName sets the DiskSnapshotName field's value. +func (s *CreateDiskSnapshotInput) SetDiskSnapshotName(v string) *CreateDiskSnapshotInput { + s.DiskSnapshotName = &v + return s +} + +type CreateDiskSnapshotOutput struct { + _ struct{} `type:"structure"` + + // An object describing the API operations. + Operations []*Operation `locationName:"operations" type:"list"` +} + +// String returns the string representation +func (s CreateDiskSnapshotOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CreateDiskSnapshotOutput) GoString() string { + return s.String() +} + +// SetOperations sets the Operations field's value. +func (s *CreateDiskSnapshotOutput) SetOperations(v []*Operation) *CreateDiskSnapshotOutput { + s.Operations = v + return s +} + +type CreateDomainEntryInput struct { + _ struct{} `type:"structure"` + + // An array of key-value pairs containing information about the domain entry + // request. + // + // DomainEntry is a required field + DomainEntry *DomainEntry `locationName:"domainEntry" type:"structure" required:"true"` + + // The domain name (e.g., example.com) for which you want to create the domain + // entry. + // + // DomainName is a required field + DomainName *string `locationName:"domainName" type:"string" required:"true"` +} + +// String returns the string representation +func (s CreateDomainEntryInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CreateDomainEntryInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *CreateDomainEntryInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "CreateDomainEntryInput"} + if s.DomainEntry == nil { + invalidParams.Add(request.NewErrParamRequired("DomainEntry")) + } + if s.DomainName == nil { + invalidParams.Add(request.NewErrParamRequired("DomainName")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetDomainEntry sets the DomainEntry field's value. +func (s *CreateDomainEntryInput) SetDomainEntry(v *DomainEntry) *CreateDomainEntryInput { + s.DomainEntry = v + return s +} + +// SetDomainName sets the DomainName field's value. +func (s *CreateDomainEntryInput) SetDomainName(v string) *CreateDomainEntryInput { + s.DomainName = &v + return s +} + +type CreateDomainEntryOutput struct { + _ struct{} `type:"structure"` + + // An array of key-value pairs containing information about the operation. + Operation *Operation `locationName:"operation" type:"structure"` +} + +// String returns the string representation +func (s CreateDomainEntryOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CreateDomainEntryOutput) GoString() string { + return s.String() +} + +// SetOperation sets the Operation field's value. +func (s *CreateDomainEntryOutput) SetOperation(v *Operation) *CreateDomainEntryOutput { + s.Operation = v + return s +} + +type CreateDomainInput struct { + _ struct{} `type:"structure"` + + // The domain name to manage (e.g., example.com). + // + // You cannot register a new domain name using Lightsail. You must register + // a domain name using Amazon Route 53 or another domain name registrar. If + // you have already registered your domain, you can enter its name in this parameter + // to manage the DNS records for that domain. + // + // DomainName is a required field + DomainName *string `locationName:"domainName" type:"string" required:"true"` +} + +// String returns the string representation +func (s CreateDomainInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CreateDomainInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *CreateDomainInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "CreateDomainInput"} + if s.DomainName == nil { + invalidParams.Add(request.NewErrParamRequired("DomainName")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetDomainName sets the DomainName field's value. +func (s *CreateDomainInput) SetDomainName(v string) *CreateDomainInput { + s.DomainName = &v + return s +} + +type CreateDomainOutput struct { + _ struct{} `type:"structure"` + + // An array of key-value pairs containing information about the domain resource + // you created. + Operation *Operation `locationName:"operation" type:"structure"` +} + +// String returns the string representation +func (s CreateDomainOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CreateDomainOutput) GoString() string { + return s.String() +} + +// SetOperation sets the Operation field's value. +func (s *CreateDomainOutput) SetOperation(v *Operation) *CreateDomainOutput { + s.Operation = v + return s +} + +type CreateInstanceSnapshotInput struct { + _ struct{} `type:"structure"` + + // The Lightsail instance on which to base your snapshot. + // + // InstanceName is a required field + InstanceName *string `locationName:"instanceName" type:"string" required:"true"` + + // The name for your new snapshot. + // + // InstanceSnapshotName is a required field + InstanceSnapshotName *string `locationName:"instanceSnapshotName" type:"string" required:"true"` +} + +// String returns the string representation +func (s CreateInstanceSnapshotInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CreateInstanceSnapshotInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *CreateInstanceSnapshotInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "CreateInstanceSnapshotInput"} + if s.InstanceName == nil { + invalidParams.Add(request.NewErrParamRequired("InstanceName")) + } + if s.InstanceSnapshotName == nil { + invalidParams.Add(request.NewErrParamRequired("InstanceSnapshotName")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetInstanceName sets the InstanceName field's value. +func (s *CreateInstanceSnapshotInput) SetInstanceName(v string) *CreateInstanceSnapshotInput { + s.InstanceName = &v + return s +} + +// SetInstanceSnapshotName sets the InstanceSnapshotName field's value. +func (s *CreateInstanceSnapshotInput) SetInstanceSnapshotName(v string) *CreateInstanceSnapshotInput { + s.InstanceSnapshotName = &v + return s +} + +type CreateInstanceSnapshotOutput struct { + _ struct{} `type:"structure"` + + // An array of key-value pairs containing information about the results of your + // create instances snapshot request. + Operations []*Operation `locationName:"operations" type:"list"` +} + +// String returns the string representation +func (s CreateInstanceSnapshotOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CreateInstanceSnapshotOutput) GoString() string { + return s.String() +} + +// SetOperations sets the Operations field's value. +func (s *CreateInstanceSnapshotOutput) SetOperations(v []*Operation) *CreateInstanceSnapshotOutput { + s.Operations = v + return s +} + +type CreateInstancesFromSnapshotInput struct { + _ struct{} `type:"structure"` + + // An object containing information about one or more disk mappings. + AttachedDiskMapping map[string][]*DiskMap `locationName:"attachedDiskMapping" type:"map"` + + // The Availability Zone where you want to create your instances. Use the following + // formatting: us-east-2a (case sensitive). You can get a list of availability + // zones by using the get regions (http://docs.aws.amazon.com/lightsail/2016-11-28/api-reference/API_GetRegions.html) + // operation. Be sure to add the include availability zones parameter to your + // request. + // + // AvailabilityZone is a required field + AvailabilityZone *string `locationName:"availabilityZone" type:"string" required:"true"` + + // The bundle of specification information for your virtual private server (or + // instance), including the pricing plan (e.g., micro_1_0). + // + // BundleId is a required field + BundleId *string `locationName:"bundleId" type:"string" required:"true"` + + // The names for your new instances. + // + // InstanceNames is a required field + InstanceNames []*string `locationName:"instanceNames" type:"list" required:"true"` + + // The name of the instance snapshot on which you are basing your new instances. + // Use the get instance snapshots operation to return information about your + // existing snapshots. + // + // InstanceSnapshotName is a required field + InstanceSnapshotName *string `locationName:"instanceSnapshotName" type:"string" required:"true"` + + // The name for your key pair. + KeyPairName *string `locationName:"keyPairName" type:"string"` + + // You can create a launch script that configures a server with additional user + // data. For example, apt-get -y update. + // + // Depending on the machine image you choose, the command to get software on + // your instance varies. Amazon Linux and CentOS use yum, Debian and Ubuntu + // use apt-get, and FreeBSD uses pkg. For a complete list, see the Dev Guide + // (http://lightsail.aws.amazon.com/ls/docs/getting-started/articles/pre-installed-apps). + UserData *string `locationName:"userData" type:"string"` +} + +// String returns the string representation +func (s CreateInstancesFromSnapshotInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CreateInstancesFromSnapshotInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *CreateInstancesFromSnapshotInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "CreateInstancesFromSnapshotInput"} + if s.AvailabilityZone == nil { + invalidParams.Add(request.NewErrParamRequired("AvailabilityZone")) + } + if s.BundleId == nil { + invalidParams.Add(request.NewErrParamRequired("BundleId")) + } + if s.InstanceNames == nil { + invalidParams.Add(request.NewErrParamRequired("InstanceNames")) + } + if s.InstanceSnapshotName == nil { + invalidParams.Add(request.NewErrParamRequired("InstanceSnapshotName")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetAttachedDiskMapping sets the AttachedDiskMapping field's value. +func (s *CreateInstancesFromSnapshotInput) SetAttachedDiskMapping(v map[string][]*DiskMap) *CreateInstancesFromSnapshotInput { + s.AttachedDiskMapping = v + return s +} + +// SetAvailabilityZone sets the AvailabilityZone field's value. +func (s *CreateInstancesFromSnapshotInput) SetAvailabilityZone(v string) *CreateInstancesFromSnapshotInput { + s.AvailabilityZone = &v + return s +} + +// SetBundleId sets the BundleId field's value. +func (s *CreateInstancesFromSnapshotInput) SetBundleId(v string) *CreateInstancesFromSnapshotInput { + s.BundleId = &v + return s +} + +// SetInstanceNames sets the InstanceNames field's value. +func (s *CreateInstancesFromSnapshotInput) SetInstanceNames(v []*string) *CreateInstancesFromSnapshotInput { + s.InstanceNames = v + return s +} + +// SetInstanceSnapshotName sets the InstanceSnapshotName field's value. +func (s *CreateInstancesFromSnapshotInput) SetInstanceSnapshotName(v string) *CreateInstancesFromSnapshotInput { + s.InstanceSnapshotName = &v + return s +} + +// SetKeyPairName sets the KeyPairName field's value. +func (s *CreateInstancesFromSnapshotInput) SetKeyPairName(v string) *CreateInstancesFromSnapshotInput { + s.KeyPairName = &v + return s +} + +// SetUserData sets the UserData field's value. +func (s *CreateInstancesFromSnapshotInput) SetUserData(v string) *CreateInstancesFromSnapshotInput { + s.UserData = &v + return s +} + +type CreateInstancesFromSnapshotOutput struct { + _ struct{} `type:"structure"` + + // An array of key-value pairs containing information about the results of your + // create instances from snapshot request. + Operations []*Operation `locationName:"operations" type:"list"` +} + +// String returns the string representation +func (s CreateInstancesFromSnapshotOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CreateInstancesFromSnapshotOutput) GoString() string { + return s.String() +} + +// SetOperations sets the Operations field's value. +func (s *CreateInstancesFromSnapshotOutput) SetOperations(v []*Operation) *CreateInstancesFromSnapshotOutput { + s.Operations = v + return s +} + +type CreateInstancesInput struct { + _ struct{} `type:"structure"` + + // The Availability Zone in which to create your instance. Use the following + // format: us-east-2a (case sensitive). You can get a list of availability zones + // by using the get regions (http://docs.aws.amazon.com/lightsail/2016-11-28/api-reference/API_GetRegions.html) + // operation. Be sure to add the include availability zones parameter to your + // request. + // + // AvailabilityZone is a required field + AvailabilityZone *string `locationName:"availabilityZone" type:"string" required:"true"` + + // The ID for a virtual private server image (e.g., app_wordpress_4_4 or app_lamp_7_0). + // Use the get blueprints operation to return a list of available images (or + // blueprints). + // + // BlueprintId is a required field + BlueprintId *string `locationName:"blueprintId" type:"string" required:"true"` + + // The bundle of specification information for your virtual private server (or + // instance), including the pricing plan (e.g., micro_1_0). + // + // BundleId is a required field + BundleId *string `locationName:"bundleId" type:"string" required:"true"` + + // (Deprecated) The name for your custom image. + // + // In releases prior to June 12, 2017, this parameter was ignored by the API. + // It is now deprecated. + CustomImageName *string `locationName:"customImageName" deprecated:"true" type:"string"` + + // The names to use for your new Lightsail instances. Separate multiple values + // using quotation marks and commas, for example: ["MyFirstInstance","MySecondInstance"] + // + // InstanceNames is a required field + InstanceNames []*string `locationName:"instanceNames" type:"list" required:"true"` + + // The name of your key pair. + KeyPairName *string `locationName:"keyPairName" type:"string"` + + // A launch script you can create that configures a server with additional user + // data. For example, you might want to run apt-get -y update. + // + // Depending on the machine image you choose, the command to get software on + // your instance varies. Amazon Linux and CentOS use yum, Debian and Ubuntu + // use apt-get, and FreeBSD uses pkg. For a complete list, see the Dev Guide + // (https://lightsail.aws.amazon.com/ls/docs/getting-started/article/compare-options-choose-lightsail-instance-image). + UserData *string `locationName:"userData" type:"string"` +} + +// String returns the string representation +func (s CreateInstancesInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CreateInstancesInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *CreateInstancesInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "CreateInstancesInput"} + if s.AvailabilityZone == nil { + invalidParams.Add(request.NewErrParamRequired("AvailabilityZone")) + } + if s.BlueprintId == nil { + invalidParams.Add(request.NewErrParamRequired("BlueprintId")) + } + if s.BundleId == nil { + invalidParams.Add(request.NewErrParamRequired("BundleId")) + } + if s.InstanceNames == nil { + invalidParams.Add(request.NewErrParamRequired("InstanceNames")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetAvailabilityZone sets the AvailabilityZone field's value. +func (s *CreateInstancesInput) SetAvailabilityZone(v string) *CreateInstancesInput { + s.AvailabilityZone = &v + return s +} + +// SetBlueprintId sets the BlueprintId field's value. +func (s *CreateInstancesInput) SetBlueprintId(v string) *CreateInstancesInput { + s.BlueprintId = &v + return s +} + +// SetBundleId sets the BundleId field's value. +func (s *CreateInstancesInput) SetBundleId(v string) *CreateInstancesInput { + s.BundleId = &v + return s +} + +// SetCustomImageName sets the CustomImageName field's value. +func (s *CreateInstancesInput) SetCustomImageName(v string) *CreateInstancesInput { + s.CustomImageName = &v + return s +} + +// SetInstanceNames sets the InstanceNames field's value. +func (s *CreateInstancesInput) SetInstanceNames(v []*string) *CreateInstancesInput { + s.InstanceNames = v + return s +} + +// SetKeyPairName sets the KeyPairName field's value. +func (s *CreateInstancesInput) SetKeyPairName(v string) *CreateInstancesInput { + s.KeyPairName = &v + return s +} + +// SetUserData sets the UserData field's value. +func (s *CreateInstancesInput) SetUserData(v string) *CreateInstancesInput { + s.UserData = &v + return s +} + +type CreateInstancesOutput struct { + _ struct{} `type:"structure"` + + // An array of key-value pairs containing information about the results of your + // create instances request. + Operations []*Operation `locationName:"operations" type:"list"` +} + +// String returns the string representation +func (s CreateInstancesOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CreateInstancesOutput) GoString() string { + return s.String() +} + +// SetOperations sets the Operations field's value. +func (s *CreateInstancesOutput) SetOperations(v []*Operation) *CreateInstancesOutput { + s.Operations = v + return s +} + +type CreateKeyPairInput struct { + _ struct{} `type:"structure"` + + // The name for your new key pair. + // + // KeyPairName is a required field + KeyPairName *string `locationName:"keyPairName" type:"string" required:"true"` +} + +// String returns the string representation +func (s CreateKeyPairInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CreateKeyPairInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *CreateKeyPairInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "CreateKeyPairInput"} + if s.KeyPairName == nil { + invalidParams.Add(request.NewErrParamRequired("KeyPairName")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetKeyPairName sets the KeyPairName field's value. +func (s *CreateKeyPairInput) SetKeyPairName(v string) *CreateKeyPairInput { + s.KeyPairName = &v + return s +} + +type CreateKeyPairOutput struct { + _ struct{} `type:"structure"` + + // An array of key-value pairs containing information about the new key pair + // you just created. + KeyPair *KeyPair `locationName:"keyPair" type:"structure"` + + // An array of key-value pairs containing information about the results of your + // create key pair request. + Operation *Operation `locationName:"operation" type:"structure"` + + // A base64-encoded RSA private key. + PrivateKeyBase64 *string `locationName:"privateKeyBase64" type:"string"` + + // A base64-encoded public key of the ssh-rsa type. + PublicKeyBase64 *string `locationName:"publicKeyBase64" type:"string"` +} + +// String returns the string representation +func (s CreateKeyPairOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CreateKeyPairOutput) GoString() string { + return s.String() +} + +// SetKeyPair sets the KeyPair field's value. +func (s *CreateKeyPairOutput) SetKeyPair(v *KeyPair) *CreateKeyPairOutput { + s.KeyPair = v + return s +} + +// SetOperation sets the Operation field's value. +func (s *CreateKeyPairOutput) SetOperation(v *Operation) *CreateKeyPairOutput { + s.Operation = v + return s +} + +// SetPrivateKeyBase64 sets the PrivateKeyBase64 field's value. +func (s *CreateKeyPairOutput) SetPrivateKeyBase64(v string) *CreateKeyPairOutput { + s.PrivateKeyBase64 = &v + return s +} + +// SetPublicKeyBase64 sets the PublicKeyBase64 field's value. +func (s *CreateKeyPairOutput) SetPublicKeyBase64(v string) *CreateKeyPairOutput { + s.PublicKeyBase64 = &v + return s +} + +type CreateLoadBalancerInput struct { + _ struct{} `type:"structure"` + + // The alternative domain names to use with your TLS/SSL certificate (e.g., + // www.example.com, www.ejemplo.com, ejemplo.com). + CertificateAlternativeNames []*string `locationName:"certificateAlternativeNames" type:"list"` + + // The domain name with which your certificate is associated (e.g., example.com). + // + // If you specify certificateDomainName, then certificateName is required (and + // vice-versa). + CertificateDomainName *string `locationName:"certificateDomainName" type:"string"` + + // The name of the TLS/SSL certificate. + // + // If you specify certificateName, then certificateDomainName is required (and + // vice-versa). + CertificateName *string `locationName:"certificateName" type:"string"` + + // The path you provided to perform the load balancer health check. If you didn't + // specify a health check path, Lightsail uses the root path of your website + // (e.g., "/"). + HealthCheckPath *string `locationName:"healthCheckPath" type:"string"` + + // The instance port where you're creating your load balancer. + // + // InstancePort is a required field + InstancePort *int64 `locationName:"instancePort" type:"integer" required:"true"` + + // The name of your load balancer. + // + // LoadBalancerName is a required field + LoadBalancerName *string `locationName:"loadBalancerName" type:"string" required:"true"` +} + +// String returns the string representation +func (s CreateLoadBalancerInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CreateLoadBalancerInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *CreateLoadBalancerInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "CreateLoadBalancerInput"} + if s.InstancePort == nil { + invalidParams.Add(request.NewErrParamRequired("InstancePort")) + } + if s.LoadBalancerName == nil { + invalidParams.Add(request.NewErrParamRequired("LoadBalancerName")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetCertificateAlternativeNames sets the CertificateAlternativeNames field's value. +func (s *CreateLoadBalancerInput) SetCertificateAlternativeNames(v []*string) *CreateLoadBalancerInput { + s.CertificateAlternativeNames = v + return s +} + +// SetCertificateDomainName sets the CertificateDomainName field's value. +func (s *CreateLoadBalancerInput) SetCertificateDomainName(v string) *CreateLoadBalancerInput { + s.CertificateDomainName = &v + return s +} + +// SetCertificateName sets the CertificateName field's value. +func (s *CreateLoadBalancerInput) SetCertificateName(v string) *CreateLoadBalancerInput { + s.CertificateName = &v + return s +} + +// SetHealthCheckPath sets the HealthCheckPath field's value. +func (s *CreateLoadBalancerInput) SetHealthCheckPath(v string) *CreateLoadBalancerInput { + s.HealthCheckPath = &v + return s +} + +// SetInstancePort sets the InstancePort field's value. +func (s *CreateLoadBalancerInput) SetInstancePort(v int64) *CreateLoadBalancerInput { + s.InstancePort = &v + return s +} + +// SetLoadBalancerName sets the LoadBalancerName field's value. +func (s *CreateLoadBalancerInput) SetLoadBalancerName(v string) *CreateLoadBalancerInput { + s.LoadBalancerName = &v + return s +} + +type CreateLoadBalancerOutput struct { + _ struct{} `type:"structure"` + + // An object containing information about the API operations. + Operations []*Operation `locationName:"operations" type:"list"` +} + +// String returns the string representation +func (s CreateLoadBalancerOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CreateLoadBalancerOutput) GoString() string { + return s.String() +} + +// SetOperations sets the Operations field's value. +func (s *CreateLoadBalancerOutput) SetOperations(v []*Operation) *CreateLoadBalancerOutput { + s.Operations = v + return s +} + +type CreateLoadBalancerTlsCertificateInput struct { + _ struct{} `type:"structure"` + + // An array of strings listing alternative domain names for your TLS/SSL certificate. + CertificateAlternativeNames []*string `locationName:"certificateAlternativeNames" type:"list"` + + // The domain name (e.g., example.com) for your TLS/SSL certificate. + // + // CertificateDomainName is a required field + CertificateDomainName *string `locationName:"certificateDomainName" type:"string" required:"true"` + + // The TLS/SSL certificate name. + // + // CertificateName is a required field + CertificateName *string `locationName:"certificateName" type:"string" required:"true"` + + // The load balancer name where you want to create the TLS/SSL certificate. + // + // LoadBalancerName is a required field + LoadBalancerName *string `locationName:"loadBalancerName" type:"string" required:"true"` +} + +// String returns the string representation +func (s CreateLoadBalancerTlsCertificateInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CreateLoadBalancerTlsCertificateInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *CreateLoadBalancerTlsCertificateInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "CreateLoadBalancerTlsCertificateInput"} + if s.CertificateDomainName == nil { + invalidParams.Add(request.NewErrParamRequired("CertificateDomainName")) + } + if s.CertificateName == nil { + invalidParams.Add(request.NewErrParamRequired("CertificateName")) + } + if s.LoadBalancerName == nil { + invalidParams.Add(request.NewErrParamRequired("LoadBalancerName")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetCertificateAlternativeNames sets the CertificateAlternativeNames field's value. +func (s *CreateLoadBalancerTlsCertificateInput) SetCertificateAlternativeNames(v []*string) *CreateLoadBalancerTlsCertificateInput { + s.CertificateAlternativeNames = v + return s +} + +// SetCertificateDomainName sets the CertificateDomainName field's value. +func (s *CreateLoadBalancerTlsCertificateInput) SetCertificateDomainName(v string) *CreateLoadBalancerTlsCertificateInput { + s.CertificateDomainName = &v + return s +} + +// SetCertificateName sets the CertificateName field's value. +func (s *CreateLoadBalancerTlsCertificateInput) SetCertificateName(v string) *CreateLoadBalancerTlsCertificateInput { + s.CertificateName = &v + return s +} + +// SetLoadBalancerName sets the LoadBalancerName field's value. +func (s *CreateLoadBalancerTlsCertificateInput) SetLoadBalancerName(v string) *CreateLoadBalancerTlsCertificateInput { + s.LoadBalancerName = &v + return s +} + +type CreateLoadBalancerTlsCertificateOutput struct { + _ struct{} `type:"structure"` + + // An object containing information about the API operations. + Operations []*Operation `locationName:"operations" type:"list"` +} + +// String returns the string representation +func (s CreateLoadBalancerTlsCertificateOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s CreateLoadBalancerTlsCertificateOutput) GoString() string { + return s.String() +} + +// SetOperations sets the Operations field's value. +func (s *CreateLoadBalancerTlsCertificateOutput) SetOperations(v []*Operation) *CreateLoadBalancerTlsCertificateOutput { + s.Operations = v + return s +} + +type DeleteDiskInput struct { + _ struct{} `type:"structure"` + + // The unique name of the disk you want to delete (e.g., my-disk). + // + // DiskName is a required field + DiskName *string `locationName:"diskName" type:"string" required:"true"` +} + +// String returns the string representation +func (s DeleteDiskInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DeleteDiskInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *DeleteDiskInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "DeleteDiskInput"} + if s.DiskName == nil { + invalidParams.Add(request.NewErrParamRequired("DiskName")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetDiskName sets the DiskName field's value. +func (s *DeleteDiskInput) SetDiskName(v string) *DeleteDiskInput { + s.DiskName = &v + return s +} + +type DeleteDiskOutput struct { + _ struct{} `type:"structure"` + + // An object describing the API operations. + Operations []*Operation `locationName:"operations" type:"list"` +} + +// String returns the string representation +func (s DeleteDiskOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DeleteDiskOutput) GoString() string { + return s.String() +} + +// SetOperations sets the Operations field's value. +func (s *DeleteDiskOutput) SetOperations(v []*Operation) *DeleteDiskOutput { + s.Operations = v + return s +} + +type DeleteDiskSnapshotInput struct { + _ struct{} `type:"structure"` + + // The name of the disk snapshot you want to delete (e.g., my-disk-snapshot). + // + // DiskSnapshotName is a required field + DiskSnapshotName *string `locationName:"diskSnapshotName" type:"string" required:"true"` +} + +// String returns the string representation +func (s DeleteDiskSnapshotInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DeleteDiskSnapshotInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *DeleteDiskSnapshotInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "DeleteDiskSnapshotInput"} + if s.DiskSnapshotName == nil { + invalidParams.Add(request.NewErrParamRequired("DiskSnapshotName")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetDiskSnapshotName sets the DiskSnapshotName field's value. +func (s *DeleteDiskSnapshotInput) SetDiskSnapshotName(v string) *DeleteDiskSnapshotInput { + s.DiskSnapshotName = &v + return s +} + +type DeleteDiskSnapshotOutput struct { + _ struct{} `type:"structure"` + + // An object describing the API operations. + Operations []*Operation `locationName:"operations" type:"list"` +} + +// String returns the string representation +func (s DeleteDiskSnapshotOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DeleteDiskSnapshotOutput) GoString() string { + return s.String() +} + +// SetOperations sets the Operations field's value. +func (s *DeleteDiskSnapshotOutput) SetOperations(v []*Operation) *DeleteDiskSnapshotOutput { + s.Operations = v + return s +} + +type DeleteDomainEntryInput struct { + _ struct{} `type:"structure"` + + // An array of key-value pairs containing information about your domain entries. + // + // DomainEntry is a required field + DomainEntry *DomainEntry `locationName:"domainEntry" type:"structure" required:"true"` + + // The name of the domain entry to delete. + // + // DomainName is a required field + DomainName *string `locationName:"domainName" type:"string" required:"true"` +} + +// String returns the string representation +func (s DeleteDomainEntryInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DeleteDomainEntryInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *DeleteDomainEntryInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "DeleteDomainEntryInput"} + if s.DomainEntry == nil { + invalidParams.Add(request.NewErrParamRequired("DomainEntry")) + } + if s.DomainName == nil { + invalidParams.Add(request.NewErrParamRequired("DomainName")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetDomainEntry sets the DomainEntry field's value. +func (s *DeleteDomainEntryInput) SetDomainEntry(v *DomainEntry) *DeleteDomainEntryInput { + s.DomainEntry = v + return s +} + +// SetDomainName sets the DomainName field's value. +func (s *DeleteDomainEntryInput) SetDomainName(v string) *DeleteDomainEntryInput { + s.DomainName = &v + return s +} + +type DeleteDomainEntryOutput struct { + _ struct{} `type:"structure"` + + // An array of key-value pairs containing information about the results of your + // delete domain entry request. + Operation *Operation `locationName:"operation" type:"structure"` +} + +// String returns the string representation +func (s DeleteDomainEntryOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DeleteDomainEntryOutput) GoString() string { + return s.String() +} + +// SetOperation sets the Operation field's value. +func (s *DeleteDomainEntryOutput) SetOperation(v *Operation) *DeleteDomainEntryOutput { + s.Operation = v + return s +} + +type DeleteDomainInput struct { + _ struct{} `type:"structure"` + + // The specific domain name to delete. + // + // DomainName is a required field + DomainName *string `locationName:"domainName" type:"string" required:"true"` +} + +// String returns the string representation +func (s DeleteDomainInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DeleteDomainInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *DeleteDomainInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "DeleteDomainInput"} + if s.DomainName == nil { + invalidParams.Add(request.NewErrParamRequired("DomainName")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetDomainName sets the DomainName field's value. +func (s *DeleteDomainInput) SetDomainName(v string) *DeleteDomainInput { + s.DomainName = &v + return s +} + +type DeleteDomainOutput struct { + _ struct{} `type:"structure"` + + // An array of key-value pairs containing information about the results of your + // delete domain request. + Operation *Operation `locationName:"operation" type:"structure"` +} + +// String returns the string representation +func (s DeleteDomainOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DeleteDomainOutput) GoString() string { + return s.String() +} + +// SetOperation sets the Operation field's value. +func (s *DeleteDomainOutput) SetOperation(v *Operation) *DeleteDomainOutput { + s.Operation = v + return s +} + +type DeleteInstanceInput struct { + _ struct{} `type:"structure"` + + // The name of the instance to delete. + // + // InstanceName is a required field + InstanceName *string `locationName:"instanceName" type:"string" required:"true"` +} + +// String returns the string representation +func (s DeleteInstanceInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DeleteInstanceInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *DeleteInstanceInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "DeleteInstanceInput"} + if s.InstanceName == nil { + invalidParams.Add(request.NewErrParamRequired("InstanceName")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetInstanceName sets the InstanceName field's value. +func (s *DeleteInstanceInput) SetInstanceName(v string) *DeleteInstanceInput { + s.InstanceName = &v + return s +} + +type DeleteInstanceOutput struct { + _ struct{} `type:"structure"` + + // An array of key-value pairs containing information about the results of your + // delete instance request. + Operations []*Operation `locationName:"operations" type:"list"` +} + +// String returns the string representation +func (s DeleteInstanceOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DeleteInstanceOutput) GoString() string { + return s.String() +} + +// SetOperations sets the Operations field's value. +func (s *DeleteInstanceOutput) SetOperations(v []*Operation) *DeleteInstanceOutput { + s.Operations = v + return s +} + +type DeleteInstanceSnapshotInput struct { + _ struct{} `type:"structure"` + + // The name of the snapshot to delete. + // + // InstanceSnapshotName is a required field + InstanceSnapshotName *string `locationName:"instanceSnapshotName" type:"string" required:"true"` +} + +// String returns the string representation +func (s DeleteInstanceSnapshotInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DeleteInstanceSnapshotInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *DeleteInstanceSnapshotInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "DeleteInstanceSnapshotInput"} + if s.InstanceSnapshotName == nil { + invalidParams.Add(request.NewErrParamRequired("InstanceSnapshotName")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetInstanceSnapshotName sets the InstanceSnapshotName field's value. +func (s *DeleteInstanceSnapshotInput) SetInstanceSnapshotName(v string) *DeleteInstanceSnapshotInput { + s.InstanceSnapshotName = &v + return s +} + +type DeleteInstanceSnapshotOutput struct { + _ struct{} `type:"structure"` + + // An array of key-value pairs containing information about the results of your + // delete instance snapshot request. + Operations []*Operation `locationName:"operations" type:"list"` +} + +// String returns the string representation +func (s DeleteInstanceSnapshotOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DeleteInstanceSnapshotOutput) GoString() string { + return s.String() +} + +// SetOperations sets the Operations field's value. +func (s *DeleteInstanceSnapshotOutput) SetOperations(v []*Operation) *DeleteInstanceSnapshotOutput { + s.Operations = v + return s +} + +type DeleteKeyPairInput struct { + _ struct{} `type:"structure"` + + // The name of the key pair to delete. + // + // KeyPairName is a required field + KeyPairName *string `locationName:"keyPairName" type:"string" required:"true"` +} + +// String returns the string representation +func (s DeleteKeyPairInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DeleteKeyPairInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *DeleteKeyPairInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "DeleteKeyPairInput"} + if s.KeyPairName == nil { + invalidParams.Add(request.NewErrParamRequired("KeyPairName")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetKeyPairName sets the KeyPairName field's value. +func (s *DeleteKeyPairInput) SetKeyPairName(v string) *DeleteKeyPairInput { + s.KeyPairName = &v + return s +} + +type DeleteKeyPairOutput struct { + _ struct{} `type:"structure"` + + // An array of key-value pairs containing information about the results of your + // delete key pair request. + Operation *Operation `locationName:"operation" type:"structure"` +} + +// String returns the string representation +func (s DeleteKeyPairOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DeleteKeyPairOutput) GoString() string { + return s.String() +} + +// SetOperation sets the Operation field's value. +func (s *DeleteKeyPairOutput) SetOperation(v *Operation) *DeleteKeyPairOutput { + s.Operation = v + return s +} + +type DeleteLoadBalancerInput struct { + _ struct{} `type:"structure"` + + // The name of the load balancer you want to delete. + // + // LoadBalancerName is a required field + LoadBalancerName *string `locationName:"loadBalancerName" type:"string" required:"true"` +} + +// String returns the string representation +func (s DeleteLoadBalancerInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DeleteLoadBalancerInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *DeleteLoadBalancerInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "DeleteLoadBalancerInput"} + if s.LoadBalancerName == nil { + invalidParams.Add(request.NewErrParamRequired("LoadBalancerName")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetLoadBalancerName sets the LoadBalancerName field's value. +func (s *DeleteLoadBalancerInput) SetLoadBalancerName(v string) *DeleteLoadBalancerInput { + s.LoadBalancerName = &v + return s +} + +type DeleteLoadBalancerOutput struct { + _ struct{} `type:"structure"` + + // An object describing the API operations. + Operations []*Operation `locationName:"operations" type:"list"` +} + +// String returns the string representation +func (s DeleteLoadBalancerOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DeleteLoadBalancerOutput) GoString() string { + return s.String() +} + +// SetOperations sets the Operations field's value. +func (s *DeleteLoadBalancerOutput) SetOperations(v []*Operation) *DeleteLoadBalancerOutput { + s.Operations = v + return s +} + +type DeleteLoadBalancerTlsCertificateInput struct { + _ struct{} `type:"structure"` + + // The TLS/SSL certificate name. + // + // CertificateName is a required field + CertificateName *string `locationName:"certificateName" type:"string" required:"true"` + + // When true, forces the deletion of a TLS/SSL certificate. + Force *bool `locationName:"force" type:"boolean"` + + // The load balancer name. + // + // LoadBalancerName is a required field + LoadBalancerName *string `locationName:"loadBalancerName" type:"string" required:"true"` +} + +// String returns the string representation +func (s DeleteLoadBalancerTlsCertificateInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DeleteLoadBalancerTlsCertificateInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *DeleteLoadBalancerTlsCertificateInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "DeleteLoadBalancerTlsCertificateInput"} + if s.CertificateName == nil { + invalidParams.Add(request.NewErrParamRequired("CertificateName")) + } + if s.LoadBalancerName == nil { + invalidParams.Add(request.NewErrParamRequired("LoadBalancerName")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetCertificateName sets the CertificateName field's value. +func (s *DeleteLoadBalancerTlsCertificateInput) SetCertificateName(v string) *DeleteLoadBalancerTlsCertificateInput { + s.CertificateName = &v + return s +} + +// SetForce sets the Force field's value. +func (s *DeleteLoadBalancerTlsCertificateInput) SetForce(v bool) *DeleteLoadBalancerTlsCertificateInput { + s.Force = &v + return s +} + +// SetLoadBalancerName sets the LoadBalancerName field's value. +func (s *DeleteLoadBalancerTlsCertificateInput) SetLoadBalancerName(v string) *DeleteLoadBalancerTlsCertificateInput { + s.LoadBalancerName = &v + return s +} + +type DeleteLoadBalancerTlsCertificateOutput struct { + _ struct{} `type:"structure"` + + // An object describing the API operations. + Operations []*Operation `locationName:"operations" type:"list"` +} + +// String returns the string representation +func (s DeleteLoadBalancerTlsCertificateOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DeleteLoadBalancerTlsCertificateOutput) GoString() string { + return s.String() +} + +// SetOperations sets the Operations field's value. +func (s *DeleteLoadBalancerTlsCertificateOutput) SetOperations(v []*Operation) *DeleteLoadBalancerTlsCertificateOutput { + s.Operations = v + return s +} + +type DetachDiskInput struct { + _ struct{} `type:"structure"` + + // The unique name of the disk you want to detach from your instance (e.g., + // my-disk). + // + // DiskName is a required field + DiskName *string `locationName:"diskName" type:"string" required:"true"` +} + +// String returns the string representation +func (s DetachDiskInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DetachDiskInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *DetachDiskInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "DetachDiskInput"} + if s.DiskName == nil { + invalidParams.Add(request.NewErrParamRequired("DiskName")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetDiskName sets the DiskName field's value. +func (s *DetachDiskInput) SetDiskName(v string) *DetachDiskInput { + s.DiskName = &v + return s +} + +type DetachDiskOutput struct { + _ struct{} `type:"structure"` + + // An object describing the API operations. + Operations []*Operation `locationName:"operations" type:"list"` +} + +// String returns the string representation +func (s DetachDiskOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DetachDiskOutput) GoString() string { + return s.String() +} + +// SetOperations sets the Operations field's value. +func (s *DetachDiskOutput) SetOperations(v []*Operation) *DetachDiskOutput { + s.Operations = v + return s +} + +type DetachInstancesFromLoadBalancerInput struct { + _ struct{} `type:"structure"` + + // An array of strings containing the names of the instances you want to detach + // from the load balancer. + // + // InstanceNames is a required field + InstanceNames []*string `locationName:"instanceNames" type:"list" required:"true"` + + // The name of the Lightsail load balancer. + // + // LoadBalancerName is a required field + LoadBalancerName *string `locationName:"loadBalancerName" type:"string" required:"true"` +} + +// String returns the string representation +func (s DetachInstancesFromLoadBalancerInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DetachInstancesFromLoadBalancerInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *DetachInstancesFromLoadBalancerInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "DetachInstancesFromLoadBalancerInput"} + if s.InstanceNames == nil { + invalidParams.Add(request.NewErrParamRequired("InstanceNames")) + } + if s.LoadBalancerName == nil { + invalidParams.Add(request.NewErrParamRequired("LoadBalancerName")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetInstanceNames sets the InstanceNames field's value. +func (s *DetachInstancesFromLoadBalancerInput) SetInstanceNames(v []*string) *DetachInstancesFromLoadBalancerInput { + s.InstanceNames = v + return s +} + +// SetLoadBalancerName sets the LoadBalancerName field's value. +func (s *DetachInstancesFromLoadBalancerInput) SetLoadBalancerName(v string) *DetachInstancesFromLoadBalancerInput { + s.LoadBalancerName = &v + return s +} + +type DetachInstancesFromLoadBalancerOutput struct { + _ struct{} `type:"structure"` + + // An object describing the API operations. + Operations []*Operation `locationName:"operations" type:"list"` +} + +// String returns the string representation +func (s DetachInstancesFromLoadBalancerOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DetachInstancesFromLoadBalancerOutput) GoString() string { + return s.String() +} + +// SetOperations sets the Operations field's value. +func (s *DetachInstancesFromLoadBalancerOutput) SetOperations(v []*Operation) *DetachInstancesFromLoadBalancerOutput { + s.Operations = v + return s +} + +type DetachStaticIpInput struct { + _ struct{} `type:"structure"` + + // The name of the static IP to detach from the instance. + // + // StaticIpName is a required field + StaticIpName *string `locationName:"staticIpName" type:"string" required:"true"` +} + +// String returns the string representation +func (s DetachStaticIpInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DetachStaticIpInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *DetachStaticIpInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "DetachStaticIpInput"} + if s.StaticIpName == nil { + invalidParams.Add(request.NewErrParamRequired("StaticIpName")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetStaticIpName sets the StaticIpName field's value. +func (s *DetachStaticIpInput) SetStaticIpName(v string) *DetachStaticIpInput { + s.StaticIpName = &v + return s +} + +type DetachStaticIpOutput struct { + _ struct{} `type:"structure"` + + // An array of key-value pairs containing information about the results of your + // detach static IP request. + Operations []*Operation `locationName:"operations" type:"list"` +} + +// String returns the string representation +func (s DetachStaticIpOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DetachStaticIpOutput) GoString() string { + return s.String() +} + +// SetOperations sets the Operations field's value. +func (s *DetachStaticIpOutput) SetOperations(v []*Operation) *DetachStaticIpOutput { + s.Operations = v + return s +} + +// Describes a system disk or an block storage disk. +type Disk struct { + _ struct{} `type:"structure"` + + // The Amazon Resource Name (ARN) of the disk. + Arn *string `locationName:"arn" type:"string"` + + // The resources to which the disk is attached. + AttachedTo *string `locationName:"attachedTo" type:"string"` + + // (Deprecated) The attachment state of the disk. + // + // In releases prior to November 14, 2017, this parameter returned attached + // for system disks in the API response. It is now deprecated, but still included + // in the response. Use isAttached instead. + AttachmentState *string `locationName:"attachmentState" deprecated:"true" type:"string"` + + // The date when the disk was created. + CreatedAt *time.Time `locationName:"createdAt" type:"timestamp" timestampFormat:"unix"` + + // (Deprecated) The number of GB in use by the disk. + // + // In releases prior to November 14, 2017, this parameter was not included in + // the API response. It is now deprecated. + GbInUse *int64 `locationName:"gbInUse" deprecated:"true" type:"integer"` + + // The input/output operations per second (IOPS) of the disk. + Iops *int64 `locationName:"iops" type:"integer"` + + // A Boolean value indicating whether the disk is attached. + IsAttached *bool `locationName:"isAttached" type:"boolean"` + + // A Boolean value indicating whether this disk is a system disk (has an operating + // system loaded on it). + IsSystemDisk *bool `locationName:"isSystemDisk" type:"boolean"` + + // The AWS Region and Availability Zone where the disk is located. + Location *ResourceLocation `locationName:"location" type:"structure"` + + // The unique name of the disk. + Name *string `locationName:"name" type:"string"` + + // The disk path. + Path *string `locationName:"path" type:"string"` + + // The Lightsail resource type (e.g., Disk). + ResourceType *string `locationName:"resourceType" type:"string" enum:"ResourceType"` + + // The size of the disk in GB. + SizeInGb *int64 `locationName:"sizeInGb" type:"integer"` + + // Describes the status of the disk. + State *string `locationName:"state" type:"string" enum:"DiskState"` + + // The support code. Include this code in your email to support when you have + // questions about an instance or another resource in Lightsail. This code enables + // our support team to look up your Lightsail information more easily. + SupportCode *string `locationName:"supportCode" type:"string"` +} + +// String returns the string representation +func (s Disk) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s Disk) GoString() string { + return s.String() +} + +// SetArn sets the Arn field's value. +func (s *Disk) SetArn(v string) *Disk { + s.Arn = &v + return s +} + +// SetAttachedTo sets the AttachedTo field's value. +func (s *Disk) SetAttachedTo(v string) *Disk { + s.AttachedTo = &v + return s +} + +// SetAttachmentState sets the AttachmentState field's value. +func (s *Disk) SetAttachmentState(v string) *Disk { + s.AttachmentState = &v + return s +} + +// SetCreatedAt sets the CreatedAt field's value. +func (s *Disk) SetCreatedAt(v time.Time) *Disk { + s.CreatedAt = &v + return s +} + +// SetGbInUse sets the GbInUse field's value. +func (s *Disk) SetGbInUse(v int64) *Disk { + s.GbInUse = &v + return s +} + +// SetIops sets the Iops field's value. +func (s *Disk) SetIops(v int64) *Disk { + s.Iops = &v + return s +} + +// SetIsAttached sets the IsAttached field's value. +func (s *Disk) SetIsAttached(v bool) *Disk { + s.IsAttached = &v + return s +} + +// SetIsSystemDisk sets the IsSystemDisk field's value. +func (s *Disk) SetIsSystemDisk(v bool) *Disk { + s.IsSystemDisk = &v + return s +} + +// SetLocation sets the Location field's value. +func (s *Disk) SetLocation(v *ResourceLocation) *Disk { + s.Location = v + return s +} + +// SetName sets the Name field's value. +func (s *Disk) SetName(v string) *Disk { + s.Name = &v + return s +} + +// SetPath sets the Path field's value. +func (s *Disk) SetPath(v string) *Disk { + s.Path = &v + return s +} + +// SetResourceType sets the ResourceType field's value. +func (s *Disk) SetResourceType(v string) *Disk { + s.ResourceType = &v + return s +} + +// SetSizeInGb sets the SizeInGb field's value. +func (s *Disk) SetSizeInGb(v int64) *Disk { + s.SizeInGb = &v + return s +} + +// SetState sets the State field's value. +func (s *Disk) SetState(v string) *Disk { + s.State = &v + return s +} + +// SetSupportCode sets the SupportCode field's value. +func (s *Disk) SetSupportCode(v string) *Disk { + s.SupportCode = &v + return s +} + +// Describes a block storage disk mapping. +type DiskMap struct { + _ struct{} `type:"structure"` + + // The new disk name (e.g., my-new-disk). + NewDiskName *string `locationName:"newDiskName" type:"string"` + + // The original disk path exposed to the instance (for example, /dev/sdh). + OriginalDiskPath *string `locationName:"originalDiskPath" type:"string"` +} + +// String returns the string representation +func (s DiskMap) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DiskMap) GoString() string { + return s.String() +} + +// SetNewDiskName sets the NewDiskName field's value. +func (s *DiskMap) SetNewDiskName(v string) *DiskMap { + s.NewDiskName = &v + return s +} + +// SetOriginalDiskPath sets the OriginalDiskPath field's value. +func (s *DiskMap) SetOriginalDiskPath(v string) *DiskMap { + s.OriginalDiskPath = &v + return s +} + +// Describes a block storage disk snapshot. +type DiskSnapshot struct { + _ struct{} `type:"structure"` + + // The Amazon Resource Name (ARN) of the disk snapshot. + Arn *string `locationName:"arn" type:"string"` + + // The date when the disk snapshot was created. + CreatedAt *time.Time `locationName:"createdAt" type:"timestamp" timestampFormat:"unix"` + + // The Amazon Resource Name (ARN) of the source disk from which you are creating + // the disk snapshot. + FromDiskArn *string `locationName:"fromDiskArn" type:"string"` + + // The unique name of the source disk from which you are creating the disk snapshot. + FromDiskName *string `locationName:"fromDiskName" type:"string"` + + // The AWS Region and Availability Zone where the disk snapshot was created. + Location *ResourceLocation `locationName:"location" type:"structure"` + + // The name of the disk snapshot (e.g., my-disk-snapshot). + Name *string `locationName:"name" type:"string"` + + // The progress of the disk snapshot operation. + Progress *string `locationName:"progress" type:"string"` + + // The Lightsail resource type (e.g., DiskSnapshot). + ResourceType *string `locationName:"resourceType" type:"string" enum:"ResourceType"` + + // The size of the disk in GB. + SizeInGb *int64 `locationName:"sizeInGb" type:"integer"` + + // The status of the disk snapshot operation. + State *string `locationName:"state" type:"string" enum:"DiskSnapshotState"` + + // The support code. Include this code in your email to support when you have + // questions about an instance or another resource in Lightsail. This code enables + // our support team to look up your Lightsail information more easily. + SupportCode *string `locationName:"supportCode" type:"string"` +} + +// String returns the string representation +func (s DiskSnapshot) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DiskSnapshot) GoString() string { + return s.String() +} + +// SetArn sets the Arn field's value. +func (s *DiskSnapshot) SetArn(v string) *DiskSnapshot { + s.Arn = &v + return s +} + +// SetCreatedAt sets the CreatedAt field's value. +func (s *DiskSnapshot) SetCreatedAt(v time.Time) *DiskSnapshot { + s.CreatedAt = &v + return s +} + +// SetFromDiskArn sets the FromDiskArn field's value. +func (s *DiskSnapshot) SetFromDiskArn(v string) *DiskSnapshot { + s.FromDiskArn = &v + return s +} + +// SetFromDiskName sets the FromDiskName field's value. +func (s *DiskSnapshot) SetFromDiskName(v string) *DiskSnapshot { + s.FromDiskName = &v + return s +} + +// SetLocation sets the Location field's value. +func (s *DiskSnapshot) SetLocation(v *ResourceLocation) *DiskSnapshot { + s.Location = v + return s +} + +// SetName sets the Name field's value. +func (s *DiskSnapshot) SetName(v string) *DiskSnapshot { + s.Name = &v + return s +} + +// SetProgress sets the Progress field's value. +func (s *DiskSnapshot) SetProgress(v string) *DiskSnapshot { + s.Progress = &v + return s +} + +// SetResourceType sets the ResourceType field's value. +func (s *DiskSnapshot) SetResourceType(v string) *DiskSnapshot { + s.ResourceType = &v + return s +} + +// SetSizeInGb sets the SizeInGb field's value. +func (s *DiskSnapshot) SetSizeInGb(v int64) *DiskSnapshot { + s.SizeInGb = &v + return s +} + +// SetState sets the State field's value. +func (s *DiskSnapshot) SetState(v string) *DiskSnapshot { + s.State = &v + return s +} + +// SetSupportCode sets the SupportCode field's value. +func (s *DiskSnapshot) SetSupportCode(v string) *DiskSnapshot { + s.SupportCode = &v + return s +} + +// Describes a domain where you are storing recordsets in Lightsail. +type Domain struct { + _ struct{} `type:"structure"` + + // The Amazon Resource Name (ARN) of the domain recordset (e.g., arn:aws:lightsail:global:123456789101:Domain/824cede0-abc7-4f84-8dbc-12345EXAMPLE). + Arn *string `locationName:"arn" type:"string"` + + // The date when the domain recordset was created. + CreatedAt *time.Time `locationName:"createdAt" type:"timestamp" timestampFormat:"unix"` + + // An array of key-value pairs containing information about the domain entries. + DomainEntries []*DomainEntry `locationName:"domainEntries" type:"list"` + + // The AWS Region and Availability Zones where the domain recordset was created. + Location *ResourceLocation `locationName:"location" type:"structure"` + + // The name of the domain. + Name *string `locationName:"name" type:"string"` + + // The resource type. + ResourceType *string `locationName:"resourceType" type:"string" enum:"ResourceType"` + + // The support code. Include this code in your email to support when you have + // questions about an instance or another resource in Lightsail. This code enables + // our support team to look up your Lightsail information more easily. + SupportCode *string `locationName:"supportCode" type:"string"` +} + +// String returns the string representation +func (s Domain) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s Domain) GoString() string { + return s.String() +} + +// SetArn sets the Arn field's value. +func (s *Domain) SetArn(v string) *Domain { + s.Arn = &v + return s +} + +// SetCreatedAt sets the CreatedAt field's value. +func (s *Domain) SetCreatedAt(v time.Time) *Domain { + s.CreatedAt = &v + return s +} + +// SetDomainEntries sets the DomainEntries field's value. +func (s *Domain) SetDomainEntries(v []*DomainEntry) *Domain { + s.DomainEntries = v + return s +} + +// SetLocation sets the Location field's value. +func (s *Domain) SetLocation(v *ResourceLocation) *Domain { + s.Location = v + return s +} + +// SetName sets the Name field's value. +func (s *Domain) SetName(v string) *Domain { + s.Name = &v + return s +} + +// SetResourceType sets the ResourceType field's value. +func (s *Domain) SetResourceType(v string) *Domain { + s.ResourceType = &v + return s +} + +// SetSupportCode sets the SupportCode field's value. +func (s *Domain) SetSupportCode(v string) *Domain { + s.SupportCode = &v + return s +} + +// Describes a domain recordset entry. +type DomainEntry struct { + _ struct{} `type:"structure"` + + // The ID of the domain recordset entry. + Id *string `locationName:"id" type:"string"` + + // When true, specifies whether the domain entry is an alias used by the Lightsail + // load balancer. + IsAlias *bool `locationName:"isAlias" type:"boolean"` + + // The name of the domain. + Name *string `locationName:"name" type:"string"` + + // (Deprecated) The options for the domain entry. + // + // In releases prior to November 29, 2017, this parameter was not included in + // the API response. It is now deprecated. + Options map[string]*string `locationName:"options" deprecated:"true" type:"map"` + + // The target AWS name server (e.g., ns-111.awsdns-22.com.). + Target *string `locationName:"target" type:"string"` + + // The type of domain entry (e.g., SOA or NS). + Type *string `locationName:"type" type:"string"` +} + +// String returns the string representation +func (s DomainEntry) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DomainEntry) GoString() string { + return s.String() +} + +// SetId sets the Id field's value. +func (s *DomainEntry) SetId(v string) *DomainEntry { + s.Id = &v + return s +} + +// SetIsAlias sets the IsAlias field's value. +func (s *DomainEntry) SetIsAlias(v bool) *DomainEntry { + s.IsAlias = &v + return s +} + +// SetName sets the Name field's value. +func (s *DomainEntry) SetName(v string) *DomainEntry { + s.Name = &v + return s +} + +// SetOptions sets the Options field's value. +func (s *DomainEntry) SetOptions(v map[string]*string) *DomainEntry { + s.Options = v + return s +} + +// SetTarget sets the Target field's value. +func (s *DomainEntry) SetTarget(v string) *DomainEntry { + s.Target = &v + return s +} + +// SetType sets the Type field's value. +func (s *DomainEntry) SetType(v string) *DomainEntry { + s.Type = &v + return s +} + +type DownloadDefaultKeyPairInput struct { + _ struct{} `type:"structure"` +} + +// String returns the string representation +func (s DownloadDefaultKeyPairInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DownloadDefaultKeyPairInput) GoString() string { + return s.String() +} + +type DownloadDefaultKeyPairOutput struct { + _ struct{} `type:"structure"` + + // A base64-encoded RSA private key. + PrivateKeyBase64 *string `locationName:"privateKeyBase64" type:"string"` + + // A base64-encoded public key of the ssh-rsa type. + PublicKeyBase64 *string `locationName:"publicKeyBase64" type:"string"` +} + +// String returns the string representation +func (s DownloadDefaultKeyPairOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DownloadDefaultKeyPairOutput) GoString() string { + return s.String() +} + +// SetPrivateKeyBase64 sets the PrivateKeyBase64 field's value. +func (s *DownloadDefaultKeyPairOutput) SetPrivateKeyBase64(v string) *DownloadDefaultKeyPairOutput { + s.PrivateKeyBase64 = &v + return s +} + +// SetPublicKeyBase64 sets the PublicKeyBase64 field's value. +func (s *DownloadDefaultKeyPairOutput) SetPublicKeyBase64(v string) *DownloadDefaultKeyPairOutput { + s.PublicKeyBase64 = &v + return s +} + +type GetActiveNamesInput struct { + _ struct{} `type:"structure"` + + // A token used for paginating results from your get active names request. + PageToken *string `locationName:"pageToken" type:"string"` +} + +// String returns the string representation +func (s GetActiveNamesInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetActiveNamesInput) GoString() string { + return s.String() +} + +// SetPageToken sets the PageToken field's value. +func (s *GetActiveNamesInput) SetPageToken(v string) *GetActiveNamesInput { + s.PageToken = &v + return s +} + +type GetActiveNamesOutput struct { + _ struct{} `type:"structure"` + + // The list of active names returned by the get active names request. + ActiveNames []*string `locationName:"activeNames" type:"list"` + + // A token used for advancing to the next page of results from your get active + // names request. + NextPageToken *string `locationName:"nextPageToken" type:"string"` +} + +// String returns the string representation +func (s GetActiveNamesOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetActiveNamesOutput) GoString() string { + return s.String() +} + +// SetActiveNames sets the ActiveNames field's value. +func (s *GetActiveNamesOutput) SetActiveNames(v []*string) *GetActiveNamesOutput { + s.ActiveNames = v + return s +} + +// SetNextPageToken sets the NextPageToken field's value. +func (s *GetActiveNamesOutput) SetNextPageToken(v string) *GetActiveNamesOutput { + s.NextPageToken = &v + return s +} + +type GetBlueprintsInput struct { + _ struct{} `type:"structure"` + + // A Boolean value indicating whether to include inactive results in your request. + IncludeInactive *bool `locationName:"includeInactive" type:"boolean"` + + // A token used for advancing to the next page of results from your get blueprints + // request. + PageToken *string `locationName:"pageToken" type:"string"` +} + +// String returns the string representation +func (s GetBlueprintsInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetBlueprintsInput) GoString() string { + return s.String() +} + +// SetIncludeInactive sets the IncludeInactive field's value. +func (s *GetBlueprintsInput) SetIncludeInactive(v bool) *GetBlueprintsInput { + s.IncludeInactive = &v + return s +} + +// SetPageToken sets the PageToken field's value. +func (s *GetBlueprintsInput) SetPageToken(v string) *GetBlueprintsInput { + s.PageToken = &v + return s +} + +type GetBlueprintsOutput struct { + _ struct{} `type:"structure"` + + // An array of key-value pairs that contains information about the available + // blueprints. + Blueprints []*Blueprint `locationName:"blueprints" type:"list"` + + // A token used for advancing to the next page of results from your get blueprints + // request. + NextPageToken *string `locationName:"nextPageToken" type:"string"` +} + +// String returns the string representation +func (s GetBlueprintsOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetBlueprintsOutput) GoString() string { + return s.String() +} + +// SetBlueprints sets the Blueprints field's value. +func (s *GetBlueprintsOutput) SetBlueprints(v []*Blueprint) *GetBlueprintsOutput { + s.Blueprints = v + return s +} + +// SetNextPageToken sets the NextPageToken field's value. +func (s *GetBlueprintsOutput) SetNextPageToken(v string) *GetBlueprintsOutput { + s.NextPageToken = &v + return s +} + +type GetBundlesInput struct { + _ struct{} `type:"structure"` + + // A Boolean value that indicates whether to include inactive bundle results + // in your request. + IncludeInactive *bool `locationName:"includeInactive" type:"boolean"` + + // A token used for advancing to the next page of results from your get bundles + // request. + PageToken *string `locationName:"pageToken" type:"string"` +} + +// String returns the string representation +func (s GetBundlesInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetBundlesInput) GoString() string { + return s.String() +} + +// SetIncludeInactive sets the IncludeInactive field's value. +func (s *GetBundlesInput) SetIncludeInactive(v bool) *GetBundlesInput { + s.IncludeInactive = &v + return s +} + +// SetPageToken sets the PageToken field's value. +func (s *GetBundlesInput) SetPageToken(v string) *GetBundlesInput { + s.PageToken = &v + return s +} + +type GetBundlesOutput struct { + _ struct{} `type:"structure"` + + // An array of key-value pairs that contains information about the available + // bundles. + Bundles []*Bundle `locationName:"bundles" type:"list"` + + // A token used for advancing to the next page of results from your get active + // names request. + NextPageToken *string `locationName:"nextPageToken" type:"string"` +} + +// String returns the string representation +func (s GetBundlesOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetBundlesOutput) GoString() string { + return s.String() +} + +// SetBundles sets the Bundles field's value. +func (s *GetBundlesOutput) SetBundles(v []*Bundle) *GetBundlesOutput { + s.Bundles = v + return s +} + +// SetNextPageToken sets the NextPageToken field's value. +func (s *GetBundlesOutput) SetNextPageToken(v string) *GetBundlesOutput { + s.NextPageToken = &v + return s +} + +type GetDiskInput struct { + _ struct{} `type:"structure"` + + // The name of the disk (e.g., my-disk). + // + // DiskName is a required field + DiskName *string `locationName:"diskName" type:"string" required:"true"` +} + +// String returns the string representation +func (s GetDiskInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetDiskInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *GetDiskInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "GetDiskInput"} + if s.DiskName == nil { + invalidParams.Add(request.NewErrParamRequired("DiskName")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetDiskName sets the DiskName field's value. +func (s *GetDiskInput) SetDiskName(v string) *GetDiskInput { + s.DiskName = &v + return s +} + +type GetDiskOutput struct { + _ struct{} `type:"structure"` + + // An object containing information about the disk. + Disk *Disk `locationName:"disk" type:"structure"` +} + +// String returns the string representation +func (s GetDiskOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetDiskOutput) GoString() string { + return s.String() +} + +// SetDisk sets the Disk field's value. +func (s *GetDiskOutput) SetDisk(v *Disk) *GetDiskOutput { + s.Disk = v + return s +} + +type GetDiskSnapshotInput struct { + _ struct{} `type:"structure"` + + // The name of the disk snapshot (e.g., my-disk-snapshot). + // + // DiskSnapshotName is a required field + DiskSnapshotName *string `locationName:"diskSnapshotName" type:"string" required:"true"` +} + +// String returns the string representation +func (s GetDiskSnapshotInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetDiskSnapshotInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *GetDiskSnapshotInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "GetDiskSnapshotInput"} + if s.DiskSnapshotName == nil { + invalidParams.Add(request.NewErrParamRequired("DiskSnapshotName")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetDiskSnapshotName sets the DiskSnapshotName field's value. +func (s *GetDiskSnapshotInput) SetDiskSnapshotName(v string) *GetDiskSnapshotInput { + s.DiskSnapshotName = &v + return s +} + +type GetDiskSnapshotOutput struct { + _ struct{} `type:"structure"` + + // An object containing information about the disk snapshot. + DiskSnapshot *DiskSnapshot `locationName:"diskSnapshot" type:"structure"` +} + +// String returns the string representation +func (s GetDiskSnapshotOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetDiskSnapshotOutput) GoString() string { + return s.String() +} + +// SetDiskSnapshot sets the DiskSnapshot field's value. +func (s *GetDiskSnapshotOutput) SetDiskSnapshot(v *DiskSnapshot) *GetDiskSnapshotOutput { + s.DiskSnapshot = v + return s +} + +type GetDiskSnapshotsInput struct { + _ struct{} `type:"structure"` + + // A token used for advancing to the next page of results from your GetDiskSnapshots + // request. + PageToken *string `locationName:"pageToken" type:"string"` +} + +// String returns the string representation +func (s GetDiskSnapshotsInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetDiskSnapshotsInput) GoString() string { + return s.String() +} + +// SetPageToken sets the PageToken field's value. +func (s *GetDiskSnapshotsInput) SetPageToken(v string) *GetDiskSnapshotsInput { + s.PageToken = &v + return s +} + +type GetDiskSnapshotsOutput struct { + _ struct{} `type:"structure"` + + // An array of objects containing information about all block storage disk snapshots. + DiskSnapshots []*DiskSnapshot `locationName:"diskSnapshots" type:"list"` + + // A token used for advancing to the next page of results from your GetDiskSnapshots + // request. + NextPageToken *string `locationName:"nextPageToken" type:"string"` +} + +// String returns the string representation +func (s GetDiskSnapshotsOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetDiskSnapshotsOutput) GoString() string { + return s.String() +} + +// SetDiskSnapshots sets the DiskSnapshots field's value. +func (s *GetDiskSnapshotsOutput) SetDiskSnapshots(v []*DiskSnapshot) *GetDiskSnapshotsOutput { + s.DiskSnapshots = v + return s +} + +// SetNextPageToken sets the NextPageToken field's value. +func (s *GetDiskSnapshotsOutput) SetNextPageToken(v string) *GetDiskSnapshotsOutput { + s.NextPageToken = &v + return s +} + +type GetDisksInput struct { + _ struct{} `type:"structure"` + + // A token used for advancing to the next page of results from your GetDisks + // request. + PageToken *string `locationName:"pageToken" type:"string"` +} + +// String returns the string representation +func (s GetDisksInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetDisksInput) GoString() string { + return s.String() +} + +// SetPageToken sets the PageToken field's value. +func (s *GetDisksInput) SetPageToken(v string) *GetDisksInput { + s.PageToken = &v + return s +} + +type GetDisksOutput struct { + _ struct{} `type:"structure"` + + // An array of objects containing information about all block storage disks. + Disks []*Disk `locationName:"disks" type:"list"` + + // A token used for advancing to the next page of results from your GetDisks + // request. + NextPageToken *string `locationName:"nextPageToken" type:"string"` +} + +// String returns the string representation +func (s GetDisksOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetDisksOutput) GoString() string { + return s.String() +} + +// SetDisks sets the Disks field's value. +func (s *GetDisksOutput) SetDisks(v []*Disk) *GetDisksOutput { + s.Disks = v + return s +} + +// SetNextPageToken sets the NextPageToken field's value. +func (s *GetDisksOutput) SetNextPageToken(v string) *GetDisksOutput { + s.NextPageToken = &v + return s +} + +type GetDomainInput struct { + _ struct{} `type:"structure"` + + // The domain name for which your want to return information about. + // + // DomainName is a required field + DomainName *string `locationName:"domainName" type:"string" required:"true"` +} + +// String returns the string representation +func (s GetDomainInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetDomainInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *GetDomainInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "GetDomainInput"} + if s.DomainName == nil { + invalidParams.Add(request.NewErrParamRequired("DomainName")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetDomainName sets the DomainName field's value. +func (s *GetDomainInput) SetDomainName(v string) *GetDomainInput { + s.DomainName = &v + return s +} + +type GetDomainOutput struct { + _ struct{} `type:"structure"` + + // An array of key-value pairs containing information about your get domain + // request. + Domain *Domain `locationName:"domain" type:"structure"` +} + +// String returns the string representation +func (s GetDomainOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetDomainOutput) GoString() string { + return s.String() +} + +// SetDomain sets the Domain field's value. +func (s *GetDomainOutput) SetDomain(v *Domain) *GetDomainOutput { + s.Domain = v + return s +} + +type GetDomainsInput struct { + _ struct{} `type:"structure"` + + // A token used for advancing to the next page of results from your get domains + // request. + PageToken *string `locationName:"pageToken" type:"string"` +} + +// String returns the string representation +func (s GetDomainsInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetDomainsInput) GoString() string { + return s.String() +} + +// SetPageToken sets the PageToken field's value. +func (s *GetDomainsInput) SetPageToken(v string) *GetDomainsInput { + s.PageToken = &v + return s +} + +type GetDomainsOutput struct { + _ struct{} `type:"structure"` + + // An array of key-value pairs containing information about each of the domain + // entries in the user's account. + Domains []*Domain `locationName:"domains" type:"list"` + + // A token used for advancing to the next page of results from your get active + // names request. + NextPageToken *string `locationName:"nextPageToken" type:"string"` +} + +// String returns the string representation +func (s GetDomainsOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetDomainsOutput) GoString() string { + return s.String() +} + +// SetDomains sets the Domains field's value. +func (s *GetDomainsOutput) SetDomains(v []*Domain) *GetDomainsOutput { + s.Domains = v + return s +} + +// SetNextPageToken sets the NextPageToken field's value. +func (s *GetDomainsOutput) SetNextPageToken(v string) *GetDomainsOutput { + s.NextPageToken = &v + return s +} + +type GetInstanceAccessDetailsInput struct { + _ struct{} `type:"structure"` + + // The name of the instance to access. + // + // InstanceName is a required field + InstanceName *string `locationName:"instanceName" type:"string" required:"true"` + + // The protocol to use to connect to your instance. Defaults to ssh. + Protocol *string `locationName:"protocol" type:"string" enum:"InstanceAccessProtocol"` +} + +// String returns the string representation +func (s GetInstanceAccessDetailsInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetInstanceAccessDetailsInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *GetInstanceAccessDetailsInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "GetInstanceAccessDetailsInput"} + if s.InstanceName == nil { + invalidParams.Add(request.NewErrParamRequired("InstanceName")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetInstanceName sets the InstanceName field's value. +func (s *GetInstanceAccessDetailsInput) SetInstanceName(v string) *GetInstanceAccessDetailsInput { + s.InstanceName = &v + return s +} + +// SetProtocol sets the Protocol field's value. +func (s *GetInstanceAccessDetailsInput) SetProtocol(v string) *GetInstanceAccessDetailsInput { + s.Protocol = &v + return s +} + +type GetInstanceAccessDetailsOutput struct { + _ struct{} `type:"structure"` + + // An array of key-value pairs containing information about a get instance access + // request. + AccessDetails *InstanceAccessDetails `locationName:"accessDetails" type:"structure"` +} + +// String returns the string representation +func (s GetInstanceAccessDetailsOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetInstanceAccessDetailsOutput) GoString() string { + return s.String() +} + +// SetAccessDetails sets the AccessDetails field's value. +func (s *GetInstanceAccessDetailsOutput) SetAccessDetails(v *InstanceAccessDetails) *GetInstanceAccessDetailsOutput { + s.AccessDetails = v + return s +} + +type GetInstanceInput struct { + _ struct{} `type:"structure"` + + // The name of the instance. + // + // InstanceName is a required field + InstanceName *string `locationName:"instanceName" type:"string" required:"true"` +} + +// String returns the string representation +func (s GetInstanceInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetInstanceInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *GetInstanceInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "GetInstanceInput"} + if s.InstanceName == nil { + invalidParams.Add(request.NewErrParamRequired("InstanceName")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetInstanceName sets the InstanceName field's value. +func (s *GetInstanceInput) SetInstanceName(v string) *GetInstanceInput { + s.InstanceName = &v + return s +} + +type GetInstanceMetricDataInput struct { + _ struct{} `type:"structure"` + + // The end time of the time period. + // + // EndTime is a required field + EndTime *time.Time `locationName:"endTime" type:"timestamp" timestampFormat:"unix" required:"true"` + + // The name of the instance for which you want to get metrics data. + // + // InstanceName is a required field + InstanceName *string `locationName:"instanceName" type:"string" required:"true"` + + // The metric name to get data about. + // + // MetricName is a required field + MetricName *string `locationName:"metricName" type:"string" required:"true" enum:"InstanceMetricName"` + + // The time period for which you are requesting data. + // + // Period is a required field + Period *int64 `locationName:"period" min:"60" type:"integer" required:"true"` + + // The start time of the time period. + // + // StartTime is a required field + StartTime *time.Time `locationName:"startTime" type:"timestamp" timestampFormat:"unix" required:"true"` + + // The instance statistics. + // + // Statistics is a required field + Statistics []*string `locationName:"statistics" type:"list" required:"true"` + + // The unit. The list of valid values is below. + // + // Unit is a required field + Unit *string `locationName:"unit" type:"string" required:"true" enum:"MetricUnit"` +} + +// String returns the string representation +func (s GetInstanceMetricDataInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetInstanceMetricDataInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *GetInstanceMetricDataInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "GetInstanceMetricDataInput"} + if s.EndTime == nil { + invalidParams.Add(request.NewErrParamRequired("EndTime")) + } + if s.InstanceName == nil { + invalidParams.Add(request.NewErrParamRequired("InstanceName")) + } + if s.MetricName == nil { + invalidParams.Add(request.NewErrParamRequired("MetricName")) + } + if s.Period == nil { + invalidParams.Add(request.NewErrParamRequired("Period")) + } + if s.Period != nil && *s.Period < 60 { + invalidParams.Add(request.NewErrParamMinValue("Period", 60)) + } + if s.StartTime == nil { + invalidParams.Add(request.NewErrParamRequired("StartTime")) + } + if s.Statistics == nil { + invalidParams.Add(request.NewErrParamRequired("Statistics")) + } + if s.Unit == nil { + invalidParams.Add(request.NewErrParamRequired("Unit")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetEndTime sets the EndTime field's value. +func (s *GetInstanceMetricDataInput) SetEndTime(v time.Time) *GetInstanceMetricDataInput { + s.EndTime = &v + return s +} + +// SetInstanceName sets the InstanceName field's value. +func (s *GetInstanceMetricDataInput) SetInstanceName(v string) *GetInstanceMetricDataInput { + s.InstanceName = &v + return s +} + +// SetMetricName sets the MetricName field's value. +func (s *GetInstanceMetricDataInput) SetMetricName(v string) *GetInstanceMetricDataInput { + s.MetricName = &v + return s +} + +// SetPeriod sets the Period field's value. +func (s *GetInstanceMetricDataInput) SetPeriod(v int64) *GetInstanceMetricDataInput { + s.Period = &v + return s +} + +// SetStartTime sets the StartTime field's value. +func (s *GetInstanceMetricDataInput) SetStartTime(v time.Time) *GetInstanceMetricDataInput { + s.StartTime = &v + return s +} + +// SetStatistics sets the Statistics field's value. +func (s *GetInstanceMetricDataInput) SetStatistics(v []*string) *GetInstanceMetricDataInput { + s.Statistics = v + return s +} + +// SetUnit sets the Unit field's value. +func (s *GetInstanceMetricDataInput) SetUnit(v string) *GetInstanceMetricDataInput { + s.Unit = &v + return s +} + +type GetInstanceMetricDataOutput struct { + _ struct{} `type:"structure"` + + // An array of key-value pairs containing information about the results of your + // get instance metric data request. + MetricData []*MetricDatapoint `locationName:"metricData" type:"list"` + + // The metric name to return data for. + MetricName *string `locationName:"metricName" type:"string" enum:"InstanceMetricName"` +} + +// String returns the string representation +func (s GetInstanceMetricDataOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetInstanceMetricDataOutput) GoString() string { + return s.String() +} + +// SetMetricData sets the MetricData field's value. +func (s *GetInstanceMetricDataOutput) SetMetricData(v []*MetricDatapoint) *GetInstanceMetricDataOutput { + s.MetricData = v + return s +} + +// SetMetricName sets the MetricName field's value. +func (s *GetInstanceMetricDataOutput) SetMetricName(v string) *GetInstanceMetricDataOutput { + s.MetricName = &v + return s +} + +type GetInstanceOutput struct { + _ struct{} `type:"structure"` + + // An array of key-value pairs containing information about the specified instance. + Instance *Instance `locationName:"instance" type:"structure"` +} + +// String returns the string representation +func (s GetInstanceOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetInstanceOutput) GoString() string { + return s.String() +} + +// SetInstance sets the Instance field's value. +func (s *GetInstanceOutput) SetInstance(v *Instance) *GetInstanceOutput { + s.Instance = v + return s +} + +type GetInstancePortStatesInput struct { + _ struct{} `type:"structure"` + + // The name of the instance. + // + // InstanceName is a required field + InstanceName *string `locationName:"instanceName" type:"string" required:"true"` +} + +// String returns the string representation +func (s GetInstancePortStatesInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetInstancePortStatesInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *GetInstancePortStatesInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "GetInstancePortStatesInput"} + if s.InstanceName == nil { + invalidParams.Add(request.NewErrParamRequired("InstanceName")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetInstanceName sets the InstanceName field's value. +func (s *GetInstancePortStatesInput) SetInstanceName(v string) *GetInstancePortStatesInput { + s.InstanceName = &v + return s +} + +type GetInstancePortStatesOutput struct { + _ struct{} `type:"structure"` + + // Information about the port states resulting from your request. + PortStates []*InstancePortState `locationName:"portStates" type:"list"` +} + +// String returns the string representation +func (s GetInstancePortStatesOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetInstancePortStatesOutput) GoString() string { + return s.String() +} + +// SetPortStates sets the PortStates field's value. +func (s *GetInstancePortStatesOutput) SetPortStates(v []*InstancePortState) *GetInstancePortStatesOutput { + s.PortStates = v + return s +} + +type GetInstanceSnapshotInput struct { + _ struct{} `type:"structure"` + + // The name of the snapshot for which you are requesting information. + // + // InstanceSnapshotName is a required field + InstanceSnapshotName *string `locationName:"instanceSnapshotName" type:"string" required:"true"` +} + +// String returns the string representation +func (s GetInstanceSnapshotInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetInstanceSnapshotInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *GetInstanceSnapshotInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "GetInstanceSnapshotInput"} + if s.InstanceSnapshotName == nil { + invalidParams.Add(request.NewErrParamRequired("InstanceSnapshotName")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetInstanceSnapshotName sets the InstanceSnapshotName field's value. +func (s *GetInstanceSnapshotInput) SetInstanceSnapshotName(v string) *GetInstanceSnapshotInput { + s.InstanceSnapshotName = &v + return s +} + +type GetInstanceSnapshotOutput struct { + _ struct{} `type:"structure"` + + // An array of key-value pairs containing information about the results of your + // get instance snapshot request. + InstanceSnapshot *InstanceSnapshot `locationName:"instanceSnapshot" type:"structure"` +} + +// String returns the string representation +func (s GetInstanceSnapshotOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetInstanceSnapshotOutput) GoString() string { + return s.String() +} + +// SetInstanceSnapshot sets the InstanceSnapshot field's value. +func (s *GetInstanceSnapshotOutput) SetInstanceSnapshot(v *InstanceSnapshot) *GetInstanceSnapshotOutput { + s.InstanceSnapshot = v + return s +} + +type GetInstanceSnapshotsInput struct { + _ struct{} `type:"structure"` + + // A token used for advancing to the next page of results from your get instance + // snapshots request. + PageToken *string `locationName:"pageToken" type:"string"` +} + +// String returns the string representation +func (s GetInstanceSnapshotsInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetInstanceSnapshotsInput) GoString() string { + return s.String() +} + +// SetPageToken sets the PageToken field's value. +func (s *GetInstanceSnapshotsInput) SetPageToken(v string) *GetInstanceSnapshotsInput { + s.PageToken = &v + return s +} + +type GetInstanceSnapshotsOutput struct { + _ struct{} `type:"structure"` + + // An array of key-value pairs containing information about the results of your + // get instance snapshots request. + InstanceSnapshots []*InstanceSnapshot `locationName:"instanceSnapshots" type:"list"` + + // A token used for advancing to the next page of results from your get instance + // snapshots request. + NextPageToken *string `locationName:"nextPageToken" type:"string"` +} + +// String returns the string representation +func (s GetInstanceSnapshotsOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetInstanceSnapshotsOutput) GoString() string { + return s.String() +} + +// SetInstanceSnapshots sets the InstanceSnapshots field's value. +func (s *GetInstanceSnapshotsOutput) SetInstanceSnapshots(v []*InstanceSnapshot) *GetInstanceSnapshotsOutput { + s.InstanceSnapshots = v + return s +} + +// SetNextPageToken sets the NextPageToken field's value. +func (s *GetInstanceSnapshotsOutput) SetNextPageToken(v string) *GetInstanceSnapshotsOutput { + s.NextPageToken = &v + return s +} + +type GetInstanceStateInput struct { + _ struct{} `type:"structure"` + + // The name of the instance to get state information about. + // + // InstanceName is a required field + InstanceName *string `locationName:"instanceName" type:"string" required:"true"` +} + +// String returns the string representation +func (s GetInstanceStateInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetInstanceStateInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *GetInstanceStateInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "GetInstanceStateInput"} + if s.InstanceName == nil { + invalidParams.Add(request.NewErrParamRequired("InstanceName")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetInstanceName sets the InstanceName field's value. +func (s *GetInstanceStateInput) SetInstanceName(v string) *GetInstanceStateInput { + s.InstanceName = &v + return s +} + +type GetInstanceStateOutput struct { + _ struct{} `type:"structure"` + + // The state of the instance. + State *InstanceState `locationName:"state" type:"structure"` +} + +// String returns the string representation +func (s GetInstanceStateOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetInstanceStateOutput) GoString() string { + return s.String() +} + +// SetState sets the State field's value. +func (s *GetInstanceStateOutput) SetState(v *InstanceState) *GetInstanceStateOutput { + s.State = v + return s +} + +type GetInstancesInput struct { + _ struct{} `type:"structure"` + + // A token used for advancing to the next page of results from your get instances + // request. + PageToken *string `locationName:"pageToken" type:"string"` +} + +// String returns the string representation +func (s GetInstancesInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetInstancesInput) GoString() string { + return s.String() +} + +// SetPageToken sets the PageToken field's value. +func (s *GetInstancesInput) SetPageToken(v string) *GetInstancesInput { + s.PageToken = &v + return s +} + +type GetInstancesOutput struct { + _ struct{} `type:"structure"` + + // An array of key-value pairs containing information about your instances. + Instances []*Instance `locationName:"instances" type:"list"` + + // A token used for advancing to the next page of results from your get instances + // request. + NextPageToken *string `locationName:"nextPageToken" type:"string"` +} + +// String returns the string representation +func (s GetInstancesOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetInstancesOutput) GoString() string { + return s.String() +} + +// SetInstances sets the Instances field's value. +func (s *GetInstancesOutput) SetInstances(v []*Instance) *GetInstancesOutput { + s.Instances = v + return s +} + +// SetNextPageToken sets the NextPageToken field's value. +func (s *GetInstancesOutput) SetNextPageToken(v string) *GetInstancesOutput { + s.NextPageToken = &v + return s +} + +type GetKeyPairInput struct { + _ struct{} `type:"structure"` + + // The name of the key pair for which you are requesting information. + // + // KeyPairName is a required field + KeyPairName *string `locationName:"keyPairName" type:"string" required:"true"` +} + +// String returns the string representation +func (s GetKeyPairInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetKeyPairInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *GetKeyPairInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "GetKeyPairInput"} + if s.KeyPairName == nil { + invalidParams.Add(request.NewErrParamRequired("KeyPairName")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetKeyPairName sets the KeyPairName field's value. +func (s *GetKeyPairInput) SetKeyPairName(v string) *GetKeyPairInput { + s.KeyPairName = &v + return s +} + +type GetKeyPairOutput struct { + _ struct{} `type:"structure"` + + // An array of key-value pairs containing information about the key pair. + KeyPair *KeyPair `locationName:"keyPair" type:"structure"` +} + +// String returns the string representation +func (s GetKeyPairOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetKeyPairOutput) GoString() string { + return s.String() +} + +// SetKeyPair sets the KeyPair field's value. +func (s *GetKeyPairOutput) SetKeyPair(v *KeyPair) *GetKeyPairOutput { + s.KeyPair = v + return s +} + +type GetKeyPairsInput struct { + _ struct{} `type:"structure"` + + // A token used for advancing to the next page of results from your get key + // pairs request. + PageToken *string `locationName:"pageToken" type:"string"` +} + +// String returns the string representation +func (s GetKeyPairsInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetKeyPairsInput) GoString() string { + return s.String() +} + +// SetPageToken sets the PageToken field's value. +func (s *GetKeyPairsInput) SetPageToken(v string) *GetKeyPairsInput { + s.PageToken = &v + return s +} + +type GetKeyPairsOutput struct { + _ struct{} `type:"structure"` + + // An array of key-value pairs containing information about the key pairs. + KeyPairs []*KeyPair `locationName:"keyPairs" type:"list"` + + // A token used for advancing to the next page of results from your get key + // pairs request. + NextPageToken *string `locationName:"nextPageToken" type:"string"` +} + +// String returns the string representation +func (s GetKeyPairsOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetKeyPairsOutput) GoString() string { + return s.String() +} + +// SetKeyPairs sets the KeyPairs field's value. +func (s *GetKeyPairsOutput) SetKeyPairs(v []*KeyPair) *GetKeyPairsOutput { + s.KeyPairs = v + return s +} + +// SetNextPageToken sets the NextPageToken field's value. +func (s *GetKeyPairsOutput) SetNextPageToken(v string) *GetKeyPairsOutput { + s.NextPageToken = &v + return s +} + +type GetLoadBalancerInput struct { + _ struct{} `type:"structure"` + + // The name of the load balancer. + // + // LoadBalancerName is a required field + LoadBalancerName *string `locationName:"loadBalancerName" type:"string" required:"true"` +} + +// String returns the string representation +func (s GetLoadBalancerInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetLoadBalancerInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *GetLoadBalancerInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "GetLoadBalancerInput"} + if s.LoadBalancerName == nil { + invalidParams.Add(request.NewErrParamRequired("LoadBalancerName")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetLoadBalancerName sets the LoadBalancerName field's value. +func (s *GetLoadBalancerInput) SetLoadBalancerName(v string) *GetLoadBalancerInput { + s.LoadBalancerName = &v + return s +} + +type GetLoadBalancerMetricDataInput struct { + _ struct{} `type:"structure"` + + // The end time of the period. + // + // EndTime is a required field + EndTime *time.Time `locationName:"endTime" type:"timestamp" timestampFormat:"unix" required:"true"` + + // The name of the load balancer. + // + // LoadBalancerName is a required field + LoadBalancerName *string `locationName:"loadBalancerName" type:"string" required:"true"` + + // The metric about which you want to return information. Valid values are listed + // below, along with the most useful statistics to include in your request. + // + // * ClientTLSNegotiationErrorCount - The number of TLS connections initiated + // by the client that did not establish a session with the load balancer. + // Possible causes include a mismatch of ciphers or protocols. + // + // Statistics: The most useful statistic is Sum. + // + // * HealthyHostCount - The number of target instances that are considered + // healthy. + // + // Statistics: The most useful statistic are Average, Minimum, and Maximum. + // + // * UnhealthyHostCount - The number of target instances that are considered + // unhealthy. + // + // Statistics: The most useful statistic are Average, Minimum, and Maximum. + // + // * HTTPCode_LB_4XX_Count - The number of HTTP 4XX client error codes that + // originate from the load balancer. Client errors are generated when requests + // are malformed or incomplete. These requests have not been received by + // the target instance. This count does not include any response codes generated + // by the target instances. + // + // Statistics: The most useful statistic is Sum. Note that Minimum, Maximum, + // and Average all return 1. + // + // * HTTPCode_LB_5XX_Count - The number of HTTP 5XX server error codes that + // originate from the load balancer. This count does not include any response + // codes generated by the target instances. + // + // Statistics: The most useful statistic is Sum. Note that Minimum, Maximum, + // and Average all return 1. Note that Minimum, Maximum, and Average all + // return 1. + // + // * HTTPCode_Instance_2XX_Count - The number of HTTP response codes generated + // by the target instances. This does not include any response codes generated + // by the load balancer. + // + // Statistics: The most useful statistic is Sum. Note that Minimum, Maximum, + // and Average all return 1. + // + // * HTTPCode_Instance_3XX_Count - The number of HTTP response codes generated + // by the target instances. This does not include any response codes generated + // by the load balancer. + // + // Statistics: The most useful statistic is Sum. Note that Minimum, Maximum, + // and Average all return 1. + // + // * HTTPCode_Instance_4XX_Count - The number of HTTP response codes generated + // by the target instances. This does not include any response codes generated + // by the load balancer. + // + // Statistics: The most useful statistic is Sum. Note that Minimum, Maximum, + // and Average all return 1. + // + // * HTTPCode_Instance_5XX_Count - The number of HTTP response codes generated + // by the target instances. This does not include any response codes generated + // by the load balancer. + // + // Statistics: The most useful statistic is Sum. Note that Minimum, Maximum, + // and Average all return 1. + // + // * InstanceResponseTime - The time elapsed, in seconds, after the request + // leaves the load balancer until a response from the target instance is + // received. + // + // Statistics: The most useful statistic is Average. + // + // * RejectedConnectionCount - The number of connections that were rejected + // because the load balancer had reached its maximum number of connections. + // + // Statistics: The most useful statistic is Sum. + // + // * RequestCount - The number of requests processed over IPv4. This count + // includes only the requests with a response generated by a target instance + // of the load balancer. + // + // Statistics: The most useful statistic is Sum. Note that Minimum, Maximum, + // and Average all return 1. + // + // MetricName is a required field + MetricName *string `locationName:"metricName" type:"string" required:"true" enum:"LoadBalancerMetricName"` + + // The time period duration for your health data request. + // + // Period is a required field + Period *int64 `locationName:"period" min:"60" type:"integer" required:"true"` + + // The start time of the period. + // + // StartTime is a required field + StartTime *time.Time `locationName:"startTime" type:"timestamp" timestampFormat:"unix" required:"true"` + + // An array of statistics that you want to request metrics for. Valid values + // are listed below. + // + // Statistics is a required field + Statistics []*string `locationName:"statistics" type:"list" required:"true"` + + // The unit for the time period request. Valid values are listed below. + // + // Unit is a required field + Unit *string `locationName:"unit" type:"string" required:"true" enum:"MetricUnit"` +} + +// String returns the string representation +func (s GetLoadBalancerMetricDataInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetLoadBalancerMetricDataInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *GetLoadBalancerMetricDataInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "GetLoadBalancerMetricDataInput"} + if s.EndTime == nil { + invalidParams.Add(request.NewErrParamRequired("EndTime")) + } + if s.LoadBalancerName == nil { + invalidParams.Add(request.NewErrParamRequired("LoadBalancerName")) + } + if s.MetricName == nil { + invalidParams.Add(request.NewErrParamRequired("MetricName")) + } + if s.Period == nil { + invalidParams.Add(request.NewErrParamRequired("Period")) + } + if s.Period != nil && *s.Period < 60 { + invalidParams.Add(request.NewErrParamMinValue("Period", 60)) + } + if s.StartTime == nil { + invalidParams.Add(request.NewErrParamRequired("StartTime")) + } + if s.Statistics == nil { + invalidParams.Add(request.NewErrParamRequired("Statistics")) + } + if s.Unit == nil { + invalidParams.Add(request.NewErrParamRequired("Unit")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetEndTime sets the EndTime field's value. +func (s *GetLoadBalancerMetricDataInput) SetEndTime(v time.Time) *GetLoadBalancerMetricDataInput { + s.EndTime = &v + return s +} + +// SetLoadBalancerName sets the LoadBalancerName field's value. +func (s *GetLoadBalancerMetricDataInput) SetLoadBalancerName(v string) *GetLoadBalancerMetricDataInput { + s.LoadBalancerName = &v + return s +} + +// SetMetricName sets the MetricName field's value. +func (s *GetLoadBalancerMetricDataInput) SetMetricName(v string) *GetLoadBalancerMetricDataInput { + s.MetricName = &v + return s +} + +// SetPeriod sets the Period field's value. +func (s *GetLoadBalancerMetricDataInput) SetPeriod(v int64) *GetLoadBalancerMetricDataInput { + s.Period = &v + return s +} + +// SetStartTime sets the StartTime field's value. +func (s *GetLoadBalancerMetricDataInput) SetStartTime(v time.Time) *GetLoadBalancerMetricDataInput { + s.StartTime = &v + return s +} + +// SetStatistics sets the Statistics field's value. +func (s *GetLoadBalancerMetricDataInput) SetStatistics(v []*string) *GetLoadBalancerMetricDataInput { + s.Statistics = v + return s +} + +// SetUnit sets the Unit field's value. +func (s *GetLoadBalancerMetricDataInput) SetUnit(v string) *GetLoadBalancerMetricDataInput { + s.Unit = &v + return s +} + +type GetLoadBalancerMetricDataOutput struct { + _ struct{} `type:"structure"` + + // An array of metric datapoint objects. + MetricData []*MetricDatapoint `locationName:"metricData" type:"list"` + + // The metric about which you are receiving information. Valid values are listed + // below. + MetricName *string `locationName:"metricName" type:"string" enum:"LoadBalancerMetricName"` +} + +// String returns the string representation +func (s GetLoadBalancerMetricDataOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetLoadBalancerMetricDataOutput) GoString() string { + return s.String() +} + +// SetMetricData sets the MetricData field's value. +func (s *GetLoadBalancerMetricDataOutput) SetMetricData(v []*MetricDatapoint) *GetLoadBalancerMetricDataOutput { + s.MetricData = v + return s +} + +// SetMetricName sets the MetricName field's value. +func (s *GetLoadBalancerMetricDataOutput) SetMetricName(v string) *GetLoadBalancerMetricDataOutput { + s.MetricName = &v + return s +} + +type GetLoadBalancerOutput struct { + _ struct{} `type:"structure"` + + // An object containing information about your load balancer. + LoadBalancer *LoadBalancer `locationName:"loadBalancer" type:"structure"` +} + +// String returns the string representation +func (s GetLoadBalancerOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetLoadBalancerOutput) GoString() string { + return s.String() +} + +// SetLoadBalancer sets the LoadBalancer field's value. +func (s *GetLoadBalancerOutput) SetLoadBalancer(v *LoadBalancer) *GetLoadBalancerOutput { + s.LoadBalancer = v + return s +} + +type GetLoadBalancerTlsCertificatesInput struct { + _ struct{} `type:"structure"` + + // The name of the load balancer where you stored your TLS/SSL certificate. + // + // LoadBalancerName is a required field + LoadBalancerName *string `locationName:"loadBalancerName" type:"string" required:"true"` +} + +// String returns the string representation +func (s GetLoadBalancerTlsCertificatesInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetLoadBalancerTlsCertificatesInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *GetLoadBalancerTlsCertificatesInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "GetLoadBalancerTlsCertificatesInput"} + if s.LoadBalancerName == nil { + invalidParams.Add(request.NewErrParamRequired("LoadBalancerName")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetLoadBalancerName sets the LoadBalancerName field's value. +func (s *GetLoadBalancerTlsCertificatesInput) SetLoadBalancerName(v string) *GetLoadBalancerTlsCertificatesInput { + s.LoadBalancerName = &v + return s +} + +type GetLoadBalancerTlsCertificatesOutput struct { + _ struct{} `type:"structure"` + + // An array of LoadBalancerTlsCertificate objects describing your TLS/SSL certificates. + TlsCertificates []*LoadBalancerTlsCertificate `locationName:"tlsCertificates" type:"list"` +} + +// String returns the string representation +func (s GetLoadBalancerTlsCertificatesOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetLoadBalancerTlsCertificatesOutput) GoString() string { + return s.String() +} + +// SetTlsCertificates sets the TlsCertificates field's value. +func (s *GetLoadBalancerTlsCertificatesOutput) SetTlsCertificates(v []*LoadBalancerTlsCertificate) *GetLoadBalancerTlsCertificatesOutput { + s.TlsCertificates = v + return s +} + +type GetLoadBalancersInput struct { + _ struct{} `type:"structure"` + + // A token used for paginating the results from your GetLoadBalancers request. + PageToken *string `locationName:"pageToken" type:"string"` +} + +// String returns the string representation +func (s GetLoadBalancersInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetLoadBalancersInput) GoString() string { + return s.String() +} + +// SetPageToken sets the PageToken field's value. +func (s *GetLoadBalancersInput) SetPageToken(v string) *GetLoadBalancersInput { + s.PageToken = &v + return s +} + +type GetLoadBalancersOutput struct { + _ struct{} `type:"structure"` + + // An array of LoadBalancer objects describing your load balancers. + LoadBalancers []*LoadBalancer `locationName:"loadBalancers" type:"list"` + + // A token used for advancing to the next page of results from your GetLoadBalancers + // request. + NextPageToken *string `locationName:"nextPageToken" type:"string"` +} + +// String returns the string representation +func (s GetLoadBalancersOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetLoadBalancersOutput) GoString() string { + return s.String() +} + +// SetLoadBalancers sets the LoadBalancers field's value. +func (s *GetLoadBalancersOutput) SetLoadBalancers(v []*LoadBalancer) *GetLoadBalancersOutput { + s.LoadBalancers = v + return s +} + +// SetNextPageToken sets the NextPageToken field's value. +func (s *GetLoadBalancersOutput) SetNextPageToken(v string) *GetLoadBalancersOutput { + s.NextPageToken = &v + return s +} + +type GetOperationInput struct { + _ struct{} `type:"structure"` + + // A GUID used to identify the operation. + // + // OperationId is a required field + OperationId *string `locationName:"operationId" type:"string" required:"true"` +} + +// String returns the string representation +func (s GetOperationInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetOperationInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *GetOperationInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "GetOperationInput"} + if s.OperationId == nil { + invalidParams.Add(request.NewErrParamRequired("OperationId")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetOperationId sets the OperationId field's value. +func (s *GetOperationInput) SetOperationId(v string) *GetOperationInput { + s.OperationId = &v + return s +} + +type GetOperationOutput struct { + _ struct{} `type:"structure"` + + // An array of key-value pairs containing information about the results of your + // get operation request. + Operation *Operation `locationName:"operation" type:"structure"` +} + +// String returns the string representation +func (s GetOperationOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetOperationOutput) GoString() string { + return s.String() +} + +// SetOperation sets the Operation field's value. +func (s *GetOperationOutput) SetOperation(v *Operation) *GetOperationOutput { + s.Operation = v + return s +} + +type GetOperationsForResourceInput struct { + _ struct{} `type:"structure"` + + // A token used for advancing to the next page of results from your get operations + // for resource request. + PageToken *string `locationName:"pageToken" type:"string"` + + // The name of the resource for which you are requesting information. + // + // ResourceName is a required field + ResourceName *string `locationName:"resourceName" type:"string" required:"true"` +} + +// String returns the string representation +func (s GetOperationsForResourceInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetOperationsForResourceInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *GetOperationsForResourceInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "GetOperationsForResourceInput"} + if s.ResourceName == nil { + invalidParams.Add(request.NewErrParamRequired("ResourceName")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetPageToken sets the PageToken field's value. +func (s *GetOperationsForResourceInput) SetPageToken(v string) *GetOperationsForResourceInput { + s.PageToken = &v + return s +} + +// SetResourceName sets the ResourceName field's value. +func (s *GetOperationsForResourceInput) SetResourceName(v string) *GetOperationsForResourceInput { + s.ResourceName = &v + return s +} + +type GetOperationsForResourceOutput struct { + _ struct{} `type:"structure"` + + // (Deprecated) Returns the number of pages of results that remain. + // + // In releases prior to June 12, 2017, this parameter returned null by the API. + // It is now deprecated, and the API returns the nextPageToken parameter instead. + NextPageCount *string `locationName:"nextPageCount" deprecated:"true" type:"string"` + + // An identifier that was returned from the previous call to this operation, + // which can be used to return the next set of items in the list. + NextPageToken *string `locationName:"nextPageToken" type:"string"` + + // An array of key-value pairs containing information about the results of your + // get operations for resource request. + Operations []*Operation `locationName:"operations" type:"list"` +} + +// String returns the string representation +func (s GetOperationsForResourceOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetOperationsForResourceOutput) GoString() string { + return s.String() +} + +// SetNextPageCount sets the NextPageCount field's value. +func (s *GetOperationsForResourceOutput) SetNextPageCount(v string) *GetOperationsForResourceOutput { + s.NextPageCount = &v + return s +} + +// SetNextPageToken sets the NextPageToken field's value. +func (s *GetOperationsForResourceOutput) SetNextPageToken(v string) *GetOperationsForResourceOutput { + s.NextPageToken = &v + return s +} + +// SetOperations sets the Operations field's value. +func (s *GetOperationsForResourceOutput) SetOperations(v []*Operation) *GetOperationsForResourceOutput { + s.Operations = v + return s +} + +type GetOperationsInput struct { + _ struct{} `type:"structure"` + + // A token used for advancing to the next page of results from your get operations + // request. + PageToken *string `locationName:"pageToken" type:"string"` +} + +// String returns the string representation +func (s GetOperationsInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetOperationsInput) GoString() string { + return s.String() +} + +// SetPageToken sets the PageToken field's value. +func (s *GetOperationsInput) SetPageToken(v string) *GetOperationsInput { + s.PageToken = &v + return s +} + +type GetOperationsOutput struct { + _ struct{} `type:"structure"` + + // A token used for advancing to the next page of results from your get operations + // request. + NextPageToken *string `locationName:"nextPageToken" type:"string"` + + // An array of key-value pairs containing information about the results of your + // get operations request. + Operations []*Operation `locationName:"operations" type:"list"` +} + +// String returns the string representation +func (s GetOperationsOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetOperationsOutput) GoString() string { + return s.String() +} + +// SetNextPageToken sets the NextPageToken field's value. +func (s *GetOperationsOutput) SetNextPageToken(v string) *GetOperationsOutput { + s.NextPageToken = &v + return s +} + +// SetOperations sets the Operations field's value. +func (s *GetOperationsOutput) SetOperations(v []*Operation) *GetOperationsOutput { + s.Operations = v + return s +} + +type GetRegionsInput struct { + _ struct{} `type:"structure"` + + // A Boolean value indicating whether to also include Availability Zones in + // your get regions request. Availability Zones are indicated with a letter: + // e.g., us-east-2a. + IncludeAvailabilityZones *bool `locationName:"includeAvailabilityZones" type:"boolean"` +} + +// String returns the string representation +func (s GetRegionsInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetRegionsInput) GoString() string { + return s.String() +} + +// SetIncludeAvailabilityZones sets the IncludeAvailabilityZones field's value. +func (s *GetRegionsInput) SetIncludeAvailabilityZones(v bool) *GetRegionsInput { + s.IncludeAvailabilityZones = &v + return s +} + +type GetRegionsOutput struct { + _ struct{} `type:"structure"` + + // An array of key-value pairs containing information about your get regions + // request. + Regions []*Region `locationName:"regions" type:"list"` +} + +// String returns the string representation +func (s GetRegionsOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetRegionsOutput) GoString() string { + return s.String() +} + +// SetRegions sets the Regions field's value. +func (s *GetRegionsOutput) SetRegions(v []*Region) *GetRegionsOutput { + s.Regions = v + return s +} + +type GetStaticIpInput struct { + _ struct{} `type:"structure"` + + // The name of the static IP in Lightsail. + // + // StaticIpName is a required field + StaticIpName *string `locationName:"staticIpName" type:"string" required:"true"` +} + +// String returns the string representation +func (s GetStaticIpInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetStaticIpInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *GetStaticIpInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "GetStaticIpInput"} + if s.StaticIpName == nil { + invalidParams.Add(request.NewErrParamRequired("StaticIpName")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetStaticIpName sets the StaticIpName field's value. +func (s *GetStaticIpInput) SetStaticIpName(v string) *GetStaticIpInput { + s.StaticIpName = &v + return s +} + +type GetStaticIpOutput struct { + _ struct{} `type:"structure"` + + // An array of key-value pairs containing information about the requested static + // IP. + StaticIp *StaticIp `locationName:"staticIp" type:"structure"` +} + +// String returns the string representation +func (s GetStaticIpOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetStaticIpOutput) GoString() string { + return s.String() +} + +// SetStaticIp sets the StaticIp field's value. +func (s *GetStaticIpOutput) SetStaticIp(v *StaticIp) *GetStaticIpOutput { + s.StaticIp = v + return s +} + +type GetStaticIpsInput struct { + _ struct{} `type:"structure"` + + // A token used for advancing to the next page of results from your get static + // IPs request. + PageToken *string `locationName:"pageToken" type:"string"` +} + +// String returns the string representation +func (s GetStaticIpsInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetStaticIpsInput) GoString() string { + return s.String() +} + +// SetPageToken sets the PageToken field's value. +func (s *GetStaticIpsInput) SetPageToken(v string) *GetStaticIpsInput { + s.PageToken = &v + return s +} + +type GetStaticIpsOutput struct { + _ struct{} `type:"structure"` + + // A token used for advancing to the next page of results from your get static + // IPs request. + NextPageToken *string `locationName:"nextPageToken" type:"string"` + + // An array of key-value pairs containing information about your get static + // IPs request. + StaticIps []*StaticIp `locationName:"staticIps" type:"list"` +} + +// String returns the string representation +func (s GetStaticIpsOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s GetStaticIpsOutput) GoString() string { + return s.String() +} + +// SetNextPageToken sets the NextPageToken field's value. +func (s *GetStaticIpsOutput) SetNextPageToken(v string) *GetStaticIpsOutput { + s.NextPageToken = &v + return s +} + +// SetStaticIps sets the StaticIps field's value. +func (s *GetStaticIpsOutput) SetStaticIps(v []*StaticIp) *GetStaticIpsOutput { + s.StaticIps = v + return s +} + +type ImportKeyPairInput struct { + _ struct{} `type:"structure"` + + // The name of the key pair for which you want to import the public key. + // + // KeyPairName is a required field + KeyPairName *string `locationName:"keyPairName" type:"string" required:"true"` + + // A base64-encoded public key of the ssh-rsa type. + // + // PublicKeyBase64 is a required field + PublicKeyBase64 *string `locationName:"publicKeyBase64" type:"string" required:"true"` +} + +// String returns the string representation +func (s ImportKeyPairInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ImportKeyPairInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *ImportKeyPairInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "ImportKeyPairInput"} + if s.KeyPairName == nil { + invalidParams.Add(request.NewErrParamRequired("KeyPairName")) + } + if s.PublicKeyBase64 == nil { + invalidParams.Add(request.NewErrParamRequired("PublicKeyBase64")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetKeyPairName sets the KeyPairName field's value. +func (s *ImportKeyPairInput) SetKeyPairName(v string) *ImportKeyPairInput { + s.KeyPairName = &v + return s +} + +// SetPublicKeyBase64 sets the PublicKeyBase64 field's value. +func (s *ImportKeyPairInput) SetPublicKeyBase64(v string) *ImportKeyPairInput { + s.PublicKeyBase64 = &v + return s +} + +type ImportKeyPairOutput struct { + _ struct{} `type:"structure"` + + // An array of key-value pairs containing information about the request operation. + Operation *Operation `locationName:"operation" type:"structure"` +} + +// String returns the string representation +func (s ImportKeyPairOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ImportKeyPairOutput) GoString() string { + return s.String() +} + +// SetOperation sets the Operation field's value. +func (s *ImportKeyPairOutput) SetOperation(v *Operation) *ImportKeyPairOutput { + s.Operation = v + return s +} + +// Describes an instance (a virtual private server). +type Instance struct { + _ struct{} `type:"structure"` + + // The Amazon Resource Name (ARN) of the instance (e.g., arn:aws:lightsail:us-east-2:123456789101:Instance/244ad76f-8aad-4741-809f-12345EXAMPLE). + Arn *string `locationName:"arn" type:"string"` + + // The blueprint ID (e.g., os_amlinux_2016_03). + BlueprintId *string `locationName:"blueprintId" type:"string"` + + // The friendly name of the blueprint (e.g., Amazon Linux). + BlueprintName *string `locationName:"blueprintName" type:"string"` + + // The bundle for the instance (e.g., micro_1_0). + BundleId *string `locationName:"bundleId" type:"string"` + + // The timestamp when the instance was created (e.g., 1479734909.17). + CreatedAt *time.Time `locationName:"createdAt" type:"timestamp" timestampFormat:"unix"` + + // The size of the vCPU and the amount of RAM for the instance. + Hardware *InstanceHardware `locationName:"hardware" type:"structure"` + + // The IPv6 address of the instance. + Ipv6Address *string `locationName:"ipv6Address" type:"string"` + + // A Boolean value indicating whether this instance has a static IP assigned + // to it. + IsStaticIp *bool `locationName:"isStaticIp" type:"boolean"` + + // The region name and availability zone where the instance is located. + Location *ResourceLocation `locationName:"location" type:"structure"` + + // The name the user gave the instance (e.g., Amazon_Linux-1GB-Ohio-1). + Name *string `locationName:"name" type:"string"` + + // Information about the public ports and monthly data transfer rates for the + // instance. + Networking *InstanceNetworking `locationName:"networking" type:"structure"` + + // The private IP address of the instance. + PrivateIpAddress *string `locationName:"privateIpAddress" type:"string"` + + // The public IP address of the instance. + PublicIpAddress *string `locationName:"publicIpAddress" type:"string"` + + // The type of resource (usually Instance). + ResourceType *string `locationName:"resourceType" type:"string" enum:"ResourceType"` + + // The name of the SSH key being used to connect to the instance (e.g., LightsailDefaultKeyPair). + SshKeyName *string `locationName:"sshKeyName" type:"string"` + + // The status code and the state (e.g., running) for the instance. + State *InstanceState `locationName:"state" type:"structure"` + + // The support code. Include this code in your email to support when you have + // questions about an instance or another resource in Lightsail. This code enables + // our support team to look up your Lightsail information more easily. + SupportCode *string `locationName:"supportCode" type:"string"` + + // The user name for connecting to the instance (e.g., ec2-user). + Username *string `locationName:"username" type:"string"` +} + +// String returns the string representation +func (s Instance) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s Instance) GoString() string { + return s.String() +} + +// SetArn sets the Arn field's value. +func (s *Instance) SetArn(v string) *Instance { + s.Arn = &v + return s +} + +// SetBlueprintId sets the BlueprintId field's value. +func (s *Instance) SetBlueprintId(v string) *Instance { + s.BlueprintId = &v + return s +} + +// SetBlueprintName sets the BlueprintName field's value. +func (s *Instance) SetBlueprintName(v string) *Instance { + s.BlueprintName = &v + return s +} + +// SetBundleId sets the BundleId field's value. +func (s *Instance) SetBundleId(v string) *Instance { + s.BundleId = &v + return s +} + +// SetCreatedAt sets the CreatedAt field's value. +func (s *Instance) SetCreatedAt(v time.Time) *Instance { + s.CreatedAt = &v + return s +} + +// SetHardware sets the Hardware field's value. +func (s *Instance) SetHardware(v *InstanceHardware) *Instance { + s.Hardware = v + return s +} + +// SetIpv6Address sets the Ipv6Address field's value. +func (s *Instance) SetIpv6Address(v string) *Instance { + s.Ipv6Address = &v + return s +} + +// SetIsStaticIp sets the IsStaticIp field's value. +func (s *Instance) SetIsStaticIp(v bool) *Instance { + s.IsStaticIp = &v + return s +} + +// SetLocation sets the Location field's value. +func (s *Instance) SetLocation(v *ResourceLocation) *Instance { + s.Location = v + return s +} + +// SetName sets the Name field's value. +func (s *Instance) SetName(v string) *Instance { + s.Name = &v + return s +} + +// SetNetworking sets the Networking field's value. +func (s *Instance) SetNetworking(v *InstanceNetworking) *Instance { + s.Networking = v + return s +} + +// SetPrivateIpAddress sets the PrivateIpAddress field's value. +func (s *Instance) SetPrivateIpAddress(v string) *Instance { + s.PrivateIpAddress = &v + return s +} + +// SetPublicIpAddress sets the PublicIpAddress field's value. +func (s *Instance) SetPublicIpAddress(v string) *Instance { + s.PublicIpAddress = &v + return s +} + +// SetResourceType sets the ResourceType field's value. +func (s *Instance) SetResourceType(v string) *Instance { + s.ResourceType = &v + return s +} + +// SetSshKeyName sets the SshKeyName field's value. +func (s *Instance) SetSshKeyName(v string) *Instance { + s.SshKeyName = &v + return s +} + +// SetState sets the State field's value. +func (s *Instance) SetState(v *InstanceState) *Instance { + s.State = v + return s +} + +// SetSupportCode sets the SupportCode field's value. +func (s *Instance) SetSupportCode(v string) *Instance { + s.SupportCode = &v + return s +} + +// SetUsername sets the Username field's value. +func (s *Instance) SetUsername(v string) *Instance { + s.Username = &v + return s +} + +// The parameters for gaining temporary access to one of your Amazon Lightsail +// instances. +type InstanceAccessDetails struct { + _ struct{} `type:"structure"` + + // For SSH access, the public key to use when accessing your instance For OpenSSH + // clients (e.g., command line SSH), you should save this value to tempkey-cert.pub. + CertKey *string `locationName:"certKey" type:"string"` + + // For SSH access, the date on which the temporary keys expire. + ExpiresAt *time.Time `locationName:"expiresAt" type:"timestamp" timestampFormat:"unix"` + + // The name of this Amazon Lightsail instance. + InstanceName *string `locationName:"instanceName" type:"string"` + + // The public IP address of the Amazon Lightsail instance. + IpAddress *string `locationName:"ipAddress" type:"string"` + + // For RDP access, the password for your Amazon Lightsail instance. Password + // will be an empty string if the password for your new instance is not ready + // yet. When you create an instance, it can take up to 15 minutes for the instance + // to be ready. + // + // If you create an instance using any key pair other than the default (LightsailDefaultKeyPair), + // password will always be an empty string. + // + // If you change the Administrator password on the instance, Lightsail will + // continue to return the original password value. When accessing the instance + // using RDP, you need to manually enter the Administrator password after changing + // it from the default. + Password *string `locationName:"password" type:"string"` + + // For a Windows Server-based instance, an object with the data you can use + // to retrieve your password. This is only needed if password is empty and the + // instance is not new (and therefore the password is not ready yet). When you + // create an instance, it can take up to 15 minutes for the instance to be ready. + PasswordData *PasswordData `locationName:"passwordData" type:"structure"` + + // For SSH access, the temporary private key. For OpenSSH clients (e.g., command + // line SSH), you should save this value to tempkey). + PrivateKey *string `locationName:"privateKey" type:"string"` + + // The protocol for these Amazon Lightsail instance access details. + Protocol *string `locationName:"protocol" type:"string" enum:"InstanceAccessProtocol"` + + // The user name to use when logging in to the Amazon Lightsail instance. + Username *string `locationName:"username" type:"string"` +} + +// String returns the string representation +func (s InstanceAccessDetails) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s InstanceAccessDetails) GoString() string { + return s.String() +} + +// SetCertKey sets the CertKey field's value. +func (s *InstanceAccessDetails) SetCertKey(v string) *InstanceAccessDetails { + s.CertKey = &v + return s +} + +// SetExpiresAt sets the ExpiresAt field's value. +func (s *InstanceAccessDetails) SetExpiresAt(v time.Time) *InstanceAccessDetails { + s.ExpiresAt = &v + return s +} + +// SetInstanceName sets the InstanceName field's value. +func (s *InstanceAccessDetails) SetInstanceName(v string) *InstanceAccessDetails { + s.InstanceName = &v + return s +} + +// SetIpAddress sets the IpAddress field's value. +func (s *InstanceAccessDetails) SetIpAddress(v string) *InstanceAccessDetails { + s.IpAddress = &v + return s +} + +// SetPassword sets the Password field's value. +func (s *InstanceAccessDetails) SetPassword(v string) *InstanceAccessDetails { + s.Password = &v + return s +} + +// SetPasswordData sets the PasswordData field's value. +func (s *InstanceAccessDetails) SetPasswordData(v *PasswordData) *InstanceAccessDetails { + s.PasswordData = v + return s +} + +// SetPrivateKey sets the PrivateKey field's value. +func (s *InstanceAccessDetails) SetPrivateKey(v string) *InstanceAccessDetails { + s.PrivateKey = &v + return s +} + +// SetProtocol sets the Protocol field's value. +func (s *InstanceAccessDetails) SetProtocol(v string) *InstanceAccessDetails { + s.Protocol = &v + return s +} + +// SetUsername sets the Username field's value. +func (s *InstanceAccessDetails) SetUsername(v string) *InstanceAccessDetails { + s.Username = &v + return s +} + +// Describes the hardware for the instance. +type InstanceHardware struct { + _ struct{} `type:"structure"` + + // The number of vCPUs the instance has. + CpuCount *int64 `locationName:"cpuCount" type:"integer"` + + // The disks attached to the instance. + Disks []*Disk `locationName:"disks" type:"list"` + + // The amount of RAM in GB on the instance (e.g., 1.0). + RamSizeInGb *float64 `locationName:"ramSizeInGb" type:"float"` +} + +// String returns the string representation +func (s InstanceHardware) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s InstanceHardware) GoString() string { + return s.String() +} + +// SetCpuCount sets the CpuCount field's value. +func (s *InstanceHardware) SetCpuCount(v int64) *InstanceHardware { + s.CpuCount = &v + return s +} + +// SetDisks sets the Disks field's value. +func (s *InstanceHardware) SetDisks(v []*Disk) *InstanceHardware { + s.Disks = v + return s +} + +// SetRamSizeInGb sets the RamSizeInGb field's value. +func (s *InstanceHardware) SetRamSizeInGb(v float64) *InstanceHardware { + s.RamSizeInGb = &v + return s +} + +// Describes information about the health of the instance. +type InstanceHealthSummary struct { + _ struct{} `type:"structure"` + + // Describes the overall instance health. Valid values are below. + InstanceHealth *string `locationName:"instanceHealth" type:"string" enum:"InstanceHealthState"` + + // More information about the instance health. Valid values are below. + InstanceHealthReason *string `locationName:"instanceHealthReason" type:"string" enum:"InstanceHealthReason"` + + // The name of the Lightsail instance for which you are requesting health check + // data. + InstanceName *string `locationName:"instanceName" type:"string"` +} + +// String returns the string representation +func (s InstanceHealthSummary) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s InstanceHealthSummary) GoString() string { + return s.String() +} + +// SetInstanceHealth sets the InstanceHealth field's value. +func (s *InstanceHealthSummary) SetInstanceHealth(v string) *InstanceHealthSummary { + s.InstanceHealth = &v + return s +} + +// SetInstanceHealthReason sets the InstanceHealthReason field's value. +func (s *InstanceHealthSummary) SetInstanceHealthReason(v string) *InstanceHealthSummary { + s.InstanceHealthReason = &v + return s +} + +// SetInstanceName sets the InstanceName field's value. +func (s *InstanceHealthSummary) SetInstanceName(v string) *InstanceHealthSummary { + s.InstanceName = &v + return s +} + +// Describes monthly data transfer rates and port information for an instance. +type InstanceNetworking struct { + _ struct{} `type:"structure"` + + // The amount of data in GB allocated for monthly data transfers. + MonthlyTransfer *MonthlyTransfer `locationName:"monthlyTransfer" type:"structure"` + + // An array of key-value pairs containing information about the ports on the + // instance. + Ports []*InstancePortInfo `locationName:"ports" type:"list"` +} + +// String returns the string representation +func (s InstanceNetworking) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s InstanceNetworking) GoString() string { + return s.String() +} + +// SetMonthlyTransfer sets the MonthlyTransfer field's value. +func (s *InstanceNetworking) SetMonthlyTransfer(v *MonthlyTransfer) *InstanceNetworking { + s.MonthlyTransfer = v + return s +} + +// SetPorts sets the Ports field's value. +func (s *InstanceNetworking) SetPorts(v []*InstancePortInfo) *InstanceNetworking { + s.Ports = v + return s +} + +// Describes information about the instance ports. +type InstancePortInfo struct { + _ struct{} `type:"structure"` + + // The access direction (inbound or outbound). + AccessDirection *string `locationName:"accessDirection" type:"string" enum:"AccessDirection"` + + // The location from which access is allowed (e.g., Anywhere (0.0.0.0/0)). + AccessFrom *string `locationName:"accessFrom" type:"string"` + + // The type of access (Public or Private). + AccessType *string `locationName:"accessType" type:"string" enum:"PortAccessType"` + + // The common name. + CommonName *string `locationName:"commonName" type:"string"` + + // The first port in the range. + FromPort *int64 `locationName:"fromPort" type:"integer"` + + // The protocol being used. Can be one of the following. + // + // * tcp - Transmission Control Protocol (TCP) provides reliable, ordered, + // and error-checked delivery of streamed data between applications running + // on hosts communicating by an IP network. If you have an application that + // doesn't require reliable data stream service, use UDP instead. + // + // * all - All transport layer protocol types. For more general information, + // see Transport layer (https://en.wikipedia.org/wiki/Transport_layer) on + // Wikipedia. + // + // * udp - With User Datagram Protocol (UDP), computer applications can send + // messages (or datagrams) to other hosts on an Internet Protocol (IP) network. + // Prior communications are not required to set up transmission channels + // or data paths. Applications that don't require reliable data stream service + // can use UDP, which provides a connectionless datagram service that emphasizes + // reduced latency over reliability. If you do require reliable data stream + // service, use TCP instead. + Protocol *string `locationName:"protocol" type:"string" enum:"NetworkProtocol"` + + // The last port in the range. + ToPort *int64 `locationName:"toPort" type:"integer"` +} + +// String returns the string representation +func (s InstancePortInfo) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s InstancePortInfo) GoString() string { + return s.String() +} + +// SetAccessDirection sets the AccessDirection field's value. +func (s *InstancePortInfo) SetAccessDirection(v string) *InstancePortInfo { + s.AccessDirection = &v + return s +} + +// SetAccessFrom sets the AccessFrom field's value. +func (s *InstancePortInfo) SetAccessFrom(v string) *InstancePortInfo { + s.AccessFrom = &v + return s +} + +// SetAccessType sets the AccessType field's value. +func (s *InstancePortInfo) SetAccessType(v string) *InstancePortInfo { + s.AccessType = &v + return s +} + +// SetCommonName sets the CommonName field's value. +func (s *InstancePortInfo) SetCommonName(v string) *InstancePortInfo { + s.CommonName = &v + return s +} + +// SetFromPort sets the FromPort field's value. +func (s *InstancePortInfo) SetFromPort(v int64) *InstancePortInfo { + s.FromPort = &v + return s +} + +// SetProtocol sets the Protocol field's value. +func (s *InstancePortInfo) SetProtocol(v string) *InstancePortInfo { + s.Protocol = &v + return s +} + +// SetToPort sets the ToPort field's value. +func (s *InstancePortInfo) SetToPort(v int64) *InstancePortInfo { + s.ToPort = &v + return s +} + +// Describes the port state. +type InstancePortState struct { + _ struct{} `type:"structure"` + + // The first port in the range. + FromPort *int64 `locationName:"fromPort" type:"integer"` + + // The protocol being used. Can be one of the following. + // + // * tcp - Transmission Control Protocol (TCP) provides reliable, ordered, + // and error-checked delivery of streamed data between applications running + // on hosts communicating by an IP network. If you have an application that + // doesn't require reliable data stream service, use UDP instead. + // + // * all - All transport layer protocol types. For more general information, + // see Transport layer (https://en.wikipedia.org/wiki/Transport_layer) on + // Wikipedia. + // + // * udp - With User Datagram Protocol (UDP), computer applications can send + // messages (or datagrams) to other hosts on an Internet Protocol (IP) network. + // Prior communications are not required to set up transmission channels + // or data paths. Applications that don't require reliable data stream service + // can use UDP, which provides a connectionless datagram service that emphasizes + // reduced latency over reliability. If you do require reliable data stream + // service, use TCP instead. + Protocol *string `locationName:"protocol" type:"string" enum:"NetworkProtocol"` + + // Specifies whether the instance port is open or closed. + State *string `locationName:"state" type:"string" enum:"PortState"` + + // The last port in the range. + ToPort *int64 `locationName:"toPort" type:"integer"` +} + +// String returns the string representation +func (s InstancePortState) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s InstancePortState) GoString() string { + return s.String() +} + +// SetFromPort sets the FromPort field's value. +func (s *InstancePortState) SetFromPort(v int64) *InstancePortState { + s.FromPort = &v + return s +} + +// SetProtocol sets the Protocol field's value. +func (s *InstancePortState) SetProtocol(v string) *InstancePortState { + s.Protocol = &v + return s +} + +// SetState sets the State field's value. +func (s *InstancePortState) SetState(v string) *InstancePortState { + s.State = &v + return s +} + +// SetToPort sets the ToPort field's value. +func (s *InstancePortState) SetToPort(v int64) *InstancePortState { + s.ToPort = &v + return s +} + +// Describes the snapshot of the virtual private server, or instance. +type InstanceSnapshot struct { + _ struct{} `type:"structure"` + + // The Amazon Resource Name (ARN) of the snapshot (e.g., arn:aws:lightsail:us-east-2:123456789101:InstanceSnapshot/d23b5706-3322-4d83-81e5-12345EXAMPLE). + Arn *string `locationName:"arn" type:"string"` + + // The timestamp when the snapshot was created (e.g., 1479907467.024). + CreatedAt *time.Time `locationName:"createdAt" type:"timestamp" timestampFormat:"unix"` + + // An array of disk objects containing information about all block storage disks. + FromAttachedDisks []*Disk `locationName:"fromAttachedDisks" type:"list"` + + // The blueprint ID from which you created the snapshot (e.g., os_debian_8_3). + // A blueprint is a virtual private server (or instance) image used to create + // instances quickly. + FromBlueprintId *string `locationName:"fromBlueprintId" type:"string"` + + // The bundle ID from which you created the snapshot (e.g., micro_1_0). + FromBundleId *string `locationName:"fromBundleId" type:"string"` + + // The Amazon Resource Name (ARN) of the instance from which the snapshot was + // created (e.g., arn:aws:lightsail:us-east-2:123456789101:Instance/64b8404c-ccb1-430b-8daf-12345EXAMPLE). + FromInstanceArn *string `locationName:"fromInstanceArn" type:"string"` + + // The instance from which the snapshot was created. + FromInstanceName *string `locationName:"fromInstanceName" type:"string"` + + // The region name and availability zone where you created the snapshot. + Location *ResourceLocation `locationName:"location" type:"structure"` + + // The name of the snapshot. + Name *string `locationName:"name" type:"string"` + + // The progress of the snapshot. + Progress *string `locationName:"progress" type:"string"` + + // The type of resource (usually InstanceSnapshot). + ResourceType *string `locationName:"resourceType" type:"string" enum:"ResourceType"` + + // The size in GB of the SSD. + SizeInGb *int64 `locationName:"sizeInGb" type:"integer"` + + // The state the snapshot is in. + State *string `locationName:"state" type:"string" enum:"InstanceSnapshotState"` + + // The support code. Include this code in your email to support when you have + // questions about an instance or another resource in Lightsail. This code enables + // our support team to look up your Lightsail information more easily. + SupportCode *string `locationName:"supportCode" type:"string"` +} + +// String returns the string representation +func (s InstanceSnapshot) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s InstanceSnapshot) GoString() string { + return s.String() +} + +// SetArn sets the Arn field's value. +func (s *InstanceSnapshot) SetArn(v string) *InstanceSnapshot { + s.Arn = &v + return s +} + +// SetCreatedAt sets the CreatedAt field's value. +func (s *InstanceSnapshot) SetCreatedAt(v time.Time) *InstanceSnapshot { + s.CreatedAt = &v + return s +} + +// SetFromAttachedDisks sets the FromAttachedDisks field's value. +func (s *InstanceSnapshot) SetFromAttachedDisks(v []*Disk) *InstanceSnapshot { + s.FromAttachedDisks = v + return s +} + +// SetFromBlueprintId sets the FromBlueprintId field's value. +func (s *InstanceSnapshot) SetFromBlueprintId(v string) *InstanceSnapshot { + s.FromBlueprintId = &v + return s +} + +// SetFromBundleId sets the FromBundleId field's value. +func (s *InstanceSnapshot) SetFromBundleId(v string) *InstanceSnapshot { + s.FromBundleId = &v + return s +} + +// SetFromInstanceArn sets the FromInstanceArn field's value. +func (s *InstanceSnapshot) SetFromInstanceArn(v string) *InstanceSnapshot { + s.FromInstanceArn = &v + return s +} + +// SetFromInstanceName sets the FromInstanceName field's value. +func (s *InstanceSnapshot) SetFromInstanceName(v string) *InstanceSnapshot { + s.FromInstanceName = &v + return s +} + +// SetLocation sets the Location field's value. +func (s *InstanceSnapshot) SetLocation(v *ResourceLocation) *InstanceSnapshot { + s.Location = v + return s +} + +// SetName sets the Name field's value. +func (s *InstanceSnapshot) SetName(v string) *InstanceSnapshot { + s.Name = &v + return s +} + +// SetProgress sets the Progress field's value. +func (s *InstanceSnapshot) SetProgress(v string) *InstanceSnapshot { + s.Progress = &v + return s +} + +// SetResourceType sets the ResourceType field's value. +func (s *InstanceSnapshot) SetResourceType(v string) *InstanceSnapshot { + s.ResourceType = &v + return s +} + +// SetSizeInGb sets the SizeInGb field's value. +func (s *InstanceSnapshot) SetSizeInGb(v int64) *InstanceSnapshot { + s.SizeInGb = &v + return s +} + +// SetState sets the State field's value. +func (s *InstanceSnapshot) SetState(v string) *InstanceSnapshot { + s.State = &v + return s +} + +// SetSupportCode sets the SupportCode field's value. +func (s *InstanceSnapshot) SetSupportCode(v string) *InstanceSnapshot { + s.SupportCode = &v + return s +} + +// Describes the virtual private server (or instance) status. +type InstanceState struct { + _ struct{} `type:"structure"` + + // The status code for the instance. + Code *int64 `locationName:"code" type:"integer"` + + // The state of the instance (e.g., running or pending). + Name *string `locationName:"name" type:"string"` +} + +// String returns the string representation +func (s InstanceState) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s InstanceState) GoString() string { + return s.String() +} + +// SetCode sets the Code field's value. +func (s *InstanceState) SetCode(v int64) *InstanceState { + s.Code = &v + return s +} + +// SetName sets the Name field's value. +func (s *InstanceState) SetName(v string) *InstanceState { + s.Name = &v + return s +} + +type IsVpcPeeredInput struct { + _ struct{} `type:"structure"` +} + +// String returns the string representation +func (s IsVpcPeeredInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s IsVpcPeeredInput) GoString() string { + return s.String() +} + +type IsVpcPeeredOutput struct { + _ struct{} `type:"structure"` + + // Returns true if the Lightsail VPC is peered; otherwise, false. + IsPeered *bool `locationName:"isPeered" type:"boolean"` +} + +// String returns the string representation +func (s IsVpcPeeredOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s IsVpcPeeredOutput) GoString() string { + return s.String() +} + +// SetIsPeered sets the IsPeered field's value. +func (s *IsVpcPeeredOutput) SetIsPeered(v bool) *IsVpcPeeredOutput { + s.IsPeered = &v + return s +} + +// Describes the SSH key pair. +type KeyPair struct { + _ struct{} `type:"structure"` + + // The Amazon Resource Name (ARN) of the key pair (e.g., arn:aws:lightsail:us-east-2:123456789101:KeyPair/05859e3d-331d-48ba-9034-12345EXAMPLE). + Arn *string `locationName:"arn" type:"string"` + + // The timestamp when the key pair was created (e.g., 1479816991.349). + CreatedAt *time.Time `locationName:"createdAt" type:"timestamp" timestampFormat:"unix"` + + // The RSA fingerprint of the key pair. + Fingerprint *string `locationName:"fingerprint" type:"string"` + + // The region name and Availability Zone where the key pair was created. + Location *ResourceLocation `locationName:"location" type:"structure"` + + // The friendly name of the SSH key pair. + Name *string `locationName:"name" type:"string"` + + // The resource type (usually KeyPair). + ResourceType *string `locationName:"resourceType" type:"string" enum:"ResourceType"` + + // The support code. Include this code in your email to support when you have + // questions about an instance or another resource in Lightsail. This code enables + // our support team to look up your Lightsail information more easily. + SupportCode *string `locationName:"supportCode" type:"string"` +} + +// String returns the string representation +func (s KeyPair) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s KeyPair) GoString() string { + return s.String() +} + +// SetArn sets the Arn field's value. +func (s *KeyPair) SetArn(v string) *KeyPair { + s.Arn = &v + return s +} + +// SetCreatedAt sets the CreatedAt field's value. +func (s *KeyPair) SetCreatedAt(v time.Time) *KeyPair { + s.CreatedAt = &v + return s +} + +// SetFingerprint sets the Fingerprint field's value. +func (s *KeyPair) SetFingerprint(v string) *KeyPair { + s.Fingerprint = &v + return s +} + +// SetLocation sets the Location field's value. +func (s *KeyPair) SetLocation(v *ResourceLocation) *KeyPair { + s.Location = v + return s +} + +// SetName sets the Name field's value. +func (s *KeyPair) SetName(v string) *KeyPair { + s.Name = &v + return s +} + +// SetResourceType sets the ResourceType field's value. +func (s *KeyPair) SetResourceType(v string) *KeyPair { + s.ResourceType = &v + return s +} + +// SetSupportCode sets the SupportCode field's value. +func (s *KeyPair) SetSupportCode(v string) *KeyPair { + s.SupportCode = &v + return s +} + +// Describes the Lightsail load balancer. +type LoadBalancer struct { + _ struct{} `type:"structure"` + + // The Amazon Resource Name (ARN) of the load balancer. + Arn *string `locationName:"arn" type:"string"` + + // A string to string map of the configuration options for your load balancer. + // Valid values are listed below. + ConfigurationOptions map[string]*string `locationName:"configurationOptions" type:"map"` + + // The date when your load balancer was created. + CreatedAt *time.Time `locationName:"createdAt" type:"timestamp" timestampFormat:"unix"` + + // The DNS name of your Lightsail load balancer. + DnsName *string `locationName:"dnsName" type:"string"` + + // The path you specified to perform your health checks. If no path is specified, + // the load balancer tries to make a request to the default (root) page. + HealthCheckPath *string `locationName:"healthCheckPath" type:"string"` + + // An array of InstanceHealthSummary objects describing the health of the load + // balancer. + InstanceHealthSummary []*InstanceHealthSummary `locationName:"instanceHealthSummary" type:"list"` + + // The instance port where the load balancer is listening. + InstancePort *int64 `locationName:"instancePort" type:"integer"` + + // The AWS Region and Availability Zone where your load balancer was created + // (e.g., us-east-2a). + Location *ResourceLocation `locationName:"location" type:"structure"` + + // The name of the load balancer (e.g., my-load-balancer). + Name *string `locationName:"name" type:"string"` + + // The protocol you have enabled for your load balancer. Valid values are below. + Protocol *string `locationName:"protocol" type:"string" enum:"LoadBalancerProtocol"` + + // An array of public port settings for your load balancer. + PublicPorts []*int64 `locationName:"publicPorts" type:"list"` + + // The resource type (e.g., LoadBalancer. + ResourceType *string `locationName:"resourceType" type:"string" enum:"ResourceType"` + + // The status of your load balancer. Valid values are below. + State *string `locationName:"state" type:"string" enum:"LoadBalancerState"` + + // The support code. Include this code in your email to support when you have + // questions about your Lightsail load balancer. This code enables our support + // team to look up your Lightsail information more easily. + SupportCode *string `locationName:"supportCode" type:"string"` + + // An array of LoadBalancerTlsCertificateSummary objects that provide additional + // information about the TLS/SSL certificates. + TlsCertificateSummaries []*LoadBalancerTlsCertificateSummary `locationName:"tlsCertificateSummaries" type:"list"` +} + +// String returns the string representation +func (s LoadBalancer) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s LoadBalancer) GoString() string { + return s.String() +} + +// SetArn sets the Arn field's value. +func (s *LoadBalancer) SetArn(v string) *LoadBalancer { + s.Arn = &v + return s +} + +// SetConfigurationOptions sets the ConfigurationOptions field's value. +func (s *LoadBalancer) SetConfigurationOptions(v map[string]*string) *LoadBalancer { + s.ConfigurationOptions = v + return s +} + +// SetCreatedAt sets the CreatedAt field's value. +func (s *LoadBalancer) SetCreatedAt(v time.Time) *LoadBalancer { + s.CreatedAt = &v + return s +} + +// SetDnsName sets the DnsName field's value. +func (s *LoadBalancer) SetDnsName(v string) *LoadBalancer { + s.DnsName = &v + return s +} + +// SetHealthCheckPath sets the HealthCheckPath field's value. +func (s *LoadBalancer) SetHealthCheckPath(v string) *LoadBalancer { + s.HealthCheckPath = &v + return s +} + +// SetInstanceHealthSummary sets the InstanceHealthSummary field's value. +func (s *LoadBalancer) SetInstanceHealthSummary(v []*InstanceHealthSummary) *LoadBalancer { + s.InstanceHealthSummary = v + return s +} + +// SetInstancePort sets the InstancePort field's value. +func (s *LoadBalancer) SetInstancePort(v int64) *LoadBalancer { + s.InstancePort = &v + return s +} + +// SetLocation sets the Location field's value. +func (s *LoadBalancer) SetLocation(v *ResourceLocation) *LoadBalancer { + s.Location = v + return s +} + +// SetName sets the Name field's value. +func (s *LoadBalancer) SetName(v string) *LoadBalancer { + s.Name = &v + return s +} + +// SetProtocol sets the Protocol field's value. +func (s *LoadBalancer) SetProtocol(v string) *LoadBalancer { + s.Protocol = &v + return s +} + +// SetPublicPorts sets the PublicPorts field's value. +func (s *LoadBalancer) SetPublicPorts(v []*int64) *LoadBalancer { + s.PublicPorts = v + return s +} + +// SetResourceType sets the ResourceType field's value. +func (s *LoadBalancer) SetResourceType(v string) *LoadBalancer { + s.ResourceType = &v + return s +} + +// SetState sets the State field's value. +func (s *LoadBalancer) SetState(v string) *LoadBalancer { + s.State = &v + return s +} + +// SetSupportCode sets the SupportCode field's value. +func (s *LoadBalancer) SetSupportCode(v string) *LoadBalancer { + s.SupportCode = &v + return s +} + +// SetTlsCertificateSummaries sets the TlsCertificateSummaries field's value. +func (s *LoadBalancer) SetTlsCertificateSummaries(v []*LoadBalancerTlsCertificateSummary) *LoadBalancer { + s.TlsCertificateSummaries = v + return s +} + +// Describes a load balancer TLS/SSL certificate. +// +// TLS is just an updated, more secure version of Secure Socket Layer (SSL). +type LoadBalancerTlsCertificate struct { + _ struct{} `type:"structure"` + + // The Amazon Resource Name (ARN) of the TLS/SSL certificate. + Arn *string `locationName:"arn" type:"string"` + + // The time when you created your TLS/SSL certificate. + CreatedAt *time.Time `locationName:"createdAt" type:"timestamp" timestampFormat:"unix"` + + // The domain name for your TLS/SSL certificate. + DomainName *string `locationName:"domainName" type:"string"` + + // An array of LoadBalancerTlsCertificateDomainValidationRecord objects describing + // the records. + DomainValidationRecords []*LoadBalancerTlsCertificateDomainValidationRecord `locationName:"domainValidationRecords" type:"list"` + + // The reason for the TLS/SSL certificate validation failure. + FailureReason *string `locationName:"failureReason" type:"string" enum:"LoadBalancerTlsCertificateFailureReason"` + + // When true, the TLS/SSL certificate is attached to the Lightsail load balancer. + IsAttached *bool `locationName:"isAttached" type:"boolean"` + + // The time when the TLS/SSL certificate was issued. + IssuedAt *time.Time `locationName:"issuedAt" type:"timestamp" timestampFormat:"unix"` + + // The issuer of the certificate. + Issuer *string `locationName:"issuer" type:"string"` + + // The algorithm that was used to generate the key pair (the public and private + // key). + KeyAlgorithm *string `locationName:"keyAlgorithm" type:"string"` + + // The load balancer name where your TLS/SSL certificate is attached. + LoadBalancerName *string `locationName:"loadBalancerName" type:"string"` + + // The AWS Region and Availability Zone where you created your certificate. + Location *ResourceLocation `locationName:"location" type:"structure"` + + // The name of the TLS/SSL certificate (e.g., my-certificate). + Name *string `locationName:"name" type:"string"` + + // The timestamp when the TLS/SSL certificate expires. + NotAfter *time.Time `locationName:"notAfter" type:"timestamp" timestampFormat:"unix"` + + // The timestamp when the TLS/SSL certificate is first valid. + NotBefore *time.Time `locationName:"notBefore" type:"timestamp" timestampFormat:"unix"` + + // An object containing information about the status of Lightsail's managed + // renewal for the certificate. + RenewalSummary *LoadBalancerTlsCertificateRenewalSummary `locationName:"renewalSummary" type:"structure"` + + // The resource type (e.g., LoadBalancerTlsCertificate. + ResourceType *string `locationName:"resourceType" type:"string" enum:"ResourceType"` + + // The reason the certificate was revoked. Valid values are below. + RevocationReason *string `locationName:"revocationReason" type:"string" enum:"LoadBalancerTlsCertificateRevocationReason"` + + // The timestamp when the TLS/SSL certificate was revoked. + RevokedAt *time.Time `locationName:"revokedAt" type:"timestamp" timestampFormat:"unix"` + + // The serial number of the certificate. + Serial *string `locationName:"serial" type:"string"` + + // The algorithm that was used to sign the certificate. + SignatureAlgorithm *string `locationName:"signatureAlgorithm" type:"string"` + + // The status of the TLS/SSL certificate. Valid values are below. + Status *string `locationName:"status" type:"string" enum:"LoadBalancerTlsCertificateStatus"` + + // The name of the entity that is associated with the public key contained in + // the certificate. + Subject *string `locationName:"subject" type:"string"` + + // One or more domain names (subject alternative names) included in the certificate. + // This list contains the domain names that are bound to the public key that + // is contained in the certificate. The subject alternative names include the + // canonical domain name (CN) of the certificate and additional domain names + // that can be used to connect to the website. + SubjectAlternativeNames []*string `locationName:"subjectAlternativeNames" type:"list"` + + // The support code. Include this code in your email to support when you have + // questions about your Lightsail load balancer or TLS/SSL certificate. This + // code enables our support team to look up your Lightsail information more + // easily. + SupportCode *string `locationName:"supportCode" type:"string"` +} + +// String returns the string representation +func (s LoadBalancerTlsCertificate) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s LoadBalancerTlsCertificate) GoString() string { + return s.String() +} + +// SetArn sets the Arn field's value. +func (s *LoadBalancerTlsCertificate) SetArn(v string) *LoadBalancerTlsCertificate { + s.Arn = &v + return s +} + +// SetCreatedAt sets the CreatedAt field's value. +func (s *LoadBalancerTlsCertificate) SetCreatedAt(v time.Time) *LoadBalancerTlsCertificate { + s.CreatedAt = &v + return s +} + +// SetDomainName sets the DomainName field's value. +func (s *LoadBalancerTlsCertificate) SetDomainName(v string) *LoadBalancerTlsCertificate { + s.DomainName = &v + return s +} + +// SetDomainValidationRecords sets the DomainValidationRecords field's value. +func (s *LoadBalancerTlsCertificate) SetDomainValidationRecords(v []*LoadBalancerTlsCertificateDomainValidationRecord) *LoadBalancerTlsCertificate { + s.DomainValidationRecords = v + return s +} + +// SetFailureReason sets the FailureReason field's value. +func (s *LoadBalancerTlsCertificate) SetFailureReason(v string) *LoadBalancerTlsCertificate { + s.FailureReason = &v + return s +} + +// SetIsAttached sets the IsAttached field's value. +func (s *LoadBalancerTlsCertificate) SetIsAttached(v bool) *LoadBalancerTlsCertificate { + s.IsAttached = &v + return s +} + +// SetIssuedAt sets the IssuedAt field's value. +func (s *LoadBalancerTlsCertificate) SetIssuedAt(v time.Time) *LoadBalancerTlsCertificate { + s.IssuedAt = &v + return s +} + +// SetIssuer sets the Issuer field's value. +func (s *LoadBalancerTlsCertificate) SetIssuer(v string) *LoadBalancerTlsCertificate { + s.Issuer = &v + return s +} + +// SetKeyAlgorithm sets the KeyAlgorithm field's value. +func (s *LoadBalancerTlsCertificate) SetKeyAlgorithm(v string) *LoadBalancerTlsCertificate { + s.KeyAlgorithm = &v + return s +} + +// SetLoadBalancerName sets the LoadBalancerName field's value. +func (s *LoadBalancerTlsCertificate) SetLoadBalancerName(v string) *LoadBalancerTlsCertificate { + s.LoadBalancerName = &v + return s +} + +// SetLocation sets the Location field's value. +func (s *LoadBalancerTlsCertificate) SetLocation(v *ResourceLocation) *LoadBalancerTlsCertificate { + s.Location = v + return s +} + +// SetName sets the Name field's value. +func (s *LoadBalancerTlsCertificate) SetName(v string) *LoadBalancerTlsCertificate { + s.Name = &v + return s +} + +// SetNotAfter sets the NotAfter field's value. +func (s *LoadBalancerTlsCertificate) SetNotAfter(v time.Time) *LoadBalancerTlsCertificate { + s.NotAfter = &v + return s +} + +// SetNotBefore sets the NotBefore field's value. +func (s *LoadBalancerTlsCertificate) SetNotBefore(v time.Time) *LoadBalancerTlsCertificate { + s.NotBefore = &v + return s +} + +// SetRenewalSummary sets the RenewalSummary field's value. +func (s *LoadBalancerTlsCertificate) SetRenewalSummary(v *LoadBalancerTlsCertificateRenewalSummary) *LoadBalancerTlsCertificate { + s.RenewalSummary = v + return s +} + +// SetResourceType sets the ResourceType field's value. +func (s *LoadBalancerTlsCertificate) SetResourceType(v string) *LoadBalancerTlsCertificate { + s.ResourceType = &v + return s +} + +// SetRevocationReason sets the RevocationReason field's value. +func (s *LoadBalancerTlsCertificate) SetRevocationReason(v string) *LoadBalancerTlsCertificate { + s.RevocationReason = &v + return s +} + +// SetRevokedAt sets the RevokedAt field's value. +func (s *LoadBalancerTlsCertificate) SetRevokedAt(v time.Time) *LoadBalancerTlsCertificate { + s.RevokedAt = &v + return s +} + +// SetSerial sets the Serial field's value. +func (s *LoadBalancerTlsCertificate) SetSerial(v string) *LoadBalancerTlsCertificate { + s.Serial = &v + return s +} + +// SetSignatureAlgorithm sets the SignatureAlgorithm field's value. +func (s *LoadBalancerTlsCertificate) SetSignatureAlgorithm(v string) *LoadBalancerTlsCertificate { + s.SignatureAlgorithm = &v + return s +} + +// SetStatus sets the Status field's value. +func (s *LoadBalancerTlsCertificate) SetStatus(v string) *LoadBalancerTlsCertificate { + s.Status = &v + return s +} + +// SetSubject sets the Subject field's value. +func (s *LoadBalancerTlsCertificate) SetSubject(v string) *LoadBalancerTlsCertificate { + s.Subject = &v + return s +} + +// SetSubjectAlternativeNames sets the SubjectAlternativeNames field's value. +func (s *LoadBalancerTlsCertificate) SetSubjectAlternativeNames(v []*string) *LoadBalancerTlsCertificate { + s.SubjectAlternativeNames = v + return s +} + +// SetSupportCode sets the SupportCode field's value. +func (s *LoadBalancerTlsCertificate) SetSupportCode(v string) *LoadBalancerTlsCertificate { + s.SupportCode = &v + return s +} + +// Contains information about the domain names on a TLS/SSL certificate that +// you will use to validate domain ownership. +type LoadBalancerTlsCertificateDomainValidationOption struct { + _ struct{} `type:"structure"` + + // A fully qualified domain name in the certificate request. + DomainName *string `locationName:"domainName" type:"string"` + + // The status of the domain validation. Valid values are listed below. + ValidationStatus *string `locationName:"validationStatus" type:"string" enum:"LoadBalancerTlsCertificateDomainStatus"` +} + +// String returns the string representation +func (s LoadBalancerTlsCertificateDomainValidationOption) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s LoadBalancerTlsCertificateDomainValidationOption) GoString() string { + return s.String() +} + +// SetDomainName sets the DomainName field's value. +func (s *LoadBalancerTlsCertificateDomainValidationOption) SetDomainName(v string) *LoadBalancerTlsCertificateDomainValidationOption { + s.DomainName = &v + return s +} + +// SetValidationStatus sets the ValidationStatus field's value. +func (s *LoadBalancerTlsCertificateDomainValidationOption) SetValidationStatus(v string) *LoadBalancerTlsCertificateDomainValidationOption { + s.ValidationStatus = &v + return s +} + +// Describes the validation record of each domain name in the TLS/SSL certificate. +type LoadBalancerTlsCertificateDomainValidationRecord struct { + _ struct{} `type:"structure"` + + // The domain name against which your TLS/SSL certificate was validated. + DomainName *string `locationName:"domainName" type:"string"` + + // A fully qualified domain name in the certificate. For example, example.com. + Name *string `locationName:"name" type:"string"` + + // The type of validation record. For example, CNAME for domain validation. + Type *string `locationName:"type" type:"string"` + + // The validation status. Valid values are listed below. + ValidationStatus *string `locationName:"validationStatus" type:"string" enum:"LoadBalancerTlsCertificateDomainStatus"` + + // The value for that type. + Value *string `locationName:"value" type:"string"` +} + +// String returns the string representation +func (s LoadBalancerTlsCertificateDomainValidationRecord) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s LoadBalancerTlsCertificateDomainValidationRecord) GoString() string { + return s.String() +} + +// SetDomainName sets the DomainName field's value. +func (s *LoadBalancerTlsCertificateDomainValidationRecord) SetDomainName(v string) *LoadBalancerTlsCertificateDomainValidationRecord { + s.DomainName = &v + return s +} + +// SetName sets the Name field's value. +func (s *LoadBalancerTlsCertificateDomainValidationRecord) SetName(v string) *LoadBalancerTlsCertificateDomainValidationRecord { + s.Name = &v + return s +} + +// SetType sets the Type field's value. +func (s *LoadBalancerTlsCertificateDomainValidationRecord) SetType(v string) *LoadBalancerTlsCertificateDomainValidationRecord { + s.Type = &v + return s +} + +// SetValidationStatus sets the ValidationStatus field's value. +func (s *LoadBalancerTlsCertificateDomainValidationRecord) SetValidationStatus(v string) *LoadBalancerTlsCertificateDomainValidationRecord { + s.ValidationStatus = &v + return s +} + +// SetValue sets the Value field's value. +func (s *LoadBalancerTlsCertificateDomainValidationRecord) SetValue(v string) *LoadBalancerTlsCertificateDomainValidationRecord { + s.Value = &v + return s +} + +// Contains information about the status of Lightsail's managed renewal for +// the certificate. +type LoadBalancerTlsCertificateRenewalSummary struct { + _ struct{} `type:"structure"` + + // Contains information about the validation of each domain name in the certificate, + // as it pertains to Lightsail's managed renewal. This is different from the + // initial validation that occurs as a result of the RequestCertificate request. + DomainValidationOptions []*LoadBalancerTlsCertificateDomainValidationOption `locationName:"domainValidationOptions" type:"list"` + + // The status of Lightsail's managed renewal of the certificate. Valid values + // are listed below. + RenewalStatus *string `locationName:"renewalStatus" type:"string" enum:"LoadBalancerTlsCertificateRenewalStatus"` +} + +// String returns the string representation +func (s LoadBalancerTlsCertificateRenewalSummary) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s LoadBalancerTlsCertificateRenewalSummary) GoString() string { + return s.String() +} + +// SetDomainValidationOptions sets the DomainValidationOptions field's value. +func (s *LoadBalancerTlsCertificateRenewalSummary) SetDomainValidationOptions(v []*LoadBalancerTlsCertificateDomainValidationOption) *LoadBalancerTlsCertificateRenewalSummary { + s.DomainValidationOptions = v + return s +} + +// SetRenewalStatus sets the RenewalStatus field's value. +func (s *LoadBalancerTlsCertificateRenewalSummary) SetRenewalStatus(v string) *LoadBalancerTlsCertificateRenewalSummary { + s.RenewalStatus = &v + return s +} + +// Provides a summary of TLS/SSL certificate metadata. +type LoadBalancerTlsCertificateSummary struct { + _ struct{} `type:"structure"` + + // When true, the TLS/SSL certificate is attached to the Lightsail load balancer. + IsAttached *bool `locationName:"isAttached" type:"boolean"` + + // The name of the TLS/SSL certificate. + Name *string `locationName:"name" type:"string"` +} + +// String returns the string representation +func (s LoadBalancerTlsCertificateSummary) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s LoadBalancerTlsCertificateSummary) GoString() string { + return s.String() +} + +// SetIsAttached sets the IsAttached field's value. +func (s *LoadBalancerTlsCertificateSummary) SetIsAttached(v bool) *LoadBalancerTlsCertificateSummary { + s.IsAttached = &v + return s +} + +// SetName sets the Name field's value. +func (s *LoadBalancerTlsCertificateSummary) SetName(v string) *LoadBalancerTlsCertificateSummary { + s.Name = &v + return s +} + +// Describes the metric data point. +type MetricDatapoint struct { + _ struct{} `type:"structure"` + + // The average. + Average *float64 `locationName:"average" type:"double"` + + // The maximum. + Maximum *float64 `locationName:"maximum" type:"double"` + + // The minimum. + Minimum *float64 `locationName:"minimum" type:"double"` + + // The sample count. + SampleCount *float64 `locationName:"sampleCount" type:"double"` + + // The sum. + Sum *float64 `locationName:"sum" type:"double"` + + // The timestamp (e.g., 1479816991.349). + Timestamp *time.Time `locationName:"timestamp" type:"timestamp" timestampFormat:"unix"` + + // The unit. + Unit *string `locationName:"unit" type:"string" enum:"MetricUnit"` +} + +// String returns the string representation +func (s MetricDatapoint) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s MetricDatapoint) GoString() string { + return s.String() +} + +// SetAverage sets the Average field's value. +func (s *MetricDatapoint) SetAverage(v float64) *MetricDatapoint { + s.Average = &v + return s +} + +// SetMaximum sets the Maximum field's value. +func (s *MetricDatapoint) SetMaximum(v float64) *MetricDatapoint { + s.Maximum = &v + return s +} + +// SetMinimum sets the Minimum field's value. +func (s *MetricDatapoint) SetMinimum(v float64) *MetricDatapoint { + s.Minimum = &v + return s +} + +// SetSampleCount sets the SampleCount field's value. +func (s *MetricDatapoint) SetSampleCount(v float64) *MetricDatapoint { + s.SampleCount = &v + return s +} + +// SetSum sets the Sum field's value. +func (s *MetricDatapoint) SetSum(v float64) *MetricDatapoint { + s.Sum = &v + return s +} + +// SetTimestamp sets the Timestamp field's value. +func (s *MetricDatapoint) SetTimestamp(v time.Time) *MetricDatapoint { + s.Timestamp = &v + return s +} + +// SetUnit sets the Unit field's value. +func (s *MetricDatapoint) SetUnit(v string) *MetricDatapoint { + s.Unit = &v + return s +} + +// Describes the monthly data transfer in and out of your virtual private server +// (or instance). +type MonthlyTransfer struct { + _ struct{} `type:"structure"` + + // The amount allocated per month (in GB). + GbPerMonthAllocated *int64 `locationName:"gbPerMonthAllocated" type:"integer"` +} + +// String returns the string representation +func (s MonthlyTransfer) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s MonthlyTransfer) GoString() string { + return s.String() +} + +// SetGbPerMonthAllocated sets the GbPerMonthAllocated field's value. +func (s *MonthlyTransfer) SetGbPerMonthAllocated(v int64) *MonthlyTransfer { + s.GbPerMonthAllocated = &v + return s +} + +type OpenInstancePublicPortsInput struct { + _ struct{} `type:"structure"` + + // The name of the instance for which you want to open the public ports. + // + // InstanceName is a required field + InstanceName *string `locationName:"instanceName" type:"string" required:"true"` + + // An array of key-value pairs containing information about the port mappings. + // + // PortInfo is a required field + PortInfo *PortInfo `locationName:"portInfo" type:"structure" required:"true"` +} + +// String returns the string representation +func (s OpenInstancePublicPortsInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s OpenInstancePublicPortsInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *OpenInstancePublicPortsInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "OpenInstancePublicPortsInput"} + if s.InstanceName == nil { + invalidParams.Add(request.NewErrParamRequired("InstanceName")) + } + if s.PortInfo == nil { + invalidParams.Add(request.NewErrParamRequired("PortInfo")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetInstanceName sets the InstanceName field's value. +func (s *OpenInstancePublicPortsInput) SetInstanceName(v string) *OpenInstancePublicPortsInput { + s.InstanceName = &v + return s +} + +// SetPortInfo sets the PortInfo field's value. +func (s *OpenInstancePublicPortsInput) SetPortInfo(v *PortInfo) *OpenInstancePublicPortsInput { + s.PortInfo = v + return s +} + +type OpenInstancePublicPortsOutput struct { + _ struct{} `type:"structure"` + + // An array of key-value pairs containing information about the request operation. + Operation *Operation `locationName:"operation" type:"structure"` +} + +// String returns the string representation +func (s OpenInstancePublicPortsOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s OpenInstancePublicPortsOutput) GoString() string { + return s.String() +} + +// SetOperation sets the Operation field's value. +func (s *OpenInstancePublicPortsOutput) SetOperation(v *Operation) *OpenInstancePublicPortsOutput { + s.Operation = v + return s +} + +// Describes the API operation. +type Operation struct { + _ struct{} `type:"structure"` + + // The timestamp when the operation was initialized (e.g., 1479816991.349). + CreatedAt *time.Time `locationName:"createdAt" type:"timestamp" timestampFormat:"unix"` + + // The error code. + ErrorCode *string `locationName:"errorCode" type:"string"` + + // The error details. + ErrorDetails *string `locationName:"errorDetails" type:"string"` + + // The ID of the operation. + Id *string `locationName:"id" type:"string"` + + // A Boolean value indicating whether the operation is terminal. + IsTerminal *bool `locationName:"isTerminal" type:"boolean"` + + // The region and Availability Zone. + Location *ResourceLocation `locationName:"location" type:"structure"` + + // Details about the operation (e.g., Debian-1GB-Ohio-1). + OperationDetails *string `locationName:"operationDetails" type:"string"` + + // The type of operation. + OperationType *string `locationName:"operationType" type:"string" enum:"OperationType"` + + // The resource name. + ResourceName *string `locationName:"resourceName" type:"string"` + + // The resource type. + ResourceType *string `locationName:"resourceType" type:"string" enum:"ResourceType"` + + // The status of the operation. + Status *string `locationName:"status" type:"string" enum:"OperationStatus"` + + // The timestamp when the status was changed (e.g., 1479816991.349). + StatusChangedAt *time.Time `locationName:"statusChangedAt" type:"timestamp" timestampFormat:"unix"` +} + +// String returns the string representation +func (s Operation) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s Operation) GoString() string { + return s.String() +} + +// SetCreatedAt sets the CreatedAt field's value. +func (s *Operation) SetCreatedAt(v time.Time) *Operation { + s.CreatedAt = &v + return s +} + +// SetErrorCode sets the ErrorCode field's value. +func (s *Operation) SetErrorCode(v string) *Operation { + s.ErrorCode = &v + return s +} + +// SetErrorDetails sets the ErrorDetails field's value. +func (s *Operation) SetErrorDetails(v string) *Operation { + s.ErrorDetails = &v + return s +} + +// SetId sets the Id field's value. +func (s *Operation) SetId(v string) *Operation { + s.Id = &v + return s +} + +// SetIsTerminal sets the IsTerminal field's value. +func (s *Operation) SetIsTerminal(v bool) *Operation { + s.IsTerminal = &v + return s +} + +// SetLocation sets the Location field's value. +func (s *Operation) SetLocation(v *ResourceLocation) *Operation { + s.Location = v + return s +} + +// SetOperationDetails sets the OperationDetails field's value. +func (s *Operation) SetOperationDetails(v string) *Operation { + s.OperationDetails = &v + return s +} + +// SetOperationType sets the OperationType field's value. +func (s *Operation) SetOperationType(v string) *Operation { + s.OperationType = &v + return s +} + +// SetResourceName sets the ResourceName field's value. +func (s *Operation) SetResourceName(v string) *Operation { + s.ResourceName = &v + return s +} + +// SetResourceType sets the ResourceType field's value. +func (s *Operation) SetResourceType(v string) *Operation { + s.ResourceType = &v + return s +} + +// SetStatus sets the Status field's value. +func (s *Operation) SetStatus(v string) *Operation { + s.Status = &v + return s +} + +// SetStatusChangedAt sets the StatusChangedAt field's value. +func (s *Operation) SetStatusChangedAt(v time.Time) *Operation { + s.StatusChangedAt = &v + return s +} + +// The password data for the Windows Server-based instance, including the ciphertext +// and the key pair name. +type PasswordData struct { + _ struct{} `type:"structure"` + + // The encrypted password. Ciphertext will be an empty string if access to your + // new instance is not ready yet. When you create an instance, it can take up + // to 15 minutes for the instance to be ready. + // + // If you use the default key pair (LightsailDefaultKeyPair), the decrypted + // password will be available in the password field. + // + // If you are using a custom key pair, you need to use your own means of decryption. + // + // If you change the Administrator password on the instance, Lightsail will + // continue to return the original ciphertext value. When accessing the instance + // using RDP, you need to manually enter the Administrator password after changing + // it from the default. + Ciphertext *string `locationName:"ciphertext" type:"string"` + + // The name of the key pair that you used when creating your instance. If no + // key pair name was specified when creating the instance, Lightsail uses the + // default key pair (LightsailDefaultKeyPair). + // + // If you are using a custom key pair, you need to use your own means of decrypting + // your password using the ciphertext. Lightsail creates the ciphertext by encrypting + // your password with the public key part of this key pair. + KeyPairName *string `locationName:"keyPairName" type:"string"` +} + +// String returns the string representation +func (s PasswordData) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s PasswordData) GoString() string { + return s.String() +} + +// SetCiphertext sets the Ciphertext field's value. +func (s *PasswordData) SetCiphertext(v string) *PasswordData { + s.Ciphertext = &v + return s +} + +// SetKeyPairName sets the KeyPairName field's value. +func (s *PasswordData) SetKeyPairName(v string) *PasswordData { + s.KeyPairName = &v + return s +} + +type PeerVpcInput struct { + _ struct{} `type:"structure"` +} + +// String returns the string representation +func (s PeerVpcInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s PeerVpcInput) GoString() string { + return s.String() +} + +type PeerVpcOutput struct { + _ struct{} `type:"structure"` + + // An array of key-value pairs containing information about the request operation. + Operation *Operation `locationName:"operation" type:"structure"` +} + +// String returns the string representation +func (s PeerVpcOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s PeerVpcOutput) GoString() string { + return s.String() +} + +// SetOperation sets the Operation field's value. +func (s *PeerVpcOutput) SetOperation(v *Operation) *PeerVpcOutput { + s.Operation = v + return s +} + +// Describes information about the ports on your virtual private server (or +// instance). +type PortInfo struct { + _ struct{} `type:"structure"` + + // The first port in the range. + FromPort *int64 `locationName:"fromPort" type:"integer"` + + // The protocol. + Protocol *string `locationName:"protocol" type:"string" enum:"NetworkProtocol"` + + // The last port in the range. + ToPort *int64 `locationName:"toPort" type:"integer"` +} + +// String returns the string representation +func (s PortInfo) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s PortInfo) GoString() string { + return s.String() +} + +// SetFromPort sets the FromPort field's value. +func (s *PortInfo) SetFromPort(v int64) *PortInfo { + s.FromPort = &v + return s +} + +// SetProtocol sets the Protocol field's value. +func (s *PortInfo) SetProtocol(v string) *PortInfo { + s.Protocol = &v + return s +} + +// SetToPort sets the ToPort field's value. +func (s *PortInfo) SetToPort(v int64) *PortInfo { + s.ToPort = &v + return s +} + +type PutInstancePublicPortsInput struct { + _ struct{} `type:"structure"` + + // The Lightsail instance name of the public port(s) you are setting. + // + // InstanceName is a required field + InstanceName *string `locationName:"instanceName" type:"string" required:"true"` + + // Specifies information about the public port(s). + // + // PortInfos is a required field + PortInfos []*PortInfo `locationName:"portInfos" type:"list" required:"true"` +} + +// String returns the string representation +func (s PutInstancePublicPortsInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s PutInstancePublicPortsInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *PutInstancePublicPortsInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "PutInstancePublicPortsInput"} + if s.InstanceName == nil { + invalidParams.Add(request.NewErrParamRequired("InstanceName")) + } + if s.PortInfos == nil { + invalidParams.Add(request.NewErrParamRequired("PortInfos")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetInstanceName sets the InstanceName field's value. +func (s *PutInstancePublicPortsInput) SetInstanceName(v string) *PutInstancePublicPortsInput { + s.InstanceName = &v + return s +} + +// SetPortInfos sets the PortInfos field's value. +func (s *PutInstancePublicPortsInput) SetPortInfos(v []*PortInfo) *PutInstancePublicPortsInput { + s.PortInfos = v + return s +} + +type PutInstancePublicPortsOutput struct { + _ struct{} `type:"structure"` + + // Describes metadata about the operation you just executed. + Operation *Operation `locationName:"operation" type:"structure"` +} + +// String returns the string representation +func (s PutInstancePublicPortsOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s PutInstancePublicPortsOutput) GoString() string { + return s.String() +} + +// SetOperation sets the Operation field's value. +func (s *PutInstancePublicPortsOutput) SetOperation(v *Operation) *PutInstancePublicPortsOutput { + s.Operation = v + return s +} + +type RebootInstanceInput struct { + _ struct{} `type:"structure"` + + // The name of the instance to reboot. + // + // InstanceName is a required field + InstanceName *string `locationName:"instanceName" type:"string" required:"true"` +} + +// String returns the string representation +func (s RebootInstanceInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s RebootInstanceInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *RebootInstanceInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "RebootInstanceInput"} + if s.InstanceName == nil { + invalidParams.Add(request.NewErrParamRequired("InstanceName")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetInstanceName sets the InstanceName field's value. +func (s *RebootInstanceInput) SetInstanceName(v string) *RebootInstanceInput { + s.InstanceName = &v + return s +} + +type RebootInstanceOutput struct { + _ struct{} `type:"structure"` + + // An array of key-value pairs containing information about the request operation. + Operations []*Operation `locationName:"operations" type:"list"` +} + +// String returns the string representation +func (s RebootInstanceOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s RebootInstanceOutput) GoString() string { + return s.String() +} + +// SetOperations sets the Operations field's value. +func (s *RebootInstanceOutput) SetOperations(v []*Operation) *RebootInstanceOutput { + s.Operations = v + return s +} + +// Describes the AWS Region. +type Region struct { + _ struct{} `type:"structure"` + + // The Availability Zones. Follows the format us-east-2a (case-sensitive). + AvailabilityZones []*AvailabilityZone `locationName:"availabilityZones" type:"list"` + + // The continent code (e.g., NA, meaning North America). + ContinentCode *string `locationName:"continentCode" type:"string"` + + // The description of the AWS Region (e.g., This region is recommended to serve + // users in the eastern United States and eastern Canada). + Description *string `locationName:"description" type:"string"` + + // The display name (e.g., Ohio). + DisplayName *string `locationName:"displayName" type:"string"` + + // The region name (e.g., us-east-2). + Name *string `locationName:"name" type:"string" enum:"RegionName"` +} + +// String returns the string representation +func (s Region) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s Region) GoString() string { + return s.String() +} + +// SetAvailabilityZones sets the AvailabilityZones field's value. +func (s *Region) SetAvailabilityZones(v []*AvailabilityZone) *Region { + s.AvailabilityZones = v + return s +} + +// SetContinentCode sets the ContinentCode field's value. +func (s *Region) SetContinentCode(v string) *Region { + s.ContinentCode = &v + return s +} + +// SetDescription sets the Description field's value. +func (s *Region) SetDescription(v string) *Region { + s.Description = &v + return s +} + +// SetDisplayName sets the DisplayName field's value. +func (s *Region) SetDisplayName(v string) *Region { + s.DisplayName = &v + return s +} + +// SetName sets the Name field's value. +func (s *Region) SetName(v string) *Region { + s.Name = &v + return s +} + +type ReleaseStaticIpInput struct { + _ struct{} `type:"structure"` + + // The name of the static IP to delete. + // + // StaticIpName is a required field + StaticIpName *string `locationName:"staticIpName" type:"string" required:"true"` +} + +// String returns the string representation +func (s ReleaseStaticIpInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ReleaseStaticIpInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *ReleaseStaticIpInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "ReleaseStaticIpInput"} + if s.StaticIpName == nil { + invalidParams.Add(request.NewErrParamRequired("StaticIpName")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetStaticIpName sets the StaticIpName field's value. +func (s *ReleaseStaticIpInput) SetStaticIpName(v string) *ReleaseStaticIpInput { + s.StaticIpName = &v + return s +} + +type ReleaseStaticIpOutput struct { + _ struct{} `type:"structure"` + + // An array of key-value pairs containing information about the request operation. + Operations []*Operation `locationName:"operations" type:"list"` +} + +// String returns the string representation +func (s ReleaseStaticIpOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ReleaseStaticIpOutput) GoString() string { + return s.String() +} + +// SetOperations sets the Operations field's value. +func (s *ReleaseStaticIpOutput) SetOperations(v []*Operation) *ReleaseStaticIpOutput { + s.Operations = v + return s +} + +// Describes the resource location. +type ResourceLocation struct { + _ struct{} `type:"structure"` + + // The Availability Zone. Follows the format us-east-2a (case-sensitive). + AvailabilityZone *string `locationName:"availabilityZone" type:"string"` + + // The AWS Region name. + RegionName *string `locationName:"regionName" type:"string" enum:"RegionName"` +} + +// String returns the string representation +func (s ResourceLocation) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ResourceLocation) GoString() string { + return s.String() +} + +// SetAvailabilityZone sets the AvailabilityZone field's value. +func (s *ResourceLocation) SetAvailabilityZone(v string) *ResourceLocation { + s.AvailabilityZone = &v + return s +} + +// SetRegionName sets the RegionName field's value. +func (s *ResourceLocation) SetRegionName(v string) *ResourceLocation { + s.RegionName = &v + return s +} + +type StartInstanceInput struct { + _ struct{} `type:"structure"` + + // The name of the instance (a virtual private server) to start. + // + // InstanceName is a required field + InstanceName *string `locationName:"instanceName" type:"string" required:"true"` +} + +// String returns the string representation +func (s StartInstanceInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s StartInstanceInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *StartInstanceInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "StartInstanceInput"} + if s.InstanceName == nil { + invalidParams.Add(request.NewErrParamRequired("InstanceName")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetInstanceName sets the InstanceName field's value. +func (s *StartInstanceInput) SetInstanceName(v string) *StartInstanceInput { + s.InstanceName = &v + return s +} + +type StartInstanceOutput struct { + _ struct{} `type:"structure"` + + // An array of key-value pairs containing information about the request operation. + Operations []*Operation `locationName:"operations" type:"list"` +} + +// String returns the string representation +func (s StartInstanceOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s StartInstanceOutput) GoString() string { + return s.String() +} + +// SetOperations sets the Operations field's value. +func (s *StartInstanceOutput) SetOperations(v []*Operation) *StartInstanceOutput { + s.Operations = v + return s +} + +// Describes the static IP. +type StaticIp struct { + _ struct{} `type:"structure"` + + // The Amazon Resource Name (ARN) of the static IP (e.g., arn:aws:lightsail:us-east-2:123456789101:StaticIp/9cbb4a9e-f8e3-4dfe-b57e-12345EXAMPLE). + Arn *string `locationName:"arn" type:"string"` + + // The instance where the static IP is attached (e.g., Amazon_Linux-1GB-Ohio-1). + AttachedTo *string `locationName:"attachedTo" type:"string"` + + // The timestamp when the static IP was created (e.g., 1479735304.222). + CreatedAt *time.Time `locationName:"createdAt" type:"timestamp" timestampFormat:"unix"` + + // The static IP address. + IpAddress *string `locationName:"ipAddress" type:"string"` + + // A Boolean value indicating whether the static IP is attached. + IsAttached *bool `locationName:"isAttached" type:"boolean"` + + // The region and Availability Zone where the static IP was created. + Location *ResourceLocation `locationName:"location" type:"structure"` + + // The name of the static IP (e.g., StaticIP-Ohio-EXAMPLE). + Name *string `locationName:"name" type:"string"` + + // The resource type (usually StaticIp). + ResourceType *string `locationName:"resourceType" type:"string" enum:"ResourceType"` + + // The support code. Include this code in your email to support when you have + // questions about an instance or another resource in Lightsail. This code enables + // our support team to look up your Lightsail information more easily. + SupportCode *string `locationName:"supportCode" type:"string"` +} + +// String returns the string representation +func (s StaticIp) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s StaticIp) GoString() string { + return s.String() +} + +// SetArn sets the Arn field's value. +func (s *StaticIp) SetArn(v string) *StaticIp { + s.Arn = &v + return s +} + +// SetAttachedTo sets the AttachedTo field's value. +func (s *StaticIp) SetAttachedTo(v string) *StaticIp { + s.AttachedTo = &v + return s +} + +// SetCreatedAt sets the CreatedAt field's value. +func (s *StaticIp) SetCreatedAt(v time.Time) *StaticIp { + s.CreatedAt = &v + return s +} + +// SetIpAddress sets the IpAddress field's value. +func (s *StaticIp) SetIpAddress(v string) *StaticIp { + s.IpAddress = &v + return s +} + +// SetIsAttached sets the IsAttached field's value. +func (s *StaticIp) SetIsAttached(v bool) *StaticIp { + s.IsAttached = &v + return s +} + +// SetLocation sets the Location field's value. +func (s *StaticIp) SetLocation(v *ResourceLocation) *StaticIp { + s.Location = v + return s +} + +// SetName sets the Name field's value. +func (s *StaticIp) SetName(v string) *StaticIp { + s.Name = &v + return s +} + +// SetResourceType sets the ResourceType field's value. +func (s *StaticIp) SetResourceType(v string) *StaticIp { + s.ResourceType = &v + return s +} + +// SetSupportCode sets the SupportCode field's value. +func (s *StaticIp) SetSupportCode(v string) *StaticIp { + s.SupportCode = &v + return s +} + +type StopInstanceInput struct { + _ struct{} `type:"structure"` + + // When set to True, forces a Lightsail instance that is stuck in a stopping + // state to stop. + // + // Only use the force parameter if your instance is stuck in the stopping state. + // In any other state, your instance should stop normally without adding this + // parameter to your API request. + Force *bool `locationName:"force" type:"boolean"` + + // The name of the instance (a virtual private server) to stop. + // + // InstanceName is a required field + InstanceName *string `locationName:"instanceName" type:"string" required:"true"` +} + +// String returns the string representation +func (s StopInstanceInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s StopInstanceInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *StopInstanceInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "StopInstanceInput"} + if s.InstanceName == nil { + invalidParams.Add(request.NewErrParamRequired("InstanceName")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetForce sets the Force field's value. +func (s *StopInstanceInput) SetForce(v bool) *StopInstanceInput { + s.Force = &v + return s +} + +// SetInstanceName sets the InstanceName field's value. +func (s *StopInstanceInput) SetInstanceName(v string) *StopInstanceInput { + s.InstanceName = &v + return s +} + +type StopInstanceOutput struct { + _ struct{} `type:"structure"` + + // An array of key-value pairs containing information about the request operation. + Operations []*Operation `locationName:"operations" type:"list"` +} + +// String returns the string representation +func (s StopInstanceOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s StopInstanceOutput) GoString() string { + return s.String() +} + +// SetOperations sets the Operations field's value. +func (s *StopInstanceOutput) SetOperations(v []*Operation) *StopInstanceOutput { + s.Operations = v + return s +} + +type UnpeerVpcInput struct { + _ struct{} `type:"structure"` +} + +// String returns the string representation +func (s UnpeerVpcInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s UnpeerVpcInput) GoString() string { + return s.String() +} + +type UnpeerVpcOutput struct { + _ struct{} `type:"structure"` + + // An array of key-value pairs containing information about the request operation. + Operation *Operation `locationName:"operation" type:"structure"` +} + +// String returns the string representation +func (s UnpeerVpcOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s UnpeerVpcOutput) GoString() string { + return s.String() +} + +// SetOperation sets the Operation field's value. +func (s *UnpeerVpcOutput) SetOperation(v *Operation) *UnpeerVpcOutput { + s.Operation = v + return s +} + +type UpdateDomainEntryInput struct { + _ struct{} `type:"structure"` + + // An array of key-value pairs containing information about the domain entry. + // + // DomainEntry is a required field + DomainEntry *DomainEntry `locationName:"domainEntry" type:"structure" required:"true"` + + // The name of the domain recordset to update. + // + // DomainName is a required field + DomainName *string `locationName:"domainName" type:"string" required:"true"` +} + +// String returns the string representation +func (s UpdateDomainEntryInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s UpdateDomainEntryInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *UpdateDomainEntryInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "UpdateDomainEntryInput"} + if s.DomainEntry == nil { + invalidParams.Add(request.NewErrParamRequired("DomainEntry")) + } + if s.DomainName == nil { + invalidParams.Add(request.NewErrParamRequired("DomainName")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetDomainEntry sets the DomainEntry field's value. +func (s *UpdateDomainEntryInput) SetDomainEntry(v *DomainEntry) *UpdateDomainEntryInput { + s.DomainEntry = v + return s +} + +// SetDomainName sets the DomainName field's value. +func (s *UpdateDomainEntryInput) SetDomainName(v string) *UpdateDomainEntryInput { + s.DomainName = &v + return s +} + +type UpdateDomainEntryOutput struct { + _ struct{} `type:"structure"` + + // An array of key-value pairs containing information about the request operation. + Operations []*Operation `locationName:"operations" type:"list"` +} + +// String returns the string representation +func (s UpdateDomainEntryOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s UpdateDomainEntryOutput) GoString() string { + return s.String() +} + +// SetOperations sets the Operations field's value. +func (s *UpdateDomainEntryOutput) SetOperations(v []*Operation) *UpdateDomainEntryOutput { + s.Operations = v + return s +} + +type UpdateLoadBalancerAttributeInput struct { + _ struct{} `type:"structure"` + + // The name of the attribute you want to update. Valid values are below. + // + // AttributeName is a required field + AttributeName *string `locationName:"attributeName" type:"string" required:"true" enum:"LoadBalancerAttributeName"` + + // The value that you want to specify for the attribute name. + // + // AttributeValue is a required field + AttributeValue *string `locationName:"attributeValue" min:"1" type:"string" required:"true"` + + // The name of the load balancer that you want to modify. + // + // LoadBalancerName is a required field + LoadBalancerName *string `locationName:"loadBalancerName" type:"string" required:"true"` +} + +// String returns the string representation +func (s UpdateLoadBalancerAttributeInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s UpdateLoadBalancerAttributeInput) GoString() string { + return s.String() +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *UpdateLoadBalancerAttributeInput) Validate() error { + invalidParams := request.ErrInvalidParams{Context: "UpdateLoadBalancerAttributeInput"} + if s.AttributeName == nil { + invalidParams.Add(request.NewErrParamRequired("AttributeName")) + } + if s.AttributeValue == nil { + invalidParams.Add(request.NewErrParamRequired("AttributeValue")) + } + if s.AttributeValue != nil && len(*s.AttributeValue) < 1 { + invalidParams.Add(request.NewErrParamMinLen("AttributeValue", 1)) + } + if s.LoadBalancerName == nil { + invalidParams.Add(request.NewErrParamRequired("LoadBalancerName")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// SetAttributeName sets the AttributeName field's value. +func (s *UpdateLoadBalancerAttributeInput) SetAttributeName(v string) *UpdateLoadBalancerAttributeInput { + s.AttributeName = &v + return s +} + +// SetAttributeValue sets the AttributeValue field's value. +func (s *UpdateLoadBalancerAttributeInput) SetAttributeValue(v string) *UpdateLoadBalancerAttributeInput { + s.AttributeValue = &v + return s +} + +// SetLoadBalancerName sets the LoadBalancerName field's value. +func (s *UpdateLoadBalancerAttributeInput) SetLoadBalancerName(v string) *UpdateLoadBalancerAttributeInput { + s.LoadBalancerName = &v + return s +} + +type UpdateLoadBalancerAttributeOutput struct { + _ struct{} `type:"structure"` + + // An object describing the API operations. + Operations []*Operation `locationName:"operations" type:"list"` +} + +// String returns the string representation +func (s UpdateLoadBalancerAttributeOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s UpdateLoadBalancerAttributeOutput) GoString() string { + return s.String() +} + +// SetOperations sets the Operations field's value. +func (s *UpdateLoadBalancerAttributeOutput) SetOperations(v []*Operation) *UpdateLoadBalancerAttributeOutput { + s.Operations = v + return s +} + +const ( + // AccessDirectionInbound is a AccessDirection enum value + AccessDirectionInbound = "inbound" + + // AccessDirectionOutbound is a AccessDirection enum value + AccessDirectionOutbound = "outbound" +) + +const ( + // BlueprintTypeOs is a BlueprintType enum value + BlueprintTypeOs = "os" + + // BlueprintTypeApp is a BlueprintType enum value + BlueprintTypeApp = "app" +) + +const ( + // DiskSnapshotStatePending is a DiskSnapshotState enum value + DiskSnapshotStatePending = "pending" + + // DiskSnapshotStateCompleted is a DiskSnapshotState enum value + DiskSnapshotStateCompleted = "completed" + + // DiskSnapshotStateError is a DiskSnapshotState enum value + DiskSnapshotStateError = "error" + + // DiskSnapshotStateUnknown is a DiskSnapshotState enum value + DiskSnapshotStateUnknown = "unknown" +) + +const ( + // DiskStatePending is a DiskState enum value + DiskStatePending = "pending" + + // DiskStateError is a DiskState enum value + DiskStateError = "error" + + // DiskStateAvailable is a DiskState enum value + DiskStateAvailable = "available" + + // DiskStateInUse is a DiskState enum value + DiskStateInUse = "in-use" + + // DiskStateUnknown is a DiskState enum value + DiskStateUnknown = "unknown" +) + +const ( + // InstanceAccessProtocolSsh is a InstanceAccessProtocol enum value + InstanceAccessProtocolSsh = "ssh" + + // InstanceAccessProtocolRdp is a InstanceAccessProtocol enum value + InstanceAccessProtocolRdp = "rdp" +) + +const ( + // InstanceHealthReasonLbRegistrationInProgress is a InstanceHealthReason enum value + InstanceHealthReasonLbRegistrationInProgress = "Lb.RegistrationInProgress" + + // InstanceHealthReasonLbInitialHealthChecking is a InstanceHealthReason enum value + InstanceHealthReasonLbInitialHealthChecking = "Lb.InitialHealthChecking" + + // InstanceHealthReasonLbInternalError is a InstanceHealthReason enum value + InstanceHealthReasonLbInternalError = "Lb.InternalError" + + // InstanceHealthReasonInstanceResponseCodeMismatch is a InstanceHealthReason enum value + InstanceHealthReasonInstanceResponseCodeMismatch = "Instance.ResponseCodeMismatch" + + // InstanceHealthReasonInstanceTimeout is a InstanceHealthReason enum value + InstanceHealthReasonInstanceTimeout = "Instance.Timeout" + + // InstanceHealthReasonInstanceFailedHealthChecks is a InstanceHealthReason enum value + InstanceHealthReasonInstanceFailedHealthChecks = "Instance.FailedHealthChecks" + + // InstanceHealthReasonInstanceNotRegistered is a InstanceHealthReason enum value + InstanceHealthReasonInstanceNotRegistered = "Instance.NotRegistered" + + // InstanceHealthReasonInstanceNotInUse is a InstanceHealthReason enum value + InstanceHealthReasonInstanceNotInUse = "Instance.NotInUse" + + // InstanceHealthReasonInstanceDeregistrationInProgress is a InstanceHealthReason enum value + InstanceHealthReasonInstanceDeregistrationInProgress = "Instance.DeregistrationInProgress" + + // InstanceHealthReasonInstanceInvalidState is a InstanceHealthReason enum value + InstanceHealthReasonInstanceInvalidState = "Instance.InvalidState" + + // InstanceHealthReasonInstanceIpUnusable is a InstanceHealthReason enum value + InstanceHealthReasonInstanceIpUnusable = "Instance.IpUnusable" +) + +const ( + // InstanceHealthStateInitial is a InstanceHealthState enum value + InstanceHealthStateInitial = "initial" + + // InstanceHealthStateHealthy is a InstanceHealthState enum value + InstanceHealthStateHealthy = "healthy" + + // InstanceHealthStateUnhealthy is a InstanceHealthState enum value + InstanceHealthStateUnhealthy = "unhealthy" + + // InstanceHealthStateUnused is a InstanceHealthState enum value + InstanceHealthStateUnused = "unused" + + // InstanceHealthStateDraining is a InstanceHealthState enum value + InstanceHealthStateDraining = "draining" + + // InstanceHealthStateUnavailable is a InstanceHealthState enum value + InstanceHealthStateUnavailable = "unavailable" +) + +const ( + // InstanceMetricNameCpuutilization is a InstanceMetricName enum value + InstanceMetricNameCpuutilization = "CPUUtilization" + + // InstanceMetricNameNetworkIn is a InstanceMetricName enum value + InstanceMetricNameNetworkIn = "NetworkIn" + + // InstanceMetricNameNetworkOut is a InstanceMetricName enum value + InstanceMetricNameNetworkOut = "NetworkOut" + + // InstanceMetricNameStatusCheckFailed is a InstanceMetricName enum value + InstanceMetricNameStatusCheckFailed = "StatusCheckFailed" + + // InstanceMetricNameStatusCheckFailedInstance is a InstanceMetricName enum value + InstanceMetricNameStatusCheckFailedInstance = "StatusCheckFailed_Instance" + + // InstanceMetricNameStatusCheckFailedSystem is a InstanceMetricName enum value + InstanceMetricNameStatusCheckFailedSystem = "StatusCheckFailed_System" +) + +const ( + // InstancePlatformLinuxUnix is a InstancePlatform enum value + InstancePlatformLinuxUnix = "LINUX_UNIX" + + // InstancePlatformWindows is a InstancePlatform enum value + InstancePlatformWindows = "WINDOWS" +) + +const ( + // InstanceSnapshotStatePending is a InstanceSnapshotState enum value + InstanceSnapshotStatePending = "pending" + + // InstanceSnapshotStateError is a InstanceSnapshotState enum value + InstanceSnapshotStateError = "error" + + // InstanceSnapshotStateAvailable is a InstanceSnapshotState enum value + InstanceSnapshotStateAvailable = "available" +) + +const ( + // LoadBalancerAttributeNameHealthCheckPath is a LoadBalancerAttributeName enum value + LoadBalancerAttributeNameHealthCheckPath = "HealthCheckPath" + + // LoadBalancerAttributeNameSessionStickinessEnabled is a LoadBalancerAttributeName enum value + LoadBalancerAttributeNameSessionStickinessEnabled = "SessionStickinessEnabled" + + // LoadBalancerAttributeNameSessionStickinessLbCookieDurationSeconds is a LoadBalancerAttributeName enum value + LoadBalancerAttributeNameSessionStickinessLbCookieDurationSeconds = "SessionStickiness_LB_CookieDurationSeconds" +) + +const ( + // LoadBalancerMetricNameClientTlsnegotiationErrorCount is a LoadBalancerMetricName enum value + LoadBalancerMetricNameClientTlsnegotiationErrorCount = "ClientTLSNegotiationErrorCount" + + // LoadBalancerMetricNameHealthyHostCount is a LoadBalancerMetricName enum value + LoadBalancerMetricNameHealthyHostCount = "HealthyHostCount" + + // LoadBalancerMetricNameUnhealthyHostCount is a LoadBalancerMetricName enum value + LoadBalancerMetricNameUnhealthyHostCount = "UnhealthyHostCount" + + // LoadBalancerMetricNameHttpcodeLb4xxCount is a LoadBalancerMetricName enum value + LoadBalancerMetricNameHttpcodeLb4xxCount = "HTTPCode_LB_4XX_Count" + + // LoadBalancerMetricNameHttpcodeLb5xxCount is a LoadBalancerMetricName enum value + LoadBalancerMetricNameHttpcodeLb5xxCount = "HTTPCode_LB_5XX_Count" + + // LoadBalancerMetricNameHttpcodeInstance2xxCount is a LoadBalancerMetricName enum value + LoadBalancerMetricNameHttpcodeInstance2xxCount = "HTTPCode_Instance_2XX_Count" + + // LoadBalancerMetricNameHttpcodeInstance3xxCount is a LoadBalancerMetricName enum value + LoadBalancerMetricNameHttpcodeInstance3xxCount = "HTTPCode_Instance_3XX_Count" + + // LoadBalancerMetricNameHttpcodeInstance4xxCount is a LoadBalancerMetricName enum value + LoadBalancerMetricNameHttpcodeInstance4xxCount = "HTTPCode_Instance_4XX_Count" + + // LoadBalancerMetricNameHttpcodeInstance5xxCount is a LoadBalancerMetricName enum value + LoadBalancerMetricNameHttpcodeInstance5xxCount = "HTTPCode_Instance_5XX_Count" + + // LoadBalancerMetricNameInstanceResponseTime is a LoadBalancerMetricName enum value + LoadBalancerMetricNameInstanceResponseTime = "InstanceResponseTime" + + // LoadBalancerMetricNameRejectedConnectionCount is a LoadBalancerMetricName enum value + LoadBalancerMetricNameRejectedConnectionCount = "RejectedConnectionCount" + + // LoadBalancerMetricNameRequestCount is a LoadBalancerMetricName enum value + LoadBalancerMetricNameRequestCount = "RequestCount" +) + +const ( + // LoadBalancerProtocolHttpHttps is a LoadBalancerProtocol enum value + LoadBalancerProtocolHttpHttps = "HTTP_HTTPS" + + // LoadBalancerProtocolHttp is a LoadBalancerProtocol enum value + LoadBalancerProtocolHttp = "HTTP" +) + +const ( + // LoadBalancerStateActive is a LoadBalancerState enum value + LoadBalancerStateActive = "active" + + // LoadBalancerStateProvisioning is a LoadBalancerState enum value + LoadBalancerStateProvisioning = "provisioning" + + // LoadBalancerStateActiveImpaired is a LoadBalancerState enum value + LoadBalancerStateActiveImpaired = "active_impaired" + + // LoadBalancerStateFailed is a LoadBalancerState enum value + LoadBalancerStateFailed = "failed" + + // LoadBalancerStateUnknown is a LoadBalancerState enum value + LoadBalancerStateUnknown = "unknown" +) + +const ( + // LoadBalancerTlsCertificateDomainStatusPendingValidation is a LoadBalancerTlsCertificateDomainStatus enum value + LoadBalancerTlsCertificateDomainStatusPendingValidation = "PENDING_VALIDATION" + + // LoadBalancerTlsCertificateDomainStatusFailed is a LoadBalancerTlsCertificateDomainStatus enum value + LoadBalancerTlsCertificateDomainStatusFailed = "FAILED" + + // LoadBalancerTlsCertificateDomainStatusSuccess is a LoadBalancerTlsCertificateDomainStatus enum value + LoadBalancerTlsCertificateDomainStatusSuccess = "SUCCESS" +) + +const ( + // LoadBalancerTlsCertificateFailureReasonNoAvailableContacts is a LoadBalancerTlsCertificateFailureReason enum value + LoadBalancerTlsCertificateFailureReasonNoAvailableContacts = "NO_AVAILABLE_CONTACTS" + + // LoadBalancerTlsCertificateFailureReasonAdditionalVerificationRequired is a LoadBalancerTlsCertificateFailureReason enum value + LoadBalancerTlsCertificateFailureReasonAdditionalVerificationRequired = "ADDITIONAL_VERIFICATION_REQUIRED" + + // LoadBalancerTlsCertificateFailureReasonDomainNotAllowed is a LoadBalancerTlsCertificateFailureReason enum value + LoadBalancerTlsCertificateFailureReasonDomainNotAllowed = "DOMAIN_NOT_ALLOWED" + + // LoadBalancerTlsCertificateFailureReasonInvalidPublicDomain is a LoadBalancerTlsCertificateFailureReason enum value + LoadBalancerTlsCertificateFailureReasonInvalidPublicDomain = "INVALID_PUBLIC_DOMAIN" + + // LoadBalancerTlsCertificateFailureReasonOther is a LoadBalancerTlsCertificateFailureReason enum value + LoadBalancerTlsCertificateFailureReasonOther = "OTHER" +) + +const ( + // LoadBalancerTlsCertificateRenewalStatusPendingAutoRenewal is a LoadBalancerTlsCertificateRenewalStatus enum value + LoadBalancerTlsCertificateRenewalStatusPendingAutoRenewal = "PENDING_AUTO_RENEWAL" + + // LoadBalancerTlsCertificateRenewalStatusPendingValidation is a LoadBalancerTlsCertificateRenewalStatus enum value + LoadBalancerTlsCertificateRenewalStatusPendingValidation = "PENDING_VALIDATION" + + // LoadBalancerTlsCertificateRenewalStatusSuccess is a LoadBalancerTlsCertificateRenewalStatus enum value + LoadBalancerTlsCertificateRenewalStatusSuccess = "SUCCESS" + + // LoadBalancerTlsCertificateRenewalStatusFailed is a LoadBalancerTlsCertificateRenewalStatus enum value + LoadBalancerTlsCertificateRenewalStatusFailed = "FAILED" +) + +const ( + // LoadBalancerTlsCertificateRevocationReasonUnspecified is a LoadBalancerTlsCertificateRevocationReason enum value + LoadBalancerTlsCertificateRevocationReasonUnspecified = "UNSPECIFIED" + + // LoadBalancerTlsCertificateRevocationReasonKeyCompromise is a LoadBalancerTlsCertificateRevocationReason enum value + LoadBalancerTlsCertificateRevocationReasonKeyCompromise = "KEY_COMPROMISE" + + // LoadBalancerTlsCertificateRevocationReasonCaCompromise is a LoadBalancerTlsCertificateRevocationReason enum value + LoadBalancerTlsCertificateRevocationReasonCaCompromise = "CA_COMPROMISE" + + // LoadBalancerTlsCertificateRevocationReasonAffiliationChanged is a LoadBalancerTlsCertificateRevocationReason enum value + LoadBalancerTlsCertificateRevocationReasonAffiliationChanged = "AFFILIATION_CHANGED" + + // LoadBalancerTlsCertificateRevocationReasonSuperceded is a LoadBalancerTlsCertificateRevocationReason enum value + LoadBalancerTlsCertificateRevocationReasonSuperceded = "SUPERCEDED" + + // LoadBalancerTlsCertificateRevocationReasonCessationOfOperation is a LoadBalancerTlsCertificateRevocationReason enum value + LoadBalancerTlsCertificateRevocationReasonCessationOfOperation = "CESSATION_OF_OPERATION" + + // LoadBalancerTlsCertificateRevocationReasonCertificateHold is a LoadBalancerTlsCertificateRevocationReason enum value + LoadBalancerTlsCertificateRevocationReasonCertificateHold = "CERTIFICATE_HOLD" + + // LoadBalancerTlsCertificateRevocationReasonRemoveFromCrl is a LoadBalancerTlsCertificateRevocationReason enum value + LoadBalancerTlsCertificateRevocationReasonRemoveFromCrl = "REMOVE_FROM_CRL" + + // LoadBalancerTlsCertificateRevocationReasonPrivilegeWithdrawn is a LoadBalancerTlsCertificateRevocationReason enum value + LoadBalancerTlsCertificateRevocationReasonPrivilegeWithdrawn = "PRIVILEGE_WITHDRAWN" + + // LoadBalancerTlsCertificateRevocationReasonAACompromise is a LoadBalancerTlsCertificateRevocationReason enum value + LoadBalancerTlsCertificateRevocationReasonAACompromise = "A_A_COMPROMISE" +) + +const ( + // LoadBalancerTlsCertificateStatusPendingValidation is a LoadBalancerTlsCertificateStatus enum value + LoadBalancerTlsCertificateStatusPendingValidation = "PENDING_VALIDATION" + + // LoadBalancerTlsCertificateStatusIssued is a LoadBalancerTlsCertificateStatus enum value + LoadBalancerTlsCertificateStatusIssued = "ISSUED" + + // LoadBalancerTlsCertificateStatusInactive is a LoadBalancerTlsCertificateStatus enum value + LoadBalancerTlsCertificateStatusInactive = "INACTIVE" + + // LoadBalancerTlsCertificateStatusExpired is a LoadBalancerTlsCertificateStatus enum value + LoadBalancerTlsCertificateStatusExpired = "EXPIRED" + + // LoadBalancerTlsCertificateStatusValidationTimedOut is a LoadBalancerTlsCertificateStatus enum value + LoadBalancerTlsCertificateStatusValidationTimedOut = "VALIDATION_TIMED_OUT" + + // LoadBalancerTlsCertificateStatusRevoked is a LoadBalancerTlsCertificateStatus enum value + LoadBalancerTlsCertificateStatusRevoked = "REVOKED" + + // LoadBalancerTlsCertificateStatusFailed is a LoadBalancerTlsCertificateStatus enum value + LoadBalancerTlsCertificateStatusFailed = "FAILED" + + // LoadBalancerTlsCertificateStatusUnknown is a LoadBalancerTlsCertificateStatus enum value + LoadBalancerTlsCertificateStatusUnknown = "UNKNOWN" +) + +const ( + // MetricStatisticMinimum is a MetricStatistic enum value + MetricStatisticMinimum = "Minimum" + + // MetricStatisticMaximum is a MetricStatistic enum value + MetricStatisticMaximum = "Maximum" + + // MetricStatisticSum is a MetricStatistic enum value + MetricStatisticSum = "Sum" + + // MetricStatisticAverage is a MetricStatistic enum value + MetricStatisticAverage = "Average" + + // MetricStatisticSampleCount is a MetricStatistic enum value + MetricStatisticSampleCount = "SampleCount" +) + +const ( + // MetricUnitSeconds is a MetricUnit enum value + MetricUnitSeconds = "Seconds" + + // MetricUnitMicroseconds is a MetricUnit enum value + MetricUnitMicroseconds = "Microseconds" + + // MetricUnitMilliseconds is a MetricUnit enum value + MetricUnitMilliseconds = "Milliseconds" + + // MetricUnitBytes is a MetricUnit enum value + MetricUnitBytes = "Bytes" + + // MetricUnitKilobytes is a MetricUnit enum value + MetricUnitKilobytes = "Kilobytes" + + // MetricUnitMegabytes is a MetricUnit enum value + MetricUnitMegabytes = "Megabytes" + + // MetricUnitGigabytes is a MetricUnit enum value + MetricUnitGigabytes = "Gigabytes" + + // MetricUnitTerabytes is a MetricUnit enum value + MetricUnitTerabytes = "Terabytes" + + // MetricUnitBits is a MetricUnit enum value + MetricUnitBits = "Bits" + + // MetricUnitKilobits is a MetricUnit enum value + MetricUnitKilobits = "Kilobits" + + // MetricUnitMegabits is a MetricUnit enum value + MetricUnitMegabits = "Megabits" + + // MetricUnitGigabits is a MetricUnit enum value + MetricUnitGigabits = "Gigabits" + + // MetricUnitTerabits is a MetricUnit enum value + MetricUnitTerabits = "Terabits" + + // MetricUnitPercent is a MetricUnit enum value + MetricUnitPercent = "Percent" + + // MetricUnitCount is a MetricUnit enum value + MetricUnitCount = "Count" + + // MetricUnitBytesSecond is a MetricUnit enum value + MetricUnitBytesSecond = "Bytes/Second" + + // MetricUnitKilobytesSecond is a MetricUnit enum value + MetricUnitKilobytesSecond = "Kilobytes/Second" + + // MetricUnitMegabytesSecond is a MetricUnit enum value + MetricUnitMegabytesSecond = "Megabytes/Second" + + // MetricUnitGigabytesSecond is a MetricUnit enum value + MetricUnitGigabytesSecond = "Gigabytes/Second" + + // MetricUnitTerabytesSecond is a MetricUnit enum value + MetricUnitTerabytesSecond = "Terabytes/Second" + + // MetricUnitBitsSecond is a MetricUnit enum value + MetricUnitBitsSecond = "Bits/Second" + + // MetricUnitKilobitsSecond is a MetricUnit enum value + MetricUnitKilobitsSecond = "Kilobits/Second" + + // MetricUnitMegabitsSecond is a MetricUnit enum value + MetricUnitMegabitsSecond = "Megabits/Second" + + // MetricUnitGigabitsSecond is a MetricUnit enum value + MetricUnitGigabitsSecond = "Gigabits/Second" + + // MetricUnitTerabitsSecond is a MetricUnit enum value + MetricUnitTerabitsSecond = "Terabits/Second" + + // MetricUnitCountSecond is a MetricUnit enum value + MetricUnitCountSecond = "Count/Second" + + // MetricUnitNone is a MetricUnit enum value + MetricUnitNone = "None" +) + +const ( + // NetworkProtocolTcp is a NetworkProtocol enum value + NetworkProtocolTcp = "tcp" + + // NetworkProtocolAll is a NetworkProtocol enum value + NetworkProtocolAll = "all" + + // NetworkProtocolUdp is a NetworkProtocol enum value + NetworkProtocolUdp = "udp" +) + +const ( + // OperationStatusNotStarted is a OperationStatus enum value + OperationStatusNotStarted = "NotStarted" + + // OperationStatusStarted is a OperationStatus enum value + OperationStatusStarted = "Started" + + // OperationStatusFailed is a OperationStatus enum value + OperationStatusFailed = "Failed" + + // OperationStatusCompleted is a OperationStatus enum value + OperationStatusCompleted = "Completed" +) + +const ( + // OperationTypeDeleteInstance is a OperationType enum value + OperationTypeDeleteInstance = "DeleteInstance" + + // OperationTypeCreateInstance is a OperationType enum value + OperationTypeCreateInstance = "CreateInstance" + + // OperationTypeStopInstance is a OperationType enum value + OperationTypeStopInstance = "StopInstance" + + // OperationTypeStartInstance is a OperationType enum value + OperationTypeStartInstance = "StartInstance" + + // OperationTypeRebootInstance is a OperationType enum value + OperationTypeRebootInstance = "RebootInstance" + + // OperationTypeOpenInstancePublicPorts is a OperationType enum value + OperationTypeOpenInstancePublicPorts = "OpenInstancePublicPorts" + + // OperationTypePutInstancePublicPorts is a OperationType enum value + OperationTypePutInstancePublicPorts = "PutInstancePublicPorts" + + // OperationTypeCloseInstancePublicPorts is a OperationType enum value + OperationTypeCloseInstancePublicPorts = "CloseInstancePublicPorts" + + // OperationTypeAllocateStaticIp is a OperationType enum value + OperationTypeAllocateStaticIp = "AllocateStaticIp" + + // OperationTypeReleaseStaticIp is a OperationType enum value + OperationTypeReleaseStaticIp = "ReleaseStaticIp" + + // OperationTypeAttachStaticIp is a OperationType enum value + OperationTypeAttachStaticIp = "AttachStaticIp" + + // OperationTypeDetachStaticIp is a OperationType enum value + OperationTypeDetachStaticIp = "DetachStaticIp" + + // OperationTypeUpdateDomainEntry is a OperationType enum value + OperationTypeUpdateDomainEntry = "UpdateDomainEntry" + + // OperationTypeDeleteDomainEntry is a OperationType enum value + OperationTypeDeleteDomainEntry = "DeleteDomainEntry" + + // OperationTypeCreateDomain is a OperationType enum value + OperationTypeCreateDomain = "CreateDomain" + + // OperationTypeDeleteDomain is a OperationType enum value + OperationTypeDeleteDomain = "DeleteDomain" + + // OperationTypeCreateInstanceSnapshot is a OperationType enum value + OperationTypeCreateInstanceSnapshot = "CreateInstanceSnapshot" + + // OperationTypeDeleteInstanceSnapshot is a OperationType enum value + OperationTypeDeleteInstanceSnapshot = "DeleteInstanceSnapshot" + + // OperationTypeCreateInstancesFromSnapshot is a OperationType enum value + OperationTypeCreateInstancesFromSnapshot = "CreateInstancesFromSnapshot" + + // OperationTypeCreateLoadBalancer is a OperationType enum value + OperationTypeCreateLoadBalancer = "CreateLoadBalancer" + + // OperationTypeDeleteLoadBalancer is a OperationType enum value + OperationTypeDeleteLoadBalancer = "DeleteLoadBalancer" + + // OperationTypeAttachInstancesToLoadBalancer is a OperationType enum value + OperationTypeAttachInstancesToLoadBalancer = "AttachInstancesToLoadBalancer" + + // OperationTypeDetachInstancesFromLoadBalancer is a OperationType enum value + OperationTypeDetachInstancesFromLoadBalancer = "DetachInstancesFromLoadBalancer" + + // OperationTypeUpdateLoadBalancerAttribute is a OperationType enum value + OperationTypeUpdateLoadBalancerAttribute = "UpdateLoadBalancerAttribute" + + // OperationTypeCreateLoadBalancerTlsCertificate is a OperationType enum value + OperationTypeCreateLoadBalancerTlsCertificate = "CreateLoadBalancerTlsCertificate" + + // OperationTypeDeleteLoadBalancerTlsCertificate is a OperationType enum value + OperationTypeDeleteLoadBalancerTlsCertificate = "DeleteLoadBalancerTlsCertificate" + + // OperationTypeAttachLoadBalancerTlsCertificate is a OperationType enum value + OperationTypeAttachLoadBalancerTlsCertificate = "AttachLoadBalancerTlsCertificate" + + // OperationTypeCreateDisk is a OperationType enum value + OperationTypeCreateDisk = "CreateDisk" + + // OperationTypeDeleteDisk is a OperationType enum value + OperationTypeDeleteDisk = "DeleteDisk" + + // OperationTypeAttachDisk is a OperationType enum value + OperationTypeAttachDisk = "AttachDisk" + + // OperationTypeDetachDisk is a OperationType enum value + OperationTypeDetachDisk = "DetachDisk" + + // OperationTypeCreateDiskSnapshot is a OperationType enum value + OperationTypeCreateDiskSnapshot = "CreateDiskSnapshot" + + // OperationTypeDeleteDiskSnapshot is a OperationType enum value + OperationTypeDeleteDiskSnapshot = "DeleteDiskSnapshot" + + // OperationTypeCreateDiskFromSnapshot is a OperationType enum value + OperationTypeCreateDiskFromSnapshot = "CreateDiskFromSnapshot" +) + +const ( + // PortAccessTypePublic is a PortAccessType enum value + PortAccessTypePublic = "Public" + + // PortAccessTypePrivate is a PortAccessType enum value + PortAccessTypePrivate = "Private" +) + +const ( + // PortStateOpen is a PortState enum value + PortStateOpen = "open" + + // PortStateClosed is a PortState enum value + PortStateClosed = "closed" +) + +const ( + // RegionNameUsEast1 is a RegionName enum value + RegionNameUsEast1 = "us-east-1" + + // RegionNameUsEast2 is a RegionName enum value + RegionNameUsEast2 = "us-east-2" + + // RegionNameUsWest1 is a RegionName enum value + RegionNameUsWest1 = "us-west-1" + + // RegionNameUsWest2 is a RegionName enum value + RegionNameUsWest2 = "us-west-2" + + // RegionNameEuWest1 is a RegionName enum value + RegionNameEuWest1 = "eu-west-1" + + // RegionNameEuCentral1 is a RegionName enum value + RegionNameEuCentral1 = "eu-central-1" + + // RegionNameApSouth1 is a RegionName enum value + RegionNameApSouth1 = "ap-south-1" + + // RegionNameApSoutheast1 is a RegionName enum value + RegionNameApSoutheast1 = "ap-southeast-1" + + // RegionNameApSoutheast2 is a RegionName enum value + RegionNameApSoutheast2 = "ap-southeast-2" + + // RegionNameApNortheast1 is a RegionName enum value + RegionNameApNortheast1 = "ap-northeast-1" + + // RegionNameApNortheast2 is a RegionName enum value + RegionNameApNortheast2 = "ap-northeast-2" +) + +const ( + // ResourceTypeInstance is a ResourceType enum value + ResourceTypeInstance = "Instance" + + // ResourceTypeStaticIp is a ResourceType enum value + ResourceTypeStaticIp = "StaticIp" + + // ResourceTypeKeyPair is a ResourceType enum value + ResourceTypeKeyPair = "KeyPair" + + // ResourceTypeInstanceSnapshot is a ResourceType enum value + ResourceTypeInstanceSnapshot = "InstanceSnapshot" + + // ResourceTypeDomain is a ResourceType enum value + ResourceTypeDomain = "Domain" + + // ResourceTypePeeredVpc is a ResourceType enum value + ResourceTypePeeredVpc = "PeeredVpc" + + // ResourceTypeLoadBalancer is a ResourceType enum value + ResourceTypeLoadBalancer = "LoadBalancer" + + // ResourceTypeLoadBalancerTlsCertificate is a ResourceType enum value + ResourceTypeLoadBalancerTlsCertificate = "LoadBalancerTlsCertificate" + + // ResourceTypeDisk is a ResourceType enum value + ResourceTypeDisk = "Disk" + + // ResourceTypeDiskSnapshot is a ResourceType enum value + ResourceTypeDiskSnapshot = "DiskSnapshot" +) diff --git a/vendor/github.com/aws/aws-sdk-go/service/lightsail/doc.go b/vendor/github.com/aws/aws-sdk-go/service/lightsail/doc.go new file mode 100644 index 000000000..9c52815bb --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/service/lightsail/doc.go @@ -0,0 +1,40 @@ +// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. + +// Package lightsail provides the client and types for making API +// requests to Amazon Lightsail. +// +// Amazon Lightsail is the easiest way to get started with AWS for developers +// who just need virtual private servers. Lightsail includes everything you +// need to launch your project quickly - a virtual machine, SSD-based storage, +// data transfer, DNS management, and a static IP - for a low, predictable price. +// You manage those Lightsail servers through the Lightsail console or by using +// the API or command-line interface (CLI). +// +// For more information about Lightsail concepts and tasks, see the Lightsail +// Dev Guide (https://lightsail.aws.amazon.com/ls/docs/all). +// +// To use the Lightsail API or the CLI, you will need to use AWS Identity and +// Access Management (IAM) to generate access keys. For details about how to +// set this up, see the Lightsail Dev Guide (http://lightsail.aws.amazon.com/ls/docs/how-to/article/lightsail-how-to-set-up-access-keys-to-use-sdk-api-cli). +// +// See https://docs.aws.amazon.com/goto/WebAPI/lightsail-2016-11-28 for more information on this service. +// +// See lightsail package documentation for more information. +// https://docs.aws.amazon.com/sdk-for-go/api/service/lightsail/ +// +// Using the Client +// +// To contact Amazon Lightsail with the SDK use the New function to create +// a new service client. With that client you can make API requests to the service. +// These clients are safe to use concurrently. +// +// See the SDK's documentation for more information on how to use the SDK. +// https://docs.aws.amazon.com/sdk-for-go/api/ +// +// See aws.Config documentation for more information on configuring SDK clients. +// https://docs.aws.amazon.com/sdk-for-go/api/aws/#Config +// +// See the Amazon Lightsail client Lightsail for more +// information on creating client for this service. +// https://docs.aws.amazon.com/sdk-for-go/api/service/lightsail/#New +package lightsail diff --git a/vendor/github.com/aws/aws-sdk-go/service/lightsail/errors.go b/vendor/github.com/aws/aws-sdk-go/service/lightsail/errors.go new file mode 100644 index 000000000..d1ef481f2 --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/service/lightsail/errors.go @@ -0,0 +1,55 @@ +// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. + +package lightsail + +const ( + + // ErrCodeAccessDeniedException for service response error code + // "AccessDeniedException". + // + // Lightsail throws this exception when the user cannot be authenticated or + // uses invalid credentials to access a resource. + ErrCodeAccessDeniedException = "AccessDeniedException" + + // ErrCodeAccountSetupInProgressException for service response error code + // "AccountSetupInProgressException". + // + // Lightsail throws this exception when an account is still in the setup in + // progress state. + ErrCodeAccountSetupInProgressException = "AccountSetupInProgressException" + + // ErrCodeInvalidInputException for service response error code + // "InvalidInputException". + // + // Lightsail throws this exception when user input does not conform to the validation + // rules of an input field. + // + // Domain-related APIs are only available in the N. Virginia (us-east-1) Region. + // Please set your Region configuration to us-east-1 to create, view, or edit + // these resources. + ErrCodeInvalidInputException = "InvalidInputException" + + // ErrCodeNotFoundException for service response error code + // "NotFoundException". + // + // Lightsail throws this exception when it cannot find a resource. + ErrCodeNotFoundException = "NotFoundException" + + // ErrCodeOperationFailureException for service response error code + // "OperationFailureException". + // + // Lightsail throws this exception when an operation fails to execute. + ErrCodeOperationFailureException = "OperationFailureException" + + // ErrCodeServiceException for service response error code + // "ServiceException". + // + // A general service exception. + ErrCodeServiceException = "ServiceException" + + // ErrCodeUnauthenticatedException for service response error code + // "UnauthenticatedException". + // + // Lightsail throws this exception when the user has not been authenticated. + ErrCodeUnauthenticatedException = "UnauthenticatedException" +) diff --git a/vendor/github.com/aws/aws-sdk-go/service/lightsail/service.go b/vendor/github.com/aws/aws-sdk-go/service/lightsail/service.go new file mode 100644 index 000000000..a76cf79e0 --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/service/lightsail/service.go @@ -0,0 +1,95 @@ +// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. + +package lightsail + +import ( + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/client" + "github.com/aws/aws-sdk-go/aws/client/metadata" + "github.com/aws/aws-sdk-go/aws/request" + "github.com/aws/aws-sdk-go/aws/signer/v4" + "github.com/aws/aws-sdk-go/private/protocol/jsonrpc" +) + +// Lightsail provides the API operation methods for making requests to +// Amazon Lightsail. See this package's package overview docs +// for details on the service. +// +// Lightsail methods are safe to use concurrently. It is not safe to +// modify mutate any of the struct's properties though. +type Lightsail struct { + *client.Client +} + +// Used for custom client initialization logic +var initClient func(*client.Client) + +// Used for custom request initialization logic +var initRequest func(*request.Request) + +// Service information constants +const ( + ServiceName = "lightsail" // Service endpoint prefix API calls made to. + EndpointsID = ServiceName // Service ID for Regions and Endpoints metadata. +) + +// New creates a new instance of the Lightsail client with a session. +// If additional configuration is needed for the client instance use the optional +// aws.Config parameter to add your extra config. +// +// Example: +// // Create a Lightsail client from just a session. +// svc := lightsail.New(mySession) +// +// // Create a Lightsail client with additional configuration +// svc := lightsail.New(mySession, aws.NewConfig().WithRegion("us-west-2")) +func New(p client.ConfigProvider, cfgs ...*aws.Config) *Lightsail { + c := p.ClientConfig(EndpointsID, cfgs...) + return newClient(*c.Config, c.Handlers, c.Endpoint, c.SigningRegion, c.SigningName) +} + +// newClient creates, initializes and returns a new service client instance. +func newClient(cfg aws.Config, handlers request.Handlers, endpoint, signingRegion, signingName string) *Lightsail { + svc := &Lightsail{ + Client: client.New( + cfg, + metadata.ClientInfo{ + ServiceName: ServiceName, + SigningName: signingName, + SigningRegion: signingRegion, + Endpoint: endpoint, + APIVersion: "2016-11-28", + JSONVersion: "1.1", + TargetPrefix: "Lightsail_20161128", + }, + handlers, + ), + } + + // Handlers + svc.Handlers.Sign.PushBackNamed(v4.SignRequestHandler) + svc.Handlers.Build.PushBackNamed(jsonrpc.BuildHandler) + svc.Handlers.Unmarshal.PushBackNamed(jsonrpc.UnmarshalHandler) + svc.Handlers.UnmarshalMeta.PushBackNamed(jsonrpc.UnmarshalMetaHandler) + svc.Handlers.UnmarshalError.PushBackNamed(jsonrpc.UnmarshalErrorHandler) + + // Run custom client initialization if present + if initClient != nil { + initClient(svc.Client) + } + + return svc +} + +// newRequest creates a new request for a Lightsail operation and runs any +// custom request initialization. +func (c *Lightsail) newRequest(op *request.Operation, params, data interface{}) *request.Request { + req := c.NewRequest(op, params, data) + + // Run custom request initialization if present + if initRequest != nil { + initRequest(req) + } + + return req +} diff --git a/vendor/github.com/namedotcom/go/LICENSE b/vendor/github.com/namedotcom/go/LICENSE new file mode 100644 index 000000000..42c65b5c9 --- /dev/null +++ b/vendor/github.com/namedotcom/go/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2017 Name.com + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/vendor/github.com/namedotcom/go/namecom/dns.go b/vendor/github.com/namedotcom/go/namecom/dns.go new file mode 100644 index 000000000..dd951725d --- /dev/null +++ b/vendor/github.com/namedotcom/go/namecom/dns.go @@ -0,0 +1,133 @@ +package namecom + +import ( + "bytes" + "encoding/json" + "fmt" + "net/url" +) + +var _ = bytes.MinRead + +// ListRecords returns all records for a zone. +func (n *NameCom) ListRecords(request *ListRecordsRequest) (*ListRecordsResponse, error) { + endpoint := fmt.Sprintf("/v4/domains/%s/records", request.DomainName) + + values := url.Values{} + if request.PerPage != 0 { + values.Set("perPage", fmt.Sprintf("%d", request.PerPage)) + } + if request.Page != 0 { + values.Set("page", fmt.Sprintf("%d", request.Page)) + } + + body, err := n.get(endpoint, values) + if err != nil { + return nil, err + } + + resp := &ListRecordsResponse{} + + err = json.NewDecoder(body).Decode(resp) + if err != nil { + return nil, err + } + + return resp, nil +} + +// GetRecord returns details about an individual record. +func (n *NameCom) GetRecord(request *GetRecordRequest) (*Record, error) { + endpoint := fmt.Sprintf("/v4/domains/%s/records/%d", request.DomainName, request.ID) + + values := url.Values{} + + body, err := n.get(endpoint, values) + if err != nil { + return nil, err + } + + resp := &Record{} + + err = json.NewDecoder(body).Decode(resp) + if err != nil { + return nil, err + } + + return resp, nil +} + +// CreateRecord creates a new record in the zone. +func (n *NameCom) CreateRecord(request *Record) (*Record, error) { + endpoint := fmt.Sprintf("/v4/domains/%s/records", request.DomainName) + + post := &bytes.Buffer{} + err := json.NewEncoder(post).Encode(request) + if err != nil { + return nil, err + } + + body, err := n.post(endpoint, post) + if err != nil { + return nil, err + } + + resp := &Record{} + + err = json.NewDecoder(body).Decode(resp) + if err != nil { + return nil, err + } + + return resp, nil +} + +// UpdateRecord replaces the record with the new record that is passed. +func (n *NameCom) UpdateRecord(request *Record) (*Record, error) { + endpoint := fmt.Sprintf("/v4/domains/%s/records/%d", request.DomainName, request.ID) + + post := &bytes.Buffer{} + err := json.NewEncoder(post).Encode(request) + if err != nil { + return nil, err + } + + body, err := n.put(endpoint, post) + if err != nil { + return nil, err + } + + resp := &Record{} + + err = json.NewDecoder(body).Decode(resp) + if err != nil { + return nil, err + } + + return resp, nil +} + +// DeleteRecord deletes a record from the zone. +func (n *NameCom) DeleteRecord(request *DeleteRecordRequest) (*EmptyResponse, error) { + endpoint := fmt.Sprintf("/v4/domains/%s/records/%d", request.DomainName, request.ID) + + post := &bytes.Buffer{} + err := json.NewEncoder(post).Encode(request) + if err != nil { + return nil, err + } + + body, err := n.delete(endpoint, post) + if err != nil { + return nil, err + } + + resp := &EmptyResponse{} + + err = json.NewDecoder(body).Decode(resp) + if err != nil { + return nil, err + } + + return resp, nil +} diff --git a/vendor/github.com/namedotcom/go/namecom/dnssecs.go b/vendor/github.com/namedotcom/go/namecom/dnssecs.go new file mode 100644 index 000000000..91d17c26c --- /dev/null +++ b/vendor/github.com/namedotcom/go/namecom/dnssecs.go @@ -0,0 +1,102 @@ +package namecom + +import ( + "bytes" + "encoding/json" + "fmt" + "net/url" +) + +var _ = bytes.MinRead + +// ListDNSSECs lists all of the DNSSEC keys registered with the registry. +func (n *NameCom) ListDNSSECs(request *ListDNSSECsRequest) (*ListDNSSECsResponse, error) { + endpoint := fmt.Sprintf("/v4/domains/%s/dnssec", request.DomainName) + + values := url.Values{} + + body, err := n.get(endpoint, values) + if err != nil { + return nil, err + } + + resp := &ListDNSSECsResponse{} + + err = json.NewDecoder(body).Decode(resp) + if err != nil { + return nil, err + } + + return resp, nil +} + +// GetDNSSEC retrieves the details for a key registered with the registry. +func (n *NameCom) GetDNSSEC(request *GetDNSSECRequest) (*DNSSEC, error) { + endpoint := fmt.Sprintf("/v4/domains/%s/dnssec/%s", request.DomainName, request.Digest) + + values := url.Values{} + + body, err := n.get(endpoint, values) + if err != nil { + return nil, err + } + + resp := &DNSSEC{} + + err = json.NewDecoder(body).Decode(resp) + if err != nil { + return nil, err + } + + return resp, nil +} + +// CreateDNSSEC registers a DNSSEC key with the registry. +func (n *NameCom) CreateDNSSEC(request *DNSSEC) (*DNSSEC, error) { + endpoint := fmt.Sprintf("/v4/domains/%s/dnssec", request.DomainName) + + post := &bytes.Buffer{} + err := json.NewEncoder(post).Encode(request) + if err != nil { + return nil, err + } + + body, err := n.post(endpoint, post) + if err != nil { + return nil, err + } + + resp := &DNSSEC{} + + err = json.NewDecoder(body).Decode(resp) + if err != nil { + return nil, err + } + + return resp, nil +} + +// DeleteDNSSEC removes a DNSSEC key from the registry. +func (n *NameCom) DeleteDNSSEC(request *DeleteDNSSECRequest) (*EmptyResponse, error) { + endpoint := fmt.Sprintf("/v4/domains/%s/dnssec/%s", request.DomainName, request.Digest) + + post := &bytes.Buffer{} + err := json.NewEncoder(post).Encode(request) + if err != nil { + return nil, err + } + + body, err := n.delete(endpoint, post) + if err != nil { + return nil, err + } + + resp := &EmptyResponse{} + + err = json.NewDecoder(body).Decode(resp) + if err != nil { + return nil, err + } + + return resp, nil +} diff --git a/vendor/github.com/namedotcom/go/namecom/domains.go b/vendor/github.com/namedotcom/go/namecom/domains.go new file mode 100644 index 000000000..bee080beb --- /dev/null +++ b/vendor/github.com/namedotcom/go/namecom/domains.go @@ -0,0 +1,382 @@ +package namecom + +import ( + "bytes" + "encoding/json" + "fmt" + "net/url" +) + +var _ = bytes.MinRead + +// ListDomains returns all domains in the account. It omits some information that can be retrieved from GetDomain. +func (n *NameCom) ListDomains(request *ListDomainsRequest) (*ListDomainsResponse, error) { + endpoint := fmt.Sprintf("/v4/domains") + + values := url.Values{} + if request.PerPage != 0 { + values.Set("perPage", fmt.Sprintf("%d", request.PerPage)) + } + if request.Page != 0 { + values.Set("page", fmt.Sprintf("%d", request.Page)) + } + + body, err := n.get(endpoint, values) + if err != nil { + return nil, err + } + + resp := &ListDomainsResponse{} + + err = json.NewDecoder(body).Decode(resp) + if err != nil { + return nil, err + } + + return resp, nil +} + +// GetDomain returns details about a specific domain +func (n *NameCom) GetDomain(request *GetDomainRequest) (*Domain, error) { + endpoint := fmt.Sprintf("/v4/domains/%s", request.DomainName) + + values := url.Values{} + + body, err := n.get(endpoint, values) + if err != nil { + return nil, err + } + + resp := &Domain{} + + err = json.NewDecoder(body).Decode(resp) + if err != nil { + return nil, err + } + + return resp, nil +} + +// CreateDomain purchases a new domain. Domains that are not regularly priced require the purchase_price field to be specified. +func (n *NameCom) CreateDomain(request *CreateDomainRequest) (*CreateDomainResponse, error) { + endpoint := fmt.Sprintf("/v4/domains") + + post := &bytes.Buffer{} + err := json.NewEncoder(post).Encode(request) + if err != nil { + return nil, err + } + + body, err := n.post(endpoint, post) + if err != nil { + return nil, err + } + + resp := &CreateDomainResponse{} + + err = json.NewDecoder(body).Decode(resp) + if err != nil { + return nil, err + } + + return resp, nil +} + +// EnableAutorenew enables the domain to be automatically renewed when it gets close to expiring. +func (n *NameCom) EnableAutorenew(request *EnableAutorenewForDomainRequest) (*Domain, error) { + endpoint := fmt.Sprintf("/v4/domains") + + post := &bytes.Buffer{} + err := json.NewEncoder(post).Encode(request) + if err != nil { + return nil, err + } + + body, err := n.post(endpoint, post) + if err != nil { + return nil, err + } + + resp := &Domain{} + + err = json.NewDecoder(body).Decode(resp) + if err != nil { + return nil, err + } + + return resp, nil +} + +// DisableAutorenew disables automatic renewals, thus requiring the domain to be renewed manually. +func (n *NameCom) DisableAutorenew(request *DisableAutorenewForDomainRequest) (*Domain, error) { + endpoint := fmt.Sprintf("/v4/domains") + + post := &bytes.Buffer{} + err := json.NewEncoder(post).Encode(request) + if err != nil { + return nil, err + } + + body, err := n.post(endpoint, post) + if err != nil { + return nil, err + } + + resp := &Domain{} + + err = json.NewDecoder(body).Decode(resp) + if err != nil { + return nil, err + } + + return resp, nil +} + +// RenewDomain will renew a domain. Purchase_price is required if the renewal is not regularly priced. +func (n *NameCom) RenewDomain(request *RenewDomainRequest) (*RenewDomainResponse, error) { + endpoint := fmt.Sprintf("/v4/domains") + + post := &bytes.Buffer{} + err := json.NewEncoder(post).Encode(request) + if err != nil { + return nil, err + } + + body, err := n.post(endpoint, post) + if err != nil { + return nil, err + } + + resp := &RenewDomainResponse{} + + err = json.NewDecoder(body).Decode(resp) + if err != nil { + return nil, err + } + + return resp, nil +} + +// GetAuthCodeForDomain returns the Transfer Authorization Code for the domain. +func (n *NameCom) GetAuthCodeForDomain(request *AuthCodeRequest) (*AuthCodeResponse, error) { + endpoint := fmt.Sprintf("/v4/domains") + + values := url.Values{} + if request.DomainName != "" { + values.Set("domainName", request.DomainName) + } + + body, err := n.get(endpoint, values) + if err != nil { + return nil, err + } + + resp := &AuthCodeResponse{} + + err = json.NewDecoder(body).Decode(resp) + if err != nil { + return nil, err + } + + return resp, nil +} + +// PurchasePrivacy will add Whois Privacy protection to a domain or will an renew existing subscription. +func (n *NameCom) PurchasePrivacy(request *PrivacyRequest) (*PrivacyResponse, error) { + endpoint := fmt.Sprintf("/v4/domains") + + post := &bytes.Buffer{} + err := json.NewEncoder(post).Encode(request) + if err != nil { + return nil, err + } + + body, err := n.post(endpoint, post) + if err != nil { + return nil, err + } + + resp := &PrivacyResponse{} + + err = json.NewDecoder(body).Decode(resp) + if err != nil { + return nil, err + } + + return resp, nil +} + +// SetNameservers will set the nameservers for the Domain. +func (n *NameCom) SetNameservers(request *SetNameserversRequest) (*Domain, error) { + endpoint := fmt.Sprintf("/v4/domains/%s:setNameservers", request.DomainName) + + post := &bytes.Buffer{} + err := json.NewEncoder(post).Encode(request) + if err != nil { + return nil, err + } + + body, err := n.post(endpoint, post) + if err != nil { + return nil, err + } + + resp := &Domain{} + + err = json.NewDecoder(body).Decode(resp) + if err != nil { + return nil, err + } + + return resp, nil +} + +// SetContacts will set the contacts for the Domain. +func (n *NameCom) SetContacts(request *SetContactsRequest) (*Domain, error) { + endpoint := fmt.Sprintf("/v4/domains") + + post := &bytes.Buffer{} + err := json.NewEncoder(post).Encode(request) + if err != nil { + return nil, err + } + + body, err := n.post(endpoint, post) + if err != nil { + return nil, err + } + + resp := &Domain{} + + err = json.NewDecoder(body).Decode(resp) + if err != nil { + return nil, err + } + + return resp, nil +} + +// LockDomain will lock a domain so that it cannot be transfered to another registrar. +func (n *NameCom) LockDomain(request *LockDomainRequest) (*Domain, error) { + endpoint := fmt.Sprintf("/v4/domains") + + post := &bytes.Buffer{} + err := json.NewEncoder(post).Encode(request) + if err != nil { + return nil, err + } + + body, err := n.post(endpoint, post) + if err != nil { + return nil, err + } + + resp := &Domain{} + + err = json.NewDecoder(body).Decode(resp) + if err != nil { + return nil, err + } + + return resp, nil +} + +// UnlockDomain will unlock a domain so that it can be transfered to another registrar. +func (n *NameCom) UnlockDomain(request *UnlockDomainRequest) (*Domain, error) { + endpoint := fmt.Sprintf("/v4/domains") + + post := &bytes.Buffer{} + err := json.NewEncoder(post).Encode(request) + if err != nil { + return nil, err + } + + body, err := n.post(endpoint, post) + if err != nil { + return nil, err + } + + resp := &Domain{} + + err = json.NewDecoder(body).Decode(resp) + if err != nil { + return nil, err + } + + return resp, nil +} + +// CheckAvailability will check a list of domains to see if they are purchaseable. A Maximum of 50 domains can be specified. +func (n *NameCom) CheckAvailability(request *AvailabilityRequest) (*SearchResponse, error) { + endpoint := fmt.Sprintf("/v4/domains:checkAvailability") + + post := &bytes.Buffer{} + err := json.NewEncoder(post).Encode(request) + if err != nil { + return nil, err + } + + body, err := n.post(endpoint, post) + if err != nil { + return nil, err + } + + resp := &SearchResponse{} + + err = json.NewDecoder(body).Decode(resp) + if err != nil { + return nil, err + } + + return resp, nil +} + +// Search will perform a search for specified keywords. +func (n *NameCom) Search(request *SearchRequest) (*SearchResponse, error) { + endpoint := fmt.Sprintf("/v4/domains:search") + + post := &bytes.Buffer{} + err := json.NewEncoder(post).Encode(request) + if err != nil { + return nil, err + } + + body, err := n.post(endpoint, post) + if err != nil { + return nil, err + } + + resp := &SearchResponse{} + + err = json.NewDecoder(body).Decode(resp) + if err != nil { + return nil, err + } + + return resp, nil +} + +// SearchStream will return JSON encoded SearchResults as they are recieved from the registry. The SearchResults are separated by newlines. This can allow clients to react to results before the search is fully completed. +func (n *NameCom) SearchStream(request *SearchRequest) (*SearchResult, error) { + endpoint := fmt.Sprintf("/v4/domains:searchStream") + + post := &bytes.Buffer{} + err := json.NewEncoder(post).Encode(request) + if err != nil { + return nil, err + } + + body, err := n.post(endpoint, post) + if err != nil { + return nil, err + } + + resp := &SearchResult{} + + err = json.NewDecoder(body).Decode(resp) + if err != nil { + return nil, err + } + + return resp, nil +} diff --git a/vendor/github.com/namedotcom/go/namecom/emailforwardings.go b/vendor/github.com/namedotcom/go/namecom/emailforwardings.go new file mode 100644 index 000000000..dab80cf6b --- /dev/null +++ b/vendor/github.com/namedotcom/go/namecom/emailforwardings.go @@ -0,0 +1,133 @@ +package namecom + +import ( + "bytes" + "encoding/json" + "fmt" + "net/url" +) + +var _ = bytes.MinRead + +// ListEmailForwardings returns a pagenated list of email forwarding entries for a domain. +func (n *NameCom) ListEmailForwardings(request *ListEmailForwardingsRequest) (*ListEmailForwardingsResponse, error) { + endpoint := fmt.Sprintf("/v4/domains/%s/email/forwarding", request.DomainName) + + values := url.Values{} + if request.PerPage != 0 { + values.Set("perPage", fmt.Sprintf("%d", request.PerPage)) + } + if request.Page != 0 { + values.Set("page", fmt.Sprintf("%d", request.Page)) + } + + body, err := n.get(endpoint, values) + if err != nil { + return nil, err + } + + resp := &ListEmailForwardingsResponse{} + + err = json.NewDecoder(body).Decode(resp) + if err != nil { + return nil, err + } + + return resp, nil +} + +// GetEmailForwarding returns an email forwarding entry. +func (n *NameCom) GetEmailForwarding(request *GetEmailForwardingRequest) (*EmailForwarding, error) { + endpoint := fmt.Sprintf("/v4/domains/%s/email/forwarding/%s", request.DomainName, request.EmailBox) + + values := url.Values{} + + body, err := n.get(endpoint, values) + if err != nil { + return nil, err + } + + resp := &EmailForwarding{} + + err = json.NewDecoder(body).Decode(resp) + if err != nil { + return nil, err + } + + return resp, nil +} + +// CreateEmailForwarding creates an email forwarding entry. If this is the first email forwarding entry, it may modify the MX records for the domain accordingly. +func (n *NameCom) CreateEmailForwarding(request *EmailForwarding) (*EmailForwarding, error) { + endpoint := fmt.Sprintf("/v4/domains/%s/email/forwarding", request.DomainName) + + post := &bytes.Buffer{} + err := json.NewEncoder(post).Encode(request) + if err != nil { + return nil, err + } + + body, err := n.post(endpoint, post) + if err != nil { + return nil, err + } + + resp := &EmailForwarding{} + + err = json.NewDecoder(body).Decode(resp) + if err != nil { + return nil, err + } + + return resp, nil +} + +// UpdateEmailForwarding updates which email address the email is being forwarded to. +func (n *NameCom) UpdateEmailForwarding(request *EmailForwarding) (*EmailForwarding, error) { + endpoint := fmt.Sprintf("/v4/domains/%s/email/forwarding/%s", request.DomainName, request.EmailBox) + + post := &bytes.Buffer{} + err := json.NewEncoder(post).Encode(request) + if err != nil { + return nil, err + } + + body, err := n.put(endpoint, post) + if err != nil { + return nil, err + } + + resp := &EmailForwarding{} + + err = json.NewDecoder(body).Decode(resp) + if err != nil { + return nil, err + } + + return resp, nil +} + +// DeleteEmailForwarding deletes the email forwarding entry. +func (n *NameCom) DeleteEmailForwarding(request *DeleteEmailForwardingRequest) (*EmptyResponse, error) { + endpoint := fmt.Sprintf("/v4/domains/%s/email/forwarding/%s", request.DomainName, request.EmailBox) + + post := &bytes.Buffer{} + err := json.NewEncoder(post).Encode(request) + if err != nil { + return nil, err + } + + body, err := n.delete(endpoint, post) + if err != nil { + return nil, err + } + + resp := &EmptyResponse{} + + err = json.NewDecoder(body).Decode(resp) + if err != nil { + return nil, err + } + + return resp, nil +} diff --git a/vendor/github.com/namedotcom/go/namecom/hello.go b/vendor/github.com/namedotcom/go/namecom/hello.go new file mode 100644 index 000000000..a65ed256e --- /dev/null +++ b/vendor/github.com/namedotcom/go/namecom/hello.go @@ -0,0 +1,31 @@ +package namecom + +import ( + "bytes" + "encoding/json" + "fmt" + "net/url" +) + +var _ = bytes.MinRead + +// HelloFunc returns some information about the API server. +func (n *NameCom) HelloFunc(request *HelloRequest) (*HelloResponse, error) { + endpoint := fmt.Sprintf("/v4/hello") + + values := url.Values{} + + body, err := n.get(endpoint, values) + if err != nil { + return nil, err + } + + resp := &HelloResponse{} + + err = json.NewDecoder(body).Decode(resp) + if err != nil { + return nil, err + } + + return resp, nil +} diff --git a/vendor/github.com/namedotcom/go/namecom/namecom.go b/vendor/github.com/namedotcom/go/namecom/namecom.go new file mode 100644 index 000000000..3c27483dd --- /dev/null +++ b/vendor/github.com/namedotcom/go/namecom/namecom.go @@ -0,0 +1,729 @@ +/* +Package namecom provides a client for accessing the Name.com v4 API. + +See https://www.name.com/api-docs for an introduction +to the Name.com v4 API. + +Creating a Client + +To start working with this package, create a client with user credentials + + nc := namecom.New("username","apitoken") + +To check if the username and token are correct using the HelloFunc endpoint + + response, err := nc.HelloFunc(&namecom.HelloRequest{}) + if err != nil { + // TODO: handle error + } + +*/ +package namecom + +import ( + "encoding/json" + "io" + "net/http" + "net/url" + "time" + + "github.com/pkg/errors" +) + +// NameCom is a client for connecting to the Name.com API. +type NameCom struct { + Server string + User string + Token string + Client *http.Client +} + +// New creates a new NameCom client using the production environment server endpoint. +func New(user, token string) *NameCom { + return &NameCom{ + Server: "api.name.com", + User: user, + Token: token, + Client: &http.Client{ + Timeout: 10 * time.Second, + }, + } +} + +// Test creates a new NameCom client using the test environment server enpoint. +func Test(user, token string) *NameCom { + return &NameCom{ + Server: "api.dev.name.com", + User: user, + Token: token, + Client: &http.Client{ + Timeout: 10 * time.Second, + }, + } +} + +// Error allows an ErrorResponse object to implement the error interface. +func (er ErrorResponse) Error() string { + return er.Message + ": " + er.Details +} + +func (n *NameCom) errorResponse(resp *http.Response) error { + er := &ErrorResponse{} + err := json.NewDecoder(resp.Body).Decode(er) + if err != nil { + return errors.Wrap(err, "api returned unexpected response") + } + + return errors.WithStack(er) +} + +func (n *NameCom) get(endpoint string, values url.Values) (io.Reader, error) { + if len(values) == 0 { + endpoint = endpoint + "?" + values.Encode() + } + return n.doRequest("GET", endpoint, nil) +} + +func (n *NameCom) post(endpoint string, post io.Reader) (io.Reader, error) { + return n.doRequest("POST", endpoint, post) +} + +func (n *NameCom) put(endpoint string, post io.Reader) (io.Reader, error) { + return n.doRequest("PUT", endpoint, post) +} + +func (n *NameCom) delete(endpoint string, post io.Reader) (io.Reader, error) { + return n.doRequest("DELETE", endpoint, post) +} + +func (n *NameCom) doRequest(method, endpoint string, post io.Reader) (io.Reader, error) { + if n.User == "" || n.Token == "" { + return nil, errors.New("both User and Token must be specified") + } + if n.Server == "" { + n.Server = "api.name.com" + } + if n.Client == nil { + n.Client = &http.Client{Timeout: 10 * time.Second} + } + + url := "https://" + n.Server + endpoint + + req, err := http.NewRequest(method, url, post) + if err != nil { + return nil, err + } + + req.SetBasicAuth(n.User, n.Token) + + resp, err := n.Client.Do(req) + if err != nil { + return nil, err + } + + if resp.StatusCode != 200 { + return nil, n.errorResponse(resp) + } + + return resp.Body, nil +} + +// EmptyResponse is an empty response used for DELETE endpoints. +type EmptyResponse struct { +} + +// ErrorResponse is what is returned if the HTTP status code is not 200. +type ErrorResponse struct { + // Message is the error message. + Message string `json:"message,omitempty"` + // Details may have some additional details about the error. + Details string `json:"details,omitempty"` +} + +// Record is an individual DNS resource record. +type Record struct { + // Unique record id. Value is ignored on Create, and must match the URI on Update. + ID int32 `json:"id,omitempty"` + // DomainName is the zone that the record belongs to. + DomainName string `json:"domainName,omitempty"` + // Host is the hostname relative to the zone: e.g. for a record for blog.example.org, domain would be "example.org" and host would be "blog". + // An apex record would be specified by either an empty host "" or "@". + // A SRV record would be specified by "_{service}._{protocal}.{host}": e.g. "_sip._tcp.phone" for _sip._tcp.phone.example.org. + Host string `json:"host,omitempty"` + // FQDN is the Fully Qualified Domain Name. It is the combination of the host and the domain name. It always ends in a ".". FQDN is ignored in CreateRecord, specify via the Host field instead. + Fqdn string `json:"fqdn,omitempty"` + // Type is one of the following: A, AAAA, ANAME, CNAME, MX, NS, SRV, or TXT. + Type string `json:"type,omitempty"` + // Answer is either the IP address for A or AAAA records; the target for ANAME, CNAME, MX, or NS records; the text for TXT records. + // For SRV records, answer has the following format: "{weight} {port} {target}" e.g. "1 5061 sip.example.org". + Answer string `json:"answer,omitempty"` + // TTL is the time this record can be cached for in seconds. Name.com allows a minimum TTL of 300, or 5 minutes. + TTL uint32 `json:"ttl,omitempty"` + // Priority is only required for MX and SRV records, it is ignored for all others. + Priority uint32 `json:"priority,omitempty"` +} + +// ListRecordsRequest requests a list of records that exist for the domain +type ListRecordsRequest struct { + // DomainName is the zone to list the records for. + DomainName string `json:"domainName,omitempty"` + // Per Page is the number of records to return per request. Per Page defaults to 1,000. + PerPage int32 `json:"perPage,omitempty"` + // Page is which page to return + Page int32 `json:"page,omitempty"` +} + +// ListRecordsResponse is the response for the ListRecords function. +type ListRecordsResponse struct { + // Records contains the records in the zone + Records []*Record `json:"records,omitempty"` + // NextPage is the identifier for the next page of results. It is only populated if there is another page of results after the current page. + NextPage int32 `json:"nextPage,omitempty"` + // LastPage is the identifier for the final page of results. It is only populated if there is another page of results after the current page. + LastPage int32 `json:"lastPage,omitempty"` +} + +// GetRecordRequest requests the record identified by id and domain. +type GetRecordRequest struct { + // DomainName is the zone the record exists in + DomainName string `json:"domainName,omitempty"` + // ID is the server-assigned unique identifier for this record + ID int32 `json:"id,omitempty"` +} + +// DeleteRecordRequest deletes a specific record +type DeleteRecordRequest struct { + // DomainName is the zone that the record to be deleted exists in. + DomainName string `json:"domainName,omitempty"` + // ID is the server-assigned unique identifier for the Record to be deleted. If the Record with that ID does not exist in the specified Domain, an error is returned. + ID int32 `json:"id,omitempty"` +} + +// DNSSEC contains all the data required to create a DS record at the registry. +type DNSSEC struct { + // DomainName is the domain name. + DomainName string `json:"domainName,omitempty"` + // KeyTag contains the key tag value of the DNSKEY RR that validates this signature. The algorithm to generate it is here: https://tools.ietf.org/html/rfc4034#appendix-B + KeyTag int32 `json:"keyTag,omitempty"` + // Algorithm is an integer identifying the algorithm used for signing. Valid values can be found here: https://www.iana.org/assignments/dns-sec-alg-numbers/dns-sec-alg-numbers.xhtml + Algorithm int32 `json:"algorithm,omitempty"` + // DigestType is an integer identifying the algorithm used to create the digest. Valid values can be found here: https://www.iana.org/assignments/ds-rr-types/ds-rr-types.xhtml + DigestType int32 `json:"digestType,omitempty"` + // Digest is a digest of the DNSKEY RR that is registered with the registry. + Digest string `json:"digest,omitempty"` +} + +// ListDNSSECsRequest contains the domain name to list DS records for. +type ListDNSSECsRequest struct { + // DomainName is the domain name to list keys for. + DomainName string `json:"domainName,omitempty"` +} + +// ListDNSSECsResponse contains the list of DS records at the registry. +type ListDNSSECsResponse struct { + // Dnssec is the list of registered DNSSEC keys. + Dnssec []*DNSSEC `json:"dnssec,omitempty"` + // NextPage is the identifier for the next page of results. It is only populated if there is another page of results after the current page. + NextPage int32 `json:"nextPage,omitempty"` + // LastPage is the identifier for the final page of results. It is only populated if there is another page of results after the current page. + LastPage int32 `json:"lastPage,omitempty"` +} + +// GetDNSSECRequest gets the information for a specific DS record at the registry. +type GetDNSSECRequest struct { + // DomainName is the domain name. + DomainName string `json:"domainName,omitempty"` + // Digest is the digest for the DNSKEY RR to retrieve. + Digest string `json:"digest,omitempty"` +} + +// DeleteDNSSECRequest specifies the domain name and digest to remove from the registry. +type DeleteDNSSECRequest struct { + // DomainName is the domain name the key is registered for. + DomainName string `json:"domainName,omitempty"` + // Digest is the digest for the DNSKEY RR to remove from the registry. + Digest string `json:"digest,omitempty"` +} + +// Contact contains all the contact data. +type Contact struct { + // First name of the contact. + FirstName string `json:"firstName,omitempty"` + // Last name of the contact. + LastName string `json:"lastName,omitempty"` + // Company name of the contact. Leave blank if the contact is an individual as some registries will assume it is a corporate entity otherwise. + CompanyName string `json:"companyName,omitempty"` + // Address1 is the first line of the contact's address. + Address1 string `json:"address1,omitempty"` + // Address2 is the second line of the contact's address. + Address2 string `json:"address2,omitempty"` + // City of the contact's address. + City string `json:"city,omitempty"` + // State or Province for the contact's address. + State string `json:"state,omitempty"` + // Zip or Postal Code for the contact's address. + Zip string `json:"zip,omitempty"` + // Country code for the contact's address. Required to be a ISO 3166-1 alpha-2 code. + Country string `json:"country,omitempty"` + // Phone number of the contact. Should be specified in the following format: "+cc.llllllll" where cc is the country code and llllllll is the local number. + Phone string `json:"phone,omitempty"` + // Fax number of the contact. Should be specified in the following format: "+cc.llllllll" where cc is the country code and llllllll is the local number. + Fax string `json:"fax,omitempty"` + // Email of the contact. Should be a complete and valid email address. + Email string `json:"email,omitempty"` +} + +// Contacts stores the contact information for the roles related to domains. +type Contacts struct { + // Registrant is the rightful owner of the account and has the right to use and/or sell the domain name. They are able to make changes to all account, domain, and product settings. This information should be reviewed and updated regularly to ensure accuracy. + Registrant *Contact `json:"registrant,omitempty"` + // Registrants often designate an administrative contact to manage their domain name(s). They primarily deal with business information such as the name on record, postal address, and contact information for the official registrant. + Admin *Contact `json:"admin,omitempty"` + // The technical contact manages and maintains a domain’s nameservers. If you’re working with a web designer or someone in a similar role, you many want to assign them as a technical contact. + Tech *Contact `json:"tech,omitempty"` + // The billing contact is the party responsible for paying bills for the account and taking care of renewals. + Billing *Contact `json:"billing,omitempty"` +} + +// Domain lists all the data for a domain. +type Domain struct { + // DomainName is the punycode encoded value of the domain name. + DomainName string `json:"domainName,omitempty"` + // Nameservers is the list of nameservers for this domain. If unspecified it defaults to your account default nameservers. + Nameservers []string `json:"nameservers,omitempty"` + // Contacts for the domain. + Contacts *Contacts `json:"contacts,omitempty"` + // PrivacyEnabled reflects if Whois Privacy is enabled for this domain. + PrivacyEnabled bool `json:"privacyEnabled,omitempty"` + // Locked indicates that the domain cannot be transfered to another registrar. + Locked bool `json:"locked,omitempty"` + // AutorenewEnabled indicates if the domain will attempt to renew automatically before expiration. + AutorenewEnabled bool `json:"autorenewEnabled,omitempty"` + // ExpireDate is the date the domain will expire. + ExpireDate string `json:"expireDate,omitempty"` + // CreateDate is the date the domain was created at the registry. + CreateDate string `json:"createDate,omitempty"` + // RenewalPrice is the price to renew the domain. It may be required for the RenewDomain command. + RenewalPrice float64 `json:"renewalPrice,omitempty"` +} + +// SearchRequest is used to specify the search parameters. +type SearchRequest struct { + // Timeout is a value in milliseconds on how long to perform the search for. Valid timeouts are between 500ms to 5,000ms. If not specified, timeout defaults to 1,000ms. + // Since some additional processing is performed on the results, a response may take longer then the timeout. + Timeout int32 `json:"timeout,omitempty"` + // Keyword is the search term to search for. It can be just a word, or a whole domain name. + Keyword string `json:"keyword,omitempty"` + // TLDFilter will limit results to only contain the specified TLDs. + TldFilter []string `json:"tldFilter,omitempty"` + // PromoCode is not implemented yet. + PromoCode string `json:"promoCode,omitempty"` +} + +// AvailabilityRequest is used to list the domain names to check availability for. +type AvailabilityRequest struct { + // DomainNames is the list of domains to check if they are available. + DomainNames []string `json:"domainNames,omitempty"` + // PromoCode is not implemented yet. + PromoCode string `json:"promoCode,omitempty"` +} + +// SearchResult is returned by the CheckAvailability, Search, and SearchStream functions. +type SearchResult struct { + // DomainName is the punycode encoding of the result domain name. + DomainName string `json:"domainName,omitempty"` + // SLD is first portion of the domain_name. + Sld string `json:"sld,omitempty"` + // TLD is the rest of the domain_name after the SLD. + Tld string `json:"tld,omitempty"` + // Purchaseable indicates whether the search result is available for purchase. + Purchasable bool `json:"purchasable,omitempty"` + // Premium indicates that this search result is a premium result and the purchase_price needs to be passed to the DomainCreate command. + Premium bool `json:"premium,omitempty"` + // PurchasePrice is the price for purchasing this domain for 1 year. Purchase_price is always in USD. + PurchasePrice float64 `json:"purchasePrice,omitempty"` + // PurchaseType indicates what kind of purchase this result is for. It should be passed to the DomainCreate command. + PurchaseType string `json:"purchaseType,omitempty"` + // RenewalPrice is the annual renewal price for this domain as it may be different then the purchase_price. + RenewalPrice float64 `json:"renewalPrice,omitempty"` +} + +// SearchResponse returns a list of search results. +type SearchResponse struct { + // Results of the search are returned here, the order should not be relied upon. + Results []*SearchResult `json:"results,omitempty"` +} + +// ListDomainsRequest is used to pass the pagination parameters to the ListDomains function. +type ListDomainsRequest struct { + // Per Page is the number of records to return per request. Per Page defaults to 1,000. + PerPage int32 `json:"perPage,omitempty"` + // Page is which page to return + Page int32 `json:"page,omitempty"` +} + +// ListDomainsResponse is the response from a list request, it contains the paginated list of Domains. +type ListDomainsResponse struct { + // Domains is the list of domains in your account. + Domains []*Domain `json:"domains,omitempty"` + // NextPage is the identifier for the next page of results. It is only populated if there is another page of results after the current page. + NextPage int32 `json:"nextPage,omitempty"` + // LastPage is the identifier for the final page of results. It is only populated if there is another page of results after the current page. + LastPage int32 `json:"lastPage,omitempty"` +} + +// GetDomainRequest specifies the domain name to request data for in the GetDomain function. +type GetDomainRequest struct { + // DomainName is the domain to retrieve. + DomainName string `json:"domainName,omitempty"` +} + +// CreateDomainRequest has the information that is needed to create a domain with the CreateDomain function. +type CreateDomainRequest struct { + // Domain is the domain object to create. If privacy_enabled is set, Whois Privacy will also be purchased for an additional amount. + Domain *Domain `json:"domain,omitempty"` + // PurchasePrice is the amount to pay for the domain. If privacy_enabled is set, the regular price for whois protection will be added automatically. If VAT tax applies, it will also be added automatically. + // PurchasePrice is required if purchase_type is not "registration" or if it is a premium domain. + PurchasePrice float64 `json:"purchasePrice,omitempty"` + // PurchaseType defaults to "registration" but should be copied from the result of a search command otherwise. + PurchaseType string `json:"purchaseType,omitempty"` + // Years is for how many years to register the domain for. Years defaults to 1 if not passed and cannot be more than 10. + // If passing purchase_price make sure to adjust it accordingly. + Years int32 `json:"years,omitempty"` + // TLDRequirements is a way to pass additional data that is required by some registries. + TldRequirements map[string]string `json:"tldRequirements,omitempty"` + // PromoCode is not yet implemented. + PromoCode string `json:"promoCode,omitempty"` +} + +// CreateDomainResponse contains the domain info as well as the order info for the created domain. +type CreateDomainResponse struct { + // Domain is the newly created domain. + Domain *Domain `json:"domain,omitempty"` + // Order is an identifier for this purchase. + Order int32 `json:"order,omitempty"` + // TotalPaid is the total amount paid, including VAT and whois protection. + TotalPaid float64 `json:"totalPaid,omitempty"` +} + +// RenewDomainRequest passes the domain name and purchase parameters to the RenewDomain function. +type RenewDomainRequest struct { + // DomainName is the domain to renew. + DomainName string `json:"domainName,omitempty"` + // PurchasePrice is the amount to pay for the domain renewal. If VAT tax applies, it will also be added automatically. + // PurchasePrice is required if this is a premium domain. + PurchasePrice float64 `json:"purchasePrice,omitempty"` + // Years is for how many years to renew the domain for. Years defaults to 1 if not passed and cannot be more than 10. + Years int32 `json:"years,omitempty"` + // PromoCode is not yet implemented. + PromoCode string `json:"promoCode,omitempty"` +} + +// RenewDomainResponse contains the updated domain info as well as the order info for the renewed domain. +type RenewDomainResponse struct { + // Domain reflects the status of the domain after renewing. + Domain *Domain `json:"domain,omitempty"` + // Order is an identifier for this purchase + Order int32 `json:"order,omitempty"` + // TotalPaid is the total amount paid, including VAT. + TotalPaid float64 `json:"totalPaid,omitempty"` +} + +// AuthCodeRequest passes the domain name to the GetAuthCodeForDomain funtion. +type AuthCodeRequest struct { + // DomainName is the domain name to retrieve the authorization code for. + DomainName string `json:"domainName,omitempty"` +} + +// AuthCodeResponse returns the auth code from the GetAuthCodeForDomain funtion. +type AuthCodeResponse struct { + // AuthCode is the authorization code needed to transfer a domain to another registrar. If you are storing auth codes, be sure to store them in a secure manner. + AuthCode string `json:"authCode,omitempty"` +} + +// PrivacyRequest passes the domain name as well as the purchase parameters to the PurchasePrivacy function. +type PrivacyRequest struct { + // DomainName is the domain to purchase Whois Privacy for. + DomainName string `json:"domainName,omitempty"` + // PurchasePrice is the amount you expect to pay. + PurchasePrice float64 `json:"purchasePrice,omitempty"` + // Years is the number of years you wish to purchase Whois Privacy for. Years defaults to 1 and cannot be more then the domain expiration date. + Years int32 `json:"years,omitempty"` + // PromoCode is not yet implemented + PromoCode string `json:"promoCode,omitempty"` +} + +// PrivacyResponse contains the updated domain info as well as the order info for the newly purchased Whois Privacy. +type PrivacyResponse struct { + // Domain is the status of the domain after the purchase of Whois Privacy. + Domain *Domain `json:"domain,omitempty"` + // Order is an identifier for this purchase. + Order int32 `json:"order,omitempty"` + // TotalPaid is the total amount paid, including VAT. + TotalPaid float64 `json:"totalPaid,omitempty"` +} + +// SetNameserversRequest passes the list of nameservers to set for the SetNameserver function. +type SetNameserversRequest struct { + // DomainName is the domain name to set the nameservers for. + DomainName string `json:"domainName,omitempty"` + // Namesevers is a list of the nameservers to set. Nameservers should already be set up and hosting the zone properly as some registries will verify before allowing the change. + Nameservers []string `json:"nameservers,omitempty"` +} + +// SetContactsRequest passes the contact info for each role to the SetContacts function. +type SetContactsRequest struct { + // DomainName is the domain name to set the contacts for. + DomainName string `json:"domainName,omitempty"` + // Contacts is the list of contacts to set. + Contacts *Contacts `json:"contacts,omitempty"` +} + +// EnableAutorenewForDomainRequest is used to pass the domain name to the EnableAutorenewForDomain function. +type EnableAutorenewForDomainRequest struct { + // DomainName is the domain name to enable autorenew for. + DomainName string `json:"domainName,omitempty"` +} + +// DisableAutorenewForDomainRequest is used to pass the domain name to the DisableAutorenewForDomain function. +type DisableAutorenewForDomainRequest struct { + // DomainName is the domain name to disable autorenew for. + DomainName string `json:"domainName,omitempty"` +} + +// LockDomainRequest is used to pass the domain name to the LockDomain function. +type LockDomainRequest struct { + // DomainName is the domain name to lock. + DomainName string `json:"domainName,omitempty"` +} + +// UnlockDomainRequest is used to pass the domain name to the UnlockDomain function. +type UnlockDomainRequest struct { + // DomainName is the domain name to unlock. + DomainName string `json:"domainName,omitempty"` +} + +// EmailForwarding contains all the information for an email forwarding entry. +type EmailForwarding struct { + // DomainName is the domain part of the email address to forward. + DomainName string `json:"domainName,omitempty"` + // EmailBox is the user portion of the email address to forward. + EmailBox string `json:"emailBox,omitempty"` + // EmailTo is the entire email address to forward email to. + EmailTo string `json:"emailTo,omitempty"` +} + +// ListEmailForwardingsRequest passes the domain name and pagination information to the ListEmailForwardings function. +type ListEmailForwardingsRequest struct { + // DomainName is the domain to list email forwarded boxes for. + DomainName string `json:"domainName,omitempty"` + // Per Page is the number of records to return per request. Per Page defaults to 1,000. + PerPage int32 `json:"perPage,omitempty"` + // Page is which page to return. + Page int32 `json:"page,omitempty"` +} + +// ListEmailForwardingsResponse returns the list of email forwarding entries as well as the pagination information. +type ListEmailForwardingsResponse struct { + // EmailForwarding is the list of forwarded email boxes. + EmailForwarding []*EmailForwarding `json:"emailForwarding,omitempty"` + // NextPage is the identifier for the next page of results. It is only populated if there is another page of results after the current page. + NextPage int32 `json:"nextPage,omitempty"` + // LastPage is the identifier for the final page of results. It is only populated if there is another page of results after the current page. + LastPage int32 `json:"lastPage,omitempty"` +} + +// GetEmailForwardingRequest passes the domain name and email box to request the email forwarding information for. +type GetEmailForwardingRequest struct { + // DomainName is the domain to list email forwarded box for. + DomainName string `json:"domainName,omitempty"` + // EmailBox is which email box to retrieve. + EmailBox string `json:"emailBox,omitempty"` +} + +// DeleteEmailForwardingRequest passes the domain name and email box to the DeleteEmailForwarding function. +type DeleteEmailForwardingRequest struct { + // DomainName is the domain to delete the email forwarded box from. + DomainName string `json:"domainName,omitempty"` + // EmailBox is which email box to delete. + EmailBox string `json:"emailBox,omitempty"` +} + +// HelloRequest doesn't take any parameters. +type HelloRequest struct { +} + +// HelloResponse is the response from the HelloFunc command +type HelloResponse struct { + // ServerName is an identfier for which server is being accessed. + ServerName string `json:"serverName,omitempty"` + // Motd is a message of the day. It might provide some useful information. + Motd string `json:"motd,omitempty"` + // Username is the account name you are currently logged into. + Username string `json:"username,omitempty"` + // ServerTime is the current date/time at the server. + ServerTime string `json:"serverTime,omitempty"` +} + +// Transfer contains the information related to a transfer of a domain name to Name.com. +type Transfer struct { + // DomainName is the domain to be transfered to Name.com. + DomainName string `json:"domainName,omitempty"` + // Email is the email address that the approval email was sent to. Not every TLD requries an approval email. This is usaully pulled from Whois. + Email string `json:"email,omitempty"` + // Status is the current status of the transfer. Details about statuses can be found in the following Knowledge Base article: . + Status string `json:"status,omitempty"` +} + +// ListTransfersRequest passes the pagination information to the ListTransfers function. +type ListTransfersRequest struct { + // Per Page is the number of records to return per request. Per Page defaults to 1,000. + PerPage int32 `json:"perPage,omitempty"` + // Page is which page to return + Page int32 `json:"page,omitempty"` +} + +// ListTransfersResponse returns the list of pending transfers as well as the paginiation information if relevent. +type ListTransfersResponse struct { + // Transfers is a list of pending transfers + Transfers []*Transfer `json:"transfers,omitempty"` + // NextPage is the identifier for the next page of results. It is only populated if there is another page of results after the current page. + NextPage int32 `json:"nextPage,omitempty"` + // LastPage is the identifier for the final page of results. It is only populated if there is another page of results after the current page. + LastPage int32 `json:"lastPage,omitempty"` +} + +// GetTransferRequest passes the domain name to the GetTransfer function. +type GetTransferRequest struct { + // DomainName is the domain you want to get the transfer information for. + DomainName string `json:"domainName,omitempty"` +} + +// CreateTransferRequest passes the required transfer info to the CreateTransfer function. +type CreateTransferRequest struct { + // DomainName is the domain you want to transfer to Name.com. + DomainName string `json:"domainName,omitempty"` + // AuthCode is the authorization code for the transfer. Not all TLDs require authorization codes, but most do. + AuthCode string `json:"authCode,omitempty"` + // PrivacyEnabled is a flag on whether to purchase Whois Privacy with the transfer. + PrivacyEnabled bool `json:"privacyEnabled,omitempty"` + // PurchasePrice is the amount to pay for the transfer of the domain. If privacy_enabled is set, the regular price for Whois Privacy will be added automatically. If VAT tax applies, it will also be added automatically. + // PurchasePrice is required if the domain to transfer is a premium domain. + PurchasePrice float64 `json:"purchasePrice,omitempty"` + // PromoCode is not implemented yet + PromoCode string `json:"promoCode,omitempty"` +} + +// CreateTransferResponse returns the newly created transfer resource as well as the order information. +type CreateTransferResponse struct { + // Transfer is the transfer resource created. + Transfer *Transfer `json:"transfer,omitempty"` + // Order is an identifier for this purchase. + Order int32 `json:"order,omitempty"` + // TotalPaid is the total amount paid, including VAT and Whois Privacy. + TotalPaid float64 `json:"totalPaid,omitempty"` +} + +// CancelTransferRequest passes the domain name to be canceled to the CancelTransfer function. +type CancelTransferRequest struct { + // DomainName is the domain to cancel the transfer for. + DomainName string `json:"domainName,omitempty"` +} + +// URLForwarding is the model for URL forwarding entries. +type URLForwarding struct { + // DomainName is the domain part of the hostname to forward. + DomainName string `json:"domainName,omitempty"` + // Host is the entirety of the hostname. i.e. www.example.org + Host string `json:"host,omitempty"` + // ForwardsTo is the URL this host will be forwarded to. + ForwardsTo string `json:"forwardsTo,omitempty"` + // Type is the type of forwarding. Valid types are: Masked - This retains the original domain in the address bar and will not reveal or display the actual destination URL. If you are forwarding knowledgebase.ninja to Name.com, the address bar will say knowledgebase.ninja. This is sometimes called iframe forwarding. And: Redirect - This does not retain the original domain in the address bar, so the user will see it change and realize they were forwarded from the URL they originally entered. If you are forwarding knowledgebase.ninja to Name.com, the address bar will say Name.com. This is also called 301 forwarding. + Type string `json:"type,omitempty"` + // Title is the title for the html page to use if the type is masked. Values are ignored for types other then "masked". + Title string `json:"title,omitempty"` + // Meta is the meta tags to add to the html page if the type is masked. ex: "". Values are ignored for types other then "masked". + Meta string `json:"meta,omitempty"` +} + +// ListURLForwardingsRequest is the request for the ListURLForwardings function. +type ListURLForwardingsRequest struct { + // DomainName is the domain to list URL forwarding entries for. + DomainName string `json:"domainName,omitempty"` + // Per Page is the number of records to return per request. Per Page defaults to 1,000. + PerPage int32 `json:"perPage,omitempty"` + // Page is which page to return. + Page int32 `json:"page,omitempty"` +} + +// ListURLForwardingsResponse is the response for the ListURLForwardings function. +type ListURLForwardingsResponse struct { + // URLForwarding is the list of URL forwarding entries. + URLForwarding []*URLForwarding `json:"urlForwarding,omitempty"` + // NextPage is the identifier for the next page of results. It is only populated if there is another page of results after the current page. + NextPage int32 `json:"nextPage,omitempty"` + // LastPage is the identifier for the final page of results. It is only populated if there is another page of results after the current page. + LastPage int32 `json:"lastPage,omitempty"` +} + +// GetURLForwardingRequest is the request for the GetURLForwarding function. +type GetURLForwardingRequest struct { + // DomainName is the domain to list URL forwarding entry for. + DomainName string `json:"domainName,omitempty"` + // Host is the part of the domain name before the domain. i.e. www is the host for www.example.org. + Host string `json:"host,omitempty"` +} + +// DeleteURLForwardingRequest is the request for the DeleteURLForwarding function. +type DeleteURLForwardingRequest struct { + // DomainName is the domain to delete the URL forwardind entry from. + DomainName string `json:"domainName,omitempty"` + // Host is the part of the domain name before the domain. i.e. www is the host for www.example.org. + Host string `json:"host,omitempty"` +} + +// VanityNameserver contains the hostname as well as the list of IP addresses for nameservers. +type VanityNameserver struct { + // DomainName is the domain the nameserver is a subdomain of. + DomainName string `json:"domainName,omitempty"` + // Hostname is the hostname of the nameserver. + Hostname string `json:"hostname,omitempty"` + // IPs is a list of IP addresses that are used for glue records for this nameserver. + Ips []string `json:"ips,omitempty"` +} + +// ListVanityNameserversRequest passes the domain name as well as the pagination parameters to the ListVanityNameservers function. +type ListVanityNameserversRequest struct { + // DomainName is the domain to list the vanity nameservers for. + DomainName string `json:"domainName,omitempty"` + // Per Page is the number of records to return per request. Per Page defaults to 1,000. + PerPage int32 `json:"perPage,omitempty"` + // Page is which page to return + Page int32 `json:"page,omitempty"` +} + +// ListVanityNameserversResponse returns the list of vanity nameservers for the domain. +type ListVanityNameserversResponse struct { + // VanityNameservers is the list of vanity nameservers. + VanityNameservers []*VanityNameserver `json:"vanityNameservers,omitempty"` + // NextPage is the identifier for the next page of results. It is only populated if there is another page of results after the current page. + NextPage int32 `json:"nextPage,omitempty"` + // LastPage is the identifier for the final page of results. It is only populated if there is another page of results after the current page. + LastPage int32 `json:"lastPage,omitempty"` +} + +// GetVanityNameserverRequest passes the hostname to get the details for. +type GetVanityNameserverRequest struct { + // DomainName is the domain to for the vanity nameserver. + DomainName string `json:"domainName,omitempty"` + // Hostname is the hostname for the vanity nameserver. + Hostname string `json:"hostname,omitempty"` +} + +// DeleteVanityNameserverRequest passes which hostname to remove from the registry. +type DeleteVanityNameserverRequest struct { + // DomainName is the domain of the vanity nameserver to delete. + DomainName string `json:"domainName,omitempty"` + // Hostname is the hostname of the vanity nameserver to delete. + Hostname string `json:"hostname,omitempty"` +} diff --git a/vendor/github.com/namedotcom/go/namecom/transfers.go b/vendor/github.com/namedotcom/go/namecom/transfers.go new file mode 100644 index 000000000..814e525f8 --- /dev/null +++ b/vendor/github.com/namedotcom/go/namecom/transfers.go @@ -0,0 +1,108 @@ +package namecom + +import ( + "bytes" + "encoding/json" + "fmt" + "net/url" +) + +var _ = bytes.MinRead + +// ListTransfers lists all pending transfer in requests. To get the information related to a non-pending transfer, you can use the GetTransfer function for that. +func (n *NameCom) ListTransfers(request *ListTransfersRequest) (*ListTransfersResponse, error) { + endpoint := fmt.Sprintf("/v4/transfers") + + values := url.Values{} + if request.PerPage != 0 { + values.Set("perPage", fmt.Sprintf("%d", request.PerPage)) + } + if request.Page != 0 { + values.Set("page", fmt.Sprintf("%d", request.Page)) + } + + body, err := n.get(endpoint, values) + if err != nil { + return nil, err + } + + resp := &ListTransfersResponse{} + + err = json.NewDecoder(body).Decode(resp) + if err != nil { + return nil, err + } + + return resp, nil +} + +// GetTransfer gets details for a transfer request. +func (n *NameCom) GetTransfer(request *GetTransferRequest) (*Transfer, error) { + endpoint := fmt.Sprintf("/v4/transfers/%s", request.DomainName) + + values := url.Values{} + + body, err := n.get(endpoint, values) + if err != nil { + return nil, err + } + + resp := &Transfer{} + + err = json.NewDecoder(body).Decode(resp) + if err != nil { + return nil, err + } + + return resp, nil +} + +// CreateTransfer purchases a new domain transfer request. +func (n *NameCom) CreateTransfer(request *CreateTransferRequest) (*CreateTransferResponse, error) { + endpoint := fmt.Sprintf("/v4/transfers") + + post := &bytes.Buffer{} + err := json.NewEncoder(post).Encode(request) + if err != nil { + return nil, err + } + + body, err := n.post(endpoint, post) + if err != nil { + return nil, err + } + + resp := &CreateTransferResponse{} + + err = json.NewDecoder(body).Decode(resp) + if err != nil { + return nil, err + } + + return resp, nil +} + +// CancelTransfer cancels a pending transfer request and refunds the amount to account credit. +func (n *NameCom) CancelTransfer(request *CancelTransferRequest) (*Transfer, error) { + endpoint := fmt.Sprintf("/v4/transfers") + + post := &bytes.Buffer{} + err := json.NewEncoder(post).Encode(request) + if err != nil { + return nil, err + } + + body, err := n.post(endpoint, post) + if err != nil { + return nil, err + } + + resp := &Transfer{} + + err = json.NewDecoder(body).Decode(resp) + if err != nil { + return nil, err + } + + return resp, nil +} diff --git a/vendor/github.com/namedotcom/go/namecom/urlforwardings.go b/vendor/github.com/namedotcom/go/namecom/urlforwardings.go new file mode 100644 index 000000000..1b608ebe6 --- /dev/null +++ b/vendor/github.com/namedotcom/go/namecom/urlforwardings.go @@ -0,0 +1,133 @@ +package namecom + +import ( + "bytes" + "encoding/json" + "fmt" + "net/url" +) + +var _ = bytes.MinRead + +// ListURLForwardings returns a pagenated list of URL forwarding entries for a domain. +func (n *NameCom) ListURLForwardings(request *ListURLForwardingsRequest) (*ListURLForwardingsResponse, error) { + endpoint := fmt.Sprintf("/v4/domains/%s/url/forwarding", request.DomainName) + + values := url.Values{} + if request.PerPage != 0 { + values.Set("perPage", fmt.Sprintf("%d", request.PerPage)) + } + if request.Page != 0 { + values.Set("page", fmt.Sprintf("%d", request.Page)) + } + + body, err := n.get(endpoint, values) + if err != nil { + return nil, err + } + + resp := &ListURLForwardingsResponse{} + + err = json.NewDecoder(body).Decode(resp) + if err != nil { + return nil, err + } + + return resp, nil +} + +// GetURLForwarding returns an URL forwarding entry. +func (n *NameCom) GetURLForwarding(request *GetURLForwardingRequest) (*URLForwarding, error) { + endpoint := fmt.Sprintf("/v4/domains/%s/url/forwarding/%s", request.DomainName, request.Host) + + values := url.Values{} + + body, err := n.get(endpoint, values) + if err != nil { + return nil, err + } + + resp := &URLForwarding{} + + err = json.NewDecoder(body).Decode(resp) + if err != nil { + return nil, err + } + + return resp, nil +} + +// CreateURLForwarding creates an URL forwarding entry. If this is the first URL forwarding entry, it may modify the A records for the domain accordingly. +func (n *NameCom) CreateURLForwarding(request *URLForwarding) (*URLForwarding, error) { + endpoint := fmt.Sprintf("/v4/domains/%s/url/forwarding", request.DomainName) + + post := &bytes.Buffer{} + err := json.NewEncoder(post).Encode(request) + if err != nil { + return nil, err + } + + body, err := n.post(endpoint, post) + if err != nil { + return nil, err + } + + resp := &URLForwarding{} + + err = json.NewDecoder(body).Decode(resp) + if err != nil { + return nil, err + } + + return resp, nil +} + +// UpdateURLForwarding updates which URL the host is being forwarded to. +func (n *NameCom) UpdateURLForwarding(request *URLForwarding) (*URLForwarding, error) { + endpoint := fmt.Sprintf("/v4/domains/%s/url/forwarding/%s", request.DomainName, request.Host) + + post := &bytes.Buffer{} + err := json.NewEncoder(post).Encode(request) + if err != nil { + return nil, err + } + + body, err := n.put(endpoint, post) + if err != nil { + return nil, err + } + + resp := &URLForwarding{} + + err = json.NewDecoder(body).Decode(resp) + if err != nil { + return nil, err + } + + return resp, nil +} + +// DeleteURLForwarding deletes the URL forwarding entry. +func (n *NameCom) DeleteURLForwarding(request *DeleteURLForwardingRequest) (*EmptyResponse, error) { + endpoint := fmt.Sprintf("/v4/domains/%s/url/forwarding/%s", request.DomainName, request.Host) + + post := &bytes.Buffer{} + err := json.NewEncoder(post).Encode(request) + if err != nil { + return nil, err + } + + body, err := n.delete(endpoint, post) + if err != nil { + return nil, err + } + + resp := &EmptyResponse{} + + err = json.NewDecoder(body).Decode(resp) + if err != nil { + return nil, err + } + + return resp, nil +} diff --git a/vendor/github.com/namedotcom/go/namecom/vanitynameservers.go b/vendor/github.com/namedotcom/go/namecom/vanitynameservers.go new file mode 100644 index 000000000..b46b249fd --- /dev/null +++ b/vendor/github.com/namedotcom/go/namecom/vanitynameservers.go @@ -0,0 +1,133 @@ +package namecom + +import ( + "bytes" + "encoding/json" + "fmt" + "net/url" +) + +var _ = bytes.MinRead + +// ListVanityNameservers lists all nameservers registered with the registry. It omits the IP addresses from the response. Those can be found from calling GetVanityNameserver. +func (n *NameCom) ListVanityNameservers(request *ListVanityNameserversRequest) (*ListVanityNameserversResponse, error) { + endpoint := fmt.Sprintf("/v4/domains/%s/vanity_nameservers", request.DomainName) + + values := url.Values{} + if request.PerPage != 0 { + values.Set("perPage", fmt.Sprintf("%d", request.PerPage)) + } + if request.Page != 0 { + values.Set("page", fmt.Sprintf("%d", request.Page)) + } + + body, err := n.get(endpoint, values) + if err != nil { + return nil, err + } + + resp := &ListVanityNameserversResponse{} + + err = json.NewDecoder(body).Decode(resp) + if err != nil { + return nil, err + } + + return resp, nil +} + +// GetVanityNameserver gets the details for a vanity nameserver registered with the registry. +func (n *NameCom) GetVanityNameserver(request *GetVanityNameserverRequest) (*VanityNameserver, error) { + endpoint := fmt.Sprintf("/v4/domains/%s/vanity_nameservers/%s", request.DomainName, request.Hostname) + + values := url.Values{} + + body, err := n.get(endpoint, values) + if err != nil { + return nil, err + } + + resp := &VanityNameserver{} + + err = json.NewDecoder(body).Decode(resp) + if err != nil { + return nil, err + } + + return resp, nil +} + +// CreateVanityNameserver registers a nameserver with the registry. +func (n *NameCom) CreateVanityNameserver(request *VanityNameserver) (*VanityNameserver, error) { + endpoint := fmt.Sprintf("/v4/domains/%s/vanity_nameservers", request.DomainName) + + post := &bytes.Buffer{} + err := json.NewEncoder(post).Encode(request) + if err != nil { + return nil, err + } + + body, err := n.post(endpoint, post) + if err != nil { + return nil, err + } + + resp := &VanityNameserver{} + + err = json.NewDecoder(body).Decode(resp) + if err != nil { + return nil, err + } + + return resp, nil +} + +// UpdateVanityNameserver allows you to update the glue record IP addresses at the registry. +func (n *NameCom) UpdateVanityNameserver(request *VanityNameserver) (*VanityNameserver, error) { + endpoint := fmt.Sprintf("/v4/domains/%s/vanity_nameservers/%s", request.DomainName, request.Hostname) + + post := &bytes.Buffer{} + err := json.NewEncoder(post).Encode(request) + if err != nil { + return nil, err + } + + body, err := n.put(endpoint, post) + if err != nil { + return nil, err + } + + resp := &VanityNameserver{} + + err = json.NewDecoder(body).Decode(resp) + if err != nil { + return nil, err + } + + return resp, nil +} + +// DeleteVanityNameserver unregisteres the nameserver at the registry. This might fail if the registry believes the nameserver is in use. +func (n *NameCom) DeleteVanityNameserver(request *DeleteVanityNameserverRequest) (*EmptyResponse, error) { + endpoint := fmt.Sprintf("/v4/domains/%s/vanity_nameservers/%s", request.DomainName, request.Hostname) + + post := &bytes.Buffer{} + err := json.NewEncoder(post).Encode(request) + if err != nil { + return nil, err + } + + body, err := n.delete(endpoint, post) + if err != nil { + return nil, err + } + + resp := &EmptyResponse{} + + err = json.NewDecoder(body).Decode(resp) + if err != nil { + return nil, err + } + + return resp, nil +} diff --git a/vendor/github.com/tuvistavie/securerandom/srandom.go b/vendor/github.com/tuvistavie/securerandom/srandom.go new file mode 100644 index 000000000..30c36f13a --- /dev/null +++ b/vendor/github.com/tuvistavie/securerandom/srandom.go @@ -0,0 +1,70 @@ +package securerandom + +import ( + "bytes" + "crypto/rand" + "encoding/base64" + "encoding/binary" + "encoding/hex" + "fmt" + "strings" +) + +func RandomBytes(n int) ([]byte, error) { + bytes := make([]byte, n) + _, err := rand.Read(bytes) + if err != nil { + return nil, err + } + return bytes, nil +} + +func Base64(n int, padded bool) (string, error) { + bytes, err := RandomBytes(n) + if err != nil { + return "", err + } + result := base64.StdEncoding.EncodeToString(bytes) + result = strings.Replace(result, "\n", "", -1) + if !padded { + result = strings.Replace(result, "=", "", -1) + } + return result, nil +} + +func UrlSafeBase64(n int, padded bool) (string, error) { + result, err := Base64(n, padded) + if err != nil { + return "", err + } + result = strings.Replace(result, "+", "-", -1) + result = strings.Replace(result, "/", "_", -1) + return result, nil +} + +func Hex(n int) (string, error) { + bytes, err := RandomBytes(n) + if err != nil { + return "", err + } + return hex.EncodeToString(bytes), nil +} + +func Uuid() (string, error) { + var first, last uint32 + var middle [4]uint16 + randomBytes, err := RandomBytes(16) + if err != nil { + return "", err + } + buffer := bytes.NewBuffer(randomBytes) + binary.Read(buffer, binary.BigEndian, &first) + for i := 0; i < 4; i++ { + binary.Read(buffer, binary.BigEndian, &middle[i]) + } + binary.Read(buffer, binary.BigEndian, &last) + middle[1] = (middle[1] & 0x0fff) | 0x4000 + middle[2] = (middle[2] & 0x3fff) | 0x8000 + return fmt.Sprintf("%08x-%04x-%04x-%04x-%04x%08x", + first, middle[0], middle[1], middle[2], middle[3], last), nil +} diff --git a/vendor/github.com/xenolf/lego/acme/challenges.go b/vendor/github.com/xenolf/lego/acme/challenges.go deleted file mode 100644 index 857900507..000000000 --- a/vendor/github.com/xenolf/lego/acme/challenges.go +++ /dev/null @@ -1,16 +0,0 @@ -package acme - -// Challenge is a string that identifies a particular type and version of ACME challenge. -type Challenge string - -const ( - // HTTP01 is the "http-01" ACME challenge https://github.com/ietf-wg-acme/acme/blob/master/draft-ietf-acme-acme.md#http - // Note: HTTP01ChallengePath returns the URL path to fulfill this challenge - HTTP01 = Challenge("http-01") - // TLSSNI01 is the "tls-sni-01" ACME challenge https://github.com/ietf-wg-acme/acme/blob/master/draft-ietf-acme-acme.md#tls-with-server-name-indication-tls-sni - // Note: TLSSNI01ChallengeCert returns a certificate to fulfill this challenge - TLSSNI01 = Challenge("tls-sni-01") - // DNS01 is the "dns-01" ACME challenge https://github.com/ietf-wg-acme/acme/blob/master/draft-ietf-acme-acme.md#dns - // Note: DNS01Record returns a DNS record which will fulfill this challenge - DNS01 = Challenge("dns-01") -) diff --git a/vendor/github.com/xenolf/lego/acme/client.go b/vendor/github.com/xenolf/lego/acme/client.go deleted file mode 100644 index bcb844371..000000000 --- a/vendor/github.com/xenolf/lego/acme/client.go +++ /dev/null @@ -1,825 +0,0 @@ -// Package acme implements the ACME protocol for Let's Encrypt and other conforming providers. -package acme - -import ( - "crypto" - "crypto/x509" - "encoding/base64" - "encoding/json" - "errors" - "fmt" - "io/ioutil" - "log" - "net" - "net/http" - "regexp" - "strconv" - "strings" - "time" -) - -var ( - // Logger is an optional custom logger. - Logger *log.Logger -) - -const ( - // maxBodySize is the maximum size of body that we will read. - maxBodySize = 1024 * 1024 - - // overallRequestLimit is the overall number of request per second limited on the - // “new-reg”, “new-authz” and “new-cert” endpoints. From the documentation the - // limitation is 20 requests per second, but using 20 as value doesn't work but 18 do - overallRequestLimit = 18 -) - -// logf writes a log entry. It uses Logger if not -// nil, otherwise it uses the default log.Logger. -func logf(format string, args ...interface{}) { - if Logger != nil { - Logger.Printf(format, args...) - } else { - log.Printf(format, args...) - } -} - -// User interface is to be implemented by users of this library. -// It is used by the client type to get user specific information. -type User interface { - GetEmail() string - GetRegistration() *RegistrationResource - GetPrivateKey() crypto.PrivateKey -} - -// Interface for all challenge solvers to implement. -type solver interface { - Solve(challenge challenge, domain string) error -} - -type validateFunc func(j *jws, domain, uri string, chlng challenge) error - -// Client is the user-friendy way to ACME -type Client struct { - directory directory - user User - jws *jws - keyType KeyType - solvers map[Challenge]solver -} - -// NewClient creates a new ACME client on behalf of the user. The client will depend on -// the ACME directory located at caDirURL for the rest of its actions. A private -// key of type keyType (see KeyType contants) will be generated when requesting a new -// certificate if one isn't provided. -func NewClient(caDirURL string, user User, keyType KeyType) (*Client, error) { - privKey := user.GetPrivateKey() - if privKey == nil { - return nil, errors.New("private key was nil") - } - - var dir directory - if _, err := getJSON(caDirURL, &dir); err != nil { - return nil, fmt.Errorf("get directory at '%s': %v", caDirURL, err) - } - - if dir.NewRegURL == "" { - return nil, errors.New("directory missing new registration URL") - } - if dir.NewAuthzURL == "" { - return nil, errors.New("directory missing new authz URL") - } - if dir.NewCertURL == "" { - return nil, errors.New("directory missing new certificate URL") - } - if dir.RevokeCertURL == "" { - return nil, errors.New("directory missing revoke certificate URL") - } - - jws := &jws{privKey: privKey, directoryURL: caDirURL} - - // REVIEW: best possibility? - // Add all available solvers with the right index as per ACME - // spec to this map. Otherwise they won`t be found. - solvers := make(map[Challenge]solver) - solvers[HTTP01] = &httpChallenge{jws: jws, validate: validate, provider: &HTTPProviderServer{}} - solvers[TLSSNI01] = &tlsSNIChallenge{jws: jws, validate: validate, provider: &TLSProviderServer{}} - - return &Client{directory: dir, user: user, jws: jws, keyType: keyType, solvers: solvers}, nil -} - -// SetChallengeProvider specifies a custom provider p that can solve the given challenge type. -func (c *Client) SetChallengeProvider(challenge Challenge, p ChallengeProvider) error { - switch challenge { - case HTTP01: - c.solvers[challenge] = &httpChallenge{jws: c.jws, validate: validate, provider: p} - case TLSSNI01: - c.solvers[challenge] = &tlsSNIChallenge{jws: c.jws, validate: validate, provider: p} - case DNS01: - c.solvers[challenge] = &dnsChallenge{jws: c.jws, validate: validate, provider: p} - default: - return fmt.Errorf("Unknown challenge %v", challenge) - } - return nil -} - -// SetHTTPAddress specifies a custom interface:port to be used for HTTP based challenges. -// If this option is not used, the default port 80 and all interfaces will be used. -// To only specify a port and no interface use the ":port" notation. -// -// NOTE: This REPLACES any custom HTTP provider previously set by calling -// c.SetChallengeProvider with the default HTTP challenge provider. -func (c *Client) SetHTTPAddress(iface string) error { - host, port, err := net.SplitHostPort(iface) - if err != nil { - return err - } - - if chlng, ok := c.solvers[HTTP01]; ok { - chlng.(*httpChallenge).provider = NewHTTPProviderServer(host, port) - } - - return nil -} - -// SetTLSAddress specifies a custom interface:port to be used for TLS based challenges. -// If this option is not used, the default port 443 and all interfaces will be used. -// To only specify a port and no interface use the ":port" notation. -// -// NOTE: This REPLACES any custom TLS-SNI provider previously set by calling -// c.SetChallengeProvider with the default TLS-SNI challenge provider. -func (c *Client) SetTLSAddress(iface string) error { - host, port, err := net.SplitHostPort(iface) - if err != nil { - return err - } - - if chlng, ok := c.solvers[TLSSNI01]; ok { - chlng.(*tlsSNIChallenge).provider = NewTLSProviderServer(host, port) - } - return nil -} - -// ExcludeChallenges explicitly removes challenges from the pool for solving. -func (c *Client) ExcludeChallenges(challenges []Challenge) { - // Loop through all challenges and delete the requested one if found. - for _, challenge := range challenges { - delete(c.solvers, challenge) - } -} - -// Register the current account to the ACME server. -func (c *Client) Register() (*RegistrationResource, error) { - if c == nil || c.user == nil { - return nil, errors.New("acme: cannot register a nil client or user") - } - logf("[INFO] acme: Registering account for %s", c.user.GetEmail()) - - regMsg := registrationMessage{ - Resource: "new-reg", - } - if c.user.GetEmail() != "" { - regMsg.Contact = []string{"mailto:" + c.user.GetEmail()} - } else { - regMsg.Contact = []string{} - } - - var serverReg Registration - var regURI string - hdr, err := postJSON(c.jws, c.directory.NewRegURL, regMsg, &serverReg) - if err != nil { - remoteErr, ok := err.(RemoteError) - if ok && remoteErr.StatusCode == 409 { - regURI = hdr.Get("Location") - regMsg = registrationMessage{ - Resource: "reg", - } - if hdr, err = postJSON(c.jws, regURI, regMsg, &serverReg); err != nil { - return nil, err - } - } else { - return nil, err - } - } - - reg := &RegistrationResource{Body: serverReg} - - links := parseLinks(hdr["Link"]) - - if regURI == "" { - regURI = hdr.Get("Location") - } - reg.URI = regURI - if links["terms-of-service"] != "" { - reg.TosURL = links["terms-of-service"] - } - - if links["next"] != "" { - reg.NewAuthzURL = links["next"] - } else { - return nil, errors.New("acme: The server did not return 'next' link to proceed") - } - - return reg, nil -} - -// DeleteRegistration deletes the client's user registration from the ACME -// server. -func (c *Client) DeleteRegistration() error { - if c == nil || c.user == nil { - return errors.New("acme: cannot unregister a nil client or user") - } - logf("[INFO] acme: Deleting account for %s", c.user.GetEmail()) - - regMsg := registrationMessage{ - Resource: "reg", - Delete: true, - } - - _, err := postJSON(c.jws, c.user.GetRegistration().URI, regMsg, nil) - if err != nil { - return err - } - - return nil -} - -// QueryRegistration runs a POST request on the client's registration and -// returns the result. -// -// This is similar to the Register function, but acting on an existing -// registration link and resource. -func (c *Client) QueryRegistration() (*RegistrationResource, error) { - if c == nil || c.user == nil { - return nil, errors.New("acme: cannot query the registration of a nil client or user") - } - // Log the URL here instead of the email as the email may not be set - logf("[INFO] acme: Querying account for %s", c.user.GetRegistration().URI) - - regMsg := registrationMessage{ - Resource: "reg", - } - - var serverReg Registration - hdr, err := postJSON(c.jws, c.user.GetRegistration().URI, regMsg, &serverReg) - if err != nil { - return nil, err - } - - reg := &RegistrationResource{Body: serverReg} - - links := parseLinks(hdr["Link"]) - // Location: header is not returned so this needs to be populated off of - // existing URI - reg.URI = c.user.GetRegistration().URI - if links["terms-of-service"] != "" { - reg.TosURL = links["terms-of-service"] - } - - if links["next"] != "" { - reg.NewAuthzURL = links["next"] - } else { - return nil, errors.New("acme: No new-authz link in response to registration query") - } - - return reg, nil -} - -// AgreeToTOS updates the Client registration and sends the agreement to -// the server. -func (c *Client) AgreeToTOS() error { - reg := c.user.GetRegistration() - - reg.Body.Agreement = c.user.GetRegistration().TosURL - reg.Body.Resource = "reg" - _, err := postJSON(c.jws, c.user.GetRegistration().URI, c.user.GetRegistration().Body, nil) - return err -} - -// ObtainCertificateForCSR tries to obtain a certificate matching the CSR passed into it. -// The domains are inferred from the CommonName and SubjectAltNames, if any. The private key -// for this CSR is not required. -// If bundle is true, the []byte contains both the issuer certificate and -// your issued certificate as a bundle. -// This function will never return a partial certificate. If one domain in the list fails, -// the whole certificate will fail. -func (c *Client) ObtainCertificateForCSR(csr x509.CertificateRequest, bundle bool) (CertificateResource, map[string]error) { - // figure out what domains it concerns - // start with the common name - domains := []string{csr.Subject.CommonName} - - // loop over the SubjectAltName DNS names -DNSNames: - for _, sanName := range csr.DNSNames { - for _, existingName := range domains { - if existingName == sanName { - // duplicate; skip this name - continue DNSNames - } - } - - // name is unique - domains = append(domains, sanName) - } - - if bundle { - logf("[INFO][%s] acme: Obtaining bundled SAN certificate given a CSR", strings.Join(domains, ", ")) - } else { - logf("[INFO][%s] acme: Obtaining SAN certificate given a CSR", strings.Join(domains, ", ")) - } - - challenges, failures := c.getChallenges(domains) - // If any challenge fails - return. Do not generate partial SAN certificates. - if len(failures) > 0 { - for _, auth := range challenges { - c.disableAuthz(auth) - } - - return CertificateResource{}, failures - } - - errs := c.solveChallenges(challenges) - // If any challenge fails - return. Do not generate partial SAN certificates. - if len(errs) > 0 { - return CertificateResource{}, errs - } - - logf("[INFO][%s] acme: Validations succeeded; requesting certificates", strings.Join(domains, ", ")) - - cert, err := c.requestCertificateForCsr(challenges, bundle, csr.Raw, nil) - if err != nil { - for _, chln := range challenges { - failures[chln.Domain] = err - } - } - - // Add the CSR to the certificate so that it can be used for renewals. - cert.CSR = pemEncode(&csr) - - return cert, failures -} - -// ObtainCertificate tries to obtain a single certificate using all domains passed into it. -// The first domain in domains is used for the CommonName field of the certificate, all other -// domains are added using the Subject Alternate Names extension. A new private key is generated -// for every invocation of this function. If you do not want that you can supply your own private key -// in the privKey parameter. If this parameter is non-nil it will be used instead of generating a new one. -// If bundle is true, the []byte contains both the issuer certificate and -// your issued certificate as a bundle. -// This function will never return a partial certificate. If one domain in the list fails, -// the whole certificate will fail. -func (c *Client) ObtainCertificate(domains []string, bundle bool, privKey crypto.PrivateKey, mustStaple bool) (CertificateResource, map[string]error) { - if bundle { - logf("[INFO][%s] acme: Obtaining bundled SAN certificate", strings.Join(domains, ", ")) - } else { - logf("[INFO][%s] acme: Obtaining SAN certificate", strings.Join(domains, ", ")) - } - - challenges, failures := c.getChallenges(domains) - // If any challenge fails - return. Do not generate partial SAN certificates. - if len(failures) > 0 { - for _, auth := range challenges { - c.disableAuthz(auth) - } - - return CertificateResource{}, failures - } - - errs := c.solveChallenges(challenges) - // If any challenge fails - return. Do not generate partial SAN certificates. - if len(errs) > 0 { - return CertificateResource{}, errs - } - - logf("[INFO][%s] acme: Validations succeeded; requesting certificates", strings.Join(domains, ", ")) - - cert, err := c.requestCertificate(challenges, bundle, privKey, mustStaple) - if err != nil { - for _, chln := range challenges { - failures[chln.Domain] = err - } - } - - return cert, failures -} - -// RevokeCertificate takes a PEM encoded certificate or bundle and tries to revoke it at the CA. -func (c *Client) RevokeCertificate(certificate []byte) error { - certificates, err := parsePEMBundle(certificate) - if err != nil { - return err - } - - x509Cert := certificates[0] - if x509Cert.IsCA { - return fmt.Errorf("Certificate bundle starts with a CA certificate") - } - - encodedCert := base64.URLEncoding.EncodeToString(x509Cert.Raw) - - _, err = postJSON(c.jws, c.directory.RevokeCertURL, revokeCertMessage{Resource: "revoke-cert", Certificate: encodedCert}, nil) - return err -} - -// RenewCertificate takes a CertificateResource and tries to renew the certificate. -// If the renewal process succeeds, the new certificate will ge returned in a new CertResource. -// Please be aware that this function will return a new certificate in ANY case that is not an error. -// If the server does not provide us with a new cert on a GET request to the CertURL -// this function will start a new-cert flow where a new certificate gets generated. -// If bundle is true, the []byte contains both the issuer certificate and -// your issued certificate as a bundle. -// For private key reuse the PrivateKey property of the passed in CertificateResource should be non-nil. -func (c *Client) RenewCertificate(cert CertificateResource, bundle, mustStaple bool) (CertificateResource, error) { - // Input certificate is PEM encoded. Decode it here as we may need the decoded - // cert later on in the renewal process. The input may be a bundle or a single certificate. - certificates, err := parsePEMBundle(cert.Certificate) - if err != nil { - return CertificateResource{}, err - } - - x509Cert := certificates[0] - if x509Cert.IsCA { - return CertificateResource{}, fmt.Errorf("[%s] Certificate bundle starts with a CA certificate", cert.Domain) - } - - // This is just meant to be informal for the user. - timeLeft := x509Cert.NotAfter.Sub(time.Now().UTC()) - logf("[INFO][%s] acme: Trying renewal with %d hours remaining", cert.Domain, int(timeLeft.Hours())) - - // We always need to request a new certificate to renew. - // Start by checking to see if the certificate was based off a CSR, and - // use that if it's defined. - if len(cert.CSR) > 0 { - csr, err := pemDecodeTox509CSR(cert.CSR) - if err != nil { - return CertificateResource{}, err - } - newCert, failures := c.ObtainCertificateForCSR(*csr, bundle) - return newCert, failures[cert.Domain] - } - - var privKey crypto.PrivateKey - if cert.PrivateKey != nil { - privKey, err = parsePEMPrivateKey(cert.PrivateKey) - if err != nil { - return CertificateResource{}, err - } - } - - var domains []string - var failures map[string]error - // check for SAN certificate - if len(x509Cert.DNSNames) > 1 { - domains = append(domains, x509Cert.Subject.CommonName) - for _, sanDomain := range x509Cert.DNSNames { - if sanDomain == x509Cert.Subject.CommonName { - continue - } - domains = append(domains, sanDomain) - } - } else { - domains = append(domains, x509Cert.Subject.CommonName) - } - - newCert, failures := c.ObtainCertificate(domains, bundle, privKey, mustStaple) - return newCert, failures[cert.Domain] -} - -// Looks through the challenge combinations to find a solvable match. -// Then solves the challenges in series and returns. -func (c *Client) solveChallenges(challenges []authorizationResource) map[string]error { - // loop through the resources, basically through the domains. - failures := make(map[string]error) - for _, authz := range challenges { - if authz.Body.Status == "valid" { - // Boulder might recycle recent validated authz (see issue #267) - logf("[INFO][%s] acme: Authorization already valid; skipping challenge", authz.Domain) - continue - } - // no solvers - no solving - if solvers := c.chooseSolvers(authz.Body, authz.Domain); solvers != nil { - for i, solver := range solvers { - // TODO: do not immediately fail if one domain fails to validate. - err := solver.Solve(authz.Body.Challenges[i], authz.Domain) - if err != nil { - c.disableAuthz(authz) - failures[authz.Domain] = err - } - } - } else { - c.disableAuthz(authz) - failures[authz.Domain] = fmt.Errorf("[%s] acme: Could not determine solvers", authz.Domain) - } - } - - return failures -} - -// Checks all combinations from the server and returns an array of -// solvers which should get executed in series. -func (c *Client) chooseSolvers(auth authorization, domain string) map[int]solver { - for _, combination := range auth.Combinations { - solvers := make(map[int]solver) - for _, idx := range combination { - if solver, ok := c.solvers[auth.Challenges[idx].Type]; ok { - solvers[idx] = solver - } else { - logf("[INFO][%s] acme: Could not find solver for: %s", domain, auth.Challenges[idx].Type) - } - } - - // If we can solve the whole combination, return the solvers - if len(solvers) == len(combination) { - return solvers - } - } - return nil -} - -// Get the challenges needed to proof our identifier to the ACME server. -func (c *Client) getChallenges(domains []string) ([]authorizationResource, map[string]error) { - resc, errc := make(chan authorizationResource), make(chan domainError) - - delay := time.Second / overallRequestLimit - - for _, domain := range domains { - time.Sleep(delay) - - go func(domain string) { - authMsg := authorization{Resource: "new-authz", Identifier: identifier{Type: "dns", Value: domain}} - var authz authorization - hdr, err := postJSON(c.jws, c.user.GetRegistration().NewAuthzURL, authMsg, &authz) - if err != nil { - errc <- domainError{Domain: domain, Error: err} - return - } - - links := parseLinks(hdr["Link"]) - if links["next"] == "" { - logf("[ERROR][%s] acme: Server did not provide next link to proceed", domain) - errc <- domainError{Domain: domain, Error: errors.New("Server did not provide next link to proceed")} - return - } - - resc <- authorizationResource{Body: authz, NewCertURL: links["next"], AuthURL: hdr.Get("Location"), Domain: domain} - }(domain) - } - - responses := make(map[string]authorizationResource) - failures := make(map[string]error) - for i := 0; i < len(domains); i++ { - select { - case res := <-resc: - responses[res.Domain] = res - case err := <-errc: - failures[err.Domain] = err.Error - } - } - - challenges := make([]authorizationResource, 0, len(responses)) - for _, domain := range domains { - if challenge, ok := responses[domain]; ok { - challenges = append(challenges, challenge) - } - } - - logAuthz(challenges) - - close(resc) - close(errc) - - return challenges, failures -} - -func logAuthz(authz []authorizationResource) { - for _, auth := range authz { - logf("[INFO][%s] AuthURL: %s", auth.Domain, auth.AuthURL) - } -} - -// cleanAuthz loops through the passed in slice and disables any auths which are not "valid" -func (c *Client) disableAuthz(auth authorizationResource) error { - var disabledAuth authorization - _, err := postJSON(c.jws, auth.AuthURL, deactivateAuthMessage{Resource: "authz", Status: "deactivated"}, &disabledAuth) - return err -} - -func (c *Client) requestCertificate(authz []authorizationResource, bundle bool, privKey crypto.PrivateKey, mustStaple bool) (CertificateResource, error) { - if len(authz) == 0 { - return CertificateResource{}, errors.New("Passed no authorizations to requestCertificate!") - } - - var err error - if privKey == nil { - privKey, err = generatePrivateKey(c.keyType) - if err != nil { - return CertificateResource{}, err - } - } - - // determine certificate name(s) based on the authorization resources - commonName := authz[0] - var san []string - for _, auth := range authz[1:] { - san = append(san, auth.Domain) - } - - // TODO: should the CSR be customizable? - csr, err := generateCsr(privKey, commonName.Domain, san, mustStaple) - if err != nil { - return CertificateResource{}, err - } - - return c.requestCertificateForCsr(authz, bundle, csr, pemEncode(privKey)) -} - -func (c *Client) requestCertificateForCsr(authz []authorizationResource, bundle bool, csr []byte, privateKeyPem []byte) (CertificateResource, error) { - commonName := authz[0] - - var authURLs []string - for _, auth := range authz[1:] { - authURLs = append(authURLs, auth.AuthURL) - } - - csrString := base64.URLEncoding.EncodeToString(csr) - jsonBytes, err := json.Marshal(csrMessage{Resource: "new-cert", Csr: csrString, Authorizations: authURLs}) - if err != nil { - return CertificateResource{}, err - } - - resp, err := c.jws.post(commonName.NewCertURL, jsonBytes) - if err != nil { - return CertificateResource{}, err - } - - certRes := CertificateResource{ - Domain: commonName.Domain, - CertURL: resp.Header.Get("Location"), - PrivateKey: privateKeyPem, - } - - maxChecks := 1000 - for i := 0; i < maxChecks; i++ { - done, err := c.checkCertResponse(resp, &certRes, bundle) - resp.Body.Close() - if err != nil { - return CertificateResource{}, err - } - if done { - break - } - if i == maxChecks-1 { - return CertificateResource{}, fmt.Errorf("polled for certificate %d times; giving up", i) - } - resp, err = httpGet(certRes.CertURL) - if err != nil { - return CertificateResource{}, err - } - } - - return certRes, nil -} - -// checkCertResponse checks resp to see if a certificate is contained in the -// response, and if so, loads it into certRes and returns true. If the cert -// is not yet ready, it returns false. This function honors the waiting period -// required by the Retry-After header of the response, if specified. This -// function may read from resp.Body but does NOT close it. The certRes input -// should already have the Domain (common name) field populated. If bundle is -// true, the certificate will be bundled with the issuer's cert. -func (c *Client) checkCertResponse(resp *http.Response, certRes *CertificateResource, bundle bool) (bool, error) { - switch resp.StatusCode { - case 201, 202: - cert, err := ioutil.ReadAll(limitReader(resp.Body, maxBodySize)) - if err != nil { - return false, err - } - - // The server returns a body with a length of zero if the - // certificate was not ready at the time this request completed. - // Otherwise the body is the certificate. - if len(cert) > 0 { - certRes.CertStableURL = resp.Header.Get("Content-Location") - certRes.AccountRef = c.user.GetRegistration().URI - - issuedCert := pemEncode(derCertificateBytes(cert)) - - // The issuer certificate link is always supplied via an "up" link - // in the response headers of a new certificate. - links := parseLinks(resp.Header["Link"]) - issuerCert, err := c.getIssuerCertificate(links["up"]) - if err != nil { - // If we fail to acquire the issuer cert, return the issued certificate - do not fail. - logf("[WARNING][%s] acme: Could not bundle issuer certificate: %v", certRes.Domain, err) - } else { - issuerCert = pemEncode(derCertificateBytes(issuerCert)) - - // If bundle is true, we want to return a certificate bundle. - // To do this, we append the issuer cert to the issued cert. - if bundle { - issuedCert = append(issuedCert, issuerCert...) - } - } - - certRes.Certificate = issuedCert - certRes.IssuerCertificate = issuerCert - logf("[INFO][%s] Server responded with a certificate.", certRes.Domain) - return true, nil - } - - // The certificate was granted but is not yet issued. - // Check retry-after and loop. - ra := resp.Header.Get("Retry-After") - retryAfter, err := strconv.Atoi(ra) - if err != nil { - return false, err - } - - logf("[INFO][%s] acme: Server responded with status 202; retrying after %ds", certRes.Domain, retryAfter) - time.Sleep(time.Duration(retryAfter) * time.Second) - - return false, nil - default: - return false, handleHTTPError(resp) - } -} - -// getIssuerCertificate requests the issuer certificate -func (c *Client) getIssuerCertificate(url string) ([]byte, error) { - logf("[INFO] acme: Requesting issuer cert from %s", url) - resp, err := httpGet(url) - if err != nil { - return nil, err - } - defer resp.Body.Close() - - issuerBytes, err := ioutil.ReadAll(limitReader(resp.Body, maxBodySize)) - if err != nil { - return nil, err - } - - _, err = x509.ParseCertificate(issuerBytes) - if err != nil { - return nil, err - } - - return issuerBytes, err -} - -func parseLinks(links []string) map[string]string { - aBrkt := regexp.MustCompile("[<>]") - slver := regexp.MustCompile("(.+) *= *\"(.+)\"") - linkMap := make(map[string]string) - - for _, link := range links { - - link = aBrkt.ReplaceAllString(link, "") - parts := strings.Split(link, ";") - - matches := slver.FindStringSubmatch(parts[1]) - if len(matches) > 0 { - linkMap[matches[2]] = parts[0] - } - } - - return linkMap -} - -// validate makes the ACME server start validating a -// challenge response, only returning once it is done. -func validate(j *jws, domain, uri string, chlng challenge) error { - var challengeResponse challenge - - hdr, err := postJSON(j, uri, chlng, &challengeResponse) - if err != nil { - return err - } - - // After the path is sent, the ACME server will access our server. - // Repeatedly check the server for an updated status on our request. - for { - switch challengeResponse.Status { - case "valid": - logf("[INFO][%s] The server validated our request", domain) - return nil - case "pending": - break - case "invalid": - return handleChallengeError(challengeResponse) - default: - return errors.New("The server returned an unexpected state.") - } - - ra, err := strconv.Atoi(hdr.Get("Retry-After")) - if err != nil { - // The ACME server MUST return a Retry-After. - // If it doesn't, we'll just poll hard. - ra = 1 - } - time.Sleep(time.Duration(ra) * time.Second) - - hdr, err = getJSON(uri, &challengeResponse) - if err != nil { - return err - } - } -} diff --git a/vendor/github.com/xenolf/lego/acme/crypto.go b/vendor/github.com/xenolf/lego/acme/crypto.go deleted file mode 100644 index fa868a90d..000000000 --- a/vendor/github.com/xenolf/lego/acme/crypto.go +++ /dev/null @@ -1,347 +0,0 @@ -package acme - -import ( - "bytes" - "crypto" - "crypto/ecdsa" - "crypto/elliptic" - "crypto/rand" - "crypto/rsa" - "crypto/x509" - "crypto/x509/pkix" - "encoding/base64" - "encoding/pem" - "errors" - "fmt" - "io" - "io/ioutil" - "math/big" - "net/http" - "strings" - "time" - - "encoding/asn1" - - "golang.org/x/crypto/ocsp" -) - -// KeyType represents the key algo as well as the key size or curve to use. -type KeyType string -type derCertificateBytes []byte - -// Constants for all key types we support. -const ( - EC256 = KeyType("P256") - EC384 = KeyType("P384") - RSA2048 = KeyType("2048") - RSA4096 = KeyType("4096") - RSA8192 = KeyType("8192") -) - -const ( - // OCSPGood means that the certificate is valid. - OCSPGood = ocsp.Good - // OCSPRevoked means that the certificate has been deliberately revoked. - OCSPRevoked = ocsp.Revoked - // OCSPUnknown means that the OCSP responder doesn't know about the certificate. - OCSPUnknown = ocsp.Unknown - // OCSPServerFailed means that the OCSP responder failed to process the request. - OCSPServerFailed = ocsp.ServerFailed -) - -// Constants for OCSP must staple -var ( - tlsFeatureExtensionOID = asn1.ObjectIdentifier{1, 3, 6, 1, 5, 5, 7, 1, 24} - ocspMustStapleFeature = []byte{0x30, 0x03, 0x02, 0x01, 0x05} -) - -// GetOCSPForCert takes a PEM encoded cert or cert bundle returning the raw OCSP response, -// the parsed response, and an error, if any. The returned []byte can be passed directly -// into the OCSPStaple property of a tls.Certificate. If the bundle only contains the -// issued certificate, this function will try to get the issuer certificate from the -// IssuingCertificateURL in the certificate. If the []byte and/or ocsp.Response return -// values are nil, the OCSP status may be assumed OCSPUnknown. -func GetOCSPForCert(bundle []byte) ([]byte, *ocsp.Response, error) { - certificates, err := parsePEMBundle(bundle) - if err != nil { - return nil, nil, err - } - - // We expect the certificate slice to be ordered downwards the chain. - // SRV CRT -> CA. We need to pull the leaf and issuer certs out of it, - // which should always be the first two certificates. If there's no - // OCSP server listed in the leaf cert, there's nothing to do. And if - // we have only one certificate so far, we need to get the issuer cert. - issuedCert := certificates[0] - if len(issuedCert.OCSPServer) == 0 { - return nil, nil, errors.New("no OCSP server specified in cert") - } - if len(certificates) == 1 { - // TODO: build fallback. If this fails, check the remaining array entries. - if len(issuedCert.IssuingCertificateURL) == 0 { - return nil, nil, errors.New("no issuing certificate URL") - } - - resp, err := httpGet(issuedCert.IssuingCertificateURL[0]) - if err != nil { - return nil, nil, err - } - defer resp.Body.Close() - - issuerBytes, err := ioutil.ReadAll(limitReader(resp.Body, 1024*1024)) - if err != nil { - return nil, nil, err - } - - issuerCert, err := x509.ParseCertificate(issuerBytes) - if err != nil { - return nil, nil, err - } - - // Insert it into the slice on position 0 - // We want it ordered right SRV CRT -> CA - certificates = append(certificates, issuerCert) - } - issuerCert := certificates[1] - - // Finally kick off the OCSP request. - ocspReq, err := ocsp.CreateRequest(issuedCert, issuerCert, nil) - if err != nil { - return nil, nil, err - } - - reader := bytes.NewReader(ocspReq) - req, err := httpPost(issuedCert.OCSPServer[0], "application/ocsp-request", reader) - if err != nil { - return nil, nil, err - } - defer req.Body.Close() - - ocspResBytes, err := ioutil.ReadAll(limitReader(req.Body, 1024*1024)) - ocspRes, err := ocsp.ParseResponse(ocspResBytes, issuerCert) - if err != nil { - return nil, nil, err - } - - return ocspResBytes, ocspRes, nil -} - -func getKeyAuthorization(token string, key interface{}) (string, error) { - var publicKey crypto.PublicKey - switch k := key.(type) { - case *ecdsa.PrivateKey: - publicKey = k.Public() - case *rsa.PrivateKey: - publicKey = k.Public() - } - - // Generate the Key Authorization for the challenge - jwk := keyAsJWK(publicKey) - if jwk == nil { - return "", errors.New("Could not generate JWK from key.") - } - thumbBytes, err := jwk.Thumbprint(crypto.SHA256) - if err != nil { - return "", err - } - - // unpad the base64URL - keyThumb := base64.URLEncoding.EncodeToString(thumbBytes) - index := strings.Index(keyThumb, "=") - if index != -1 { - keyThumb = keyThumb[:index] - } - - return token + "." + keyThumb, nil -} - -// parsePEMBundle parses a certificate bundle from top to bottom and returns -// a slice of x509 certificates. This function will error if no certificates are found. -func parsePEMBundle(bundle []byte) ([]*x509.Certificate, error) { - var certificates []*x509.Certificate - var certDERBlock *pem.Block - - for { - certDERBlock, bundle = pem.Decode(bundle) - if certDERBlock == nil { - break - } - - if certDERBlock.Type == "CERTIFICATE" { - cert, err := x509.ParseCertificate(certDERBlock.Bytes) - if err != nil { - return nil, err - } - certificates = append(certificates, cert) - } - } - - if len(certificates) == 0 { - return nil, errors.New("No certificates were found while parsing the bundle.") - } - - return certificates, nil -} - -func parsePEMPrivateKey(key []byte) (crypto.PrivateKey, error) { - keyBlock, _ := pem.Decode(key) - - switch keyBlock.Type { - case "RSA PRIVATE KEY": - return x509.ParsePKCS1PrivateKey(keyBlock.Bytes) - case "EC PRIVATE KEY": - return x509.ParseECPrivateKey(keyBlock.Bytes) - default: - return nil, errors.New("Unknown PEM header value") - } -} - -func generatePrivateKey(keyType KeyType) (crypto.PrivateKey, error) { - - switch keyType { - case EC256: - return ecdsa.GenerateKey(elliptic.P256(), rand.Reader) - case EC384: - return ecdsa.GenerateKey(elliptic.P384(), rand.Reader) - case RSA2048: - return rsa.GenerateKey(rand.Reader, 2048) - case RSA4096: - return rsa.GenerateKey(rand.Reader, 4096) - case RSA8192: - return rsa.GenerateKey(rand.Reader, 8192) - } - - return nil, fmt.Errorf("Invalid KeyType: %s", keyType) -} - -func generateCsr(privateKey crypto.PrivateKey, domain string, san []string, mustStaple bool) ([]byte, error) { - template := x509.CertificateRequest{ - Subject: pkix.Name{ - CommonName: domain, - }, - } - - if len(san) > 0 { - template.DNSNames = san - } - - if mustStaple { - template.ExtraExtensions = append(template.ExtraExtensions, pkix.Extension{ - Id: tlsFeatureExtensionOID, - Value: ocspMustStapleFeature, - }) - } - - return x509.CreateCertificateRequest(rand.Reader, &template, privateKey) -} - -func pemEncode(data interface{}) []byte { - var pemBlock *pem.Block - switch key := data.(type) { - case *ecdsa.PrivateKey: - keyBytes, _ := x509.MarshalECPrivateKey(key) - pemBlock = &pem.Block{Type: "EC PRIVATE KEY", Bytes: keyBytes} - case *rsa.PrivateKey: - pemBlock = &pem.Block{Type: "RSA PRIVATE KEY", Bytes: x509.MarshalPKCS1PrivateKey(key)} - break - case *x509.CertificateRequest: - pemBlock = &pem.Block{Type: "CERTIFICATE REQUEST", Bytes: key.Raw} - break - case derCertificateBytes: - pemBlock = &pem.Block{Type: "CERTIFICATE", Bytes: []byte(data.(derCertificateBytes))} - } - - return pem.EncodeToMemory(pemBlock) -} - -func pemDecode(data []byte) (*pem.Block, error) { - pemBlock, _ := pem.Decode(data) - if pemBlock == nil { - return nil, fmt.Errorf("Pem decode did not yield a valid block. Is the certificate in the right format?") - } - - return pemBlock, nil -} - -func pemDecodeTox509(pem []byte) (*x509.Certificate, error) { - pemBlock, err := pemDecode(pem) - if pemBlock == nil { - return nil, err - } - - return x509.ParseCertificate(pemBlock.Bytes) -} - -func pemDecodeTox509CSR(pem []byte) (*x509.CertificateRequest, error) { - pemBlock, err := pemDecode(pem) - if pemBlock == nil { - return nil, err - } - - if pemBlock.Type != "CERTIFICATE REQUEST" { - return nil, fmt.Errorf("PEM block is not a certificate request") - } - - return x509.ParseCertificateRequest(pemBlock.Bytes) -} - -// GetPEMCertExpiration returns the "NotAfter" date of a PEM encoded certificate. -// The certificate has to be PEM encoded. Any other encodings like DER will fail. -func GetPEMCertExpiration(cert []byte) (time.Time, error) { - pemBlock, err := pemDecode(cert) - if pemBlock == nil { - return time.Time{}, err - } - - return getCertExpiration(pemBlock.Bytes) -} - -// getCertExpiration returns the "NotAfter" date of a DER encoded certificate. -func getCertExpiration(cert []byte) (time.Time, error) { - pCert, err := x509.ParseCertificate(cert) - if err != nil { - return time.Time{}, err - } - - return pCert.NotAfter, nil -} - -func generatePemCert(privKey *rsa.PrivateKey, domain string) ([]byte, error) { - derBytes, err := generateDerCert(privKey, time.Time{}, domain) - if err != nil { - return nil, err - } - - return pem.EncodeToMemory(&pem.Block{Type: "CERTIFICATE", Bytes: derBytes}), nil -} - -func generateDerCert(privKey *rsa.PrivateKey, expiration time.Time, domain string) ([]byte, error) { - serialNumberLimit := new(big.Int).Lsh(big.NewInt(1), 128) - serialNumber, err := rand.Int(rand.Reader, serialNumberLimit) - if err != nil { - return nil, err - } - - if expiration.IsZero() { - expiration = time.Now().Add(365) - } - - template := x509.Certificate{ - SerialNumber: serialNumber, - Subject: pkix.Name{ - CommonName: "ACME Challenge TEMP", - }, - NotBefore: time.Now(), - NotAfter: expiration, - - KeyUsage: x509.KeyUsageKeyEncipherment, - BasicConstraintsValid: true, - DNSNames: []string{domain}, - } - - return x509.CreateCertificate(rand.Reader, &template, &template, &privKey.PublicKey, privKey) -} - -func limitReader(rd io.ReadCloser, numBytes int64) io.ReadCloser { - return http.MaxBytesReader(nil, rd, numBytes) -} diff --git a/vendor/github.com/xenolf/lego/acme/dns_challenge.go b/vendor/github.com/xenolf/lego/acme/dns_challenge.go deleted file mode 100644 index d6844dcd4..000000000 --- a/vendor/github.com/xenolf/lego/acme/dns_challenge.go +++ /dev/null @@ -1,309 +0,0 @@ -package acme - -import ( - "crypto/sha256" - "encoding/base64" - "errors" - "fmt" - "log" - "net" - "strings" - "time" - - "github.com/miekg/dns" -) - -type preCheckDNSFunc func(fqdn, value string) (bool, error) - -var ( - // PreCheckDNS checks DNS propagation before notifying ACME that - // the DNS challenge is ready. - PreCheckDNS preCheckDNSFunc = checkDNSPropagation - fqdnToZone = map[string]string{} -) - -const defaultResolvConf = "/etc/resolv.conf" - -var defaultNameservers = []string{ - "google-public-dns-a.google.com:53", - "google-public-dns-b.google.com:53", -} - -var RecursiveNameservers = getNameservers(defaultResolvConf, defaultNameservers) - -// DNSTimeout is used to override the default DNS timeout of 10 seconds. -var DNSTimeout = 10 * time.Second - -// getNameservers attempts to get systems nameservers before falling back to the defaults -func getNameservers(path string, defaults []string) []string { - config, err := dns.ClientConfigFromFile(path) - if err != nil || len(config.Servers) == 0 { - return defaults - } - - systemNameservers := []string{} - for _, server := range config.Servers { - // ensure all servers have a port number - if _, _, err := net.SplitHostPort(server); err != nil { - systemNameservers = append(systemNameservers, net.JoinHostPort(server, "53")) - } else { - systemNameservers = append(systemNameservers, server) - } - } - return systemNameservers -} - -// DNS01Record returns a DNS record which will fulfill the `dns-01` challenge -func DNS01Record(domain, keyAuth string) (fqdn string, value string, ttl int) { - keyAuthShaBytes := sha256.Sum256([]byte(keyAuth)) - // base64URL encoding without padding - keyAuthSha := base64.URLEncoding.EncodeToString(keyAuthShaBytes[:sha256.Size]) - value = strings.TrimRight(keyAuthSha, "=") - ttl = 120 - fqdn = fmt.Sprintf("_acme-challenge.%s.", domain) - return -} - -// dnsChallenge implements the dns-01 challenge according to ACME 7.5 -type dnsChallenge struct { - jws *jws - validate validateFunc - provider ChallengeProvider -} - -func (s *dnsChallenge) Solve(chlng challenge, domain string) error { - logf("[INFO][%s] acme: Trying to solve DNS-01", domain) - - if s.provider == nil { - return errors.New("No DNS Provider configured") - } - - // Generate the Key Authorization for the challenge - keyAuth, err := getKeyAuthorization(chlng.Token, s.jws.privKey) - if err != nil { - return err - } - - err = s.provider.Present(domain, chlng.Token, keyAuth) - if err != nil { - return fmt.Errorf("Error presenting token: %s", err) - } - defer func() { - err := s.provider.CleanUp(domain, chlng.Token, keyAuth) - if err != nil { - log.Printf("Error cleaning up %s: %v ", domain, err) - } - }() - - fqdn, value, _ := DNS01Record(domain, keyAuth) - - logf("[INFO][%s] Checking DNS record propagation using %+v", domain, RecursiveNameservers) - - var timeout, interval time.Duration - switch provider := s.provider.(type) { - case ChallengeProviderTimeout: - timeout, interval = provider.Timeout() - default: - timeout, interval = 60*time.Second, 2*time.Second - } - - err = WaitFor(timeout, interval, func() (bool, error) { - return PreCheckDNS(fqdn, value) - }) - if err != nil { - return err - } - - return s.validate(s.jws, domain, chlng.URI, challenge{Resource: "challenge", Type: chlng.Type, Token: chlng.Token, KeyAuthorization: keyAuth}) -} - -// checkDNSPropagation checks if the expected TXT record has been propagated to all authoritative nameservers. -func checkDNSPropagation(fqdn, value string) (bool, error) { - // Initial attempt to resolve at the recursive NS - r, err := dnsQuery(fqdn, dns.TypeTXT, RecursiveNameservers, true) - if err != nil { - return false, err - } - if r.Rcode == dns.RcodeSuccess { - // If we see a CNAME here then use the alias - for _, rr := range r.Answer { - if cn, ok := rr.(*dns.CNAME); ok { - if cn.Hdr.Name == fqdn { - fqdn = cn.Target - break - } - } - } - } - - authoritativeNss, err := lookupNameservers(fqdn) - if err != nil { - return false, err - } - - return checkAuthoritativeNss(fqdn, value, authoritativeNss) -} - -// checkAuthoritativeNss queries each of the given nameservers for the expected TXT record. -func checkAuthoritativeNss(fqdn, value string, nameservers []string) (bool, error) { - for _, ns := range nameservers { - r, err := dnsQuery(fqdn, dns.TypeTXT, []string{net.JoinHostPort(ns, "53")}, false) - if err != nil { - return false, err - } - - if r.Rcode != dns.RcodeSuccess { - return false, fmt.Errorf("NS %s returned %s for %s", ns, dns.RcodeToString[r.Rcode], fqdn) - } - - var found bool - for _, rr := range r.Answer { - if txt, ok := rr.(*dns.TXT); ok { - if strings.Join(txt.Txt, "") == value { - found = true - break - } - } - } - - if !found { - return false, fmt.Errorf("NS %s did not return the expected TXT record", ns) - } - } - - return true, nil -} - -// dnsQuery will query a nameserver, iterating through the supplied servers as it retries -// The nameserver should include a port, to facilitate testing where we talk to a mock dns server. -func dnsQuery(fqdn string, rtype uint16, nameservers []string, recursive bool) (in *dns.Msg, err error) { - m := new(dns.Msg) - m.SetQuestion(fqdn, rtype) - m.SetEdns0(4096, false) - - if !recursive { - m.RecursionDesired = false - } - - // Will retry the request based on the number of servers (n+1) - for i := 1; i <= len(nameservers)+1; i++ { - ns := nameservers[i%len(nameservers)] - udp := &dns.Client{Net: "udp", Timeout: DNSTimeout} - in, _, err = udp.Exchange(m, ns) - - if err == dns.ErrTruncated { - tcp := &dns.Client{Net: "tcp", Timeout: DNSTimeout} - // If the TCP request succeeds, the err will reset to nil - in, _, err = tcp.Exchange(m, ns) - } - - if err == nil { - break - } - } - return -} - -// lookupNameservers returns the authoritative nameservers for the given fqdn. -func lookupNameservers(fqdn string) ([]string, error) { - var authoritativeNss []string - - zone, err := FindZoneByFqdn(fqdn, RecursiveNameservers) - if err != nil { - return nil, fmt.Errorf("Could not determine the zone: %v", err) - } - - r, err := dnsQuery(zone, dns.TypeNS, RecursiveNameservers, true) - if err != nil { - return nil, err - } - - for _, rr := range r.Answer { - if ns, ok := rr.(*dns.NS); ok { - authoritativeNss = append(authoritativeNss, strings.ToLower(ns.Ns)) - } - } - - if len(authoritativeNss) > 0 { - return authoritativeNss, nil - } - return nil, fmt.Errorf("Could not determine authoritative nameservers") -} - -// FindZoneByFqdn determines the zone apex for the given fqdn by recursing up the -// domain labels until the nameserver returns a SOA record in the answer section. -func FindZoneByFqdn(fqdn string, nameservers []string) (string, error) { - // Do we have it cached? - if zone, ok := fqdnToZone[fqdn]; ok { - return zone, nil - } - - labelIndexes := dns.Split(fqdn) - for _, index := range labelIndexes { - domain := fqdn[index:] - - in, err := dnsQuery(domain, dns.TypeSOA, nameservers, true) - if err != nil { - return "", err - } - - // Any response code other than NOERROR and NXDOMAIN is treated as error - if in.Rcode != dns.RcodeNameError && in.Rcode != dns.RcodeSuccess { - return "", fmt.Errorf("Unexpected response code '%s' for %s", - dns.RcodeToString[in.Rcode], domain) - } - - // Check if we got a SOA RR in the answer section - if in.Rcode == dns.RcodeSuccess { - - // CNAME records cannot/should not exist at the root of a zone. - // So we skip a domain when a CNAME is found. - if dnsMsgContainsCNAME(in) { - continue - } - - for _, ans := range in.Answer { - if soa, ok := ans.(*dns.SOA); ok { - zone := soa.Hdr.Name - fqdnToZone[fqdn] = zone - return zone, nil - } - } - } - } - - return "", fmt.Errorf("Could not find the start of authority") -} - -// dnsMsgContainsCNAME checks for a CNAME answer in msg -func dnsMsgContainsCNAME(msg *dns.Msg) bool { - for _, ans := range msg.Answer { - if _, ok := ans.(*dns.CNAME); ok { - return true - } - } - return false -} - -// ClearFqdnCache clears the cache of fqdn to zone mappings. Primarily used in testing. -func ClearFqdnCache() { - fqdnToZone = map[string]string{} -} - -// ToFqdn converts the name into a fqdn appending a trailing dot. -func ToFqdn(name string) string { - n := len(name) - if n == 0 || name[n-1] == '.' { - return name - } - return name + "." -} - -// UnFqdn converts the fqdn into a name removing the trailing dot. -func UnFqdn(name string) string { - n := len(name) - if n != 0 && name[n-1] == '.' { - return name[:n-1] - } - return name -} diff --git a/vendor/github.com/xenolf/lego/acme/dns_challenge_manual.go b/vendor/github.com/xenolf/lego/acme/dns_challenge_manual.go deleted file mode 100644 index 240384e60..000000000 --- a/vendor/github.com/xenolf/lego/acme/dns_challenge_manual.go +++ /dev/null @@ -1,53 +0,0 @@ -package acme - -import ( - "bufio" - "fmt" - "os" -) - -const ( - dnsTemplate = "%s %d IN TXT \"%s\"" -) - -// DNSProviderManual is an implementation of the ChallengeProvider interface -type DNSProviderManual struct{} - -// NewDNSProviderManual returns a DNSProviderManual instance. -func NewDNSProviderManual() (*DNSProviderManual, error) { - return &DNSProviderManual{}, nil -} - -// Present prints instructions for manually creating the TXT record -func (*DNSProviderManual) Present(domain, token, keyAuth string) error { - fqdn, value, ttl := DNS01Record(domain, keyAuth) - dnsRecord := fmt.Sprintf(dnsTemplate, fqdn, ttl, value) - - authZone, err := FindZoneByFqdn(fqdn, RecursiveNameservers) - if err != nil { - return err - } - - logf("[INFO] acme: Please create the following TXT record in your %s zone:", authZone) - logf("[INFO] acme: %s", dnsRecord) - logf("[INFO] acme: Press 'Enter' when you are done") - - reader := bufio.NewReader(os.Stdin) - _, _ = reader.ReadString('\n') - return nil -} - -// CleanUp prints instructions for manually removing the TXT record -func (*DNSProviderManual) CleanUp(domain, token, keyAuth string) error { - fqdn, _, ttl := DNS01Record(domain, keyAuth) - dnsRecord := fmt.Sprintf(dnsTemplate, fqdn, ttl, "...") - - authZone, err := FindZoneByFqdn(fqdn, RecursiveNameservers) - if err != nil { - return err - } - - logf("[INFO] acme: You can now remove this TXT record from your %s zone:", authZone) - logf("[INFO] acme: %s", dnsRecord) - return nil -} diff --git a/vendor/github.com/xenolf/lego/acme/error.go b/vendor/github.com/xenolf/lego/acme/error.go deleted file mode 100644 index e4bc934c2..000000000 --- a/vendor/github.com/xenolf/lego/acme/error.go +++ /dev/null @@ -1,94 +0,0 @@ -package acme - -import ( - "encoding/json" - "fmt" - "io/ioutil" - "net/http" - "strings" -) - -const ( - tosAgreementError = "Must agree to subscriber agreement before any further actions" - invalidNonceError = "JWS has invalid anti-replay nonce" -) - -// RemoteError is the base type for all errors specific to the ACME protocol. -type RemoteError struct { - StatusCode int `json:"status,omitempty"` - Type string `json:"type"` - Detail string `json:"detail"` -} - -func (e RemoteError) Error() string { - return fmt.Sprintf("acme: Error %d - %s - %s", e.StatusCode, e.Type, e.Detail) -} - -// TOSError represents the error which is returned if the user needs to -// accept the TOS. -// TODO: include the new TOS url if we can somehow obtain it. -type TOSError struct { - RemoteError -} - -// NonceError represents the error which is returned if the -// nonce sent by the client was not accepted by the server. -type NonceError struct { - RemoteError -} - -type domainError struct { - Domain string - Error error -} - -type challengeError struct { - RemoteError - records []validationRecord -} - -func (c challengeError) Error() string { - - var errStr string - for _, validation := range c.records { - errStr = errStr + fmt.Sprintf("\tValidation for %s:%s\n\tResolved to:\n\t\t%s\n\tUsed: %s\n\n", - validation.Hostname, validation.Port, strings.Join(validation.ResolvedAddresses, "\n\t\t"), validation.UsedAddress) - } - - return fmt.Sprintf("%s\nError Detail:\n%s", c.RemoteError.Error(), errStr) -} - -func handleHTTPError(resp *http.Response) error { - var errorDetail RemoteError - - contentType := resp.Header.Get("Content-Type") - if contentType == "application/json" || contentType == "application/problem+json" { - err := json.NewDecoder(resp.Body).Decode(&errorDetail) - if err != nil { - return err - } - } else { - detailBytes, err := ioutil.ReadAll(limitReader(resp.Body, maxBodySize)) - if err != nil { - return err - } - errorDetail.Detail = string(detailBytes) - } - - errorDetail.StatusCode = resp.StatusCode - - // Check for errors we handle specifically - if errorDetail.StatusCode == http.StatusForbidden && errorDetail.Detail == tosAgreementError { - return TOSError{errorDetail} - } - - if errorDetail.StatusCode == http.StatusBadRequest && strings.HasPrefix(errorDetail.Detail, invalidNonceError) { - return NonceError{errorDetail} - } - - return errorDetail -} - -func handleChallengeError(chlng challenge) error { - return challengeError{chlng.Error, chlng.ValidationRecords} -} diff --git a/vendor/github.com/xenolf/lego/acme/http.go b/vendor/github.com/xenolf/lego/acme/http.go deleted file mode 100644 index e469e0de2..000000000 --- a/vendor/github.com/xenolf/lego/acme/http.go +++ /dev/null @@ -1,160 +0,0 @@ -package acme - -import ( - "encoding/json" - "errors" - "fmt" - "io" - "net" - "net/http" - "runtime" - "strings" - "time" -) - -// UserAgent (if non-empty) will be tacked onto the User-Agent string in requests. -var UserAgent string - -// HTTPClient is an HTTP client with a reasonable timeout value. -var HTTPClient = http.Client{ - Transport: &http.Transport{ - Proxy: http.ProxyFromEnvironment, - Dial: (&net.Dialer{ - Timeout: 30 * time.Second, - KeepAlive: 30 * time.Second, - }).Dial, - TLSHandshakeTimeout: 15 * time.Second, - ResponseHeaderTimeout: 15 * time.Second, - ExpectContinueTimeout: 1 * time.Second, - }, -} - -const ( - // defaultGoUserAgent is the Go HTTP package user agent string. Too - // bad it isn't exported. If it changes, we should update it here, too. - defaultGoUserAgent = "Go-http-client/1.1" - - // ourUserAgent is the User-Agent of this underlying library package. - ourUserAgent = "xenolf-acme" -) - -// httpHead performs a HEAD request with a proper User-Agent string. -// The response body (resp.Body) is already closed when this function returns. -func httpHead(url string) (resp *http.Response, err error) { - req, err := http.NewRequest("HEAD", url, nil) - if err != nil { - return nil, fmt.Errorf("failed to head %q: %v", url, err) - } - - req.Header.Set("User-Agent", userAgent()) - - resp, err = HTTPClient.Do(req) - if err != nil { - return resp, fmt.Errorf("failed to do head %q: %v", url, err) - } - resp.Body.Close() - return resp, err -} - -// httpPost performs a POST request with a proper User-Agent string. -// Callers should close resp.Body when done reading from it. -func httpPost(url string, bodyType string, body io.Reader) (resp *http.Response, err error) { - req, err := http.NewRequest("POST", url, body) - if err != nil { - return nil, fmt.Errorf("failed to post %q: %v", url, err) - } - req.Header.Set("Content-Type", bodyType) - req.Header.Set("User-Agent", userAgent()) - - return HTTPClient.Do(req) -} - -// httpGet performs a GET request with a proper User-Agent string. -// Callers should close resp.Body when done reading from it. -func httpGet(url string) (resp *http.Response, err error) { - req, err := http.NewRequest("GET", url, nil) - if err != nil { - return nil, fmt.Errorf("failed to get %q: %v", url, err) - } - req.Header.Set("User-Agent", userAgent()) - - return HTTPClient.Do(req) -} - -// getJSON performs an HTTP GET request and parses the response body -// as JSON, into the provided respBody object. -func getJSON(uri string, respBody interface{}) (http.Header, error) { - resp, err := httpGet(uri) - if err != nil { - return nil, fmt.Errorf("failed to get json %q: %v", uri, err) - } - defer resp.Body.Close() - - if resp.StatusCode >= http.StatusBadRequest { - return resp.Header, handleHTTPError(resp) - } - - return resp.Header, json.NewDecoder(resp.Body).Decode(respBody) -} - -// postJSON performs an HTTP POST request and parses the response body -// as JSON, into the provided respBody object. -func postJSON(j *jws, uri string, reqBody, respBody interface{}) (http.Header, error) { - jsonBytes, err := json.Marshal(reqBody) - if err != nil { - return nil, errors.New("Failed to marshal network message...") - } - - resp, err := j.post(uri, jsonBytes) - if err != nil { - return nil, fmt.Errorf("Failed to post JWS message. -> %v", err) - } - - defer resp.Body.Close() - - if resp.StatusCode >= http.StatusBadRequest { - - err := handleHTTPError(resp) - - switch err.(type) { - - case NonceError: - - // Retry once if the nonce was invalidated - - retryResp, err := j.post(uri, jsonBytes) - if err != nil { - return nil, fmt.Errorf("Failed to post JWS message. -> %v", err) - } - - defer retryResp.Body.Close() - - if retryResp.StatusCode >= http.StatusBadRequest { - return retryResp.Header, handleHTTPError(retryResp) - } - - if respBody == nil { - return retryResp.Header, nil - } - - return retryResp.Header, json.NewDecoder(retryResp.Body).Decode(respBody) - - default: - return resp.Header, err - - } - - } - - if respBody == nil { - return resp.Header, nil - } - - return resp.Header, json.NewDecoder(resp.Body).Decode(respBody) -} - -// userAgent builds and returns the User-Agent string to use in requests. -func userAgent() string { - ua := fmt.Sprintf("%s (%s; %s) %s %s", defaultGoUserAgent, runtime.GOOS, runtime.GOARCH, ourUserAgent, UserAgent) - return strings.TrimSpace(ua) -} diff --git a/vendor/github.com/xenolf/lego/acme/http_challenge.go b/vendor/github.com/xenolf/lego/acme/http_challenge.go deleted file mode 100644 index 95cb1fd81..000000000 --- a/vendor/github.com/xenolf/lego/acme/http_challenge.go +++ /dev/null @@ -1,41 +0,0 @@ -package acme - -import ( - "fmt" - "log" -) - -type httpChallenge struct { - jws *jws - validate validateFunc - provider ChallengeProvider -} - -// HTTP01ChallengePath returns the URL path for the `http-01` challenge -func HTTP01ChallengePath(token string) string { - return "/.well-known/acme-challenge/" + token -} - -func (s *httpChallenge) Solve(chlng challenge, domain string) error { - - logf("[INFO][%s] acme: Trying to solve HTTP-01", domain) - - // Generate the Key Authorization for the challenge - keyAuth, err := getKeyAuthorization(chlng.Token, s.jws.privKey) - if err != nil { - return err - } - - err = s.provider.Present(domain, chlng.Token, keyAuth) - if err != nil { - return fmt.Errorf("[%s] error presenting token: %v", domain, err) - } - defer func() { - err := s.provider.CleanUp(domain, chlng.Token, keyAuth) - if err != nil { - log.Printf("[%s] error cleaning up: %v", domain, err) - } - }() - - return s.validate(s.jws, domain, chlng.URI, challenge{Resource: "challenge", Type: chlng.Type, Token: chlng.Token, KeyAuthorization: keyAuth}) -} diff --git a/vendor/github.com/xenolf/lego/acme/http_challenge_server.go b/vendor/github.com/xenolf/lego/acme/http_challenge_server.go deleted file mode 100644 index 64c6a8280..000000000 --- a/vendor/github.com/xenolf/lego/acme/http_challenge_server.go +++ /dev/null @@ -1,79 +0,0 @@ -package acme - -import ( - "fmt" - "net" - "net/http" - "strings" -) - -// HTTPProviderServer implements ChallengeProvider for `http-01` challenge -// It may be instantiated without using the NewHTTPProviderServer function if -// you want only to use the default values. -type HTTPProviderServer struct { - iface string - port string - done chan bool - listener net.Listener -} - -// NewHTTPProviderServer creates a new HTTPProviderServer on the selected interface and port. -// Setting iface and / or port to an empty string will make the server fall back to -// the "any" interface and port 80 respectively. -func NewHTTPProviderServer(iface, port string) *HTTPProviderServer { - return &HTTPProviderServer{iface: iface, port: port} -} - -// Present starts a web server and makes the token available at `HTTP01ChallengePath(token)` for web requests. -func (s *HTTPProviderServer) Present(domain, token, keyAuth string) error { - if s.port == "" { - s.port = "80" - } - - var err error - s.listener, err = net.Listen("tcp", net.JoinHostPort(s.iface, s.port)) - if err != nil { - return fmt.Errorf("Could not start HTTP server for challenge -> %v", err) - } - - s.done = make(chan bool) - go s.serve(domain, token, keyAuth) - return nil -} - -// CleanUp closes the HTTP server and removes the token from `HTTP01ChallengePath(token)` -func (s *HTTPProviderServer) CleanUp(domain, token, keyAuth string) error { - if s.listener == nil { - return nil - } - s.listener.Close() - <-s.done - return nil -} - -func (s *HTTPProviderServer) serve(domain, token, keyAuth string) { - path := HTTP01ChallengePath(token) - - // The handler validates the HOST header and request type. - // For validation it then writes the token the server returned with the challenge - mux := http.NewServeMux() - mux.HandleFunc(path, func(w http.ResponseWriter, r *http.Request) { - if strings.HasPrefix(r.Host, domain) && r.Method == "GET" { - w.Header().Add("Content-Type", "text/plain") - w.Write([]byte(keyAuth)) - logf("[INFO][%s] Served key authentication", domain) - } else { - logf("[WARN] Received request for domain %s with method %s but the domain did not match any challenge. Please ensure your are passing the HOST header properly.", r.Host, r.Method) - w.Write([]byte("TEST")) - } - }) - - httpServer := &http.Server{ - Handler: mux, - } - // Once httpServer is shut down we don't want any lingering - // connections, so disable KeepAlives. - httpServer.SetKeepAlivesEnabled(false) - httpServer.Serve(s.listener) - s.done <- true -} diff --git a/vendor/github.com/xenolf/lego/acme/jws.go b/vendor/github.com/xenolf/lego/acme/jws.go deleted file mode 100644 index a39434342..000000000 --- a/vendor/github.com/xenolf/lego/acme/jws.go +++ /dev/null @@ -1,131 +0,0 @@ -package acme - -import ( - "bytes" - "crypto" - "crypto/ecdsa" - "crypto/elliptic" - "crypto/rsa" - "fmt" - "net/http" - "sync" - - "gopkg.in/square/go-jose.v1" -) - -type jws struct { - directoryURL string - privKey crypto.PrivateKey - nonces nonceManager -} - -func keyAsJWK(key interface{}) *jose.JsonWebKey { - switch k := key.(type) { - case *ecdsa.PublicKey: - return &jose.JsonWebKey{Key: k, Algorithm: "EC"} - case *rsa.PublicKey: - return &jose.JsonWebKey{Key: k, Algorithm: "RSA"} - - default: - return nil - } -} - -// Posts a JWS signed message to the specified URL. -// It does NOT close the response body, so the caller must -// do that if no error was returned. -func (j *jws) post(url string, content []byte) (*http.Response, error) { - signedContent, err := j.signContent(content) - if err != nil { - return nil, fmt.Errorf("Failed to sign content -> %s", err.Error()) - } - - resp, err := httpPost(url, "application/jose+json", bytes.NewBuffer([]byte(signedContent.FullSerialize()))) - if err != nil { - return nil, fmt.Errorf("Failed to HTTP POST to %s -> %s", url, err.Error()) - } - - nonce, nonceErr := getNonceFromResponse(resp) - if nonceErr == nil { - j.nonces.Push(nonce) - } - - return resp, nil -} - -func (j *jws) signContent(content []byte) (*jose.JsonWebSignature, error) { - - var alg jose.SignatureAlgorithm - switch k := j.privKey.(type) { - case *rsa.PrivateKey: - alg = jose.RS256 - case *ecdsa.PrivateKey: - if k.Curve == elliptic.P256() { - alg = jose.ES256 - } else if k.Curve == elliptic.P384() { - alg = jose.ES384 - } - } - - signer, err := jose.NewSigner(alg, j.privKey) - if err != nil { - return nil, fmt.Errorf("Failed to create jose signer -> %s", err.Error()) - } - signer.SetNonceSource(j) - - signed, err := signer.Sign(content) - if err != nil { - return nil, fmt.Errorf("Failed to sign content -> %s", err.Error()) - } - return signed, nil -} - -func (j *jws) Nonce() (string, error) { - if nonce, ok := j.nonces.Pop(); ok { - return nonce, nil - } - - return getNonce(j.directoryURL) -} - -type nonceManager struct { - nonces []string - sync.Mutex -} - -func (n *nonceManager) Pop() (string, bool) { - n.Lock() - defer n.Unlock() - - if len(n.nonces) == 0 { - return "", false - } - - nonce := n.nonces[len(n.nonces)-1] - n.nonces = n.nonces[:len(n.nonces)-1] - return nonce, true -} - -func (n *nonceManager) Push(nonce string) { - n.Lock() - defer n.Unlock() - n.nonces = append(n.nonces, nonce) -} - -func getNonce(url string) (string, error) { - resp, err := httpHead(url) - if err != nil { - return "", fmt.Errorf("Failed to get nonce from HTTP HEAD -> %s", err.Error()) - } - - return getNonceFromResponse(resp) -} - -func getNonceFromResponse(resp *http.Response) (string, error) { - nonce := resp.Header.Get("Replay-Nonce") - if nonce == "" { - return "", fmt.Errorf("Server did not respond with a proper nonce header.") - } - - return nonce, nil -} diff --git a/vendor/github.com/xenolf/lego/acme/messages.go b/vendor/github.com/xenolf/lego/acme/messages.go deleted file mode 100644 index 79ccf154e..000000000 --- a/vendor/github.com/xenolf/lego/acme/messages.go +++ /dev/null @@ -1,115 +0,0 @@ -package acme - -import ( - "time" - - "gopkg.in/square/go-jose.v1" -) - -type directory struct { - NewAuthzURL string `json:"new-authz"` - NewCertURL string `json:"new-cert"` - NewRegURL string `json:"new-reg"` - RevokeCertURL string `json:"revoke-cert"` -} - -type registrationMessage struct { - Resource string `json:"resource"` - Contact []string `json:"contact"` - Delete bool `json:"delete,omitempty"` -} - -// Registration is returned by the ACME server after the registration -// The client implementation should save this registration somewhere. -type Registration struct { - Resource string `json:"resource,omitempty"` - ID int `json:"id"` - Key jose.JsonWebKey `json:"key"` - Contact []string `json:"contact"` - Agreement string `json:"agreement,omitempty"` - Authorizations string `json:"authorizations,omitempty"` - Certificates string `json:"certificates,omitempty"` -} - -// RegistrationResource represents all important informations about a registration -// of which the client needs to keep track itself. -type RegistrationResource struct { - Body Registration `json:"body,omitempty"` - URI string `json:"uri,omitempty"` - NewAuthzURL string `json:"new_authzr_uri,omitempty"` - TosURL string `json:"terms_of_service,omitempty"` -} - -type authorizationResource struct { - Body authorization - Domain string - NewCertURL string - AuthURL string -} - -type authorization struct { - Resource string `json:"resource,omitempty"` - Identifier identifier `json:"identifier"` - Status string `json:"status,omitempty"` - Expires time.Time `json:"expires,omitempty"` - Challenges []challenge `json:"challenges,omitempty"` - Combinations [][]int `json:"combinations,omitempty"` -} - -type identifier struct { - Type string `json:"type"` - Value string `json:"value"` -} - -type validationRecord struct { - URI string `json:"url,omitempty"` - Hostname string `json:"hostname,omitempty"` - Port string `json:"port,omitempty"` - ResolvedAddresses []string `json:"addressesResolved,omitempty"` - UsedAddress string `json:"addressUsed,omitempty"` -} - -type challenge struct { - Resource string `json:"resource,omitempty"` - Type Challenge `json:"type,omitempty"` - Status string `json:"status,omitempty"` - URI string `json:"uri,omitempty"` - Token string `json:"token,omitempty"` - KeyAuthorization string `json:"keyAuthorization,omitempty"` - TLS bool `json:"tls,omitempty"` - Iterations int `json:"n,omitempty"` - Error RemoteError `json:"error,omitempty"` - ValidationRecords []validationRecord `json:"validationRecord,omitempty"` -} - -type csrMessage struct { - Resource string `json:"resource,omitempty"` - Csr string `json:"csr"` - Authorizations []string `json:"authorizations"` -} - -type revokeCertMessage struct { - Resource string `json:"resource"` - Certificate string `json:"certificate"` -} - -type deactivateAuthMessage struct { - Resource string `json:"resource,omitempty"` - Status string `jsom:"status"` -} - -// CertificateResource represents a CA issued certificate. -// PrivateKey, Certificate and IssuerCertificate are all -// already PEM encoded and can be directly written to disk. -// Certificate may be a certificate bundle, depending on the -// options supplied to create it. -type CertificateResource struct { - Domain string `json:"domain"` - CertURL string `json:"certUrl"` - CertStableURL string `json:"certStableUrl"` - AccountRef string `json:"accountRef,omitempty"` - PrivateKey []byte `json:"-"` - Certificate []byte `json:"-"` - IssuerCertificate []byte `json:"-"` - CSR []byte `json:"-"` -} diff --git a/vendor/github.com/xenolf/lego/acme/pop_challenge.go b/vendor/github.com/xenolf/lego/acme/pop_challenge.go deleted file mode 100644 index 8d2a213b0..000000000 --- a/vendor/github.com/xenolf/lego/acme/pop_challenge.go +++ /dev/null @@ -1 +0,0 @@ -package acme diff --git a/vendor/github.com/xenolf/lego/acme/provider.go b/vendor/github.com/xenolf/lego/acme/provider.go deleted file mode 100644 index d177ff07a..000000000 --- a/vendor/github.com/xenolf/lego/acme/provider.go +++ /dev/null @@ -1,28 +0,0 @@ -package acme - -import "time" - -// ChallengeProvider enables implementing a custom challenge -// provider. Present presents the solution to a challenge available to -// be solved. CleanUp will be called by the challenge if Present ends -// in a non-error state. -type ChallengeProvider interface { - Present(domain, token, keyAuth string) error - CleanUp(domain, token, keyAuth string) error -} - -// ChallengeProviderTimeout allows for implementing a -// ChallengeProvider where an unusually long timeout is required when -// waiting for an ACME challenge to be satisfied, such as when -// checking for DNS record progagation. If an implementor of a -// ChallengeProvider provides a Timeout method, then the return values -// of the Timeout method will be used when appropriate by the acme -// package. The interval value is the time between checks. -// -// The default values used for timeout and interval are 60 seconds and -// 2 seconds respectively. These are used when no Timeout method is -// defined for the ChallengeProvider. -type ChallengeProviderTimeout interface { - ChallengeProvider - Timeout() (timeout, interval time.Duration) -} diff --git a/vendor/github.com/xenolf/lego/acme/tls_sni_challenge.go b/vendor/github.com/xenolf/lego/acme/tls_sni_challenge.go deleted file mode 100644 index 34383cbfa..000000000 --- a/vendor/github.com/xenolf/lego/acme/tls_sni_challenge.go +++ /dev/null @@ -1,67 +0,0 @@ -package acme - -import ( - "crypto/rsa" - "crypto/sha256" - "crypto/tls" - "encoding/hex" - "fmt" - "log" -) - -type tlsSNIChallenge struct { - jws *jws - validate validateFunc - provider ChallengeProvider -} - -func (t *tlsSNIChallenge) Solve(chlng challenge, domain string) error { - // FIXME: https://github.com/ietf-wg-acme/acme/pull/22 - // Currently we implement this challenge to track boulder, not the current spec! - - logf("[INFO][%s] acme: Trying to solve TLS-SNI-01", domain) - - // Generate the Key Authorization for the challenge - keyAuth, err := getKeyAuthorization(chlng.Token, t.jws.privKey) - if err != nil { - return err - } - - err = t.provider.Present(domain, chlng.Token, keyAuth) - if err != nil { - return fmt.Errorf("[%s] error presenting token: %v", domain, err) - } - defer func() { - err := t.provider.CleanUp(domain, chlng.Token, keyAuth) - if err != nil { - log.Printf("[%s] error cleaning up: %v", domain, err) - } - }() - return t.validate(t.jws, domain, chlng.URI, challenge{Resource: "challenge", Type: chlng.Type, Token: chlng.Token, KeyAuthorization: keyAuth}) -} - -// TLSSNI01ChallengeCert returns a certificate and target domain for the `tls-sni-01` challenge -func TLSSNI01ChallengeCert(keyAuth string) (tls.Certificate, string, error) { - // generate a new RSA key for the certificates - tempPrivKey, err := generatePrivateKey(RSA2048) - if err != nil { - return tls.Certificate{}, "", err - } - rsaPrivKey := tempPrivKey.(*rsa.PrivateKey) - rsaPrivPEM := pemEncode(rsaPrivKey) - - zBytes := sha256.Sum256([]byte(keyAuth)) - z := hex.EncodeToString(zBytes[:sha256.Size]) - domain := fmt.Sprintf("%s.%s.acme.invalid", z[:32], z[32:]) - tempCertPEM, err := generatePemCert(rsaPrivKey, domain) - if err != nil { - return tls.Certificate{}, "", err - } - - certificate, err := tls.X509KeyPair(tempCertPEM, rsaPrivPEM) - if err != nil { - return tls.Certificate{}, "", err - } - - return certificate, domain, nil -} diff --git a/vendor/github.com/xenolf/lego/acme/tls_sni_challenge_server.go b/vendor/github.com/xenolf/lego/acme/tls_sni_challenge_server.go deleted file mode 100644 index df00fbb5a..000000000 --- a/vendor/github.com/xenolf/lego/acme/tls_sni_challenge_server.go +++ /dev/null @@ -1,62 +0,0 @@ -package acme - -import ( - "crypto/tls" - "fmt" - "net" - "net/http" -) - -// TLSProviderServer implements ChallengeProvider for `TLS-SNI-01` challenge -// It may be instantiated without using the NewTLSProviderServer function if -// you want only to use the default values. -type TLSProviderServer struct { - iface string - port string - done chan bool - listener net.Listener -} - -// NewTLSProviderServer creates a new TLSProviderServer on the selected interface and port. -// Setting iface and / or port to an empty string will make the server fall back to -// the "any" interface and port 443 respectively. -func NewTLSProviderServer(iface, port string) *TLSProviderServer { - return &TLSProviderServer{iface: iface, port: port} -} - -// Present makes the keyAuth available as a cert -func (s *TLSProviderServer) Present(domain, token, keyAuth string) error { - if s.port == "" { - s.port = "443" - } - - cert, _, err := TLSSNI01ChallengeCert(keyAuth) - if err != nil { - return err - } - - tlsConf := new(tls.Config) - tlsConf.Certificates = []tls.Certificate{cert} - - s.listener, err = tls.Listen("tcp", net.JoinHostPort(s.iface, s.port), tlsConf) - if err != nil { - return fmt.Errorf("Could not start HTTPS server for challenge -> %v", err) - } - - s.done = make(chan bool) - go func() { - http.Serve(s.listener, nil) - s.done <- true - }() - return nil -} - -// CleanUp closes the HTTP server. -func (s *TLSProviderServer) CleanUp(domain, token, keyAuth string) error { - if s.listener == nil { - return nil - } - s.listener.Close() - <-s.done - return nil -} diff --git a/vendor/github.com/xenolf/lego/acme/utils.go b/vendor/github.com/xenolf/lego/acme/utils.go deleted file mode 100644 index 2fa0db304..000000000 --- a/vendor/github.com/xenolf/lego/acme/utils.go +++ /dev/null @@ -1,29 +0,0 @@ -package acme - -import ( - "fmt" - "time" -) - -// WaitFor polls the given function 'f', once every 'interval', up to 'timeout'. -func WaitFor(timeout, interval time.Duration, f func() (bool, error)) error { - var lastErr string - timeup := time.After(timeout) - for { - select { - case <-timeup: - return fmt.Errorf("Time limit exceeded. Last error: %s", lastErr) - default: - } - - stop, err := f() - if stop { - return nil - } - if err != nil { - lastErr = err.Error() - } - - time.Sleep(interval) - } -} diff --git a/vendor/github.com/xenolf/lego/acmev2/challenges.go b/vendor/github.com/xenolf/lego/acmev2/challenges.go index cf7bd7f75..8fcc5bf87 100644 --- a/vendor/github.com/xenolf/lego/acmev2/challenges.go +++ b/vendor/github.com/xenolf/lego/acmev2/challenges.go @@ -1,13 +1,13 @@ -package acme +package acmev2 // Challenge is a string that identifies a particular type and version of ACME challenge. type Challenge string const ( - // HTTP01 is the "http-01" ACME challenge https://github.com/ietf-wg-acme/acme/blob/master/draft-ietf-acme-acme.md#http + // HTTP01 is the "http-01" ACME challenge https://github.com/ietf-wg-acme/acme/blob/master/draft-ietf-acme-acmev2.md#http // Note: HTTP01ChallengePath returns the URL path to fulfill this challenge HTTP01 = Challenge("http-01") - // DNS01 is the "dns-01" ACME challenge https://github.com/ietf-wg-acme/acme/blob/master/draft-ietf-acme-acme.md#dns + // DNS01 is the "dns-01" ACME challenge https://github.com/ietf-wg-acme/acme/blob/master/draft-ietf-acme-acmev2.md#dns // Note: DNS01Record returns a DNS record which will fulfill this challenge DNS01 = Challenge("dns-01") ) diff --git a/vendor/github.com/xenolf/lego/acmev2/client.go b/vendor/github.com/xenolf/lego/acmev2/client.go index 40acdbc14..86e371adc 100644 --- a/vendor/github.com/xenolf/lego/acmev2/client.go +++ b/vendor/github.com/xenolf/lego/acmev2/client.go @@ -1,5 +1,5 @@ -// Package acme implements the ACME protocol for Let's Encrypt and other conforming providers. -package acme +// package acmev2 implements the ACME protocol for Let's Encrypt and other conforming providers. +package acmev2 import ( "crypto" diff --git a/vendor/github.com/xenolf/lego/acmev2/crypto.go b/vendor/github.com/xenolf/lego/acmev2/crypto.go index e50ca30d8..8f299a65b 100644 --- a/vendor/github.com/xenolf/lego/acmev2/crypto.go +++ b/vendor/github.com/xenolf/lego/acmev2/crypto.go @@ -1,4 +1,4 @@ -package acme +package acmev2 import ( "bytes" diff --git a/vendor/github.com/xenolf/lego/acmev2/dns_challenge.go b/vendor/github.com/xenolf/lego/acmev2/dns_challenge.go index d129dacc6..d57a4bd63 100644 --- a/vendor/github.com/xenolf/lego/acmev2/dns_challenge.go +++ b/vendor/github.com/xenolf/lego/acmev2/dns_challenge.go @@ -1,4 +1,4 @@ -package acme +package acmev2 import ( "crypto/sha256" diff --git a/vendor/github.com/xenolf/lego/acmev2/dns_challenge_manual.go b/vendor/github.com/xenolf/lego/acmev2/dns_challenge_manual.go index 240384e60..85dd9ca88 100644 --- a/vendor/github.com/xenolf/lego/acmev2/dns_challenge_manual.go +++ b/vendor/github.com/xenolf/lego/acmev2/dns_challenge_manual.go @@ -1,4 +1,4 @@ -package acme +package acmev2 import ( "bufio" diff --git a/vendor/github.com/xenolf/lego/acmev2/error.go b/vendor/github.com/xenolf/lego/acmev2/error.go index 650270b1e..15cbc02bb 100644 --- a/vendor/github.com/xenolf/lego/acmev2/error.go +++ b/vendor/github.com/xenolf/lego/acmev2/error.go @@ -1,4 +1,4 @@ -package acme +package acmev2 import ( "encoding/json" diff --git a/vendor/github.com/xenolf/lego/acmev2/http.go b/vendor/github.com/xenolf/lego/acmev2/http.go index b93e53445..bc51a36db 100644 --- a/vendor/github.com/xenolf/lego/acmev2/http.go +++ b/vendor/github.com/xenolf/lego/acmev2/http.go @@ -1,4 +1,4 @@ -package acme +package acmev2 import ( "encoding/json" diff --git a/vendor/github.com/xenolf/lego/acmev2/http_challenge.go b/vendor/github.com/xenolf/lego/acmev2/http_challenge.go index b6c969fe2..687297b94 100644 --- a/vendor/github.com/xenolf/lego/acmev2/http_challenge.go +++ b/vendor/github.com/xenolf/lego/acmev2/http_challenge.go @@ -1,4 +1,4 @@ -package acme +package acmev2 import ( "fmt" diff --git a/vendor/github.com/xenolf/lego/acmev2/http_challenge_server.go b/vendor/github.com/xenolf/lego/acmev2/http_challenge_server.go index 64c6a8280..052d24050 100644 --- a/vendor/github.com/xenolf/lego/acmev2/http_challenge_server.go +++ b/vendor/github.com/xenolf/lego/acmev2/http_challenge_server.go @@ -1,4 +1,4 @@ -package acme +package acmev2 import ( "fmt" diff --git a/vendor/github.com/xenolf/lego/acmev2/jws.go b/vendor/github.com/xenolf/lego/acmev2/jws.go index 9b87e437a..7ab8edb76 100644 --- a/vendor/github.com/xenolf/lego/acmev2/jws.go +++ b/vendor/github.com/xenolf/lego/acmev2/jws.go @@ -1,4 +1,4 @@ -package acme +package acmev2 import ( "bytes" diff --git a/vendor/github.com/xenolf/lego/acmev2/messages.go b/vendor/github.com/xenolf/lego/acmev2/messages.go index 9981851d9..9fc450e06 100644 --- a/vendor/github.com/xenolf/lego/acmev2/messages.go +++ b/vendor/github.com/xenolf/lego/acmev2/messages.go @@ -1,4 +1,4 @@ -package acme +package acmev2 import ( "time" diff --git a/vendor/github.com/xenolf/lego/acmev2/pop_challenge.go b/vendor/github.com/xenolf/lego/acmev2/pop_challenge.go index 8d2a213b0..f8f4e4e7c 100644 --- a/vendor/github.com/xenolf/lego/acmev2/pop_challenge.go +++ b/vendor/github.com/xenolf/lego/acmev2/pop_challenge.go @@ -1 +1 @@ -package acme +package acmev2 diff --git a/vendor/github.com/xenolf/lego/acmev2/provider.go b/vendor/github.com/xenolf/lego/acmev2/provider.go index d177ff07a..70fb525ab 100644 --- a/vendor/github.com/xenolf/lego/acmev2/provider.go +++ b/vendor/github.com/xenolf/lego/acmev2/provider.go @@ -1,4 +1,4 @@ -package acme +package acmev2 import "time" diff --git a/vendor/github.com/xenolf/lego/acmev2/utils.go b/vendor/github.com/xenolf/lego/acmev2/utils.go index 2fa0db304..86df09124 100644 --- a/vendor/github.com/xenolf/lego/acmev2/utils.go +++ b/vendor/github.com/xenolf/lego/acmev2/utils.go @@ -1,4 +1,4 @@ -package acme +package acmev2 import ( "fmt" diff --git a/vendor/github.com/xenolf/lego/providers/dns/auroradns/auroradns.go b/vendor/github.com/xenolf/lego/providers/dns/auroradns/auroradns.go index 55b48f9b4..4acf0b386 100644 --- a/vendor/github.com/xenolf/lego/providers/dns/auroradns/auroradns.go +++ b/vendor/github.com/xenolf/lego/providers/dns/auroradns/auroradns.go @@ -2,12 +2,13 @@ package auroradns import ( "fmt" + "os" + "sync" + "github.com/edeckers/auroradnsclient" "github.com/edeckers/auroradnsclient/records" "github.com/edeckers/auroradnsclient/zones" - "github.com/xenolf/lego/acme" - "os" - "sync" + "github.com/xenolf/lego/acmev2" ) // DNSProvider describes a provider for AuroraDNS @@ -64,9 +65,9 @@ func (provider *DNSProvider) getZoneInformationByName(name string) (zones.ZoneRe // Present creates a record with a secret func (provider *DNSProvider) Present(domain, token, keyAuth string) error { - fqdn, value, _ := acme.DNS01Record(domain, keyAuth) + fqdn, value, _ := acmev2.DNS01Record(domain, keyAuth) - authZone, err := acme.FindZoneByFqdn(acme.ToFqdn(domain), acme.RecursiveNameservers) + authZone, err := acmev2.FindZoneByFqdn(acmev2.ToFqdn(domain), acmev2.RecursiveNameservers) if err != nil { return fmt.Errorf("Could not determine zone for domain: '%s'. %s", domain, err) } @@ -80,7 +81,7 @@ func (provider *DNSProvider) Present(domain, token, keyAuth string) error { subdomain := fqdn[0 : len(fqdn)-len(authZone)-1] - authZone = acme.UnFqdn(authZone) + authZone = acmev2.UnFqdn(authZone) zoneRecord, err := provider.getZoneInformationByName(authZone) @@ -106,7 +107,7 @@ func (provider *DNSProvider) Present(domain, token, keyAuth string) error { // CleanUp removes a given record that was generated by Present func (provider *DNSProvider) CleanUp(domain, token, keyAuth string) error { - fqdn, _, _ := acme.DNS01Record(domain, keyAuth) + fqdn, _, _ := acmev2.DNS01Record(domain, keyAuth) provider.recordIDsMu.Lock() recordID, ok := provider.recordIDs[fqdn] @@ -116,12 +117,12 @@ func (provider *DNSProvider) CleanUp(domain, token, keyAuth string) error { return fmt.Errorf("Unknown recordID for '%s'", fqdn) } - authZone, err := acme.FindZoneByFqdn(acme.ToFqdn(domain), acme.RecursiveNameservers) + authZone, err := acmev2.FindZoneByFqdn(acmev2.ToFqdn(domain), acmev2.RecursiveNameservers) if err != nil { return fmt.Errorf("Could not determine zone for domain: '%s'. %s", domain, err) } - authZone = acme.UnFqdn(authZone) + authZone = acmev2.UnFqdn(authZone) zoneRecord, err := provider.getZoneInformationByName(authZone) if err != nil { diff --git a/vendor/github.com/xenolf/lego/providers/dns/azure/azure.go b/vendor/github.com/xenolf/lego/providers/dns/azure/azure.go index 6a30b318a..994af9660 100644 --- a/vendor/github.com/xenolf/lego/providers/dns/azure/azure.go +++ b/vendor/github.com/xenolf/lego/providers/dns/azure/azure.go @@ -16,10 +16,10 @@ import ( "github.com/Azure/go-autorest/autorest/adal" "github.com/Azure/go-autorest/autorest/azure" "github.com/Azure/go-autorest/autorest/to" - "github.com/xenolf/lego/acme" + "github.com/xenolf/lego/acmev2" ) -// DNSProvider is an implementation of the acme.ChallengeProvider interface +// DNSProvider is an implementation of the acmev2.ChallengeProvider interface type DNSProvider struct { clientId string clientSecret string @@ -64,7 +64,7 @@ func (c *DNSProvider) Timeout() (timeout, interval time.Duration) { // Present creates a TXT record to fulfil the dns-01 challenge func (c *DNSProvider) Present(domain, token, keyAuth string) error { - fqdn, value, _ := acme.DNS01Record(domain, keyAuth) + fqdn, value, _ := acmev2.DNS01Record(domain, keyAuth) zone, err := c.getHostedZoneID(fqdn) if err != nil { return err @@ -74,7 +74,7 @@ func (c *DNSProvider) Present(domain, token, keyAuth string) error { spt, err := c.newServicePrincipalTokenFromCredentials(azure.PublicCloud.ResourceManagerEndpoint) rsc.Authorizer = autorest.NewBearerAuthorizer(spt) - relative := toRelativeRecord(fqdn, acme.ToFqdn(zone)) + relative := toRelativeRecord(fqdn, acmev2.ToFqdn(zone)) rec := dns.RecordSet{ Name: &relative, RecordSetProperties: &dns.RecordSetProperties{ @@ -93,19 +93,19 @@ func (c *DNSProvider) Present(domain, token, keyAuth string) error { // Returns the relative record to the domain func toRelativeRecord(domain, zone string) string { - return acme.UnFqdn(strings.TrimSuffix(domain, zone)) + return acmev2.UnFqdn(strings.TrimSuffix(domain, zone)) } // CleanUp removes the TXT record matching the specified parameters func (c *DNSProvider) CleanUp(domain, token, keyAuth string) error { - fqdn, _, _ := acme.DNS01Record(domain, keyAuth) + fqdn, _, _ := acmev2.DNS01Record(domain, keyAuth) zone, err := c.getHostedZoneID(fqdn) if err != nil { return err } - relative := toRelativeRecord(fqdn, acme.ToFqdn(zone)) + relative := toRelativeRecord(fqdn, acmev2.ToFqdn(zone)) rsc := dns.NewRecordSetsClient(c.subscriptionId) spt, err := c.newServicePrincipalTokenFromCredentials(azure.PublicCloud.ResourceManagerEndpoint) rsc.Authorizer = autorest.NewBearerAuthorizer(spt) @@ -119,7 +119,7 @@ func (c *DNSProvider) CleanUp(domain, token, keyAuth string) error { // Checks that azure has a zone for this domain name. func (c *DNSProvider) getHostedZoneID(fqdn string) (string, error) { - authZone, err := acme.FindZoneByFqdn(fqdn, acme.RecursiveNameservers) + authZone, err := acmev2.FindZoneByFqdn(fqdn, acmev2.RecursiveNameservers) if err != nil { return "", err } @@ -130,7 +130,7 @@ func (c *DNSProvider) getHostedZoneID(fqdn string) (string, error) { dc := dns.NewZonesClient(c.subscriptionId) dc.Authorizer = autorest.NewBearerAuthorizer(spt) - zone, err := dc.Get(c.resourceGroup, acme.UnFqdn(authZone)) + zone, err := dc.Get(c.resourceGroup, acmev2.UnFqdn(authZone)) if err != nil { return "", err diff --git a/vendor/github.com/xenolf/lego/providers/dns/bluecat/bluecat.go b/vendor/github.com/xenolf/lego/providers/dns/bluecat/bluecat.go new file mode 100644 index 000000000..2bb02230e --- /dev/null +++ b/vendor/github.com/xenolf/lego/providers/dns/bluecat/bluecat.go @@ -0,0 +1,419 @@ +// Package bluecat implements a DNS provider for solving the DNS-01 challenge +// using a self-hosted Bluecat Address Manager. +package bluecat + +import ( + "bytes" + "encoding/json" + "fmt" + "net/http" + "os" + "regexp" + "strconv" + "strings" + "time" + + "io/ioutil" + + "github.com/xenolf/lego/acmev2" +) + +const bluecatUrlTemplate = "%s/Services/REST/v1" +const configType = "Configuration" +const viewType = "View" +const txtType = "TXTRecord" +const zoneType = "Zone" + +type entityResponse struct { + Id uint `json:"id"` + Name string `json:"name"` + Type string `json:"type"` + Properties string `json:"properties"` +} + +// DNSProvider is an implementation of the acmev2.ChallengeProvider interface that uses +// Bluecat's Address Manager REST API to manage TXT records for a domain. +type DNSProvider struct { + baseUrl string + userName string + password string + configName string + dnsView string + token string + httpClient *http.Client +} + +// NewDNSProvider returns a DNSProvider instance configured for Bluecat DNS. +// Credentials must be passed in the environment variables: BLUECAT_SERVER_URL, +// BLUECAT_USER_NAME and BLUECAT_PASSWORD. BLUECAT_SERVER_URL should have the +// scheme, hostname, and port (if required) of the authoritative Bluecat BAM +// server. The REST endpoint will be appended. In addition, the Configuration name +// and external DNS View Name must be passed in BLUECAT_CONFIG_NAME and +// BLUECAT_DNS_VIEW +func NewDNSProvider() (*DNSProvider, error) { + server := os.Getenv("BLUECAT_SERVER_URL") + userName := os.Getenv("BLUECAT_USER_NAME") + password := os.Getenv("BLUECAT_PASSWORD") + configName := os.Getenv("BLUECAT_CONFIG_NAME") + dnsView := os.Getenv("BLUECAT_DNS_VIEW") + httpClient := http.Client{Timeout: time.Duration(30 * time.Second)} + return NewDNSProviderCredentials(server, userName, password, configName, dnsView, httpClient) +} + +// NewDNSProviderCredentials uses the supplied credentials to return a +// DNSProvider instance configured for Bluecat DNS. +func NewDNSProviderCredentials(server, userName, password, configName, dnsView string, httpClient http.Client) (*DNSProvider, error) { + if server == "" || userName == "" || password == "" || configName == "" || dnsView == "" { + return nil, fmt.Errorf("Bluecat credentials missing") + } + + return &DNSProvider{ + baseUrl: fmt.Sprintf(bluecatUrlTemplate, server), + userName: userName, + password: password, + configName: configName, + dnsView: dnsView, + httpClient: http.DefaultClient, + }, nil +} + +// Send a REST request, using query parameters specified. The Authorization +// header will be set if we have an active auth token +func (d *DNSProvider) sendRequest(method, resource string, payload interface{}, queryArgs map[string]string) (*http.Response, error) { + url := fmt.Sprintf("%s/%s", d.baseUrl, resource) + + body, err := json.Marshal(payload) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(method, url, bytes.NewReader(body)) + if err != nil { + return nil, err + } + req.Header.Set("Content-Type", "application/json") + if len(d.token) > 0 { + req.Header.Set("Authorization", d.token) + } + + // Add all query parameters + q := req.URL.Query() + for argName, argVal := range queryArgs { + q.Add(argName, argVal) + } + req.URL.RawQuery = q.Encode() + resp, err := d.httpClient.Do(req) + if err != nil { + return nil, err + } + + if resp.StatusCode >= 400 { + errBytes, _ := ioutil.ReadAll(resp.Body) + errResp := string(errBytes) + return nil, fmt.Errorf("Bluecat API request failed with HTTP status code %d\n Full message: %s", + resp.StatusCode, errResp) + } + + return resp, nil +} + +// Starts a new Bluecat API Session. Authenticates using customerName, userName, +// password and receives a token to be used in for subsequent requests. +func (d *DNSProvider) login() error { + queryArgs := map[string]string{ + "username": d.userName, + "password": d.password, + } + + resp, err := d.sendRequest("GET", "login", nil, queryArgs) + if err != nil { + return err + } + defer resp.Body.Close() + + authBytes, _ := ioutil.ReadAll(resp.Body) + authResp := string(authBytes) + + if strings.Contains(authResp, "Authentication Error") { + msg := strings.Trim(authResp, "\"") + return fmt.Errorf("Bluecat API request failed: %s", msg) + } + // Upon success, API responds with "Session Token-> BAMAuthToken: dQfuRMTUxNjc3MjcyNDg1ODppcGFybXM= <- for User : username" + re := regexp.MustCompile("BAMAuthToken: [^ ]+") + token := re.FindString(authResp) + d.token = token + return nil +} + +// Destroys Bluecat Session +func (d *DNSProvider) logout() error { + if len(d.token) == 0 { + // nothing to do + return nil + } + + resp, err := d.sendRequest("GET", "logout", nil, nil) + if err != nil { + return err + } + defer resp.Body.Close() + + if resp.StatusCode != 200 { + return fmt.Errorf("Bluecat API request failed to delete session with HTTP status code %d", resp.StatusCode) + } else { + authBytes, _ := ioutil.ReadAll(resp.Body) + authResp := string(authBytes) + + if !strings.Contains(authResp, "successfully") { + msg := strings.Trim(authResp, "\"") + return fmt.Errorf("Bluecat API request failed to delete session: %s", msg) + } + } + + d.token = "" + + return nil +} + +// Lookup the entity ID of the configuration named in our properties +func (d *DNSProvider) lookupConfId() (uint, error) { + queryArgs := map[string]string{ + "parentId": strconv.Itoa(0), + "name": d.configName, + "type": configType, + } + + resp, err := d.sendRequest("GET", "getEntityByName", nil, queryArgs) + if err != nil { + return 0, err + } + defer resp.Body.Close() + + var conf entityResponse + err = json.NewDecoder(resp.Body).Decode(&conf) + if err != nil { + return 0, err + } + return conf.Id, nil +} + +// Find the DNS view with the given name within +func (d *DNSProvider) lookupViewId(viewName string) (uint, error) { + confId, err := d.lookupConfId() + if err != nil { + return 0, err + } + + queryArgs := map[string]string{ + "parentId": strconv.FormatUint(uint64(confId), 10), + "name": d.dnsView, + "type": viewType, + } + + resp, err := d.sendRequest("GET", "getEntityByName", nil, queryArgs) + if err != nil { + return 0, err + } + defer resp.Body.Close() + + var view entityResponse + err = json.NewDecoder(resp.Body).Decode(&view) + if err != nil { + return 0, err + } + + return view.Id, nil +} + +// Return the entityId of the parent zone by recursing from the root view +// Also return the simple name of the host +func (d *DNSProvider) lookupParentZoneId(viewId uint, fqdn string) (uint, string, error) { + parentViewId := viewId + name := "" + + if fqdn != "" { + zones := strings.Split(strings.Trim(fqdn, "."), ".") + last := len(zones) - 1 + name = zones[0] + + for i := last; i > -1; i-- { + zoneId, err := d.getZone(parentViewId, zones[i]) + if err != nil || zoneId == 0 { + return parentViewId, name, err + } + if i > 0 { + name = strings.Join(zones[0:i], ".") + } + parentViewId = zoneId + } + } + + return parentViewId, name, nil +} + +// Get the DNS zone with the specified name under the parentId +func (d *DNSProvider) getZone(parentId uint, name string) (uint, error) { + + queryArgs := map[string]string{ + "parentId": strconv.FormatUint(uint64(parentId), 10), + "name": name, + "type": zoneType, + } + + resp, err := d.sendRequest("GET", "getEntityByName", nil, queryArgs) + // Return an empty zone if the named zone doesn't exist + if resp != nil && resp.StatusCode == 404 { + return 0, fmt.Errorf("Bluecat API could not find zone named %s", name) + } + if err != nil { + return 0, err + } + defer resp.Body.Close() + + var zone entityResponse + err = json.NewDecoder(resp.Body).Decode(&zone) + if err != nil { + return 0, err + } + + return zone.Id, nil +} + +// Present creates a TXT record using the specified parameters +// This will *not* create a subzone to contain the TXT record, +// so make sure the FQDN specified is within an extant zone. +func (d *DNSProvider) Present(domain, token, keyAuth string) error { + fqdn, value, ttl := acmev2.DNS01Record(domain, keyAuth) + + err := d.login() + if err != nil { + return err + } + + viewId, err := d.lookupViewId(d.dnsView) + if err != nil { + return err + } + + parentZoneId, name, err := d.lookupParentZoneId(viewId, fqdn) + + queryArgs := map[string]string{ + "parentId": strconv.FormatUint(uint64(parentZoneId), 10), + } + + body := bluecatEntity{ + Name: name, + Type: "TXTRecord", + Properties: fmt.Sprintf("ttl=%d|absoluteName=%s|txt=%s|", ttl, fqdn, value), + } + + resp, err := d.sendRequest("POST", "addEntity", body, queryArgs) + + if err != nil { + return err + } + defer resp.Body.Close() + + addTxtBytes, _ := ioutil.ReadAll(resp.Body) + addTxtResp := string(addTxtBytes) + // addEntity responds only with body text containing the ID of the created record + _, err = strconv.ParseUint(addTxtResp, 10, 64) + if err != nil { + return fmt.Errorf("Bluecat API addEntity request failed: %s", addTxtResp) + } + + err = d.deploy(uint(parentZoneId)) + if err != nil { + return err + } + + err = d.logout() + if err != nil { + return err + } + + return nil +} + +// Deploy the DNS config for the specified entity to the authoritative servers +func (d *DNSProvider) deploy(entityId uint) error { + queryArgs := map[string]string{ + "entityId": strconv.FormatUint(uint64(entityId), 10), + } + + resp, err := d.sendRequest("POST", "quickDeploy", nil, queryArgs) + + if err != nil { + return err + } + defer resp.Body.Close() + + return nil +} + +// CleanUp removes the TXT record matching the specified parameters +func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { + fqdn, _, _ := acmev2.DNS01Record(domain, keyAuth) + + err := d.login() + if err != nil { + return err + } + + viewId, err := d.lookupViewId(d.dnsView) + if err != nil { + return err + } + + parentId, name, err := d.lookupParentZoneId(viewId, fqdn) + if err != nil { + return err + } + + queryArgs := map[string]string{ + "parentId": strconv.FormatUint(uint64(parentId), 10), + "name": name, + "type": txtType, + } + + resp, err := d.sendRequest("GET", "getEntityByName", nil, queryArgs) + if err != nil { + return err + } + defer resp.Body.Close() + + var txtRec entityResponse + err = json.NewDecoder(resp.Body).Decode(&txtRec) + if err != nil { + return err + } + queryArgs = map[string]string{ + "objectId": strconv.FormatUint(uint64(txtRec.Id), 10), + } + + resp, err = d.sendRequest("DELETE", "delete", nil, queryArgs) + if err != nil { + return err + } + defer resp.Body.Close() + + err = d.deploy(parentId) + if err != nil { + return err + } + + err = d.logout() + if err != nil { + return err + } + + return nil +} + +//JSON body for Bluecat entity requests and responses +type bluecatEntity struct { + ID string `json:"id,omitempty"` + Name string `json:"name"` + Type string `json:"type"` + Properties string `json:"properties"` +} diff --git a/vendor/github.com/xenolf/lego/providers/dns/cloudflare/cloudflare.go b/vendor/github.com/xenolf/lego/providers/dns/cloudflare/cloudflare.go index 84952238d..ccea830ad 100644 --- a/vendor/github.com/xenolf/lego/providers/dns/cloudflare/cloudflare.go +++ b/vendor/github.com/xenolf/lego/providers/dns/cloudflare/cloudflare.go @@ -11,14 +11,14 @@ import ( "os" "time" - "github.com/xenolf/lego/acme" + "github.com/xenolf/lego/acmev2" ) // CloudFlareAPIURL represents the API endpoint to call. // TODO: Unexport? const CloudFlareAPIURL = "https://api.cloudflare.com/client/v4" -// DNSProvider is an implementation of the acme.ChallengeProvider interface +// DNSProvider is an implementation of the acmev2.ChallengeProvider interface type DNSProvider struct { authEmail string authKey string @@ -54,7 +54,7 @@ func (c *DNSProvider) Timeout() (timeout, interval time.Duration) { // Present creates a TXT record to fulfil the dns-01 challenge func (c *DNSProvider) Present(domain, token, keyAuth string) error { - fqdn, value, _ := acme.DNS01Record(domain, keyAuth) + fqdn, value, _ := acmev2.DNS01Record(domain, keyAuth) zoneID, err := c.getHostedZoneID(fqdn) if err != nil { return err @@ -62,7 +62,7 @@ func (c *DNSProvider) Present(domain, token, keyAuth string) error { rec := cloudFlareRecord{ Type: "TXT", - Name: acme.UnFqdn(fqdn), + Name: acmev2.UnFqdn(fqdn), Content: value, TTL: 120, } @@ -82,7 +82,7 @@ func (c *DNSProvider) Present(domain, token, keyAuth string) error { // CleanUp removes the TXT record matching the specified parameters func (c *DNSProvider) CleanUp(domain, token, keyAuth string) error { - fqdn, _, _ := acme.DNS01Record(domain, keyAuth) + fqdn, _, _ := acmev2.DNS01Record(domain, keyAuth) record, err := c.findTxtRecord(fqdn) if err != nil { @@ -104,12 +104,12 @@ func (c *DNSProvider) getHostedZoneID(fqdn string) (string, error) { Name string `json:"name"` } - authZone, err := acme.FindZoneByFqdn(fqdn, acme.RecursiveNameservers) + authZone, err := acmev2.FindZoneByFqdn(fqdn, acmev2.RecursiveNameservers) if err != nil { return "", err } - result, err := c.makeRequest("GET", "/zones?name="+acme.UnFqdn(authZone), nil) + result, err := c.makeRequest("GET", "/zones?name="+acmev2.UnFqdn(authZone), nil) if err != nil { return "", err } @@ -135,7 +135,7 @@ func (c *DNSProvider) findTxtRecord(fqdn string) (*cloudFlareRecord, error) { result, err := c.makeRequest( "GET", - fmt.Sprintf("/zones/%s/dns_records?per_page=1000&type=TXT&name=%s", zoneID, acme.UnFqdn(fqdn)), + fmt.Sprintf("/zones/%s/dns_records?per_page=1000&type=TXT&name=%s", zoneID, acmev2.UnFqdn(fqdn)), nil, ) if err != nil { @@ -149,7 +149,7 @@ func (c *DNSProvider) findTxtRecord(fqdn string) (*cloudFlareRecord, error) { } for _, rec := range records { - if rec.Name == acme.UnFqdn(fqdn) { + if rec.Name == acmev2.UnFqdn(fqdn) { return &rec, nil } } diff --git a/vendor/github.com/xenolf/lego/providers/dns/cloudxns/cloudxns.go b/vendor/github.com/xenolf/lego/providers/dns/cloudxns/cloudxns.go index 57efdeaec..e69c60260 100644 --- a/vendor/github.com/xenolf/lego/providers/dns/cloudxns/cloudxns.go +++ b/vendor/github.com/xenolf/lego/providers/dns/cloudxns/cloudxns.go @@ -13,12 +13,12 @@ import ( "strconv" "time" - "github.com/xenolf/lego/acme" + "github.com/xenolf/lego/acmev2" ) const cloudXNSBaseURL = "https://www.cloudxns.net/api2/" -// DNSProvider is an implementation of the acme.ChallengeProvider interface +// DNSProvider is an implementation of the acmev2.ChallengeProvider interface type DNSProvider struct { apiKey string secretKey string @@ -48,7 +48,7 @@ func NewDNSProviderCredentials(apiKey, secretKey string) (*DNSProvider, error) { // Present creates a TXT record to fulfil the dns-01 challenge. func (c *DNSProvider) Present(domain, token, keyAuth string) error { - fqdn, value, ttl := acme.DNS01Record(domain, keyAuth) + fqdn, value, ttl := acmev2.DNS01Record(domain, keyAuth) zoneID, err := c.getHostedZoneID(fqdn) if err != nil { return err @@ -59,7 +59,7 @@ func (c *DNSProvider) Present(domain, token, keyAuth string) error { // CleanUp removes the TXT record matching the specified parameters. func (c *DNSProvider) CleanUp(domain, token, keyAuth string) error { - fqdn, _, _ := acme.DNS01Record(domain, keyAuth) + fqdn, _, _ := acmev2.DNS01Record(domain, keyAuth) zoneID, err := c.getHostedZoneID(fqdn) if err != nil { return err @@ -79,7 +79,7 @@ func (c *DNSProvider) getHostedZoneID(fqdn string) (string, error) { Domain string `json:"domain"` } - authZone, err := acme.FindZoneByFqdn(fqdn, acme.RecursiveNameservers) + authZone, err := acmev2.FindZoneByFqdn(fqdn, acmev2.RecursiveNameservers) if err != nil { return "", err } @@ -117,7 +117,7 @@ func (c *DNSProvider) findTxtRecord(zoneID, fqdn string) (string, error) { } for _, record := range records { - if record.Host == acme.UnFqdn(fqdn) && record.Type == "TXT" { + if record.Host == acmev2.UnFqdn(fqdn) && record.Type == "TXT" { return record.RecordID, nil } } @@ -133,7 +133,7 @@ func (c *DNSProvider) addTxtRecord(zoneID, fqdn, value string, ttl int) error { payload := cloudXNSRecord{ ID: id, - Host: acme.UnFqdn(fqdn), + Host: acmev2.UnFqdn(fqdn), Value: value, Type: "TXT", LineID: 1, @@ -183,7 +183,7 @@ func (c *DNSProvider) makeRequest(method, uri string, body []byte) (json.RawMess req.Header.Set("API-HMAC", c.hmac(url, requestDate, string(body))) req.Header.Set("API-FORMAT", "json") - resp, err := acme.HTTPClient.Do(req) + resp, err := acmev2.HTTPClient.Do(req) if err != nil { return nil, err } diff --git a/vendor/github.com/xenolf/lego/providers/dns/digitalocean/digitalocean.go b/vendor/github.com/xenolf/lego/providers/dns/digitalocean/digitalocean.go index da261b39a..6c989b07d 100644 --- a/vendor/github.com/xenolf/lego/providers/dns/digitalocean/digitalocean.go +++ b/vendor/github.com/xenolf/lego/providers/dns/digitalocean/digitalocean.go @@ -11,10 +11,10 @@ import ( "sync" "time" - "github.com/xenolf/lego/acme" + "github.com/xenolf/lego/acmev2" ) -// DNSProvider is an implementation of the acme.ChallengeProvider interface +// DNSProvider is an implementation of the acmev2.ChallengeProvider interface // that uses DigitalOcean's REST API to manage TXT records for a domain. type DNSProvider struct { apiAuthToken string @@ -49,6 +49,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error { RecordType string `json:"type"` Name string `json:"name"` Data string `json:"data"` + TTL int `json:"ttl"` } // txtRecordResponse represents a response from DO's API after making a TXT record @@ -61,17 +62,17 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error { } `json:"domain_record"` } - fqdn, value, _ := acme.DNS01Record(domain, keyAuth) + fqdn, value, _ := acmev2.DNS01Record(domain, keyAuth) - authZone, err := acme.FindZoneByFqdn(acme.ToFqdn(domain), acme.RecursiveNameservers) + authZone, err := acmev2.FindZoneByFqdn(acmev2.ToFqdn(domain), acmev2.RecursiveNameservers) if err != nil { return fmt.Errorf("Could not determine zone for domain: '%s'. %s", domain, err) } - authZone = acme.UnFqdn(authZone) + authZone = acmev2.UnFqdn(authZone) reqURL := fmt.Sprintf("%s/v2/domains/%s/records", digitalOceanBaseURL, authZone) - reqData := txtRecordRequest{RecordType: "TXT", Name: fqdn, Data: value} + reqData := txtRecordRequest{RecordType: "TXT", Name: fqdn, Data: value, TTL: 60} body, err := json.Marshal(reqData) if err != nil { return err @@ -112,7 +113,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error { // CleanUp removes the TXT record matching the specified parameters func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { - fqdn, _, _ := acme.DNS01Record(domain, keyAuth) + fqdn, _, _ := acmev2.DNS01Record(domain, keyAuth) // get the record's unique ID from when we created it d.recordIDsMu.Lock() @@ -122,12 +123,12 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { return fmt.Errorf("unknown record ID for '%s'", fqdn) } - authZone, err := acme.FindZoneByFqdn(acme.ToFqdn(domain), acme.RecursiveNameservers) + authZone, err := acmev2.FindZoneByFqdn(acmev2.ToFqdn(domain), acmev2.RecursiveNameservers) if err != nil { return fmt.Errorf("Could not determine zone for domain: '%s'. %s", domain, err) } - authZone = acme.UnFqdn(authZone) + authZone = acmev2.UnFqdn(authZone) reqURL := fmt.Sprintf("%s/v2/domains/%s/records/%d", digitalOceanBaseURL, authZone, recordID) req, err := http.NewRequest("DELETE", reqURL, nil) @@ -164,3 +165,9 @@ type digitalOceanAPIError struct { } var digitalOceanBaseURL = "https://api.digitalocean.com" + +// Timeout returns the timeout and interval to use when checking for DNS +// propagation. Adjusting here to cope with spikes in propagation times. +func (d *DNSProvider) Timeout() (timeout, interval time.Duration) { + return 90 * time.Second, 5 * time.Second +} diff --git a/vendor/github.com/xenolf/lego/providers/dns/dns_providers.go b/vendor/github.com/xenolf/lego/providers/dns/dns_providers.go index 062353098..2f1344a69 100644 --- a/vendor/github.com/xenolf/lego/providers/dns/dns_providers.go +++ b/vendor/github.com/xenolf/lego/providers/dns/dns_providers.go @@ -4,23 +4,30 @@ package dns import ( "fmt" - "github.com/xenolf/lego/acme" + "github.com/xenolf/lego/acmev2" "github.com/xenolf/lego/providers/dns/auroradns" "github.com/xenolf/lego/providers/dns/azure" + "github.com/xenolf/lego/providers/dns/bluecat" "github.com/xenolf/lego/providers/dns/cloudflare" "github.com/xenolf/lego/providers/dns/cloudxns" "github.com/xenolf/lego/providers/dns/digitalocean" "github.com/xenolf/lego/providers/dns/dnsimple" "github.com/xenolf/lego/providers/dns/dnsmadeeasy" "github.com/xenolf/lego/providers/dns/dnspod" + "github.com/xenolf/lego/providers/dns/duckdns" "github.com/xenolf/lego/providers/dns/dyn" + "github.com/xenolf/lego/providers/dns/exec" "github.com/xenolf/lego/providers/dns/exoscale" + "github.com/xenolf/lego/providers/dns/fastdns" "github.com/xenolf/lego/providers/dns/gandi" "github.com/xenolf/lego/providers/dns/gandiv5" - "github.com/xenolf/lego/providers/dns/googlecloud" + "github.com/xenolf/lego/providers/dns/glesys" "github.com/xenolf/lego/providers/dns/godaddy" + "github.com/xenolf/lego/providers/dns/googlecloud" + "github.com/xenolf/lego/providers/dns/lightsail" "github.com/xenolf/lego/providers/dns/linode" "github.com/xenolf/lego/providers/dns/namecheap" + "github.com/xenolf/lego/providers/dns/namedotcom" "github.com/xenolf/lego/providers/dns/ns1" "github.com/xenolf/lego/providers/dns/otc" "github.com/xenolf/lego/providers/dns/ovh" @@ -31,14 +38,16 @@ import ( "github.com/xenolf/lego/providers/dns/vultr" ) -func NewDNSChallengeProviderByName(name string) (acme.ChallengeProvider, error) { +func NewDNSChallengeProviderByName(name string) (acmev2.ChallengeProvider, error) { var err error - var provider acme.ChallengeProvider + var provider acmev2.ChallengeProvider switch name { case "azure": provider, err = azure.NewDNSProvider() case "auroradns": provider, err = auroradns.NewDNSProvider() + case "bluecat": + provider, err = bluecat.NewDNSProvider() case "cloudflare": provider, err = cloudflare.NewDNSProvider() case "cloudxns": @@ -51,24 +60,34 @@ func NewDNSChallengeProviderByName(name string) (acme.ChallengeProvider, error) provider, err = dnsmadeeasy.NewDNSProvider() case "dnspod": provider, err = dnspod.NewDNSProvider() + case "duckdns": + provider, err = duckdns.NewDNSProvider() case "dyn": provider, err = dyn.NewDNSProvider() + case "fastdns": + provider, err = fastdns.NewDNSProvider() case "exoscale": provider, err = exoscale.NewDNSProvider() case "gandi": provider, err = gandi.NewDNSProvider() case "gandiv5": provider, err = gandiv5.NewDNSProvider() + case "glesys": + provider, err = glesys.NewDNSProvider() case "gcloud": provider, err = googlecloud.NewDNSProvider() case "godaddy": provider, err = godaddy.NewDNSProvider() + case "lightsail": + provider, err = lightsail.NewDNSProvider() case "linode": provider, err = linode.NewDNSProvider() case "manual": - provider, err = acme.NewDNSProviderManual() + provider, err = acmev2.NewDNSProviderManual() case "namecheap": provider, err = namecheap.NewDNSProvider() + case "namedotcom": + provider, err = namedotcom.NewDNSProvider() case "rackspace": provider, err = rackspace.NewDNSProvider() case "route53": @@ -85,6 +104,8 @@ func NewDNSChallengeProviderByName(name string) (acme.ChallengeProvider, error) provider, err = ns1.NewDNSProvider() case "otc": provider, err = otc.NewDNSProvider() + case "exec": + provider, err = exec.NewDNSProvider() default: err = fmt.Errorf("Unrecognised DNS provider: %s", name) } diff --git a/vendor/github.com/xenolf/lego/providers/dns/dnsimple/dnsimple.go b/vendor/github.com/xenolf/lego/providers/dns/dnsimple/dnsimple.go index e3fea79ec..cebdff1ce 100644 --- a/vendor/github.com/xenolf/lego/providers/dns/dnsimple/dnsimple.go +++ b/vendor/github.com/xenolf/lego/providers/dns/dnsimple/dnsimple.go @@ -9,10 +9,10 @@ import ( "strings" "github.com/dnsimple/dnsimple-go/dnsimple" - "github.com/xenolf/lego/acme" + "github.com/xenolf/lego/acmev2" ) -// DNSProvider is an implementation of the acme.ChallengeProvider interface. +// DNSProvider is an implementation of the acmev2.ChallengeProvider interface. type DNSProvider struct { client *dnsimple.Client } @@ -47,7 +47,7 @@ func NewDNSProviderCredentials(accessToken, baseUrl string) (*DNSProvider, error // Present creates a TXT record to fulfil the dns-01 challenge. func (c *DNSProvider) Present(domain, token, keyAuth string) error { - fqdn, value, ttl := acme.DNS01Record(domain, keyAuth) + fqdn, value, ttl := acmev2.DNS01Record(domain, keyAuth) zoneName, err := c.getHostedZone(domain) @@ -71,7 +71,7 @@ func (c *DNSProvider) Present(domain, token, keyAuth string) error { // CleanUp removes the TXT record matching the specified parameters. func (c *DNSProvider) CleanUp(domain, token, keyAuth string) error { - fqdn, _, _ := acme.DNS01Record(domain, keyAuth) + fqdn, _, _ := acmev2.DNS01Record(domain, keyAuth) records, err := c.findTxtRecords(domain, fqdn) if err != nil { @@ -94,7 +94,7 @@ func (c *DNSProvider) CleanUp(domain, token, keyAuth string) error { } func (c *DNSProvider) getHostedZone(domain string) (string, error) { - authZone, err := acme.FindZoneByFqdn(acme.ToFqdn(domain), acme.RecursiveNameservers) + authZone, err := acmev2.FindZoneByFqdn(acmev2.ToFqdn(domain), acmev2.RecursiveNameservers) if err != nil { return "", err } @@ -104,7 +104,7 @@ func (c *DNSProvider) getHostedZone(domain string) (string, error) { return "", err } - zoneName := acme.UnFqdn(authZone) + zoneName := acmev2.UnFqdn(authZone) zones, err := c.client.Zones.ListZones(accountID, &dnsimple.ZoneListOptions{NameLike: zoneName}) if err != nil { @@ -159,7 +159,7 @@ func (c *DNSProvider) newTxtRecord(zoneName, fqdn, value string, ttl int) *dnsim } func (c *DNSProvider) extractRecordName(fqdn, domain string) string { - name := acme.UnFqdn(fqdn) + name := acmev2.UnFqdn(fqdn) if idx := strings.Index(name, "."+domain); idx != -1 { return name[:idx] } diff --git a/vendor/github.com/xenolf/lego/providers/dns/dnsmadeeasy/dnsmadeeasy.go b/vendor/github.com/xenolf/lego/providers/dns/dnsmadeeasy/dnsmadeeasy.go index c4363a4eb..9ea7b51f7 100644 --- a/vendor/github.com/xenolf/lego/providers/dns/dnsmadeeasy/dnsmadeeasy.go +++ b/vendor/github.com/xenolf/lego/providers/dns/dnsmadeeasy/dnsmadeeasy.go @@ -14,10 +14,10 @@ import ( "strings" "time" - "github.com/xenolf/lego/acme" + "github.com/xenolf/lego/acmev2" ) -// DNSProvider is an implementation of the acme.ChallengeProvider interface that uses +// DNSProvider is an implementation of the acmev2.ChallengeProvider interface that uses // DNSMadeEasy's DNS API to manage TXT records for a domain. type DNSProvider struct { baseURL string @@ -77,9 +77,9 @@ func NewDNSProviderCredentials(baseURL, apiKey, apiSecret string) (*DNSProvider, // Present creates a TXT record using the specified parameters func (d *DNSProvider) Present(domainName, token, keyAuth string) error { - fqdn, value, ttl := acme.DNS01Record(domainName, keyAuth) + fqdn, value, ttl := acmev2.DNS01Record(domainName, keyAuth) - authZone, err := acme.FindZoneByFqdn(fqdn, acme.RecursiveNameservers) + authZone, err := acmev2.FindZoneByFqdn(fqdn, acmev2.RecursiveNameservers) if err != nil { return err } @@ -104,9 +104,9 @@ func (d *DNSProvider) Present(domainName, token, keyAuth string) error { // CleanUp removes the TXT records matching the specified parameters func (d *DNSProvider) CleanUp(domainName, token, keyAuth string) error { - fqdn, _, _ := acme.DNS01Record(domainName, keyAuth) + fqdn, _, _ := acmev2.DNS01Record(domainName, keyAuth) - authZone, err := acme.FindZoneByFqdn(fqdn, acme.RecursiveNameservers) + authZone, err := acmev2.FindZoneByFqdn(fqdn, acmev2.RecursiveNameservers) if err != nil { return err } diff --git a/vendor/github.com/xenolf/lego/providers/dns/dnspod/dnspod.go b/vendor/github.com/xenolf/lego/providers/dns/dnspod/dnspod.go index 0ce08a8bb..4942eba75 100644 --- a/vendor/github.com/xenolf/lego/providers/dns/dnspod/dnspod.go +++ b/vendor/github.com/xenolf/lego/providers/dns/dnspod/dnspod.go @@ -8,10 +8,10 @@ import ( "strings" "github.com/decker502/dnspod-go" - "github.com/xenolf/lego/acme" + "github.com/xenolf/lego/acmev2" ) -// DNSProvider is an implementation of the acme.ChallengeProvider interface. +// DNSProvider is an implementation of the acmev2.ChallengeProvider interface. type DNSProvider struct { client *dnspod.Client } @@ -38,7 +38,7 @@ func NewDNSProviderCredentials(key string) (*DNSProvider, error) { // Present creates a TXT record to fulfil the dns-01 challenge. func (c *DNSProvider) Present(domain, token, keyAuth string) error { - fqdn, value, ttl := acme.DNS01Record(domain, keyAuth) + fqdn, value, ttl := acmev2.DNS01Record(domain, keyAuth) zoneID, zoneName, err := c.getHostedZone(domain) if err != nil { return err @@ -55,7 +55,7 @@ func (c *DNSProvider) Present(domain, token, keyAuth string) error { // CleanUp removes the TXT record matching the specified parameters. func (c *DNSProvider) CleanUp(domain, token, keyAuth string) error { - fqdn, _, _ := acme.DNS01Record(domain, keyAuth) + fqdn, _, _ := acmev2.DNS01Record(domain, keyAuth) records, err := c.findTxtRecords(domain, fqdn) if err != nil { @@ -82,14 +82,14 @@ func (c *DNSProvider) getHostedZone(domain string) (string, string, error) { return "", "", fmt.Errorf("dnspod API call failed: %v", err) } - authZone, err := acme.FindZoneByFqdn(acme.ToFqdn(domain), acme.RecursiveNameservers) + authZone, err := acmev2.FindZoneByFqdn(acmev2.ToFqdn(domain), acmev2.RecursiveNameservers) if err != nil { return "", "", err } var hostedZone dnspod.Domain for _, zone := range zones { - if zone.Name == acme.UnFqdn(authZone) { + if zone.Name == acmev2.UnFqdn(authZone) { hostedZone = zone } } @@ -138,7 +138,7 @@ func (c *DNSProvider) findTxtRecords(domain, fqdn string) ([]dnspod.Record, erro } func (c *DNSProvider) extractRecordName(fqdn, domain string) string { - name := acme.UnFqdn(fqdn) + name := acmev2.UnFqdn(fqdn) if idx := strings.Index(name, "."+domain); idx != -1 { return name[:idx] } diff --git a/vendor/github.com/xenolf/lego/providers/dns/duckdns/duckdns.go b/vendor/github.com/xenolf/lego/providers/dns/duckdns/duckdns.go new file mode 100644 index 000000000..defafe35c --- /dev/null +++ b/vendor/github.com/xenolf/lego/providers/dns/duckdns/duckdns.go @@ -0,0 +1,82 @@ +// Adds lego support for http://duckdns.org . +// +// See http://www.duckdns.org/spec.jsp for more info on updating TXT records. +package duckdns + +import ( + "errors" + "fmt" + "io/ioutil" + "os" + + "github.com/xenolf/lego/acmev2" +) + +// DNSProvider adds and removes the record for the DNS challenge +type DNSProvider struct { + // The duckdns api token + token string +} + +// NewDNSProvider returns a new DNS provider using +// environment variable DUCKDNS_TOKEN for adding and removing the DNS record. +func NewDNSProvider() (*DNSProvider, error) { + duckdnsToken := os.Getenv("DUCKDNS_TOKEN") + + return NewDNSProviderCredentials(duckdnsToken) +} + +// NewDNSProviderCredentials uses the supplied credentials to return a +// DNSProvider instance configured for http://duckdns.org . +func NewDNSProviderCredentials(duckdnsToken string) (*DNSProvider, error) { + if duckdnsToken == "" { + return nil, errors.New("environment variable DUCKDNS_TOKEN not set") + } + + return &DNSProvider{token: duckdnsToken}, nil +} + +// makeDuckdnsURL creates a url to clear the set or unset the TXT record. +// txt == "" will clear the TXT record. +func makeDuckdnsURL(domain, token, txt string) string { + requestBase := fmt.Sprintf("https://www.duckdns.org/update?domains=%s&token=%s", domain, token) + if txt == "" { + return requestBase + "&clear=true" + } + return requestBase + "&txt=" + txt +} + +func issueDuckdnsRequest(url string) error { + response, err := acmev2.HTTPClient.Get(url) + if err != nil { + return err + } + defer response.Body.Close() + + bodyBytes, err := ioutil.ReadAll(response.Body) + if err != nil { + return err + } + body := string(bodyBytes) + if body != "OK" { + return fmt.Errorf("Request to change TXT record for duckdns returned the following result (%s) this does not match expectation (OK) used url [%s]", body, url) + } + return nil +} + +// Present creates a TXT record to fulfil the dns-01 challenge. +// In duckdns you only have one TXT record shared with +// the domain and all sub domains. +// +// To update the TXT record we just need to make one simple get request. +func (d *DNSProvider) Present(domain, token, keyAuth string) error { + _, txtRecord, _ := acmev2.DNS01Record(domain, keyAuth) + url := makeDuckdnsURL(domain, d.token, txtRecord) + return issueDuckdnsRequest(url) +} + +// CleanUp clears duckdns TXT record +func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { + url := makeDuckdnsURL(domain, d.token, "") + return issueDuckdnsRequest(url) +} diff --git a/vendor/github.com/xenolf/lego/providers/dns/dyn/dyn.go b/vendor/github.com/xenolf/lego/providers/dns/dyn/dyn.go index 384bc850c..b75febce8 100644 --- a/vendor/github.com/xenolf/lego/providers/dns/dyn/dyn.go +++ b/vendor/github.com/xenolf/lego/providers/dns/dyn/dyn.go @@ -11,7 +11,7 @@ import ( "strconv" "time" - "github.com/xenolf/lego/acme" + "github.com/xenolf/lego/acmev2" ) var dynBaseURL = "https://api.dynect.net/REST" @@ -30,7 +30,7 @@ type dynResponse struct { Messages json.RawMessage `json:"msgs"` } -// DNSProvider is an implementation of the acme.ChallengeProvider interface that uses +// DNSProvider is an implementation of the acmev2.ChallengeProvider interface that uses // Dyn's Managed DNS API to manage TXT records for a domain. type DNSProvider struct { customerName string @@ -87,11 +87,8 @@ func (d *DNSProvider) sendRequest(method, resource string, payload interface{}) } defer resp.Body.Close() - if resp.StatusCode >= 400 { + if resp.StatusCode >= 500 { return nil, fmt.Errorf("Dyn API request failed with HTTP status code %d", resp.StatusCode) - } else if resp.StatusCode == 307 { - // TODO add support for HTTP 307 response and long running jobs - return nil, fmt.Errorf("Dyn API request returned HTTP 307. This is currently unsupported") } var dynRes dynResponse @@ -100,6 +97,13 @@ func (d *DNSProvider) sendRequest(method, resource string, payload interface{}) return nil, err } + if resp.StatusCode >= 400 { + return nil, fmt.Errorf("Dyn API request failed with HTTP status code %d: %s", resp.StatusCode, dynRes.Messages) + } else if resp.StatusCode == 307 { + // TODO add support for HTTP 307 response and long running jobs + return nil, fmt.Errorf("Dyn API request returned HTTP 307. This is currently unsupported") + } + if dynRes.Status == "failure" { // TODO add better error handling return nil, fmt.Errorf("Dyn API request failed: %s", dynRes.Messages) @@ -172,9 +176,9 @@ func (d *DNSProvider) logout() error { // Present creates a TXT record using the specified parameters func (d *DNSProvider) Present(domain, token, keyAuth string) error { - fqdn, value, ttl := acme.DNS01Record(domain, keyAuth) + fqdn, value, ttl := acmev2.DNS01Record(domain, keyAuth) - authZone, err := acme.FindZoneByFqdn(fqdn, acme.RecursiveNameservers) + authZone, err := acmev2.FindZoneByFqdn(fqdn, acmev2.RecursiveNameservers) if err != nil { return err } @@ -228,9 +232,9 @@ func (d *DNSProvider) publish(zone, notes string) error { // CleanUp removes the TXT record matching the specified parameters func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { - fqdn, _, _ := acme.DNS01Record(domain, keyAuth) + fqdn, _, _ := acmev2.DNS01Record(domain, keyAuth) - authZone, err := acme.FindZoneByFqdn(fqdn, acme.RecursiveNameservers) + authZone, err := acmev2.FindZoneByFqdn(fqdn, acmev2.RecursiveNameservers) if err != nil { return err } diff --git a/vendor/github.com/xenolf/lego/providers/dns/exec/exec.go b/vendor/github.com/xenolf/lego/providers/dns/exec/exec.go new file mode 100644 index 000000000..86f1aa5ee --- /dev/null +++ b/vendor/github.com/xenolf/lego/providers/dns/exec/exec.go @@ -0,0 +1,72 @@ +// Package exec implements a manual DNS provider which runs a program for +// adding/removing the DNS record. +// +// The file name of the external program is specified in the environment +// variable EXEC_PATH. When it is run by lego, three command-line parameters +// are passed to it: The action ("present" or "cleanup"), the fully-qualified domain +// name, the value for the record and the TTL. +// +// For example, requesting a certificate for the domain 'foo.example.com' can +// be achieved by calling lego as follows: +// +// EXEC_PATH=./update-dns.sh \ +// lego --dns exec \ +// --domains foo.example.com \ +// --email invalid@example.com run +// +// It will then call the program './update-dns.sh' with like this: +// +// ./update-dns.sh "present" "_acme-challenge.foo.example.com." "MsijOYZxqyjGnFGwhjrhfg-Xgbl5r68WPda0J9EgqqI" "120" +// +// The program then needs to make sure the record is inserted. When it returns +// an error via a non-zero exit code, lego aborts. +// +// When the record is to be removed again, the program is called with the first +// command-line parameter set to "cleanup" instead of "present". +package exec + +import ( + "errors" + "os" + "os/exec" + "strconv" + + "github.com/xenolf/lego/acmev2" +) + +// DNSProvider adds and removes the record for the DNS challenge by calling a +// program with command-line parameters. +type DNSProvider struct { + program string +} + +// NewDNSProvider returns a new DNS provider which runs the program in the +// environment variable EXEC_PATH for adding and removing the DNS record. +func NewDNSProvider() (*DNSProvider, error) { + s := os.Getenv("EXEC_PATH") + if s == "" { + return nil, errors.New("environment variable EXEC_PATH not set") + } + + return &DNSProvider{program: s}, nil +} + +// Present creates a TXT record to fulfil the dns-01 challenge. +func (d *DNSProvider) Present(domain, token, keyAuth string) error { + fqdn, value, ttl := acmev2.DNS01Record(domain, keyAuth) + cmd := exec.Command(d.program, "present", fqdn, value, strconv.Itoa(ttl)) + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + + return cmd.Run() +} + +// CleanUp removes the TXT record matching the specified parameters +func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { + fqdn, value, ttl := acmev2.DNS01Record(domain, keyAuth) + cmd := exec.Command(d.program, "cleanup", fqdn, value, strconv.Itoa(ttl)) + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + + return cmd.Run() +} diff --git a/vendor/github.com/xenolf/lego/providers/dns/exoscale/exoscale.go b/vendor/github.com/xenolf/lego/providers/dns/exoscale/exoscale.go index 4b125e8df..5d97ac085 100644 --- a/vendor/github.com/xenolf/lego/providers/dns/exoscale/exoscale.go +++ b/vendor/github.com/xenolf/lego/providers/dns/exoscale/exoscale.go @@ -8,10 +8,10 @@ import ( "os" "github.com/exoscale/egoscale" - "github.com/xenolf/lego/acme" + "github.com/xenolf/lego/acmev2" ) -// DNSProvider is an implementation of the acme.ChallengeProvider interface. +// DNSProvider is an implementation of the acmev2.ChallengeProvider interface. type DNSProvider struct { client *egoscale.Client } @@ -42,7 +42,7 @@ func NewDNSProviderClient(key, secret, endpoint string) (*DNSProvider, error) { // Present creates a TXT record to fulfil the dns-01 challenge. func (c *DNSProvider) Present(domain, token, keyAuth string) error { - fqdn, value, ttl := acme.DNS01Record(domain, keyAuth) + fqdn, value, ttl := acmev2.DNS01Record(domain, keyAuth) zone, recordName, err := c.FindZoneAndRecordName(fqdn, domain) if err != nil { return err @@ -78,7 +78,7 @@ func (c *DNSProvider) Present(domain, token, keyAuth string) error { // CleanUp removes the record matching the specified parameters. func (c *DNSProvider) CleanUp(domain, token, keyAuth string) error { - fqdn, _, _ := acme.DNS01Record(domain, keyAuth) + fqdn, _, _ := acmev2.DNS01Record(domain, keyAuth) zone, recordName, err := c.FindZoneAndRecordName(fqdn, domain) if err != nil { return err @@ -116,12 +116,12 @@ func (c *DNSProvider) FindExistingRecordId(zone, recordName string) (int64, erro // Extract DNS zone and DNS entry name func (c *DNSProvider) FindZoneAndRecordName(fqdn, domain string) (string, string, error) { - zone, err := acme.FindZoneByFqdn(acme.ToFqdn(domain), acme.RecursiveNameservers) + zone, err := acmev2.FindZoneByFqdn(acmev2.ToFqdn(domain), acmev2.RecursiveNameservers) if err != nil { return "", "", err } - zone = acme.UnFqdn(zone) - name := acme.UnFqdn(fqdn) + zone = acmev2.UnFqdn(zone) + name := acmev2.UnFqdn(fqdn) name = name[:len(name)-len("."+zone)] return zone, name, nil diff --git a/vendor/github.com/xenolf/lego/providers/dns/fastdns/fastdns.go b/vendor/github.com/xenolf/lego/providers/dns/fastdns/fastdns.go new file mode 100644 index 000000000..349f12d49 --- /dev/null +++ b/vendor/github.com/xenolf/lego/providers/dns/fastdns/fastdns.go @@ -0,0 +1,139 @@ +package fastdns + +import ( + "fmt" + "os" + "reflect" + + configdns "github.com/akamai/AkamaiOPEN-edgegrid-golang/configdns-v1" + "github.com/akamai/AkamaiOPEN-edgegrid-golang/edgegrid" + "github.com/xenolf/lego/acmev2" +) + +// DNSProvider is an implementation of the acmev2.ChallengeProvider interface. +type DNSProvider struct { + config edgegrid.Config +} + +// NewDNSProvider uses the supplied environment variables to return a DNSProvider instance: +// AKAMAI_HOST, AKAMAI_CLIENT_TOKEN, AKAMAI_CLIENT_SECRET, AKAMAI_ACCESS_TOKEN +func NewDNSProvider() (*DNSProvider, error) { + host := os.Getenv("AKAMAI_HOST") + clientToken := os.Getenv("AKAMAI_CLIENT_TOKEN") + clientSecret := os.Getenv("AKAMAI_CLIENT_SECRET") + accessToken := os.Getenv("AKAMAI_ACCESS_TOKEN") + + return NewDNSProviderClient(host, clientToken, clientSecret, accessToken) +} + +// NewDNSProviderClient uses the supplied parameters to return a DNSProvider instance +// configured for FastDNS. +func NewDNSProviderClient(host, clientToken, clientSecret, accessToken string) (*DNSProvider, error) { + if clientToken == "" || clientSecret == "" || accessToken == "" || host == "" { + return nil, fmt.Errorf("Akamai FastDNS credentials missing") + } + config := edgegrid.Config{ + Host: host, + ClientToken: clientToken, + ClientSecret: clientSecret, + AccessToken: accessToken, + MaxBody: 131072, + } + + return &DNSProvider{ + config: config, + }, nil +} + +// Present creates a TXT record to fullfil the dns-01 challenge. +func (c *DNSProvider) Present(domain, token, keyAuth string) error { + fqdn, value, ttl := acmev2.DNS01Record(domain, keyAuth) + zoneName, recordName, err := c.findZoneAndRecordName(fqdn, domain) + if err != nil { + return err + } + + configdns.Init(c.config) + + zone, err := configdns.GetZone(zoneName) + if err != nil { + return err + } + + record := configdns.NewTxtRecord() + record.SetField("name", recordName) + record.SetField("ttl", ttl) + record.SetField("target", value) + record.SetField("active", true) + + existingRecord := c.findExistingRecord(zone, recordName) + + if existingRecord != nil { + if reflect.DeepEqual(existingRecord.ToMap(), record.ToMap()) { + return nil + } + zone.RemoveRecord(existingRecord) + return c.createRecord(zone, record) + } + + return c.createRecord(zone, record) +} + +// CleanUp removes the record matching the specified parameters. +func (c *DNSProvider) CleanUp(domain, token, keyAuth string) error { + fqdn, _, _ := acmev2.DNS01Record(domain, keyAuth) + zoneName, recordName, err := c.findZoneAndRecordName(fqdn, domain) + if err != nil { + return err + } + + configdns.Init(c.config) + + zone, err := configdns.GetZone(zoneName) + if err != nil { + return err + } + + existingRecord := c.findExistingRecord(zone, recordName) + + if existingRecord != nil { + err := zone.RemoveRecord(existingRecord) + if err != nil { + return err + } + return zone.Save() + } + + return nil +} + +func (c *DNSProvider) findZoneAndRecordName(fqdn, domain string) (string, string, error) { + zone, err := acmev2.FindZoneByFqdn(acmev2.ToFqdn(domain), acmev2.RecursiveNameservers) + if err != nil { + return "", "", err + } + zone = acmev2.UnFqdn(zone) + name := acmev2.UnFqdn(fqdn) + name = name[:len(name)-len("."+zone)] + + return zone, name, nil +} + +func (c *DNSProvider) findExistingRecord(zone *configdns.Zone, recordName string) *configdns.TxtRecord { + for _, r := range zone.Zone.Txt { + if r.Name == recordName { + return r + } + } + + return nil +} + +func (c *DNSProvider) createRecord(zone *configdns.Zone, record *configdns.TxtRecord) error { + err := zone.AddRecord(record) + if err != nil { + return err + } + + return zone.Save() +} diff --git a/vendor/github.com/xenolf/lego/providers/dns/gandi/gandi.go b/vendor/github.com/xenolf/lego/providers/dns/gandi/gandi.go index 422b02a21..689fff1d1 100644 --- a/vendor/github.com/xenolf/lego/providers/dns/gandi/gandi.go +++ b/vendor/github.com/xenolf/lego/providers/dns/gandi/gandi.go @@ -14,7 +14,7 @@ import ( "sync" "time" - "github.com/xenolf/lego/acme" + "github.com/xenolf/lego/acmev2" ) // Gandi API reference: http://doc.rpc.gandi.net/index.html @@ -26,7 +26,7 @@ var ( endpoint = "https://rpc.gandi.net/xmlrpc/" // findZoneByFqdn determines the DNS zone of an fqdn. It is overridden // during tests. - findZoneByFqdn = acme.FindZoneByFqdn + findZoneByFqdn = acmev2.FindZoneByFqdn ) // inProgressInfo contains information about an in-progress challenge @@ -37,7 +37,7 @@ type inProgressInfo struct { } // DNSProvider is an implementation of the -// acme.ChallengeProviderTimeout interface that uses Gandi's XML-RPC +// acmev2.ChallengeProviderTimeout interface that uses Gandi's XML-RPC // API to manage TXT records for a domain. type DNSProvider struct { apiKey string @@ -70,12 +70,12 @@ func NewDNSProviderCredentials(apiKey string) (*DNSProvider, error) { // does this by creating and activating a new temporary Gandi DNS // zone. This new zone contains the TXT record. func (d *DNSProvider) Present(domain, token, keyAuth string) error { - fqdn, value, ttl := acme.DNS01Record(domain, keyAuth) + fqdn, value, ttl := acmev2.DNS01Record(domain, keyAuth) if ttl < 300 { ttl = 300 // 300 is gandi minimum value for ttl } // find authZone and Gandi zone_id for fqdn - authZone, err := findZoneByFqdn(fqdn, acme.RecursiveNameservers) + authZone, err := findZoneByFqdn(fqdn, acmev2.RecursiveNameservers) if err != nil { return fmt.Errorf("Gandi DNS: findZoneByFqdn failure: %v", err) } @@ -103,7 +103,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error { // containing the required TXT record newZoneName := fmt.Sprintf( "%s [ACME Challenge %s]", - acme.UnFqdn(authZone), time.Now().Format(time.RFC822Z)) + acmev2.UnFqdn(authZone), time.Now().Format(time.RFC822Z)) newZoneID, err := d.cloneZone(zoneID, newZoneName) if err != nil { return err @@ -138,7 +138,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error { // parameters. It does this by restoring the old Gandi DNS zone and // removing the temporary one created by Present. func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { - fqdn, _, _ := acme.DNS01Record(domain, keyAuth) + fqdn, _, _ := acmev2.DNS01Record(domain, keyAuth) // acquire lock and retrieve zoneID, newZoneID and authZone d.inProgressMu.Lock() defer d.inProgressMu.Unlock() diff --git a/vendor/github.com/xenolf/lego/providers/dns/gandiv5/gandiv5.go b/vendor/github.com/xenolf/lego/providers/dns/gandiv5/gandiv5.go index 86cc7bf3f..6b96ef72a 100644 --- a/vendor/github.com/xenolf/lego/providers/dns/gandiv5/gandiv5.go +++ b/vendor/github.com/xenolf/lego/providers/dns/gandiv5/gandiv5.go @@ -12,7 +12,7 @@ import ( "sync" "time" - "github.com/xenolf/lego/acme" + "github.com/xenolf/lego/acmev2" ) // Gandi API reference: http://doc.livedns.gandi.net/ @@ -23,7 +23,7 @@ var ( endpoint = "https://dns.api.gandi.net/api/v5" // findZoneByFqdn determines the DNS zone of an fqdn. It is overridden // during tests. - findZoneByFqdn = acme.FindZoneByFqdn + findZoneByFqdn = acmev2.FindZoneByFqdn ) // inProgressInfo contains information about an in-progress challenge @@ -33,7 +33,7 @@ type inProgressInfo struct { } // DNSProvider is an implementation of the -// acme.ChallengeProviderTimeout interface that uses Gandi's LiveDNS +// acmev2.ChallengeProviderTimeout interface that uses Gandi's LiveDNS // API to manage TXT records for a domain. type DNSProvider struct { apiKey string @@ -62,12 +62,12 @@ func NewDNSProviderCredentials(apiKey string) (*DNSProvider, error) { // Present creates a TXT record using the specified parameters. func (d *DNSProvider) Present(domain, token, keyAuth string) error { - fqdn, value, ttl := acme.DNS01Record(domain, keyAuth) + fqdn, value, ttl := acmev2.DNS01Record(domain, keyAuth) if ttl < 300 { ttl = 300 // 300 is gandi minimum value for ttl } // find authZone - authZone, err := findZoneByFqdn(fqdn, acme.RecursiveNameservers) + authZone, err := findZoneByFqdn(fqdn, acmev2.RecursiveNameservers) if err != nil { return fmt.Errorf("Gandi DNS: findZoneByFqdn failure: %v", err) } @@ -83,7 +83,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error { d.inProgressMu.Lock() defer d.inProgressMu.Unlock() // add TXT record into authZone - err = d.addTXTRecord(acme.UnFqdn(authZone), name, value, ttl) + err = d.addTXTRecord(acmev2.UnFqdn(authZone), name, value, ttl) if err != nil { return err } @@ -97,7 +97,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error { // CleanUp removes the TXT record matching the specified parameters. func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { - fqdn, _, _ := acme.DNS01Record(domain, keyAuth) + fqdn, _, _ := acmev2.DNS01Record(domain, keyAuth) // acquire lock and retrieve authZone d.inProgressMu.Lock() defer d.inProgressMu.Unlock() @@ -109,7 +109,7 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { authZone := d.inProgressFQDNs[fqdn].authZone delete(d.inProgressFQDNs, fqdn) // delete TXT record from authZone - err := d.deleteTXTRecord(acme.UnFqdn(authZone), fieldName) + err := d.deleteTXTRecord(acmev2.UnFqdn(authZone), fieldName) if err != nil { return err } diff --git a/vendor/github.com/xenolf/lego/providers/dns/glesys/glesys.go b/vendor/github.com/xenolf/lego/providers/dns/glesys/glesys.go new file mode 100644 index 000000000..7f8168b23 --- /dev/null +++ b/vendor/github.com/xenolf/lego/providers/dns/glesys/glesys.go @@ -0,0 +1,211 @@ +// Package glesys implements a DNS provider for solving the DNS-01 +// challenge using GleSYS api. +package glesys + +import ( + "bytes" + "encoding/json" + "fmt" + "log" + "net/http" + "os" + "strings" + "sync" + "time" + + "github.com/xenolf/lego/acmev2" +) + +// GleSYS API reference: https://github.com/GleSYS/API/wiki/API-Documentation + +// domainAPI is the GleSYS API endpoint used by Present and CleanUp. +const domainAPI = "https://api.glesys.com/domain" + +var ( + // Logger is used to log API communication results; + // if nil, the default log.Logger is used. + Logger *log.Logger +) + +// logf writes a log entry. It uses Logger if not +// nil, otherwise it uses the default log.Logger. +func logf(format string, args ...interface{}) { + if Logger != nil { + Logger.Printf(format, args...) + } else { + log.Printf(format, args...) + } +} + +// DNSProvider is an implementation of the +// acmev2.ChallengeProviderTimeout interface that uses GleSYS +// API to manage TXT records for a domain. +type DNSProvider struct { + apiUser string + apiKey string + activeRecords map[string]int + inProgressMu sync.Mutex +} + +// NewDNSProvider returns a DNSProvider instance configured for GleSYS. +// Credentials must be passed in the environment variables: GLESYS_API_USER +// and GLESYS_API_KEY. +func NewDNSProvider() (*DNSProvider, error) { + apiUser := os.Getenv("GLESYS_API_USER") + apiKey := os.Getenv("GLESYS_API_KEY") + return NewDNSProviderCredentials(apiUser, apiKey) +} + +// NewDNSProviderCredentials uses the supplied credentials to return a +// DNSProvider instance configured for GleSYS. +func NewDNSProviderCredentials(apiUser string, apiKey string) (*DNSProvider, error) { + if apiUser == "" || apiKey == "" { + return nil, fmt.Errorf("GleSYS DNS: Incomplete credentials provided") + } + return &DNSProvider{ + apiUser: apiUser, + apiKey: apiKey, + activeRecords: make(map[string]int), + }, nil +} + +// Present creates a TXT record using the specified parameters. +func (d *DNSProvider) Present(domain, token, keyAuth string) error { + fqdn, value, ttl := acmev2.DNS01Record(domain, keyAuth) + if ttl < 60 { + ttl = 60 // 60 is GleSYS minimum value for ttl + } + // find authZone + authZone, err := acmev2.FindZoneByFqdn(fqdn, acmev2.RecursiveNameservers) + if err != nil { + return fmt.Errorf("GleSYS DNS: findZoneByFqdn failure: %v", err) + } + // determine name of TXT record + if !strings.HasSuffix( + strings.ToLower(fqdn), strings.ToLower("."+authZone)) { + return fmt.Errorf( + "GleSYS DNS: unexpected authZone %s for fqdn %s", authZone, fqdn) + } + name := fqdn[:len(fqdn)-len("."+authZone)] + // acquire lock and check there is not a challenge already in + // progress for this value of authZone + d.inProgressMu.Lock() + defer d.inProgressMu.Unlock() + // add TXT record into authZone + recordId, err := d.addTXTRecord(domain, acmev2.UnFqdn(authZone), name, value, ttl) + if err != nil { + return err + } + // save data necessary for CleanUp + d.activeRecords[fqdn] = recordId + return nil +} + +// CleanUp removes the TXT record matching the specified parameters. +func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { + fqdn, _, _ := acmev2.DNS01Record(domain, keyAuth) + // acquire lock and retrieve authZone + d.inProgressMu.Lock() + defer d.inProgressMu.Unlock() + if _, ok := d.activeRecords[fqdn]; !ok { + // if there is no cleanup information then just return + return nil + } + recordId := d.activeRecords[fqdn] + delete(d.activeRecords, fqdn) + // delete TXT record from authZone + err := d.deleteTXTRecord(domain, recordId) + if err != nil { + return err + } + return nil +} + +// Timeout returns the values (20*time.Minute, 20*time.Second) which +// are used by the acme package as timeout and check interval values +// when checking for DNS record propagation with GleSYS. +func (d *DNSProvider) Timeout() (timeout, interval time.Duration) { + return 20 * time.Minute, 20 * time.Second +} + +// types for JSON method calls, parameters, and responses + +type addRecordRequest struct { + Domainname string `json:"domainname"` + Host string `json:"host"` + Type string `json:"type"` + Data string `json:"data"` + Ttl int `json:"ttl,omitempty"` +} + +type deleteRecordRequest struct { + Recordid int `json:"recordid"` +} + +type responseStruct struct { + Response struct { + Status struct { + Code int `json:"code"` + } `json:"status"` + Record deleteRecordRequest `json:"record"` + } `json:"response"` +} + +// POSTing/Marshalling/Unmarshalling + +func (d *DNSProvider) sendRequest(method string, resource string, payload interface{}) (*responseStruct, error) { + url := fmt.Sprintf("%s/%s", domainAPI, resource) + + body, err := json.Marshal(payload) + if err != nil { + return nil, err + } + req, err := http.NewRequest(method, url, bytes.NewReader(body)) + if err != nil { + return nil, err + } + req.Header.Set("Content-Type", "application/json") + req.SetBasicAuth(d.apiUser, d.apiKey) + + client := &http.Client{Timeout: time.Duration(10 * time.Second)} + resp, err := client.Do(req) + if err != nil { + return nil, err + } + defer resp.Body.Close() + + if resp.StatusCode >= 400 { + return nil, fmt.Errorf("GleSYS DNS: request failed with HTTP status code %d", resp.StatusCode) + } + var response responseStruct + err = json.NewDecoder(resp.Body).Decode(&response) + + return &response, err +} + +// functions to perform API actions + +func (d *DNSProvider) addTXTRecord(fqdn string, domain string, name string, value string, ttl int) (int, error) { + response, err := d.sendRequest("POST", "addrecord", addRecordRequest{ + Domainname: domain, + Host: name, + Type: "TXT", + Data: value, + Ttl: ttl, + }) + if response != nil && response.Response.Status.Code == 200 { + logf("[INFO][%s] GleSYS DNS: Successfully created recordid %d", fqdn, response.Response.Record.Recordid) + return response.Response.Record.Recordid, nil + } + return 0, err +} + +func (d *DNSProvider) deleteTXTRecord(fqdn string, recordid int) error { + response, err := d.sendRequest("POST", "deleterecord", deleteRecordRequest{ + Recordid: recordid, + }) + if response != nil && response.Response.Status.Code == 200 { + logf("[INFO][%s] GleSYS DNS: Successfully deleted recordid %d", fqdn, recordid) + } + return err +} diff --git a/vendor/github.com/xenolf/lego/providers/dns/godaddy/godaddy.go b/vendor/github.com/xenolf/lego/providers/dns/godaddy/godaddy.go index 4112f6628..de55a9f22 100644 --- a/vendor/github.com/xenolf/lego/providers/dns/godaddy/godaddy.go +++ b/vendor/github.com/xenolf/lego/providers/dns/godaddy/godaddy.go @@ -10,15 +10,16 @@ import ( "bytes" "encoding/json" - "github.com/xenolf/lego/acme" "io/ioutil" "strings" + + "github.com/xenolf/lego/acmev2" ) // GoDaddyAPIURL represents the API endpoint to call. const apiURL = "https://api.godaddy.com" -// DNSProvider is an implementation of the acme.ChallengeProvider interface +// DNSProvider is an implementation of the acmev2.ChallengeProvider interface type DNSProvider struct { apiKey string apiSecret string @@ -50,7 +51,7 @@ func (c *DNSProvider) Timeout() (timeout, interval time.Duration) { } func (c *DNSProvider) extractRecordName(fqdn, domain string) string { - name := acme.UnFqdn(fqdn) + name := acmev2.UnFqdn(fqdn) if idx := strings.Index(name, "."+domain); idx != -1 { return name[:idx] } @@ -59,7 +60,7 @@ func (c *DNSProvider) extractRecordName(fqdn, domain string) string { // Present creates a TXT record to fulfil the dns-01 challenge func (c *DNSProvider) Present(domain, token, keyAuth string) error { - fqdn, value, ttl := acme.DNS01Record(domain, keyAuth) + fqdn, value, ttl := acmev2.DNS01Record(domain, keyAuth) domainZone, err := c.getZone(fqdn) if err != nil { return err @@ -105,7 +106,7 @@ func (c *DNSProvider) updateRecords(records []DNSRecord, domainZone string, reco // CleanUp sets null value in the TXT DNS record as GoDaddy has no proper DELETE record method func (c *DNSProvider) CleanUp(domain, token, keyAuth string) error { - fqdn, _, _ := acme.DNS01Record(domain, keyAuth) + fqdn, _, _ := acmev2.DNS01Record(domain, keyAuth) domainZone, err := c.getZone(fqdn) if err != nil { return err @@ -124,12 +125,12 @@ func (c *DNSProvider) CleanUp(domain, token, keyAuth string) error { } func (c *DNSProvider) getZone(fqdn string) (string, error) { - authZone, err := acme.FindZoneByFqdn(fqdn, acme.RecursiveNameservers) + authZone, err := acmev2.FindZoneByFqdn(fqdn, acmev2.RecursiveNameservers) if err != nil { return "", err } - return acme.UnFqdn(authZone), nil + return acmev2.UnFqdn(authZone), nil } func (c *DNSProvider) makeRequest(method, uri string, body io.Reader) (*http.Response, error) { diff --git a/vendor/github.com/xenolf/lego/providers/dns/googlecloud/googlecloud.go b/vendor/github.com/xenolf/lego/providers/dns/googlecloud/googlecloud.go index ba753f6dc..052c8dae5 100644 --- a/vendor/github.com/xenolf/lego/providers/dns/googlecloud/googlecloud.go +++ b/vendor/github.com/xenolf/lego/providers/dns/googlecloud/googlecloud.go @@ -8,7 +8,7 @@ import ( "os" "time" - "github.com/xenolf/lego/acme" + "github.com/xenolf/lego/acmev2" "golang.org/x/net/context" "golang.org/x/oauth2" @@ -88,7 +88,7 @@ func NewDNSProviderServiceAccount(project string, saFile string) (*DNSProvider, // Present creates a TXT record to fulfil the dns-01 challenge. func (c *DNSProvider) Present(domain, token, keyAuth string) error { - fqdn, value, ttl := acme.DNS01Record(domain, keyAuth) + fqdn, value, ttl := acmev2.DNS01Record(domain, keyAuth) zone, err := c.getHostedZone(domain) if err != nil { @@ -135,7 +135,7 @@ func (c *DNSProvider) Present(domain, token, keyAuth string) error { // CleanUp removes the TXT record matching the specified parameters. func (c *DNSProvider) CleanUp(domain, token, keyAuth string) error { - fqdn, _, _ := acme.DNS01Record(domain, keyAuth) + fqdn, _, _ := acmev2.DNS01Record(domain, keyAuth) zone, err := c.getHostedZone(domain) if err != nil { @@ -167,7 +167,7 @@ func (c *DNSProvider) Timeout() (timeout, interval time.Duration) { // getHostedZone returns the managed-zone func (c *DNSProvider) getHostedZone(domain string) (string, error) { - authZone, err := acme.FindZoneByFqdn(acme.ToFqdn(domain), acme.RecursiveNameservers) + authZone, err := acmev2.FindZoneByFqdn(acmev2.ToFqdn(domain), acmev2.RecursiveNameservers) if err != nil { return "", err } diff --git a/vendor/github.com/xenolf/lego/providers/dns/lightsail/lightsail.go b/vendor/github.com/xenolf/lego/providers/dns/lightsail/lightsail.go new file mode 100644 index 000000000..4bd709d13 --- /dev/null +++ b/vendor/github.com/xenolf/lego/providers/dns/lightsail/lightsail.go @@ -0,0 +1,107 @@ +// Package lightsail implements a DNS provider for solving the DNS-01 challenge +// using AWS Lightsail DNS. +package lightsail + +import ( + "math/rand" + "time" + + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/client" + "github.com/aws/aws-sdk-go/aws/request" + "github.com/aws/aws-sdk-go/aws/session" + "github.com/aws/aws-sdk-go/service/lightsail" + "github.com/xenolf/lego/acmev2" +) + +const ( + maxRetries = 5 +) + +// DNSProvider implements the acmev2.ChallengeProvider interface +type DNSProvider struct { + client *lightsail.Lightsail +} + +// customRetryer implements the client.Retryer interface by composing the +// DefaultRetryer. It controls the logic for retrying recoverable request +// errors (e.g. when rate limits are exceeded). +type customRetryer struct { + client.DefaultRetryer +} + +// RetryRules overwrites the DefaultRetryer's method. +// It uses a basic exponential backoff algorithm that returns an initial +// delay of ~400ms with an upper limit of ~30 seconds which should prevent +// causing a high number of consecutive throttling errors. +// For reference: Route 53 enforces an account-wide(!) 5req/s query limit. +func (d customRetryer) RetryRules(r *request.Request) time.Duration { + retryCount := r.RetryCount + if retryCount > 7 { + retryCount = 7 + } + + delay := (1 << uint(retryCount)) * (rand.Intn(50) + 200) + return time.Duration(delay) * time.Millisecond +} + +// NewDNSProvider returns a DNSProvider instance configured for the AWS +// Lightsail service. +// +// AWS Credentials are automatically detected in the following locations +// and prioritized in the following order: +// 1. Environment variables: AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, +// [AWS_SESSION_TOKEN], [DNS_ZONE] +// 2. Shared credentials file (defaults to ~/.aws/credentials) +// 3. Amazon EC2 IAM role +// +// public hosted zone via the FQDN. +// +// See also: https://github.com/aws/aws-sdk-go/wiki/configuring-sdk +func NewDNSProvider() (*DNSProvider, error) { + r := customRetryer{} + r.NumMaxRetries = maxRetries + config := request.WithRetryer(aws.NewConfig(), r) + client := lightsail.New(session.New(config)) + + return &DNSProvider{ + client: client, + }, nil +} + +// Present creates a TXT record using the specified parameters +func (r *DNSProvider) Present(domain, token, keyAuth string) error { + fqdn, value, _ := acmev2.DNS01Record(domain, keyAuth) + value = `"` + value + `"` + err := r.newTxtRecord(domain, fqdn, value) + return err +} + +// CleanUp removes the TXT record matching the specified parameters +func (r *DNSProvider) CleanUp(domain, token, keyAuth string) error { + fqdn, value, _ := acmev2.DNS01Record(domain, keyAuth) + value = `"` + value + `"` + params := &lightsail.DeleteDomainEntryInput{ + DomainName: aws.String(domain), + DomainEntry: &lightsail.DomainEntry{ + Name: aws.String(fqdn), + Type: aws.String("TXT"), + Target: aws.String(value), + }, + } + _, err := r.client.DeleteDomainEntry(params) + return err +} + +func (r *DNSProvider) newTxtRecord(domain string, fqdn string, value string) error { + params := &lightsail.CreateDomainEntryInput{ + DomainName: aws.String(domain), + DomainEntry: &lightsail.DomainEntry{ + Name: aws.String(fqdn), + Target: aws.String(value), + Type: aws.String("TXT"), + }, + } + _, err := r.client.CreateDomainEntry(params) + return err +} diff --git a/vendor/github.com/xenolf/lego/providers/dns/linode/linode.go b/vendor/github.com/xenolf/lego/providers/dns/linode/linode.go index a91d2b489..4c6345ac7 100644 --- a/vendor/github.com/xenolf/lego/providers/dns/linode/linode.go +++ b/vendor/github.com/xenolf/lego/providers/dns/linode/linode.go @@ -9,7 +9,7 @@ import ( "time" "github.com/timewasted/linode/dns" - "github.com/xenolf/lego/acme" + "github.com/xenolf/lego/acmev2" ) const ( @@ -23,7 +23,7 @@ type hostedZoneInfo struct { resourceName string } -// DNSProvider implements the acme.ChallengeProvider interface. +// DNSProvider implements the acmev2.ChallengeProvider interface. type DNSProvider struct { linode *dns.DNS } @@ -66,13 +66,13 @@ func (p *DNSProvider) Timeout() (timeout, interval time.Duration) { // Present creates a TXT record using the specified parameters. func (p *DNSProvider) Present(domain, token, keyAuth string) error { - fqdn, value, _ := acme.DNS01Record(domain, keyAuth) + fqdn, value, _ := acmev2.DNS01Record(domain, keyAuth) zone, err := p.getHostedZoneInfo(fqdn) if err != nil { return err } - if _, err = p.linode.CreateDomainResourceTXT(zone.domainId, acme.UnFqdn(fqdn), value, 60); err != nil { + if _, err = p.linode.CreateDomainResourceTXT(zone.domainId, acmev2.UnFqdn(fqdn), value, 60); err != nil { return err } @@ -81,7 +81,7 @@ func (p *DNSProvider) Present(domain, token, keyAuth string) error { // CleanUp removes the TXT record matching the specified parameters. func (p *DNSProvider) CleanUp(domain, token, keyAuth string) error { - fqdn, value, _ := acme.DNS01Record(domain, keyAuth) + fqdn, value, _ := acmev2.DNS01Record(domain, keyAuth) zone, err := p.getHostedZoneInfo(fqdn) if err != nil { return err @@ -112,14 +112,14 @@ func (p *DNSProvider) CleanUp(domain, token, keyAuth string) error { func (p *DNSProvider) getHostedZoneInfo(fqdn string) (*hostedZoneInfo, error) { // Lookup the zone that handles the specified FQDN. - authZone, err := acme.FindZoneByFqdn(fqdn, acme.RecursiveNameservers) + authZone, err := acmev2.FindZoneByFqdn(fqdn, acmev2.RecursiveNameservers) if err != nil { return nil, err } resourceName := strings.TrimSuffix(fqdn, "."+authZone) // Query the authority zone. - domain, err := p.linode.GetDomain(acme.UnFqdn(authZone)) + domain, err := p.linode.GetDomain(acmev2.UnFqdn(authZone)) if err != nil { return nil, err } diff --git a/vendor/github.com/xenolf/lego/providers/dns/namecheap/namecheap.go b/vendor/github.com/xenolf/lego/providers/dns/namecheap/namecheap.go index d7eb40935..f21bfeeb3 100644 --- a/vendor/github.com/xenolf/lego/providers/dns/namecheap/namecheap.go +++ b/vendor/github.com/xenolf/lego/providers/dns/namecheap/namecheap.go @@ -12,7 +12,7 @@ import ( "strings" "time" - "github.com/xenolf/lego/acme" + "github.com/xenolf/lego/acmev2" ) // Notes about namecheap's tool API: @@ -132,7 +132,7 @@ type challenge struct { // newChallenge builds a challenge record from a domain name, a challenge // authentication key, and a map of available TLDs. func newChallenge(domain, keyAuth string, tlds map[string]string) (*challenge, error) { - domain = acme.UnFqdn(domain) + domain = acmev2.UnFqdn(domain) parts := strings.Split(domain, ".") // Find the longest matching TLD. @@ -155,7 +155,7 @@ func newChallenge(domain, keyAuth string, tlds map[string]string) (*challenge, e host = strings.Join(parts[:longest-1], ".") } - key, keyValue, _ := acme.DNS01Record(domain, keyAuth) + key, keyValue, _ := acmev2.DNS01Record(domain, keyAuth) return &challenge{ domain: domain, diff --git a/vendor/github.com/xenolf/lego/providers/dns/namedotcom/namedotcom.go b/vendor/github.com/xenolf/lego/providers/dns/namedotcom/namedotcom.go new file mode 100644 index 000000000..0bd3a43ee --- /dev/null +++ b/vendor/github.com/xenolf/lego/providers/dns/namedotcom/namedotcom.go @@ -0,0 +1,124 @@ +// Package namedotcom implements a DNS provider for solving the DNS-01 challenge +// using Name.com's DNS service. +package namedotcom + +import ( + "fmt" + "os" + "strings" + + "github.com/namedotcom/go/namecom" + "github.com/xenolf/lego/acmev2" +) + +// DNSProvider is an implementation of the acmev2.ChallengeProvider interface. +type DNSProvider struct { + client *namecom.NameCom +} + +// NewDNSProvider returns a DNSProvider instance configured for namedotcom. +// Credentials must be passed in the environment variables: NAMECOM_USERNAME and NAMECOM_API_TOKEN +func NewDNSProvider() (*DNSProvider, error) { + username := os.Getenv("NAMECOM_USERNAME") + apiToken := os.Getenv("NAMECOM_API_TOKEN") + server := os.Getenv("NAMECOM_SERVER") + + return NewDNSProviderCredentials(username, apiToken, server) +} + +// NewDNSProviderCredentials uses the supplied credentials to return a +// DNSProvider instance configured for namedotcom. +func NewDNSProviderCredentials(username, apiToken, server string) (*DNSProvider, error) { + if username == "" { + return nil, fmt.Errorf("Name.com Username is required") + } + if apiToken == "" { + return nil, fmt.Errorf("Name.com API token is required") + } + + client := namecom.New(username, apiToken) + + if server != "" { + client.Server = server + } + + return &DNSProvider{client: client}, nil +} + +// Present creates a TXT record to fulfil the dns-01 challenge. +func (c *DNSProvider) Present(domain, token, keyAuth string) error { + fqdn, value, ttl := acmev2.DNS01Record(domain, keyAuth) + + request := &namecom.Record{ + DomainName: domain, + Host: c.extractRecordName(fqdn, domain), + Type: "TXT", + TTL: uint32(ttl), + Answer: value, + } + + _, err := c.client.CreateRecord(request) + if err != nil { + return fmt.Errorf("namedotcom API call failed: %v", err) + } + + return nil +} + +// CleanUp removes the TXT record matching the specified parameters. +func (c *DNSProvider) CleanUp(domain, token, keyAuth string) error { + fqdn, _, _ := acmev2.DNS01Record(domain, keyAuth) + + records, err := c.getRecords(domain) + if err != nil { + return err + } + + for _, rec := range records { + if rec.Fqdn == fqdn && rec.Type == "TXT" { + request := &namecom.DeleteRecordRequest{ + DomainName: domain, + ID: rec.ID, + } + _, err := c.client.DeleteRecord(request) + if err != nil { + return err + } + } + } + + return nil +} + +func (c *DNSProvider) getRecords(domain string) ([]*namecom.Record, error) { + var ( + err error + records []*namecom.Record + response *namecom.ListRecordsResponse + ) + + request := &namecom.ListRecordsRequest{ + DomainName: domain, + Page: 1, + } + + for request.Page > 0 { + response, err = c.client.ListRecords(request) + if err != nil { + return nil, err + } + + records = append(records, response.Records...) + request.Page = response.NextPage + } + + return records, nil +} + +func (c *DNSProvider) extractRecordName(fqdn, domain string) string { + name := acmev2.UnFqdn(fqdn) + if idx := strings.Index(name, "."+domain); idx != -1 { + return name[:idx] + } + return name +} diff --git a/vendor/github.com/xenolf/lego/providers/dns/ns1/ns1.go b/vendor/github.com/xenolf/lego/providers/dns/ns1/ns1.go index 105d73f89..d7afcfc89 100644 --- a/vendor/github.com/xenolf/lego/providers/dns/ns1/ns1.go +++ b/vendor/github.com/xenolf/lego/providers/dns/ns1/ns1.go @@ -8,12 +8,12 @@ import ( "os" "time" - "github.com/xenolf/lego/acme" + "github.com/xenolf/lego/acmev2" "gopkg.in/ns1/ns1-go.v2/rest" "gopkg.in/ns1/ns1-go.v2/rest/model/dns" ) -// DNSProvider is an implementation of the acme.ChallengeProvider interface. +// DNSProvider is an implementation of the acmev2.ChallengeProvider interface. type DNSProvider struct { client *rest.Client } @@ -43,7 +43,7 @@ func NewDNSProviderCredentials(key string) (*DNSProvider, error) { // Present creates a TXT record to fulfil the dns-01 challenge. func (c *DNSProvider) Present(domain, token, keyAuth string) error { - fqdn, value, ttl := acme.DNS01Record(domain, keyAuth) + fqdn, value, ttl := acmev2.DNS01Record(domain, keyAuth) zone, err := c.getHostedZone(domain) if err != nil { @@ -61,14 +61,14 @@ func (c *DNSProvider) Present(domain, token, keyAuth string) error { // CleanUp removes the TXT record matching the specified parameters. func (c *DNSProvider) CleanUp(domain, token, keyAuth string) error { - fqdn, _, _ := acme.DNS01Record(domain, keyAuth) + fqdn, _, _ := acmev2.DNS01Record(domain, keyAuth) zone, err := c.getHostedZone(domain) if err != nil { return err } - name := acme.UnFqdn(fqdn) + name := acmev2.UnFqdn(fqdn) _, err = c.client.Records.Delete(zone.Zone, name, "TXT") return err } @@ -83,7 +83,7 @@ func (c *DNSProvider) getHostedZone(domain string) (*dns.Zone, error) { } func (c *DNSProvider) newTxtRecord(zone *dns.Zone, fqdn, value string, ttl int) *dns.Record { - name := acme.UnFqdn(fqdn) + name := acmev2.UnFqdn(fqdn) return &dns.Record{ Type: "TXT", diff --git a/vendor/github.com/xenolf/lego/providers/dns/otc/otc.go b/vendor/github.com/xenolf/lego/providers/dns/otc/otc.go index 86bcaa9b7..8b243d624 100644 --- a/vendor/github.com/xenolf/lego/providers/dns/otc/otc.go +++ b/vendor/github.com/xenolf/lego/providers/dns/otc/otc.go @@ -12,10 +12,10 @@ import ( "os" "time" - "github.com/xenolf/lego/acme" + "github.com/xenolf/lego/acmev2" ) -// DNSProvider is an implementation of the acme.ChallengeProvider interface that uses +// DNSProvider is an implementation of the acmev2.ChallengeProvider interface that uses // OTC's Managed DNS API to manage TXT records for a domain. type DNSProvider struct { identityEndpoint string @@ -313,13 +313,13 @@ func (d *DNSProvider) deleteRecordSet(zoneID, recordID string) error { // Present creates a TXT record using the specified parameters func (d *DNSProvider) Present(domain, token, keyAuth string) error { - fqdn, value, ttl := acme.DNS01Record(domain, keyAuth) + fqdn, value, ttl := acmev2.DNS01Record(domain, keyAuth) if ttl < 300 { ttl = 300 // 300 is otc minimum value for ttl } - authZone, err := acme.FindZoneByFqdn(fqdn, acme.RecursiveNameservers) + authZone, err := acmev2.FindZoneByFqdn(fqdn, acmev2.RecursiveNameservers) if err != nil { return err } @@ -362,9 +362,9 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error { // CleanUp removes the TXT record matching the specified parameters func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { - fqdn, _, _ := acme.DNS01Record(domain, keyAuth) + fqdn, _, _ := acmev2.DNS01Record(domain, keyAuth) - authZone, err := acme.FindZoneByFqdn(fqdn, acme.RecursiveNameservers) + authZone, err := acmev2.FindZoneByFqdn(fqdn, acmev2.RecursiveNameservers) if err != nil { return err } diff --git a/vendor/github.com/xenolf/lego/providers/dns/ovh/ovh.go b/vendor/github.com/xenolf/lego/providers/dns/ovh/ovh.go index 290a8d7df..417de2e2c 100644 --- a/vendor/github.com/xenolf/lego/providers/dns/ovh/ovh.go +++ b/vendor/github.com/xenolf/lego/providers/dns/ovh/ovh.go @@ -9,13 +9,13 @@ import ( "sync" "github.com/ovh/go-ovh/ovh" - "github.com/xenolf/lego/acme" + "github.com/xenolf/lego/acmev2" ) // OVH API reference: https://eu.api.ovh.com/ // Create a Token: https://eu.api.ovh.com/createToken/ -// DNSProvider is an implementation of the acme.ChallengeProvider interface +// DNSProvider is an implementation of the acmev2.ChallengeProvider interface // that uses OVH's REST API to manage TXT records for a domain. type DNSProvider struct { client *ovh.Client @@ -78,15 +78,15 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error { Zone string `json:"zone"` } - fqdn, value, ttl := acme.DNS01Record(domain, keyAuth) + fqdn, value, ttl := acmev2.DNS01Record(domain, keyAuth) // Parse domain name - authZone, err := acme.FindZoneByFqdn(acme.ToFqdn(domain), acme.RecursiveNameservers) + authZone, err := acmev2.FindZoneByFqdn(acmev2.ToFqdn(domain), acmev2.RecursiveNameservers) if err != nil { return fmt.Errorf("Could not determine zone for domain: '%s'. %s", domain, err) } - authZone = acme.UnFqdn(authZone) + authZone = acmev2.UnFqdn(authZone) subDomain := d.extractRecordName(fqdn, authZone) reqURL := fmt.Sprintf("/domain/zone/%s/record", authZone) @@ -117,7 +117,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error { // CleanUp removes the TXT record matching the specified parameters func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { - fqdn, _, _ := acme.DNS01Record(domain, keyAuth) + fqdn, _, _ := acmev2.DNS01Record(domain, keyAuth) // get the record's unique ID from when we created it d.recordIDsMu.Lock() @@ -127,12 +127,12 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { return fmt.Errorf("unknown record ID for '%s'", fqdn) } - authZone, err := acme.FindZoneByFqdn(acme.ToFqdn(domain), acme.RecursiveNameservers) + authZone, err := acmev2.FindZoneByFqdn(acmev2.ToFqdn(domain), acmev2.RecursiveNameservers) if err != nil { return fmt.Errorf("Could not determine zone for domain: '%s'. %s", domain, err) } - authZone = acme.UnFqdn(authZone) + authZone = acmev2.UnFqdn(authZone) reqURL := fmt.Sprintf("/domain/zone/%s/record/%d", authZone, recordID) @@ -151,7 +151,7 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { } func (d *DNSProvider) extractRecordName(fqdn, domain string) string { - name := acme.UnFqdn(fqdn) + name := acmev2.UnFqdn(fqdn) if idx := strings.Index(name, "."+domain); idx != -1 { return name[:idx] } diff --git a/vendor/github.com/xenolf/lego/providers/dns/pdns/pdns.go b/vendor/github.com/xenolf/lego/providers/dns/pdns/pdns.go index a7856e6d0..0ce84c6b9 100644 --- a/vendor/github.com/xenolf/lego/providers/dns/pdns/pdns.go +++ b/vendor/github.com/xenolf/lego/providers/dns/pdns/pdns.go @@ -14,10 +14,10 @@ import ( "strings" "time" - "github.com/xenolf/lego/acme" + "github.com/xenolf/lego/acmev2" ) -// DNSProvider is an implementation of the acme.ChallengeProvider interface +// DNSProvider is an implementation of the acmev2.ChallengeProvider interface type DNSProvider struct { apiKey string host *url.URL @@ -65,7 +65,7 @@ func (c *DNSProvider) Timeout() (timeout, interval time.Duration) { // Present creates a TXT record to fulfil the dns-01 challenge func (c *DNSProvider) Present(domain, token, keyAuth string) error { - fqdn, value, _ := acme.DNS01Record(domain, keyAuth) + fqdn, value, _ := acmev2.DNS01Record(domain, keyAuth) zone, err := c.getHostedZone(fqdn) if err != nil { return err @@ -75,7 +75,7 @@ func (c *DNSProvider) Present(domain, token, keyAuth string) error { // pre-v1 API wants non-fqdn if c.apiVersion == 0 { - name = acme.UnFqdn(fqdn) + name = acmev2.UnFqdn(fqdn) } rec := pdnsRecord{ @@ -117,7 +117,7 @@ func (c *DNSProvider) Present(domain, token, keyAuth string) error { // CleanUp removes the TXT record matching the specified parameters func (c *DNSProvider) CleanUp(domain, token, keyAuth string) error { - fqdn, _, _ := acme.DNS01Record(domain, keyAuth) + fqdn, _, _ := acmev2.DNS01Record(domain, keyAuth) zone, err := c.getHostedZone(fqdn) if err != nil { @@ -153,7 +153,7 @@ func (c *DNSProvider) CleanUp(domain, token, keyAuth string) error { func (c *DNSProvider) getHostedZone(fqdn string) (*hostedZone, error) { var zone hostedZone - authZone, err := acme.FindZoneByFqdn(fqdn, acme.RecursiveNameservers) + authZone, err := acmev2.FindZoneByFqdn(fqdn, acmev2.RecursiveNameservers) if err != nil { return nil, err } @@ -172,7 +172,7 @@ func (c *DNSProvider) getHostedZone(fqdn string) (*hostedZone, error) { url = "" for _, zone := range zones { - if acme.UnFqdn(zone.Name) == acme.UnFqdn(authZone) { + if acmev2.UnFqdn(zone.Name) == acmev2.UnFqdn(authZone) { url = zone.URL } } @@ -215,7 +215,7 @@ func (c *DNSProvider) findTxtRecord(fqdn string) (*rrSet, error) { } for _, set := range zone.RRSets { - if (set.Name == acme.UnFqdn(fqdn) || set.Name == fqdn) && set.Type == "TXT" { + if (set.Name == acmev2.UnFqdn(fqdn) || set.Name == fqdn) && set.Type == "TXT" { return &set, nil } } diff --git a/vendor/github.com/xenolf/lego/providers/dns/rackspace/rackspace.go b/vendor/github.com/xenolf/lego/providers/dns/rackspace/rackspace.go index 13daa8c8a..97a2bc9c9 100644 --- a/vendor/github.com/xenolf/lego/providers/dns/rackspace/rackspace.go +++ b/vendor/github.com/xenolf/lego/providers/dns/rackspace/rackspace.go @@ -11,13 +11,13 @@ import ( "os" "time" - "github.com/xenolf/lego/acme" + "github.com/xenolf/lego/acmev2" ) // rackspaceAPIURL represents the Identity API endpoint to call var rackspaceAPIURL = "https://identity.api.rackspacecloud.com/v2.0/tokens" -// DNSProvider is an implementation of the acme.ChallengeProvider interface +// DNSProvider is an implementation of the acmev2.ChallengeProvider interface // used to store the reusable token and DNS API endpoint type DNSProvider struct { token string @@ -126,7 +126,7 @@ func NewDNSProviderCredentials(user, key string) (*DNSProvider, error) { // Present creates a TXT record to fulfil the dns-01 challenge func (c *DNSProvider) Present(domain, token, keyAuth string) error { - fqdn, value, _ := acme.DNS01Record(domain, keyAuth) + fqdn, value, _ := acmev2.DNS01Record(domain, keyAuth) zoneID, err := c.getHostedZoneID(fqdn) if err != nil { return err @@ -134,7 +134,7 @@ func (c *DNSProvider) Present(domain, token, keyAuth string) error { rec := RackspaceRecords{ RackspaceRecord: []RackspaceRecord{{ - Name: acme.UnFqdn(fqdn), + Name: acmev2.UnFqdn(fqdn), Type: "TXT", Data: value, TTL: 300, @@ -156,7 +156,7 @@ func (c *DNSProvider) Present(domain, token, keyAuth string) error { // CleanUp removes the TXT record matching the specified parameters func (c *DNSProvider) CleanUp(domain, token, keyAuth string) error { - fqdn, _, _ := acme.DNS01Record(domain, keyAuth) + fqdn, _, _ := acmev2.DNS01Record(domain, keyAuth) zoneID, err := c.getHostedZoneID(fqdn) if err != nil { return err @@ -187,12 +187,12 @@ func (c *DNSProvider) getHostedZoneID(fqdn string) (int, error) { } `json:"domains"` } - authZone, err := acme.FindZoneByFqdn(fqdn, acme.RecursiveNameservers) + authZone, err := acmev2.FindZoneByFqdn(fqdn, acmev2.RecursiveNameservers) if err != nil { return 0, err } - result, err := c.makeRequest("GET", fmt.Sprintf("/domains?name=%s", acme.UnFqdn(authZone)), nil) + result, err := c.makeRequest("GET", fmt.Sprintf("/domains?name=%s", acmev2.UnFqdn(authZone)), nil) if err != nil { return 0, err } @@ -213,7 +213,7 @@ func (c *DNSProvider) getHostedZoneID(fqdn string) (int, error) { // findTxtRecord searches a DNS zone for a TXT record with a specific name func (c *DNSProvider) findTxtRecord(fqdn string, zoneID int) (*RackspaceRecord, error) { - result, err := c.makeRequest("GET", fmt.Sprintf("/domains/%d/records?type=TXT&name=%s", zoneID, acme.UnFqdn(fqdn)), nil) + result, err := c.makeRequest("GET", fmt.Sprintf("/domains/%d/records?type=TXT&name=%s", zoneID, acmev2.UnFqdn(fqdn)), nil) if err != nil { return nil, err } diff --git a/vendor/github.com/xenolf/lego/providers/dns/rfc2136/rfc2136.go b/vendor/github.com/xenolf/lego/providers/dns/rfc2136/rfc2136.go index dde42ddf1..c185de162 100644 --- a/vendor/github.com/xenolf/lego/providers/dns/rfc2136/rfc2136.go +++ b/vendor/github.com/xenolf/lego/providers/dns/rfc2136/rfc2136.go @@ -10,10 +10,10 @@ import ( "time" "github.com/miekg/dns" - "github.com/xenolf/lego/acme" + "github.com/xenolf/lego/acmev2" ) -// DNSProvider is an implementation of the acme.ChallengeProvider interface that +// DNSProvider is an implementation of the acmev2.ChallengeProvider interface that // uses dynamic DNS updates (RFC 2136) to create TXT records on a nameserver. type DNSProvider struct { nameserver string @@ -27,7 +27,7 @@ type DNSProvider struct { // dynamic update. Configured with environment variables: // RFC2136_NAMESERVER: Network address in the form "host" or "host:port". // RFC2136_TSIG_ALGORITHM: Defaults to hmac-md5.sig-alg.reg.int. (HMAC-MD5). -// See https://github.com/miekg/dns/blob/master/tsig.go for supported values. +// See https://github.com/miekg/dns/blob/master/tsig.go for supported values. // RFC2136_TSIG_KEY: Name of the secret key as defined in DNS server configuration. // RFC2136_TSIG_SECRET: Secret key payload. // RFC2136_TIMEOUT: DNS propagation timeout in time.ParseDuration format. (60s) @@ -88,24 +88,24 @@ func NewDNSProviderCredentials(nameserver, tsigAlgorithm, tsigKey, tsigSecret, t // Returns the timeout configured with RFC2136_TIMEOUT, or 60s. func (d *DNSProvider) Timeout() (timeout, interval time.Duration) { - return d.timeout, 2 * time.Second + return d.timeout, 2 * time.Second } // Present creates a TXT record using the specified parameters func (r *DNSProvider) Present(domain, token, keyAuth string) error { - fqdn, value, ttl := acme.DNS01Record(domain, keyAuth) + fqdn, value, ttl := acmev2.DNS01Record(domain, keyAuth) return r.changeRecord("INSERT", fqdn, value, ttl) } // CleanUp removes the TXT record matching the specified parameters func (r *DNSProvider) CleanUp(domain, token, keyAuth string) error { - fqdn, value, ttl := acme.DNS01Record(domain, keyAuth) + fqdn, value, ttl := acmev2.DNS01Record(domain, keyAuth) return r.changeRecord("REMOVE", fqdn, value, ttl) } func (r *DNSProvider) changeRecord(action, fqdn, value string, ttl int) error { // Find the zone for the given fqdn - zone, err := acme.FindZoneByFqdn(fqdn, []string{r.nameserver}) + zone, err := acmev2.FindZoneByFqdn(fqdn, []string{r.nameserver}) if err != nil { return err } diff --git a/vendor/github.com/xenolf/lego/providers/dns/route53/route53.go b/vendor/github.com/xenolf/lego/providers/dns/route53/route53.go index 934f0a2d4..82d13cef1 100644 --- a/vendor/github.com/xenolf/lego/providers/dns/route53/route53.go +++ b/vendor/github.com/xenolf/lego/providers/dns/route53/route53.go @@ -14,7 +14,7 @@ import ( "github.com/aws/aws-sdk-go/aws/request" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/route53" - "github.com/xenolf/lego/acme" + "github.com/xenolf/lego/acmev2" ) const ( @@ -22,7 +22,7 @@ const ( route53TTL = 10 ) -// DNSProvider implements the acme.ChallengeProvider interface +// DNSProvider implements the acmev2.ChallengeProvider interface type DNSProvider struct { client *route53.Route53 hostedZoneID string @@ -80,14 +80,14 @@ func NewDNSProvider() (*DNSProvider, error) { // Present creates a TXT record using the specified parameters func (r *DNSProvider) Present(domain, token, keyAuth string) error { - fqdn, value, _ := acme.DNS01Record(domain, keyAuth) + fqdn, value, _ := acmev2.DNS01Record(domain, keyAuth) value = `"` + value + `"` return r.changeRecord("UPSERT", fqdn, value, route53TTL) } // CleanUp removes the TXT record matching the specified parameters func (r *DNSProvider) CleanUp(domain, token, keyAuth string) error { - fqdn, value, _ := acme.DNS01Record(domain, keyAuth) + fqdn, value, _ := acmev2.DNS01Record(domain, keyAuth) value = `"` + value + `"` return r.changeRecord("DELETE", fqdn, value, route53TTL) } @@ -119,7 +119,7 @@ func (r *DNSProvider) changeRecord(action, fqdn, value string, ttl int) error { statusID := resp.ChangeInfo.Id - return acme.WaitFor(120*time.Second, 4*time.Second, func() (bool, error) { + return acmev2.WaitFor(120*time.Second, 4*time.Second, func() (bool, error) { reqParams := &route53.GetChangeInput{ Id: statusID, } @@ -139,14 +139,14 @@ func (r *DNSProvider) getHostedZoneID(fqdn string) (string, error) { return r.hostedZoneID, nil } - authZone, err := acme.FindZoneByFqdn(fqdn, acme.RecursiveNameservers) + authZone, err := acmev2.FindZoneByFqdn(fqdn, acmev2.RecursiveNameservers) if err != nil { return "", err } // .DNSName should not have a trailing dot reqParams := &route53.ListHostedZonesByNameInput{ - DNSName: aws.String(acme.UnFqdn(authZone)), + DNSName: aws.String(acmev2.UnFqdn(authZone)), } resp, err := r.client.ListHostedZonesByName(reqParams) if err != nil { diff --git a/vendor/github.com/xenolf/lego/providers/dns/vultr/vultr.go b/vendor/github.com/xenolf/lego/providers/dns/vultr/vultr.go index bc2067579..6e0633264 100644 --- a/vendor/github.com/xenolf/lego/providers/dns/vultr/vultr.go +++ b/vendor/github.com/xenolf/lego/providers/dns/vultr/vultr.go @@ -9,10 +9,10 @@ import ( "strings" vultr "github.com/JamesClonk/vultr/lib" - "github.com/xenolf/lego/acme" + "github.com/xenolf/lego/acmev2" ) -// DNSProvider is an implementation of the acme.ChallengeProvider interface. +// DNSProvider is an implementation of the acmev2.ChallengeProvider interface. type DNSProvider struct { client *vultr.Client } @@ -40,7 +40,7 @@ func NewDNSProviderCredentials(apiKey string) (*DNSProvider, error) { // Present creates a TXT record to fulfil the DNS-01 challenge. func (c *DNSProvider) Present(domain, token, keyAuth string) error { - fqdn, value, ttl := acme.DNS01Record(domain, keyAuth) + fqdn, value, ttl := acmev2.DNS01Record(domain, keyAuth) zoneDomain, err := c.getHostedZone(domain) if err != nil { @@ -59,7 +59,7 @@ func (c *DNSProvider) Present(domain, token, keyAuth string) error { // CleanUp removes the TXT record matching the specified parameters. func (c *DNSProvider) CleanUp(domain, token, keyAuth string) error { - fqdn, _, _ := acme.DNS01Record(domain, keyAuth) + fqdn, _, _ := acmev2.DNS01Record(domain, keyAuth) zoneDomain, records, err := c.findTxtRecords(domain, fqdn) if err != nil { @@ -119,7 +119,7 @@ func (c *DNSProvider) findTxtRecords(domain, fqdn string) (string, []vultr.DNSRe } func (c *DNSProvider) extractRecordName(fqdn, domain string) string { - name := acme.UnFqdn(fqdn) + name := acmev2.UnFqdn(fqdn) if idx := strings.Index(name, "."+domain); idx != -1 { return name[:idx] } diff --git a/vendor/gopkg.in/mattes/go-expand-tilde.v1/tilde.go b/vendor/gopkg.in/mattes/go-expand-tilde.v1/tilde.go new file mode 100644 index 000000000..f3bed6090 --- /dev/null +++ b/vendor/gopkg.in/mattes/go-expand-tilde.v1/tilde.go @@ -0,0 +1,46 @@ +package tilde + +import ( + "errors" + "os" + "path/filepath" + "runtime" + "strings" +) + +var ( + ErrNoHome = errors.New("no home found") +) + +func Expand(path string) (string, error) { + if !strings.HasPrefix(path, "~") { + return path, nil + } + + home, err := Home() + if err != nil { + return "", err + } + + return home + path[1:], nil +} + +func Home() (string, error) { + home := "" + + switch runtime.GOOS { + case "windows": + home = filepath.Join(os.Getenv("HomeDrive"), os.Getenv("HomePath")) + if home == "" { + home = os.Getenv("UserProfile") + } + + default: + home = os.Getenv("HOME") + } + + if home == "" { + return "", ErrNoHome + } + return home, nil +} diff --git a/vendor/gopkg.in/square/go-jose.v1/asymmetric.go b/vendor/gopkg.in/square/go-jose.v1/asymmetric.go deleted file mode 100644 index cd36c21da..000000000 --- a/vendor/gopkg.in/square/go-jose.v1/asymmetric.go +++ /dev/null @@ -1,520 +0,0 @@ -/*- - * Copyright 2014 Square Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package jose - -import ( - "crypto" - "crypto/aes" - "crypto/ecdsa" - "crypto/rand" - "crypto/rsa" - "crypto/sha1" - "crypto/sha256" - "errors" - "fmt" - "math/big" - - "gopkg.in/square/go-jose.v1/cipher" -) - -// A generic RSA-based encrypter/verifier -type rsaEncrypterVerifier struct { - publicKey *rsa.PublicKey -} - -// A generic RSA-based decrypter/signer -type rsaDecrypterSigner struct { - privateKey *rsa.PrivateKey -} - -// A generic EC-based encrypter/verifier -type ecEncrypterVerifier struct { - publicKey *ecdsa.PublicKey -} - -// A key generator for ECDH-ES -type ecKeyGenerator struct { - size int - algID string - publicKey *ecdsa.PublicKey -} - -// A generic EC-based decrypter/signer -type ecDecrypterSigner struct { - privateKey *ecdsa.PrivateKey -} - -// newRSARecipient creates recipientKeyInfo based on the given key. -func newRSARecipient(keyAlg KeyAlgorithm, publicKey *rsa.PublicKey) (recipientKeyInfo, error) { - // Verify that key management algorithm is supported by this encrypter - switch keyAlg { - case RSA1_5, RSA_OAEP, RSA_OAEP_256: - default: - return recipientKeyInfo{}, ErrUnsupportedAlgorithm - } - - if publicKey == nil { - return recipientKeyInfo{}, errors.New("invalid public key") - } - - return recipientKeyInfo{ - keyAlg: keyAlg, - keyEncrypter: &rsaEncrypterVerifier{ - publicKey: publicKey, - }, - }, nil -} - -// newRSASigner creates a recipientSigInfo based on the given key. -func newRSASigner(sigAlg SignatureAlgorithm, privateKey *rsa.PrivateKey) (recipientSigInfo, error) { - // Verify that key management algorithm is supported by this encrypter - switch sigAlg { - case RS256, RS384, RS512, PS256, PS384, PS512: - default: - return recipientSigInfo{}, ErrUnsupportedAlgorithm - } - - if privateKey == nil { - return recipientSigInfo{}, errors.New("invalid private key") - } - - return recipientSigInfo{ - sigAlg: sigAlg, - publicKey: &JsonWebKey{ - Key: &privateKey.PublicKey, - }, - signer: &rsaDecrypterSigner{ - privateKey: privateKey, - }, - }, nil -} - -// newECDHRecipient creates recipientKeyInfo based on the given key. -func newECDHRecipient(keyAlg KeyAlgorithm, publicKey *ecdsa.PublicKey) (recipientKeyInfo, error) { - // Verify that key management algorithm is supported by this encrypter - switch keyAlg { - case ECDH_ES, ECDH_ES_A128KW, ECDH_ES_A192KW, ECDH_ES_A256KW: - default: - return recipientKeyInfo{}, ErrUnsupportedAlgorithm - } - - if publicKey == nil || !publicKey.Curve.IsOnCurve(publicKey.X, publicKey.Y) { - return recipientKeyInfo{}, errors.New("invalid public key") - } - - return recipientKeyInfo{ - keyAlg: keyAlg, - keyEncrypter: &ecEncrypterVerifier{ - publicKey: publicKey, - }, - }, nil -} - -// newECDSASigner creates a recipientSigInfo based on the given key. -func newECDSASigner(sigAlg SignatureAlgorithm, privateKey *ecdsa.PrivateKey) (recipientSigInfo, error) { - // Verify that key management algorithm is supported by this encrypter - switch sigAlg { - case ES256, ES384, ES512: - default: - return recipientSigInfo{}, ErrUnsupportedAlgorithm - } - - if privateKey == nil { - return recipientSigInfo{}, errors.New("invalid private key") - } - - return recipientSigInfo{ - sigAlg: sigAlg, - publicKey: &JsonWebKey{ - Key: &privateKey.PublicKey, - }, - signer: &ecDecrypterSigner{ - privateKey: privateKey, - }, - }, nil -} - -// Encrypt the given payload and update the object. -func (ctx rsaEncrypterVerifier) encryptKey(cek []byte, alg KeyAlgorithm) (recipientInfo, error) { - encryptedKey, err := ctx.encrypt(cek, alg) - if err != nil { - return recipientInfo{}, err - } - - return recipientInfo{ - encryptedKey: encryptedKey, - header: &rawHeader{}, - }, nil -} - -// Encrypt the given payload. Based on the key encryption algorithm, -// this will either use RSA-PKCS1v1.5 or RSA-OAEP (with SHA-1 or SHA-256). -func (ctx rsaEncrypterVerifier) encrypt(cek []byte, alg KeyAlgorithm) ([]byte, error) { - switch alg { - case RSA1_5: - return rsa.EncryptPKCS1v15(randReader, ctx.publicKey, cek) - case RSA_OAEP: - return rsa.EncryptOAEP(sha1.New(), randReader, ctx.publicKey, cek, []byte{}) - case RSA_OAEP_256: - return rsa.EncryptOAEP(sha256.New(), randReader, ctx.publicKey, cek, []byte{}) - } - - return nil, ErrUnsupportedAlgorithm -} - -// Decrypt the given payload and return the content encryption key. -func (ctx rsaDecrypterSigner) decryptKey(headers rawHeader, recipient *recipientInfo, generator keyGenerator) ([]byte, error) { - return ctx.decrypt(recipient.encryptedKey, KeyAlgorithm(headers.Alg), generator) -} - -// Decrypt the given payload. Based on the key encryption algorithm, -// this will either use RSA-PKCS1v1.5 or RSA-OAEP (with SHA-1 or SHA-256). -func (ctx rsaDecrypterSigner) decrypt(jek []byte, alg KeyAlgorithm, generator keyGenerator) ([]byte, error) { - // Note: The random reader on decrypt operations is only used for blinding, - // so stubbing is meanlingless (hence the direct use of rand.Reader). - switch alg { - case RSA1_5: - defer func() { - // DecryptPKCS1v15SessionKey sometimes panics on an invalid payload - // because of an index out of bounds error, which we want to ignore. - // This has been fixed in Go 1.3.1 (released 2014/08/13), the recover() - // only exists for preventing crashes with unpatched versions. - // See: https://groups.google.com/forum/#!topic/golang-dev/7ihX6Y6kx9k - // See: https://code.google.com/p/go/source/detail?r=58ee390ff31602edb66af41ed10901ec95904d33 - _ = recover() - }() - - // Perform some input validation. - keyBytes := ctx.privateKey.PublicKey.N.BitLen() / 8 - if keyBytes != len(jek) { - // Input size is incorrect, the encrypted payload should always match - // the size of the public modulus (e.g. using a 2048 bit key will - // produce 256 bytes of output). Reject this since it's invalid input. - return nil, ErrCryptoFailure - } - - cek, _, err := generator.genKey() - if err != nil { - return nil, ErrCryptoFailure - } - - // When decrypting an RSA-PKCS1v1.5 payload, we must take precautions to - // prevent chosen-ciphertext attacks as described in RFC 3218, "Preventing - // the Million Message Attack on Cryptographic Message Syntax". We are - // therefore deliberately ignoring errors here. - _ = rsa.DecryptPKCS1v15SessionKey(rand.Reader, ctx.privateKey, jek, cek) - - return cek, nil - case RSA_OAEP: - // Use rand.Reader for RSA blinding - return rsa.DecryptOAEP(sha1.New(), rand.Reader, ctx.privateKey, jek, []byte{}) - case RSA_OAEP_256: - // Use rand.Reader for RSA blinding - return rsa.DecryptOAEP(sha256.New(), rand.Reader, ctx.privateKey, jek, []byte{}) - } - - return nil, ErrUnsupportedAlgorithm -} - -// Sign the given payload -func (ctx rsaDecrypterSigner) signPayload(payload []byte, alg SignatureAlgorithm) (Signature, error) { - var hash crypto.Hash - - switch alg { - case RS256, PS256: - hash = crypto.SHA256 - case RS384, PS384: - hash = crypto.SHA384 - case RS512, PS512: - hash = crypto.SHA512 - default: - return Signature{}, ErrUnsupportedAlgorithm - } - - hasher := hash.New() - - // According to documentation, Write() on hash never fails - _, _ = hasher.Write(payload) - hashed := hasher.Sum(nil) - - var out []byte - var err error - - switch alg { - case RS256, RS384, RS512: - out, err = rsa.SignPKCS1v15(randReader, ctx.privateKey, hash, hashed) - case PS256, PS384, PS512: - out, err = rsa.SignPSS(randReader, ctx.privateKey, hash, hashed, &rsa.PSSOptions{ - SaltLength: rsa.PSSSaltLengthAuto, - }) - } - - if err != nil { - return Signature{}, err - } - - return Signature{ - Signature: out, - protected: &rawHeader{}, - }, nil -} - -// Verify the given payload -func (ctx rsaEncrypterVerifier) verifyPayload(payload []byte, signature []byte, alg SignatureAlgorithm) error { - var hash crypto.Hash - - switch alg { - case RS256, PS256: - hash = crypto.SHA256 - case RS384, PS384: - hash = crypto.SHA384 - case RS512, PS512: - hash = crypto.SHA512 - default: - return ErrUnsupportedAlgorithm - } - - hasher := hash.New() - - // According to documentation, Write() on hash never fails - _, _ = hasher.Write(payload) - hashed := hasher.Sum(nil) - - switch alg { - case RS256, RS384, RS512: - return rsa.VerifyPKCS1v15(ctx.publicKey, hash, hashed, signature) - case PS256, PS384, PS512: - return rsa.VerifyPSS(ctx.publicKey, hash, hashed, signature, nil) - } - - return ErrUnsupportedAlgorithm -} - -// Encrypt the given payload and update the object. -func (ctx ecEncrypterVerifier) encryptKey(cek []byte, alg KeyAlgorithm) (recipientInfo, error) { - switch alg { - case ECDH_ES: - // ECDH-ES mode doesn't wrap a key, the shared secret is used directly as the key. - return recipientInfo{ - header: &rawHeader{}, - }, nil - case ECDH_ES_A128KW, ECDH_ES_A192KW, ECDH_ES_A256KW: - default: - return recipientInfo{}, ErrUnsupportedAlgorithm - } - - generator := ecKeyGenerator{ - algID: string(alg), - publicKey: ctx.publicKey, - } - - switch alg { - case ECDH_ES_A128KW: - generator.size = 16 - case ECDH_ES_A192KW: - generator.size = 24 - case ECDH_ES_A256KW: - generator.size = 32 - } - - kek, header, err := generator.genKey() - if err != nil { - return recipientInfo{}, err - } - - block, err := aes.NewCipher(kek) - if err != nil { - return recipientInfo{}, err - } - - jek, err := josecipher.KeyWrap(block, cek) - if err != nil { - return recipientInfo{}, err - } - - return recipientInfo{ - encryptedKey: jek, - header: &header, - }, nil -} - -// Get key size for EC key generator -func (ctx ecKeyGenerator) keySize() int { - return ctx.size -} - -// Get a content encryption key for ECDH-ES -func (ctx ecKeyGenerator) genKey() ([]byte, rawHeader, error) { - priv, err := ecdsa.GenerateKey(ctx.publicKey.Curve, randReader) - if err != nil { - return nil, rawHeader{}, err - } - - out := josecipher.DeriveECDHES(ctx.algID, []byte{}, []byte{}, priv, ctx.publicKey, ctx.size) - - headers := rawHeader{ - Epk: &JsonWebKey{ - Key: &priv.PublicKey, - }, - } - - return out, headers, nil -} - -// Decrypt the given payload and return the content encryption key. -func (ctx ecDecrypterSigner) decryptKey(headers rawHeader, recipient *recipientInfo, generator keyGenerator) ([]byte, error) { - if headers.Epk == nil { - return nil, errors.New("square/go-jose: missing epk header") - } - - publicKey, ok := headers.Epk.Key.(*ecdsa.PublicKey) - if publicKey == nil || !ok { - return nil, errors.New("square/go-jose: invalid epk header") - } - - if !ctx.privateKey.Curve.IsOnCurve(publicKey.X, publicKey.Y) { - return nil, errors.New("square/go-jose: invalid public key in epk header") - } - - apuData := headers.Apu.bytes() - apvData := headers.Apv.bytes() - - deriveKey := func(algID string, size int) []byte { - return josecipher.DeriveECDHES(algID, apuData, apvData, ctx.privateKey, publicKey, size) - } - - var keySize int - - switch KeyAlgorithm(headers.Alg) { - case ECDH_ES: - // ECDH-ES uses direct key agreement, no key unwrapping necessary. - return deriveKey(string(headers.Enc), generator.keySize()), nil - case ECDH_ES_A128KW: - keySize = 16 - case ECDH_ES_A192KW: - keySize = 24 - case ECDH_ES_A256KW: - keySize = 32 - default: - return nil, ErrUnsupportedAlgorithm - } - - key := deriveKey(headers.Alg, keySize) - block, err := aes.NewCipher(key) - if err != nil { - return nil, err - } - - return josecipher.KeyUnwrap(block, recipient.encryptedKey) -} - -// Sign the given payload -func (ctx ecDecrypterSigner) signPayload(payload []byte, alg SignatureAlgorithm) (Signature, error) { - var expectedBitSize int - var hash crypto.Hash - - switch alg { - case ES256: - expectedBitSize = 256 - hash = crypto.SHA256 - case ES384: - expectedBitSize = 384 - hash = crypto.SHA384 - case ES512: - expectedBitSize = 521 - hash = crypto.SHA512 - } - - curveBits := ctx.privateKey.Curve.Params().BitSize - if expectedBitSize != curveBits { - return Signature{}, fmt.Errorf("square/go-jose: expected %d bit key, got %d bits instead", expectedBitSize, curveBits) - } - - hasher := hash.New() - - // According to documentation, Write() on hash never fails - _, _ = hasher.Write(payload) - hashed := hasher.Sum(nil) - - r, s, err := ecdsa.Sign(randReader, ctx.privateKey, hashed) - if err != nil { - return Signature{}, err - } - - keyBytes := curveBits / 8 - if curveBits%8 > 0 { - keyBytes += 1 - } - - // We serialize the outpus (r and s) into big-endian byte arrays and pad - // them with zeros on the left to make sure the sizes work out. Both arrays - // must be keyBytes long, and the output must be 2*keyBytes long. - rBytes := r.Bytes() - rBytesPadded := make([]byte, keyBytes) - copy(rBytesPadded[keyBytes-len(rBytes):], rBytes) - - sBytes := s.Bytes() - sBytesPadded := make([]byte, keyBytes) - copy(sBytesPadded[keyBytes-len(sBytes):], sBytes) - - out := append(rBytesPadded, sBytesPadded...) - - return Signature{ - Signature: out, - protected: &rawHeader{}, - }, nil -} - -// Verify the given payload -func (ctx ecEncrypterVerifier) verifyPayload(payload []byte, signature []byte, alg SignatureAlgorithm) error { - var keySize int - var hash crypto.Hash - - switch alg { - case ES256: - keySize = 32 - hash = crypto.SHA256 - case ES384: - keySize = 48 - hash = crypto.SHA384 - case ES512: - keySize = 66 - hash = crypto.SHA512 - default: - return ErrUnsupportedAlgorithm - } - - if len(signature) != 2*keySize { - return fmt.Errorf("square/go-jose: invalid signature size, have %d bytes, wanted %d", len(signature), 2*keySize) - } - - hasher := hash.New() - - // According to documentation, Write() on hash never fails - _, _ = hasher.Write(payload) - hashed := hasher.Sum(nil) - - r := big.NewInt(0).SetBytes(signature[:keySize]) - s := big.NewInt(0).SetBytes(signature[keySize:]) - - match := ecdsa.Verify(ctx.publicKey, hashed, r, s) - if !match { - return errors.New("square/go-jose: ecdsa signature failed to verify") - } - - return nil -} diff --git a/vendor/gopkg.in/square/go-jose.v1/cipher/cbc_hmac.go b/vendor/gopkg.in/square/go-jose.v1/cipher/cbc_hmac.go deleted file mode 100644 index 126b85ce2..000000000 --- a/vendor/gopkg.in/square/go-jose.v1/cipher/cbc_hmac.go +++ /dev/null @@ -1,196 +0,0 @@ -/*- - * Copyright 2014 Square Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package josecipher - -import ( - "bytes" - "crypto/cipher" - "crypto/hmac" - "crypto/sha256" - "crypto/sha512" - "crypto/subtle" - "encoding/binary" - "errors" - "hash" -) - -const ( - nonceBytes = 16 -) - -// NewCBCHMAC instantiates a new AEAD based on CBC+HMAC. -func NewCBCHMAC(key []byte, newBlockCipher func([]byte) (cipher.Block, error)) (cipher.AEAD, error) { - keySize := len(key) / 2 - integrityKey := key[:keySize] - encryptionKey := key[keySize:] - - blockCipher, err := newBlockCipher(encryptionKey) - if err != nil { - return nil, err - } - - var hash func() hash.Hash - switch keySize { - case 16: - hash = sha256.New - case 24: - hash = sha512.New384 - case 32: - hash = sha512.New - } - - return &cbcAEAD{ - hash: hash, - blockCipher: blockCipher, - authtagBytes: keySize, - integrityKey: integrityKey, - }, nil -} - -// An AEAD based on CBC+HMAC -type cbcAEAD struct { - hash func() hash.Hash - authtagBytes int - integrityKey []byte - blockCipher cipher.Block -} - -func (ctx *cbcAEAD) NonceSize() int { - return nonceBytes -} - -func (ctx *cbcAEAD) Overhead() int { - // Maximum overhead is block size (for padding) plus auth tag length, where - // the length of the auth tag is equivalent to the key size. - return ctx.blockCipher.BlockSize() + ctx.authtagBytes -} - -// Seal encrypts and authenticates the plaintext. -func (ctx *cbcAEAD) Seal(dst, nonce, plaintext, data []byte) []byte { - // Output buffer -- must take care not to mangle plaintext input. - ciphertext := make([]byte, uint64(len(plaintext))+uint64(ctx.Overhead()))[:len(plaintext)] - copy(ciphertext, plaintext) - ciphertext = padBuffer(ciphertext, ctx.blockCipher.BlockSize()) - - cbc := cipher.NewCBCEncrypter(ctx.blockCipher, nonce) - - cbc.CryptBlocks(ciphertext, ciphertext) - authtag := ctx.computeAuthTag(data, nonce, ciphertext) - - ret, out := resize(dst, uint64(len(dst))+uint64(len(ciphertext))+uint64(len(authtag))) - copy(out, ciphertext) - copy(out[len(ciphertext):], authtag) - - return ret -} - -// Open decrypts and authenticates the ciphertext. -func (ctx *cbcAEAD) Open(dst, nonce, ciphertext, data []byte) ([]byte, error) { - if len(ciphertext) < ctx.authtagBytes { - return nil, errors.New("square/go-jose: invalid ciphertext (too short)") - } - - offset := len(ciphertext) - ctx.authtagBytes - expectedTag := ctx.computeAuthTag(data, nonce, ciphertext[:offset]) - match := subtle.ConstantTimeCompare(expectedTag, ciphertext[offset:]) - if match != 1 { - return nil, errors.New("square/go-jose: invalid ciphertext (auth tag mismatch)") - } - - cbc := cipher.NewCBCDecrypter(ctx.blockCipher, nonce) - - // Make copy of ciphertext buffer, don't want to modify in place - buffer := append([]byte{}, []byte(ciphertext[:offset])...) - - if len(buffer)%ctx.blockCipher.BlockSize() > 0 { - return nil, errors.New("square/go-jose: invalid ciphertext (invalid length)") - } - - cbc.CryptBlocks(buffer, buffer) - - // Remove padding - plaintext, err := unpadBuffer(buffer, ctx.blockCipher.BlockSize()) - if err != nil { - return nil, err - } - - ret, out := resize(dst, uint64(len(dst))+uint64(len(plaintext))) - copy(out, plaintext) - - return ret, nil -} - -// Compute an authentication tag -func (ctx *cbcAEAD) computeAuthTag(aad, nonce, ciphertext []byte) []byte { - buffer := make([]byte, uint64(len(aad))+uint64(len(nonce))+uint64(len(ciphertext))+8) - n := 0 - n += copy(buffer, aad) - n += copy(buffer[n:], nonce) - n += copy(buffer[n:], ciphertext) - binary.BigEndian.PutUint64(buffer[n:], uint64(len(aad))*8) - - // According to documentation, Write() on hash.Hash never fails. - hmac := hmac.New(ctx.hash, ctx.integrityKey) - _, _ = hmac.Write(buffer) - - return hmac.Sum(nil)[:ctx.authtagBytes] -} - -// resize ensures the the given slice has a capacity of at least n bytes. -// If the capacity of the slice is less than n, a new slice is allocated -// and the existing data will be copied. -func resize(in []byte, n uint64) (head, tail []byte) { - if uint64(cap(in)) >= n { - head = in[:n] - } else { - head = make([]byte, n) - copy(head, in) - } - - tail = head[len(in):] - return -} - -// Apply padding -func padBuffer(buffer []byte, blockSize int) []byte { - missing := blockSize - (len(buffer) % blockSize) - ret, out := resize(buffer, uint64(len(buffer))+uint64(missing)) - padding := bytes.Repeat([]byte{byte(missing)}, missing) - copy(out, padding) - return ret -} - -// Remove padding -func unpadBuffer(buffer []byte, blockSize int) ([]byte, error) { - if len(buffer)%blockSize != 0 { - return nil, errors.New("square/go-jose: invalid padding") - } - - last := buffer[len(buffer)-1] - count := int(last) - - if count == 0 || count > blockSize || count > len(buffer) { - return nil, errors.New("square/go-jose: invalid padding") - } - - padding := bytes.Repeat([]byte{last}, count) - if !bytes.HasSuffix(buffer, padding) { - return nil, errors.New("square/go-jose: invalid padding") - } - - return buffer[:len(buffer)-count], nil -} diff --git a/vendor/gopkg.in/square/go-jose.v1/cipher/concat_kdf.go b/vendor/gopkg.in/square/go-jose.v1/cipher/concat_kdf.go deleted file mode 100644 index f62c3bdba..000000000 --- a/vendor/gopkg.in/square/go-jose.v1/cipher/concat_kdf.go +++ /dev/null @@ -1,75 +0,0 @@ -/*- - * Copyright 2014 Square Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package josecipher - -import ( - "crypto" - "encoding/binary" - "hash" - "io" -) - -type concatKDF struct { - z, info []byte - i uint32 - cache []byte - hasher hash.Hash -} - -// NewConcatKDF builds a KDF reader based on the given inputs. -func NewConcatKDF(hash crypto.Hash, z, algID, ptyUInfo, ptyVInfo, supPubInfo, supPrivInfo []byte) io.Reader { - buffer := make([]byte, uint64(len(algID))+uint64(len(ptyUInfo))+uint64(len(ptyVInfo))+uint64(len(supPubInfo))+uint64(len(supPrivInfo))) - n := 0 - n += copy(buffer, algID) - n += copy(buffer[n:], ptyUInfo) - n += copy(buffer[n:], ptyVInfo) - n += copy(buffer[n:], supPubInfo) - copy(buffer[n:], supPrivInfo) - - hasher := hash.New() - - return &concatKDF{ - z: z, - info: buffer, - hasher: hasher, - cache: []byte{}, - i: 1, - } -} - -func (ctx *concatKDF) Read(out []byte) (int, error) { - copied := copy(out, ctx.cache) - ctx.cache = ctx.cache[copied:] - - for copied < len(out) { - ctx.hasher.Reset() - - // Write on a hash.Hash never fails - _ = binary.Write(ctx.hasher, binary.BigEndian, ctx.i) - _, _ = ctx.hasher.Write(ctx.z) - _, _ = ctx.hasher.Write(ctx.info) - - hash := ctx.hasher.Sum(nil) - chunkCopied := copy(out[copied:], hash) - copied += chunkCopied - ctx.cache = hash[chunkCopied:] - - ctx.i++ - } - - return copied, nil -} diff --git a/vendor/gopkg.in/square/go-jose.v1/cipher/ecdh_es.go b/vendor/gopkg.in/square/go-jose.v1/cipher/ecdh_es.go deleted file mode 100644 index f23d49e1f..000000000 --- a/vendor/gopkg.in/square/go-jose.v1/cipher/ecdh_es.go +++ /dev/null @@ -1,62 +0,0 @@ -/*- - * Copyright 2014 Square Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package josecipher - -import ( - "crypto" - "crypto/ecdsa" - "encoding/binary" -) - -// DeriveECDHES derives a shared encryption key using ECDH/ConcatKDF as described in JWE/JWA. -// It is an error to call this function with a private/public key that are not on the same -// curve. Callers must ensure that the keys are valid before calling this function. Output -// size may be at most 1<<16 bytes (64 KiB). -func DeriveECDHES(alg string, apuData, apvData []byte, priv *ecdsa.PrivateKey, pub *ecdsa.PublicKey, size int) []byte { - if size > 1<<16 { - panic("ECDH-ES output size too large, must be less than 1<<16") - } - - // algId, partyUInfo, partyVInfo inputs must be prefixed with the length - algID := lengthPrefixed([]byte(alg)) - ptyUInfo := lengthPrefixed(apuData) - ptyVInfo := lengthPrefixed(apvData) - - // suppPubInfo is the encoded length of the output size in bits - supPubInfo := make([]byte, 4) - binary.BigEndian.PutUint32(supPubInfo, uint32(size)*8) - - if !priv.PublicKey.Curve.IsOnCurve(pub.X, pub.Y) { - panic("public key not on same curve as private key") - } - - z, _ := priv.PublicKey.Curve.ScalarMult(pub.X, pub.Y, priv.D.Bytes()) - reader := NewConcatKDF(crypto.SHA256, z.Bytes(), algID, ptyUInfo, ptyVInfo, supPubInfo, []byte{}) - - key := make([]byte, size) - - // Read on the KDF will never fail - _, _ = reader.Read(key) - return key -} - -func lengthPrefixed(data []byte) []byte { - out := make([]byte, len(data)+4) - binary.BigEndian.PutUint32(out, uint32(len(data))) - copy(out[4:], data) - return out -} diff --git a/vendor/gopkg.in/square/go-jose.v1/cipher/key_wrap.go b/vendor/gopkg.in/square/go-jose.v1/cipher/key_wrap.go deleted file mode 100644 index 1d36d5015..000000000 --- a/vendor/gopkg.in/square/go-jose.v1/cipher/key_wrap.go +++ /dev/null @@ -1,109 +0,0 @@ -/*- - * Copyright 2014 Square Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package josecipher - -import ( - "crypto/cipher" - "crypto/subtle" - "encoding/binary" - "errors" -) - -var defaultIV = []byte{0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6} - -// KeyWrap implements NIST key wrapping; it wraps a content encryption key (cek) with the given block cipher. -func KeyWrap(block cipher.Block, cek []byte) ([]byte, error) { - if len(cek)%8 != 0 { - return nil, errors.New("square/go-jose: key wrap input must be 8 byte blocks") - } - - n := len(cek) / 8 - r := make([][]byte, n) - - for i := range r { - r[i] = make([]byte, 8) - copy(r[i], cek[i*8:]) - } - - buffer := make([]byte, 16) - tBytes := make([]byte, 8) - copy(buffer, defaultIV) - - for t := 0; t < 6*n; t++ { - copy(buffer[8:], r[t%n]) - - block.Encrypt(buffer, buffer) - - binary.BigEndian.PutUint64(tBytes, uint64(t+1)) - - for i := 0; i < 8; i++ { - buffer[i] = buffer[i] ^ tBytes[i] - } - copy(r[t%n], buffer[8:]) - } - - out := make([]byte, (n+1)*8) - copy(out, buffer[:8]) - for i := range r { - copy(out[(i+1)*8:], r[i]) - } - - return out, nil -} - -// KeyUnwrap implements NIST key unwrapping; it unwraps a content encryption key (cek) with the given block cipher. -func KeyUnwrap(block cipher.Block, ciphertext []byte) ([]byte, error) { - if len(ciphertext)%8 != 0 { - return nil, errors.New("square/go-jose: key wrap input must be 8 byte blocks") - } - - n := (len(ciphertext) / 8) - 1 - r := make([][]byte, n) - - for i := range r { - r[i] = make([]byte, 8) - copy(r[i], ciphertext[(i+1)*8:]) - } - - buffer := make([]byte, 16) - tBytes := make([]byte, 8) - copy(buffer[:8], ciphertext[:8]) - - for t := 6*n - 1; t >= 0; t-- { - binary.BigEndian.PutUint64(tBytes, uint64(t+1)) - - for i := 0; i < 8; i++ { - buffer[i] = buffer[i] ^ tBytes[i] - } - copy(buffer[8:], r[t%n]) - - block.Decrypt(buffer, buffer) - - copy(r[t%n], buffer[8:]) - } - - if subtle.ConstantTimeCompare(buffer[:8], defaultIV) == 0 { - return nil, errors.New("square/go-jose: failed to unwrap key") - } - - out := make([]byte, n*8) - for i := range r { - copy(out[i*8:], r[i]) - } - - return out, nil -} diff --git a/vendor/gopkg.in/square/go-jose.v1/crypter.go b/vendor/gopkg.in/square/go-jose.v1/crypter.go deleted file mode 100644 index b3bdaec80..000000000 --- a/vendor/gopkg.in/square/go-jose.v1/crypter.go +++ /dev/null @@ -1,416 +0,0 @@ -/*- - * Copyright 2014 Square Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package jose - -import ( - "crypto/ecdsa" - "crypto/rsa" - "errors" - "fmt" - "reflect" -) - -// Encrypter represents an encrypter which produces an encrypted JWE object. -type Encrypter interface { - Encrypt(plaintext []byte) (*JsonWebEncryption, error) - EncryptWithAuthData(plaintext []byte, aad []byte) (*JsonWebEncryption, error) - SetCompression(alg CompressionAlgorithm) -} - -// MultiEncrypter represents an encrypter which supports multiple recipients. -type MultiEncrypter interface { - Encrypt(plaintext []byte) (*JsonWebEncryption, error) - EncryptWithAuthData(plaintext []byte, aad []byte) (*JsonWebEncryption, error) - SetCompression(alg CompressionAlgorithm) - AddRecipient(alg KeyAlgorithm, encryptionKey interface{}) error -} - -// A generic content cipher -type contentCipher interface { - keySize() int - encrypt(cek []byte, aad, plaintext []byte) (*aeadParts, error) - decrypt(cek []byte, aad []byte, parts *aeadParts) ([]byte, error) -} - -// A key generator (for generating/getting a CEK) -type keyGenerator interface { - keySize() int - genKey() ([]byte, rawHeader, error) -} - -// A generic key encrypter -type keyEncrypter interface { - encryptKey(cek []byte, alg KeyAlgorithm) (recipientInfo, error) // Encrypt a key -} - -// A generic key decrypter -type keyDecrypter interface { - decryptKey(headers rawHeader, recipient *recipientInfo, generator keyGenerator) ([]byte, error) // Decrypt a key -} - -// A generic encrypter based on the given key encrypter and content cipher. -type genericEncrypter struct { - contentAlg ContentEncryption - compressionAlg CompressionAlgorithm - cipher contentCipher - recipients []recipientKeyInfo - keyGenerator keyGenerator -} - -type recipientKeyInfo struct { - keyID string - keyAlg KeyAlgorithm - keyEncrypter keyEncrypter -} - -// SetCompression sets a compression algorithm to be applied before encryption. -func (ctx *genericEncrypter) SetCompression(compressionAlg CompressionAlgorithm) { - ctx.compressionAlg = compressionAlg -} - -// NewEncrypter creates an appropriate encrypter based on the key type -func NewEncrypter(alg KeyAlgorithm, enc ContentEncryption, encryptionKey interface{}) (Encrypter, error) { - encrypter := &genericEncrypter{ - contentAlg: enc, - compressionAlg: NONE, - recipients: []recipientKeyInfo{}, - cipher: getContentCipher(enc), - } - - if encrypter.cipher == nil { - return nil, ErrUnsupportedAlgorithm - } - - var keyID string - var rawKey interface{} - switch encryptionKey := encryptionKey.(type) { - case *JsonWebKey: - keyID = encryptionKey.KeyID - rawKey = encryptionKey.Key - default: - rawKey = encryptionKey - } - - switch alg { - case DIRECT: - // Direct encryption mode must be treated differently - if reflect.TypeOf(rawKey) != reflect.TypeOf([]byte{}) { - return nil, ErrUnsupportedKeyType - } - encrypter.keyGenerator = staticKeyGenerator{ - key: rawKey.([]byte), - } - recipient, _ := newSymmetricRecipient(alg, rawKey.([]byte)) - if keyID != "" { - recipient.keyID = keyID - } - encrypter.recipients = []recipientKeyInfo{recipient} - return encrypter, nil - case ECDH_ES: - // ECDH-ES (w/o key wrapping) is similar to DIRECT mode - typeOf := reflect.TypeOf(rawKey) - if typeOf != reflect.TypeOf(&ecdsa.PublicKey{}) { - return nil, ErrUnsupportedKeyType - } - encrypter.keyGenerator = ecKeyGenerator{ - size: encrypter.cipher.keySize(), - algID: string(enc), - publicKey: rawKey.(*ecdsa.PublicKey), - } - recipient, _ := newECDHRecipient(alg, rawKey.(*ecdsa.PublicKey)) - if keyID != "" { - recipient.keyID = keyID - } - encrypter.recipients = []recipientKeyInfo{recipient} - return encrypter, nil - default: - // Can just add a standard recipient - encrypter.keyGenerator = randomKeyGenerator{ - size: encrypter.cipher.keySize(), - } - err := encrypter.AddRecipient(alg, encryptionKey) - return encrypter, err - } -} - -// NewMultiEncrypter creates a multi-encrypter based on the given parameters -func NewMultiEncrypter(enc ContentEncryption) (MultiEncrypter, error) { - cipher := getContentCipher(enc) - - if cipher == nil { - return nil, ErrUnsupportedAlgorithm - } - - encrypter := &genericEncrypter{ - contentAlg: enc, - compressionAlg: NONE, - recipients: []recipientKeyInfo{}, - cipher: cipher, - keyGenerator: randomKeyGenerator{ - size: cipher.keySize(), - }, - } - - return encrypter, nil -} - -func (ctx *genericEncrypter) AddRecipient(alg KeyAlgorithm, encryptionKey interface{}) (err error) { - var recipient recipientKeyInfo - - switch alg { - case DIRECT, ECDH_ES: - return fmt.Errorf("square/go-jose: key algorithm '%s' not supported in multi-recipient mode", alg) - } - - recipient, err = makeJWERecipient(alg, encryptionKey) - - if err == nil { - ctx.recipients = append(ctx.recipients, recipient) - } - return err -} - -func makeJWERecipient(alg KeyAlgorithm, encryptionKey interface{}) (recipientKeyInfo, error) { - switch encryptionKey := encryptionKey.(type) { - case *rsa.PublicKey: - return newRSARecipient(alg, encryptionKey) - case *ecdsa.PublicKey: - return newECDHRecipient(alg, encryptionKey) - case []byte: - return newSymmetricRecipient(alg, encryptionKey) - case *JsonWebKey: - recipient, err := makeJWERecipient(alg, encryptionKey.Key) - if err == nil && encryptionKey.KeyID != "" { - recipient.keyID = encryptionKey.KeyID - } - return recipient, err - default: - return recipientKeyInfo{}, ErrUnsupportedKeyType - } -} - -// newDecrypter creates an appropriate decrypter based on the key type -func newDecrypter(decryptionKey interface{}) (keyDecrypter, error) { - switch decryptionKey := decryptionKey.(type) { - case *rsa.PrivateKey: - return &rsaDecrypterSigner{ - privateKey: decryptionKey, - }, nil - case *ecdsa.PrivateKey: - return &ecDecrypterSigner{ - privateKey: decryptionKey, - }, nil - case []byte: - return &symmetricKeyCipher{ - key: decryptionKey, - }, nil - case *JsonWebKey: - return newDecrypter(decryptionKey.Key) - default: - return nil, ErrUnsupportedKeyType - } -} - -// Implementation of encrypt method producing a JWE object. -func (ctx *genericEncrypter) Encrypt(plaintext []byte) (*JsonWebEncryption, error) { - return ctx.EncryptWithAuthData(plaintext, nil) -} - -// Implementation of encrypt method producing a JWE object. -func (ctx *genericEncrypter) EncryptWithAuthData(plaintext, aad []byte) (*JsonWebEncryption, error) { - obj := &JsonWebEncryption{} - obj.aad = aad - - obj.protected = &rawHeader{ - Enc: ctx.contentAlg, - } - obj.recipients = make([]recipientInfo, len(ctx.recipients)) - - if len(ctx.recipients) == 0 { - return nil, fmt.Errorf("square/go-jose: no recipients to encrypt to") - } - - cek, headers, err := ctx.keyGenerator.genKey() - if err != nil { - return nil, err - } - - obj.protected.merge(&headers) - - for i, info := range ctx.recipients { - recipient, err := info.keyEncrypter.encryptKey(cek, info.keyAlg) - if err != nil { - return nil, err - } - - recipient.header.Alg = string(info.keyAlg) - if info.keyID != "" { - recipient.header.Kid = info.keyID - } - obj.recipients[i] = recipient - } - - if len(ctx.recipients) == 1 { - // Move per-recipient headers into main protected header if there's - // only a single recipient. - obj.protected.merge(obj.recipients[0].header) - obj.recipients[0].header = nil - } - - if ctx.compressionAlg != NONE { - plaintext, err = compress(ctx.compressionAlg, plaintext) - if err != nil { - return nil, err - } - - obj.protected.Zip = ctx.compressionAlg - } - - authData := obj.computeAuthData() - parts, err := ctx.cipher.encrypt(cek, authData, plaintext) - if err != nil { - return nil, err - } - - obj.iv = parts.iv - obj.ciphertext = parts.ciphertext - obj.tag = parts.tag - - return obj, nil -} - -// Decrypt and validate the object and return the plaintext. Note that this -// function does not support multi-recipient, if you desire multi-recipient -// decryption use DecryptMulti instead. -func (obj JsonWebEncryption) Decrypt(decryptionKey interface{}) ([]byte, error) { - headers := obj.mergedHeaders(nil) - - if len(obj.recipients) > 1 { - return nil, errors.New("square/go-jose: too many recipients in payload; expecting only one") - } - - if len(headers.Crit) > 0 { - return nil, fmt.Errorf("square/go-jose: unsupported crit header") - } - - decrypter, err := newDecrypter(decryptionKey) - if err != nil { - return nil, err - } - - cipher := getContentCipher(headers.Enc) - if cipher == nil { - return nil, fmt.Errorf("square/go-jose: unsupported enc value '%s'", string(headers.Enc)) - } - - generator := randomKeyGenerator{ - size: cipher.keySize(), - } - - parts := &aeadParts{ - iv: obj.iv, - ciphertext: obj.ciphertext, - tag: obj.tag, - } - - authData := obj.computeAuthData() - - var plaintext []byte - recipient := obj.recipients[0] - recipientHeaders := obj.mergedHeaders(&recipient) - - cek, err := decrypter.decryptKey(recipientHeaders, &recipient, generator) - if err == nil { - // Found a valid CEK -- let's try to decrypt. - plaintext, err = cipher.decrypt(cek, authData, parts) - } - - if plaintext == nil { - return nil, ErrCryptoFailure - } - - // The "zip" header parameter may only be present in the protected header. - if obj.protected.Zip != "" { - plaintext, err = decompress(obj.protected.Zip, plaintext) - } - - return plaintext, err -} - -// DecryptMulti decrypts and validates the object and returns the plaintexts, -// with support for multiple recipients. It returns the index of the recipient -// for which the decryption was successful, the merged headers for that recipient, -// and the plaintext. -func (obj JsonWebEncryption) DecryptMulti(decryptionKey interface{}) (int, JoseHeader, []byte, error) { - globalHeaders := obj.mergedHeaders(nil) - - if len(globalHeaders.Crit) > 0 { - return -1, JoseHeader{}, nil, fmt.Errorf("square/go-jose: unsupported crit header") - } - - decrypter, err := newDecrypter(decryptionKey) - if err != nil { - return -1, JoseHeader{}, nil, err - } - - cipher := getContentCipher(globalHeaders.Enc) - if cipher == nil { - return -1, JoseHeader{}, nil, fmt.Errorf("square/go-jose: unsupported enc value '%s'", string(globalHeaders.Enc)) - } - - generator := randomKeyGenerator{ - size: cipher.keySize(), - } - - parts := &aeadParts{ - iv: obj.iv, - ciphertext: obj.ciphertext, - tag: obj.tag, - } - - authData := obj.computeAuthData() - - index := -1 - var plaintext []byte - var headers rawHeader - - for i, recipient := range obj.recipients { - recipientHeaders := obj.mergedHeaders(&recipient) - - cek, err := decrypter.decryptKey(recipientHeaders, &recipient, generator) - if err == nil { - // Found a valid CEK -- let's try to decrypt. - plaintext, err = cipher.decrypt(cek, authData, parts) - if err == nil { - index = i - headers = recipientHeaders - break - } - } - } - - if plaintext == nil || err != nil { - return -1, JoseHeader{}, nil, ErrCryptoFailure - } - - // The "zip" header parameter may only be present in the protected header. - if obj.protected.Zip != "" { - plaintext, err = decompress(obj.protected.Zip, plaintext) - } - - return index, headers.sanitized(), plaintext, err -} diff --git a/vendor/gopkg.in/square/go-jose.v1/doc.go b/vendor/gopkg.in/square/go-jose.v1/doc.go deleted file mode 100644 index b4cd1e989..000000000 --- a/vendor/gopkg.in/square/go-jose.v1/doc.go +++ /dev/null @@ -1,26 +0,0 @@ -/*- - * Copyright 2014 Square Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - -Package jose aims to provide an implementation of the Javascript Object Signing -and Encryption set of standards. For the moment, it mainly focuses on -encryption and signing based on the JSON Web Encryption and JSON Web Signature -standards. The library supports both the compact and full serialization -formats, and has optional support for multiple recipients. - -*/ -package jose // import "gopkg.in/square/go-jose.v1" diff --git a/vendor/gopkg.in/square/go-jose.v1/encoding.go b/vendor/gopkg.in/square/go-jose.v1/encoding.go deleted file mode 100644 index dde0a42db..000000000 --- a/vendor/gopkg.in/square/go-jose.v1/encoding.go +++ /dev/null @@ -1,193 +0,0 @@ -/*- - * Copyright 2014 Square Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package jose - -import ( - "bytes" - "compress/flate" - "encoding/base64" - "encoding/binary" - "io" - "math/big" - "regexp" - "strings" - - "gopkg.in/square/go-jose.v1/json" -) - -var stripWhitespaceRegex = regexp.MustCompile("\\s") - -// Url-safe base64 encode that strips padding -func base64URLEncode(data []byte) string { - var result = base64.URLEncoding.EncodeToString(data) - return strings.TrimRight(result, "=") -} - -// Url-safe base64 decoder that adds padding -func base64URLDecode(data string) ([]byte, error) { - var missing = (4 - len(data)%4) % 4 - data += strings.Repeat("=", missing) - return base64.URLEncoding.DecodeString(data) -} - -// Helper function to serialize known-good objects. -// Precondition: value is not a nil pointer. -func mustSerializeJSON(value interface{}) []byte { - out, err := json.Marshal(value) - if err != nil { - panic(err) - } - // We never want to serialize the top-level value "null," since it's not a - // valid JOSE message. But if a caller passes in a nil pointer to this method, - // MarshalJSON will happily serialize it as the top-level value "null". If - // that value is then embedded in another operation, for instance by being - // base64-encoded and fed as input to a signing algorithm - // (https://github.com/square/go-jose/issues/22), the result will be - // incorrect. Because this method is intended for known-good objects, and a nil - // pointer is not a known-good object, we are free to panic in this case. - // Note: It's not possible to directly check whether the data pointed at by an - // interface is a nil pointer, so we do this hacky workaround. - // https://groups.google.com/forum/#!topic/golang-nuts/wnH302gBa4I - if string(out) == "null" { - panic("Tried to serialize a nil pointer.") - } - return out -} - -// Strip all newlines and whitespace -func stripWhitespace(data string) string { - return stripWhitespaceRegex.ReplaceAllString(data, "") -} - -// Perform compression based on algorithm -func compress(algorithm CompressionAlgorithm, input []byte) ([]byte, error) { - switch algorithm { - case DEFLATE: - return deflate(input) - default: - return nil, ErrUnsupportedAlgorithm - } -} - -// Perform decompression based on algorithm -func decompress(algorithm CompressionAlgorithm, input []byte) ([]byte, error) { - switch algorithm { - case DEFLATE: - return inflate(input) - default: - return nil, ErrUnsupportedAlgorithm - } -} - -// Compress with DEFLATE -func deflate(input []byte) ([]byte, error) { - output := new(bytes.Buffer) - - // Writing to byte buffer, err is always nil - writer, _ := flate.NewWriter(output, 1) - _, _ = io.Copy(writer, bytes.NewBuffer(input)) - - err := writer.Close() - return output.Bytes(), err -} - -// Decompress with DEFLATE -func inflate(input []byte) ([]byte, error) { - output := new(bytes.Buffer) - reader := flate.NewReader(bytes.NewBuffer(input)) - - _, err := io.Copy(output, reader) - if err != nil { - return nil, err - } - - err = reader.Close() - return output.Bytes(), err -} - -// byteBuffer represents a slice of bytes that can be serialized to url-safe base64. -type byteBuffer struct { - data []byte -} - -func newBuffer(data []byte) *byteBuffer { - if data == nil { - return nil - } - return &byteBuffer{ - data: data, - } -} - -func newFixedSizeBuffer(data []byte, length int) *byteBuffer { - if len(data) > length { - panic("square/go-jose: invalid call to newFixedSizeBuffer (len(data) > length)") - } - pad := make([]byte, length-len(data)) - return newBuffer(append(pad, data...)) -} - -func newBufferFromInt(num uint64) *byteBuffer { - data := make([]byte, 8) - binary.BigEndian.PutUint64(data, num) - return newBuffer(bytes.TrimLeft(data, "\x00")) -} - -func (b *byteBuffer) MarshalJSON() ([]byte, error) { - return json.Marshal(b.base64()) -} - -func (b *byteBuffer) UnmarshalJSON(data []byte) error { - var encoded string - err := json.Unmarshal(data, &encoded) - if err != nil { - return err - } - - if encoded == "" { - return nil - } - - decoded, err := base64URLDecode(encoded) - if err != nil { - return err - } - - *b = *newBuffer(decoded) - - return nil -} - -func (b *byteBuffer) base64() string { - return base64URLEncode(b.data) -} - -func (b *byteBuffer) bytes() []byte { - // Handling nil here allows us to transparently handle nil slices when serializing. - if b == nil { - return nil - } - return b.data -} - -func (b byteBuffer) bigInt() *big.Int { - return new(big.Int).SetBytes(b.data) -} - -func (b byteBuffer) toInt() int { - return int(b.bigInt().Int64()) -} diff --git a/vendor/gopkg.in/square/go-jose.v1/json/LICENSE b/vendor/gopkg.in/square/go-jose.v1/json/LICENSE deleted file mode 100644 index 744875676..000000000 --- a/vendor/gopkg.in/square/go-jose.v1/json/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2012 The Go Authors. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/gopkg.in/square/go-jose.v1/json/decode.go b/vendor/gopkg.in/square/go-jose.v1/json/decode.go deleted file mode 100644 index 37457e5a8..000000000 --- a/vendor/gopkg.in/square/go-jose.v1/json/decode.go +++ /dev/null @@ -1,1183 +0,0 @@ -// Copyright 2010 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Represents JSON data structure using native Go types: booleans, floats, -// strings, arrays, and maps. - -package json - -import ( - "bytes" - "encoding" - "encoding/base64" - "errors" - "fmt" - "reflect" - "runtime" - "strconv" - "unicode" - "unicode/utf16" - "unicode/utf8" -) - -// Unmarshal parses the JSON-encoded data and stores the result -// in the value pointed to by v. -// -// Unmarshal uses the inverse of the encodings that -// Marshal uses, allocating maps, slices, and pointers as necessary, -// with the following additional rules: -// -// To unmarshal JSON into a pointer, Unmarshal first handles the case of -// the JSON being the JSON literal null. In that case, Unmarshal sets -// the pointer to nil. Otherwise, Unmarshal unmarshals the JSON into -// the value pointed at by the pointer. If the pointer is nil, Unmarshal -// allocates a new value for it to point to. -// -// To unmarshal JSON into a struct, Unmarshal matches incoming object -// keys to the keys used by Marshal (either the struct field name or its tag), -// preferring an exact match but also accepting a case-insensitive match. -// Unmarshal will only set exported fields of the struct. -// -// To unmarshal JSON into an interface value, -// Unmarshal stores one of these in the interface value: -// -// bool, for JSON booleans -// float64, for JSON numbers -// string, for JSON strings -// []interface{}, for JSON arrays -// map[string]interface{}, for JSON objects -// nil for JSON null -// -// To unmarshal a JSON array into a slice, Unmarshal resets the slice length -// to zero and then appends each element to the slice. -// As a special case, to unmarshal an empty JSON array into a slice, -// Unmarshal replaces the slice with a new empty slice. -// -// To unmarshal a JSON array into a Go array, Unmarshal decodes -// JSON array elements into corresponding Go array elements. -// If the Go array is smaller than the JSON array, -// the additional JSON array elements are discarded. -// If the JSON array is smaller than the Go array, -// the additional Go array elements are set to zero values. -// -// To unmarshal a JSON object into a string-keyed map, Unmarshal first -// establishes a map to use, If the map is nil, Unmarshal allocates a new map. -// Otherwise Unmarshal reuses the existing map, keeping existing entries. -// Unmarshal then stores key-value pairs from the JSON object into the map. -// -// If a JSON value is not appropriate for a given target type, -// or if a JSON number overflows the target type, Unmarshal -// skips that field and completes the unmarshaling as best it can. -// If no more serious errors are encountered, Unmarshal returns -// an UnmarshalTypeError describing the earliest such error. -// -// The JSON null value unmarshals into an interface, map, pointer, or slice -// by setting that Go value to nil. Because null is often used in JSON to mean -// ``not present,'' unmarshaling a JSON null into any other Go type has no effect -// on the value and produces no error. -// -// When unmarshaling quoted strings, invalid UTF-8 or -// invalid UTF-16 surrogate pairs are not treated as an error. -// Instead, they are replaced by the Unicode replacement -// character U+FFFD. -// -func Unmarshal(data []byte, v interface{}) error { - // Check for well-formedness. - // Avoids filling out half a data structure - // before discovering a JSON syntax error. - var d decodeState - err := checkValid(data, &d.scan) - if err != nil { - return err - } - - d.init(data) - return d.unmarshal(v) -} - -// Unmarshaler is the interface implemented by objects -// that can unmarshal a JSON description of themselves. -// The input can be assumed to be a valid encoding of -// a JSON value. UnmarshalJSON must copy the JSON data -// if it wishes to retain the data after returning. -type Unmarshaler interface { - UnmarshalJSON([]byte) error -} - -// An UnmarshalTypeError describes a JSON value that was -// not appropriate for a value of a specific Go type. -type UnmarshalTypeError struct { - Value string // description of JSON value - "bool", "array", "number -5" - Type reflect.Type // type of Go value it could not be assigned to - Offset int64 // error occurred after reading Offset bytes -} - -func (e *UnmarshalTypeError) Error() string { - return "json: cannot unmarshal " + e.Value + " into Go value of type " + e.Type.String() -} - -// An UnmarshalFieldError describes a JSON object key that -// led to an unexported (and therefore unwritable) struct field. -// (No longer used; kept for compatibility.) -type UnmarshalFieldError struct { - Key string - Type reflect.Type - Field reflect.StructField -} - -func (e *UnmarshalFieldError) Error() string { - return "json: cannot unmarshal object key " + strconv.Quote(e.Key) + " into unexported field " + e.Field.Name + " of type " + e.Type.String() -} - -// An InvalidUnmarshalError describes an invalid argument passed to Unmarshal. -// (The argument to Unmarshal must be a non-nil pointer.) -type InvalidUnmarshalError struct { - Type reflect.Type -} - -func (e *InvalidUnmarshalError) Error() string { - if e.Type == nil { - return "json: Unmarshal(nil)" - } - - if e.Type.Kind() != reflect.Ptr { - return "json: Unmarshal(non-pointer " + e.Type.String() + ")" - } - return "json: Unmarshal(nil " + e.Type.String() + ")" -} - -func (d *decodeState) unmarshal(v interface{}) (err error) { - defer func() { - if r := recover(); r != nil { - if _, ok := r.(runtime.Error); ok { - panic(r) - } - err = r.(error) - } - }() - - rv := reflect.ValueOf(v) - if rv.Kind() != reflect.Ptr || rv.IsNil() { - return &InvalidUnmarshalError{reflect.TypeOf(v)} - } - - d.scan.reset() - // We decode rv not rv.Elem because the Unmarshaler interface - // test must be applied at the top level of the value. - d.value(rv) - return d.savedError -} - -// A Number represents a JSON number literal. -type Number string - -// String returns the literal text of the number. -func (n Number) String() string { return string(n) } - -// Float64 returns the number as a float64. -func (n Number) Float64() (float64, error) { - return strconv.ParseFloat(string(n), 64) -} - -// Int64 returns the number as an int64. -func (n Number) Int64() (int64, error) { - return strconv.ParseInt(string(n), 10, 64) -} - -// isValidNumber reports whether s is a valid JSON number literal. -func isValidNumber(s string) bool { - // This function implements the JSON numbers grammar. - // See https://tools.ietf.org/html/rfc7159#section-6 - // and http://json.org/number.gif - - if s == "" { - return false - } - - // Optional - - if s[0] == '-' { - s = s[1:] - if s == "" { - return false - } - } - - // Digits - switch { - default: - return false - - case s[0] == '0': - s = s[1:] - - case '1' <= s[0] && s[0] <= '9': - s = s[1:] - for len(s) > 0 && '0' <= s[0] && s[0] <= '9' { - s = s[1:] - } - } - - // . followed by 1 or more digits. - if len(s) >= 2 && s[0] == '.' && '0' <= s[1] && s[1] <= '9' { - s = s[2:] - for len(s) > 0 && '0' <= s[0] && s[0] <= '9' { - s = s[1:] - } - } - - // e or E followed by an optional - or + and - // 1 or more digits. - if len(s) >= 2 && (s[0] == 'e' || s[0] == 'E') { - s = s[1:] - if s[0] == '+' || s[0] == '-' { - s = s[1:] - if s == "" { - return false - } - } - for len(s) > 0 && '0' <= s[0] && s[0] <= '9' { - s = s[1:] - } - } - - // Make sure we are at the end. - return s == "" -} - -// decodeState represents the state while decoding a JSON value. -type decodeState struct { - data []byte - off int // read offset in data - scan scanner - nextscan scanner // for calls to nextValue - savedError error - useNumber bool -} - -// errPhase is used for errors that should not happen unless -// there is a bug in the JSON decoder or something is editing -// the data slice while the decoder executes. -var errPhase = errors.New("JSON decoder out of sync - data changing underfoot?") - -func (d *decodeState) init(data []byte) *decodeState { - d.data = data - d.off = 0 - d.savedError = nil - return d -} - -// error aborts the decoding by panicking with err. -func (d *decodeState) error(err error) { - panic(err) -} - -// saveError saves the first err it is called with, -// for reporting at the end of the unmarshal. -func (d *decodeState) saveError(err error) { - if d.savedError == nil { - d.savedError = err - } -} - -// next cuts off and returns the next full JSON value in d.data[d.off:]. -// The next value is known to be an object or array, not a literal. -func (d *decodeState) next() []byte { - c := d.data[d.off] - item, rest, err := nextValue(d.data[d.off:], &d.nextscan) - if err != nil { - d.error(err) - } - d.off = len(d.data) - len(rest) - - // Our scanner has seen the opening brace/bracket - // and thinks we're still in the middle of the object. - // invent a closing brace/bracket to get it out. - if c == '{' { - d.scan.step(&d.scan, '}') - } else { - d.scan.step(&d.scan, ']') - } - - return item -} - -// scanWhile processes bytes in d.data[d.off:] until it -// receives a scan code not equal to op. -// It updates d.off and returns the new scan code. -func (d *decodeState) scanWhile(op int) int { - var newOp int - for { - if d.off >= len(d.data) { - newOp = d.scan.eof() - d.off = len(d.data) + 1 // mark processed EOF with len+1 - } else { - c := d.data[d.off] - d.off++ - newOp = d.scan.step(&d.scan, c) - } - if newOp != op { - break - } - } - return newOp -} - -// value decodes a JSON value from d.data[d.off:] into the value. -// it updates d.off to point past the decoded value. -func (d *decodeState) value(v reflect.Value) { - if !v.IsValid() { - _, rest, err := nextValue(d.data[d.off:], &d.nextscan) - if err != nil { - d.error(err) - } - d.off = len(d.data) - len(rest) - - // d.scan thinks we're still at the beginning of the item. - // Feed in an empty string - the shortest, simplest value - - // so that it knows we got to the end of the value. - if d.scan.redo { - // rewind. - d.scan.redo = false - d.scan.step = stateBeginValue - } - d.scan.step(&d.scan, '"') - d.scan.step(&d.scan, '"') - - n := len(d.scan.parseState) - if n > 0 && d.scan.parseState[n-1] == parseObjectKey { - // d.scan thinks we just read an object key; finish the object - d.scan.step(&d.scan, ':') - d.scan.step(&d.scan, '"') - d.scan.step(&d.scan, '"') - d.scan.step(&d.scan, '}') - } - - return - } - - switch op := d.scanWhile(scanSkipSpace); op { - default: - d.error(errPhase) - - case scanBeginArray: - d.array(v) - - case scanBeginObject: - d.object(v) - - case scanBeginLiteral: - d.literal(v) - } -} - -type unquotedValue struct{} - -// valueQuoted is like value but decodes a -// quoted string literal or literal null into an interface value. -// If it finds anything other than a quoted string literal or null, -// valueQuoted returns unquotedValue{}. -func (d *decodeState) valueQuoted() interface{} { - switch op := d.scanWhile(scanSkipSpace); op { - default: - d.error(errPhase) - - case scanBeginArray: - d.array(reflect.Value{}) - - case scanBeginObject: - d.object(reflect.Value{}) - - case scanBeginLiteral: - switch v := d.literalInterface().(type) { - case nil, string: - return v - } - } - return unquotedValue{} -} - -// indirect walks down v allocating pointers as needed, -// until it gets to a non-pointer. -// if it encounters an Unmarshaler, indirect stops and returns that. -// if decodingNull is true, indirect stops at the last pointer so it can be set to nil. -func (d *decodeState) indirect(v reflect.Value, decodingNull bool) (Unmarshaler, encoding.TextUnmarshaler, reflect.Value) { - // If v is a named type and is addressable, - // start with its address, so that if the type has pointer methods, - // we find them. - if v.Kind() != reflect.Ptr && v.Type().Name() != "" && v.CanAddr() { - v = v.Addr() - } - for { - // Load value from interface, but only if the result will be - // usefully addressable. - if v.Kind() == reflect.Interface && !v.IsNil() { - e := v.Elem() - if e.Kind() == reflect.Ptr && !e.IsNil() && (!decodingNull || e.Elem().Kind() == reflect.Ptr) { - v = e - continue - } - } - - if v.Kind() != reflect.Ptr { - break - } - - if v.Elem().Kind() != reflect.Ptr && decodingNull && v.CanSet() { - break - } - if v.IsNil() { - v.Set(reflect.New(v.Type().Elem())) - } - if v.Type().NumMethod() > 0 { - if u, ok := v.Interface().(Unmarshaler); ok { - return u, nil, reflect.Value{} - } - if u, ok := v.Interface().(encoding.TextUnmarshaler); ok { - return nil, u, reflect.Value{} - } - } - v = v.Elem() - } - return nil, nil, v -} - -// array consumes an array from d.data[d.off-1:], decoding into the value v. -// the first byte of the array ('[') has been read already. -func (d *decodeState) array(v reflect.Value) { - // Check for unmarshaler. - u, ut, pv := d.indirect(v, false) - if u != nil { - d.off-- - err := u.UnmarshalJSON(d.next()) - if err != nil { - d.error(err) - } - return - } - if ut != nil { - d.saveError(&UnmarshalTypeError{"array", v.Type(), int64(d.off)}) - d.off-- - d.next() - return - } - - v = pv - - // Check type of target. - switch v.Kind() { - case reflect.Interface: - if v.NumMethod() == 0 { - // Decoding into nil interface? Switch to non-reflect code. - v.Set(reflect.ValueOf(d.arrayInterface())) - return - } - // Otherwise it's invalid. - fallthrough - default: - d.saveError(&UnmarshalTypeError{"array", v.Type(), int64(d.off)}) - d.off-- - d.next() - return - case reflect.Array: - case reflect.Slice: - break - } - - i := 0 - for { - // Look ahead for ] - can only happen on first iteration. - op := d.scanWhile(scanSkipSpace) - if op == scanEndArray { - break - } - - // Back up so d.value can have the byte we just read. - d.off-- - d.scan.undo(op) - - // Get element of array, growing if necessary. - if v.Kind() == reflect.Slice { - // Grow slice if necessary - if i >= v.Cap() { - newcap := v.Cap() + v.Cap()/2 - if newcap < 4 { - newcap = 4 - } - newv := reflect.MakeSlice(v.Type(), v.Len(), newcap) - reflect.Copy(newv, v) - v.Set(newv) - } - if i >= v.Len() { - v.SetLen(i + 1) - } - } - - if i < v.Len() { - // Decode into element. - d.value(v.Index(i)) - } else { - // Ran out of fixed array: skip. - d.value(reflect.Value{}) - } - i++ - - // Next token must be , or ]. - op = d.scanWhile(scanSkipSpace) - if op == scanEndArray { - break - } - if op != scanArrayValue { - d.error(errPhase) - } - } - - if i < v.Len() { - if v.Kind() == reflect.Array { - // Array. Zero the rest. - z := reflect.Zero(v.Type().Elem()) - for ; i < v.Len(); i++ { - v.Index(i).Set(z) - } - } else { - v.SetLen(i) - } - } - if i == 0 && v.Kind() == reflect.Slice { - v.Set(reflect.MakeSlice(v.Type(), 0, 0)) - } -} - -var nullLiteral = []byte("null") - -// object consumes an object from d.data[d.off-1:], decoding into the value v. -// the first byte ('{') of the object has been read already. -func (d *decodeState) object(v reflect.Value) { - // Check for unmarshaler. - u, ut, pv := d.indirect(v, false) - if u != nil { - d.off-- - err := u.UnmarshalJSON(d.next()) - if err != nil { - d.error(err) - } - return - } - if ut != nil { - d.saveError(&UnmarshalTypeError{"object", v.Type(), int64(d.off)}) - d.off-- - d.next() // skip over { } in input - return - } - v = pv - - // Decoding into nil interface? Switch to non-reflect code. - if v.Kind() == reflect.Interface && v.NumMethod() == 0 { - v.Set(reflect.ValueOf(d.objectInterface())) - return - } - - // Check type of target: struct or map[string]T - switch v.Kind() { - case reflect.Map: - // map must have string kind - t := v.Type() - if t.Key().Kind() != reflect.String { - d.saveError(&UnmarshalTypeError{"object", v.Type(), int64(d.off)}) - d.off-- - d.next() // skip over { } in input - return - } - if v.IsNil() { - v.Set(reflect.MakeMap(t)) - } - case reflect.Struct: - - default: - d.saveError(&UnmarshalTypeError{"object", v.Type(), int64(d.off)}) - d.off-- - d.next() // skip over { } in input - return - } - - var mapElem reflect.Value - keys := map[string]bool{} - - for { - // Read opening " of string key or closing }. - op := d.scanWhile(scanSkipSpace) - if op == scanEndObject { - // closing } - can only happen on first iteration. - break - } - if op != scanBeginLiteral { - d.error(errPhase) - } - - // Read key. - start := d.off - 1 - op = d.scanWhile(scanContinue) - item := d.data[start : d.off-1] - key, ok := unquote(item) - if !ok { - d.error(errPhase) - } - - // Check for duplicate keys. - _, ok = keys[key] - if !ok { - keys[key] = true - } else { - d.error(fmt.Errorf("json: duplicate key '%s' in object", key)) - } - - // Figure out field corresponding to key. - var subv reflect.Value - destring := false // whether the value is wrapped in a string to be decoded first - - if v.Kind() == reflect.Map { - elemType := v.Type().Elem() - if !mapElem.IsValid() { - mapElem = reflect.New(elemType).Elem() - } else { - mapElem.Set(reflect.Zero(elemType)) - } - subv = mapElem - } else { - var f *field - fields := cachedTypeFields(v.Type()) - for i := range fields { - ff := &fields[i] - if bytes.Equal(ff.nameBytes, []byte(key)) { - f = ff - break - } - } - if f != nil { - subv = v - destring = f.quoted - for _, i := range f.index { - if subv.Kind() == reflect.Ptr { - if subv.IsNil() { - subv.Set(reflect.New(subv.Type().Elem())) - } - subv = subv.Elem() - } - subv = subv.Field(i) - } - } - } - - // Read : before value. - if op == scanSkipSpace { - op = d.scanWhile(scanSkipSpace) - } - if op != scanObjectKey { - d.error(errPhase) - } - - // Read value. - if destring { - switch qv := d.valueQuoted().(type) { - case nil: - d.literalStore(nullLiteral, subv, false) - case string: - d.literalStore([]byte(qv), subv, true) - default: - d.saveError(fmt.Errorf("json: invalid use of ,string struct tag, trying to unmarshal unquoted value into %v", subv.Type())) - } - } else { - d.value(subv) - } - - // Write value back to map; - // if using struct, subv points into struct already. - if v.Kind() == reflect.Map { - kv := reflect.ValueOf(key).Convert(v.Type().Key()) - v.SetMapIndex(kv, subv) - } - - // Next token must be , or }. - op = d.scanWhile(scanSkipSpace) - if op == scanEndObject { - break - } - if op != scanObjectValue { - d.error(errPhase) - } - } -} - -// literal consumes a literal from d.data[d.off-1:], decoding into the value v. -// The first byte of the literal has been read already -// (that's how the caller knows it's a literal). -func (d *decodeState) literal(v reflect.Value) { - // All bytes inside literal return scanContinue op code. - start := d.off - 1 - op := d.scanWhile(scanContinue) - - // Scan read one byte too far; back up. - d.off-- - d.scan.undo(op) - - d.literalStore(d.data[start:d.off], v, false) -} - -// convertNumber converts the number literal s to a float64 or a Number -// depending on the setting of d.useNumber. -func (d *decodeState) convertNumber(s string) (interface{}, error) { - if d.useNumber { - return Number(s), nil - } - f, err := strconv.ParseFloat(s, 64) - if err != nil { - return nil, &UnmarshalTypeError{"number " + s, reflect.TypeOf(0.0), int64(d.off)} - } - return f, nil -} - -var numberType = reflect.TypeOf(Number("")) - -// literalStore decodes a literal stored in item into v. -// -// fromQuoted indicates whether this literal came from unwrapping a -// string from the ",string" struct tag option. this is used only to -// produce more helpful error messages. -func (d *decodeState) literalStore(item []byte, v reflect.Value, fromQuoted bool) { - // Check for unmarshaler. - if len(item) == 0 { - //Empty string given - d.saveError(fmt.Errorf("json: invalid use of ,string struct tag, trying to unmarshal %q into %v", item, v.Type())) - return - } - wantptr := item[0] == 'n' // null - u, ut, pv := d.indirect(v, wantptr) - if u != nil { - err := u.UnmarshalJSON(item) - if err != nil { - d.error(err) - } - return - } - if ut != nil { - if item[0] != '"' { - if fromQuoted { - d.saveError(fmt.Errorf("json: invalid use of ,string struct tag, trying to unmarshal %q into %v", item, v.Type())) - } else { - d.saveError(&UnmarshalTypeError{"string", v.Type(), int64(d.off)}) - } - return - } - s, ok := unquoteBytes(item) - if !ok { - if fromQuoted { - d.error(fmt.Errorf("json: invalid use of ,string struct tag, trying to unmarshal %q into %v", item, v.Type())) - } else { - d.error(errPhase) - } - } - err := ut.UnmarshalText(s) - if err != nil { - d.error(err) - } - return - } - - v = pv - - switch c := item[0]; c { - case 'n': // null - switch v.Kind() { - case reflect.Interface, reflect.Ptr, reflect.Map, reflect.Slice: - v.Set(reflect.Zero(v.Type())) - // otherwise, ignore null for primitives/string - } - case 't', 'f': // true, false - value := c == 't' - switch v.Kind() { - default: - if fromQuoted { - d.saveError(fmt.Errorf("json: invalid use of ,string struct tag, trying to unmarshal %q into %v", item, v.Type())) - } else { - d.saveError(&UnmarshalTypeError{"bool", v.Type(), int64(d.off)}) - } - case reflect.Bool: - v.SetBool(value) - case reflect.Interface: - if v.NumMethod() == 0 { - v.Set(reflect.ValueOf(value)) - } else { - d.saveError(&UnmarshalTypeError{"bool", v.Type(), int64(d.off)}) - } - } - - case '"': // string - s, ok := unquoteBytes(item) - if !ok { - if fromQuoted { - d.error(fmt.Errorf("json: invalid use of ,string struct tag, trying to unmarshal %q into %v", item, v.Type())) - } else { - d.error(errPhase) - } - } - switch v.Kind() { - default: - d.saveError(&UnmarshalTypeError{"string", v.Type(), int64(d.off)}) - case reflect.Slice: - if v.Type().Elem().Kind() != reflect.Uint8 { - d.saveError(&UnmarshalTypeError{"string", v.Type(), int64(d.off)}) - break - } - b := make([]byte, base64.StdEncoding.DecodedLen(len(s))) - n, err := base64.StdEncoding.Decode(b, s) - if err != nil { - d.saveError(err) - break - } - v.SetBytes(b[:n]) - case reflect.String: - v.SetString(string(s)) - case reflect.Interface: - if v.NumMethod() == 0 { - v.Set(reflect.ValueOf(string(s))) - } else { - d.saveError(&UnmarshalTypeError{"string", v.Type(), int64(d.off)}) - } - } - - default: // number - if c != '-' && (c < '0' || c > '9') { - if fromQuoted { - d.error(fmt.Errorf("json: invalid use of ,string struct tag, trying to unmarshal %q into %v", item, v.Type())) - } else { - d.error(errPhase) - } - } - s := string(item) - switch v.Kind() { - default: - if v.Kind() == reflect.String && v.Type() == numberType { - v.SetString(s) - if !isValidNumber(s) { - d.error(fmt.Errorf("json: invalid number literal, trying to unmarshal %q into Number", item)) - } - break - } - if fromQuoted { - d.error(fmt.Errorf("json: invalid use of ,string struct tag, trying to unmarshal %q into %v", item, v.Type())) - } else { - d.error(&UnmarshalTypeError{"number", v.Type(), int64(d.off)}) - } - case reflect.Interface: - n, err := d.convertNumber(s) - if err != nil { - d.saveError(err) - break - } - if v.NumMethod() != 0 { - d.saveError(&UnmarshalTypeError{"number", v.Type(), int64(d.off)}) - break - } - v.Set(reflect.ValueOf(n)) - - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - n, err := strconv.ParseInt(s, 10, 64) - if err != nil || v.OverflowInt(n) { - d.saveError(&UnmarshalTypeError{"number " + s, v.Type(), int64(d.off)}) - break - } - v.SetInt(n) - - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: - n, err := strconv.ParseUint(s, 10, 64) - if err != nil || v.OverflowUint(n) { - d.saveError(&UnmarshalTypeError{"number " + s, v.Type(), int64(d.off)}) - break - } - v.SetUint(n) - - case reflect.Float32, reflect.Float64: - n, err := strconv.ParseFloat(s, v.Type().Bits()) - if err != nil || v.OverflowFloat(n) { - d.saveError(&UnmarshalTypeError{"number " + s, v.Type(), int64(d.off)}) - break - } - v.SetFloat(n) - } - } -} - -// The xxxInterface routines build up a value to be stored -// in an empty interface. They are not strictly necessary, -// but they avoid the weight of reflection in this common case. - -// valueInterface is like value but returns interface{} -func (d *decodeState) valueInterface() interface{} { - switch d.scanWhile(scanSkipSpace) { - default: - d.error(errPhase) - panic("unreachable") - case scanBeginArray: - return d.arrayInterface() - case scanBeginObject: - return d.objectInterface() - case scanBeginLiteral: - return d.literalInterface() - } -} - -// arrayInterface is like array but returns []interface{}. -func (d *decodeState) arrayInterface() []interface{} { - var v = make([]interface{}, 0) - for { - // Look ahead for ] - can only happen on first iteration. - op := d.scanWhile(scanSkipSpace) - if op == scanEndArray { - break - } - - // Back up so d.value can have the byte we just read. - d.off-- - d.scan.undo(op) - - v = append(v, d.valueInterface()) - - // Next token must be , or ]. - op = d.scanWhile(scanSkipSpace) - if op == scanEndArray { - break - } - if op != scanArrayValue { - d.error(errPhase) - } - } - return v -} - -// objectInterface is like object but returns map[string]interface{}. -func (d *decodeState) objectInterface() map[string]interface{} { - m := make(map[string]interface{}) - keys := map[string]bool{} - - for { - // Read opening " of string key or closing }. - op := d.scanWhile(scanSkipSpace) - if op == scanEndObject { - // closing } - can only happen on first iteration. - break - } - if op != scanBeginLiteral { - d.error(errPhase) - } - - // Read string key. - start := d.off - 1 - op = d.scanWhile(scanContinue) - item := d.data[start : d.off-1] - key, ok := unquote(item) - if !ok { - d.error(errPhase) - } - - // Check for duplicate keys. - _, ok = keys[key] - if !ok { - keys[key] = true - } else { - d.error(fmt.Errorf("json: duplicate key '%s' in object", key)) - } - - // Read : before value. - if op == scanSkipSpace { - op = d.scanWhile(scanSkipSpace) - } - if op != scanObjectKey { - d.error(errPhase) - } - - // Read value. - m[key] = d.valueInterface() - - // Next token must be , or }. - op = d.scanWhile(scanSkipSpace) - if op == scanEndObject { - break - } - if op != scanObjectValue { - d.error(errPhase) - } - } - return m -} - -// literalInterface is like literal but returns an interface value. -func (d *decodeState) literalInterface() interface{} { - // All bytes inside literal return scanContinue op code. - start := d.off - 1 - op := d.scanWhile(scanContinue) - - // Scan read one byte too far; back up. - d.off-- - d.scan.undo(op) - item := d.data[start:d.off] - - switch c := item[0]; c { - case 'n': // null - return nil - - case 't', 'f': // true, false - return c == 't' - - case '"': // string - s, ok := unquote(item) - if !ok { - d.error(errPhase) - } - return s - - default: // number - if c != '-' && (c < '0' || c > '9') { - d.error(errPhase) - } - n, err := d.convertNumber(string(item)) - if err != nil { - d.saveError(err) - } - return n - } -} - -// getu4 decodes \uXXXX from the beginning of s, returning the hex value, -// or it returns -1. -func getu4(s []byte) rune { - if len(s) < 6 || s[0] != '\\' || s[1] != 'u' { - return -1 - } - r, err := strconv.ParseUint(string(s[2:6]), 16, 64) - if err != nil { - return -1 - } - return rune(r) -} - -// unquote converts a quoted JSON string literal s into an actual string t. -// The rules are different than for Go, so cannot use strconv.Unquote. -func unquote(s []byte) (t string, ok bool) { - s, ok = unquoteBytes(s) - t = string(s) - return -} - -func unquoteBytes(s []byte) (t []byte, ok bool) { - if len(s) < 2 || s[0] != '"' || s[len(s)-1] != '"' { - return - } - s = s[1 : len(s)-1] - - // Check for unusual characters. If there are none, - // then no unquoting is needed, so return a slice of the - // original bytes. - r := 0 - for r < len(s) { - c := s[r] - if c == '\\' || c == '"' || c < ' ' { - break - } - if c < utf8.RuneSelf { - r++ - continue - } - rr, size := utf8.DecodeRune(s[r:]) - if rr == utf8.RuneError && size == 1 { - break - } - r += size - } - if r == len(s) { - return s, true - } - - b := make([]byte, len(s)+2*utf8.UTFMax) - w := copy(b, s[0:r]) - for r < len(s) { - // Out of room? Can only happen if s is full of - // malformed UTF-8 and we're replacing each - // byte with RuneError. - if w >= len(b)-2*utf8.UTFMax { - nb := make([]byte, (len(b)+utf8.UTFMax)*2) - copy(nb, b[0:w]) - b = nb - } - switch c := s[r]; { - case c == '\\': - r++ - if r >= len(s) { - return - } - switch s[r] { - default: - return - case '"', '\\', '/', '\'': - b[w] = s[r] - r++ - w++ - case 'b': - b[w] = '\b' - r++ - w++ - case 'f': - b[w] = '\f' - r++ - w++ - case 'n': - b[w] = '\n' - r++ - w++ - case 'r': - b[w] = '\r' - r++ - w++ - case 't': - b[w] = '\t' - r++ - w++ - case 'u': - r-- - rr := getu4(s[r:]) - if rr < 0 { - return - } - r += 6 - if utf16.IsSurrogate(rr) { - rr1 := getu4(s[r:]) - if dec := utf16.DecodeRune(rr, rr1); dec != unicode.ReplacementChar { - // A valid pair; consume. - r += 6 - w += utf8.EncodeRune(b[w:], dec) - break - } - // Invalid surrogate; fall back to replacement rune. - rr = unicode.ReplacementChar - } - w += utf8.EncodeRune(b[w:], rr) - } - - // Quote, control characters are invalid. - case c == '"', c < ' ': - return - - // ASCII - case c < utf8.RuneSelf: - b[w] = c - r++ - w++ - - // Coerce to well-formed UTF-8. - default: - rr, size := utf8.DecodeRune(s[r:]) - r += size - w += utf8.EncodeRune(b[w:], rr) - } - } - return b[0:w], true -} diff --git a/vendor/gopkg.in/square/go-jose.v1/json/encode.go b/vendor/gopkg.in/square/go-jose.v1/json/encode.go deleted file mode 100644 index 1dae8bb7c..000000000 --- a/vendor/gopkg.in/square/go-jose.v1/json/encode.go +++ /dev/null @@ -1,1197 +0,0 @@ -// Copyright 2010 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package json implements encoding and decoding of JSON objects as defined in -// RFC 4627. The mapping between JSON objects and Go values is described -// in the documentation for the Marshal and Unmarshal functions. -// -// See "JSON and Go" for an introduction to this package: -// https://golang.org/doc/articles/json_and_go.html -package json - -import ( - "bytes" - "encoding" - "encoding/base64" - "fmt" - "math" - "reflect" - "runtime" - "sort" - "strconv" - "strings" - "sync" - "unicode" - "unicode/utf8" -) - -// Marshal returns the JSON encoding of v. -// -// Marshal traverses the value v recursively. -// If an encountered value implements the Marshaler interface -// and is not a nil pointer, Marshal calls its MarshalJSON method -// to produce JSON. If no MarshalJSON method is present but the -// value implements encoding.TextMarshaler instead, Marshal calls -// its MarshalText method. -// The nil pointer exception is not strictly necessary -// but mimics a similar, necessary exception in the behavior of -// UnmarshalJSON. -// -// Otherwise, Marshal uses the following type-dependent default encodings: -// -// Boolean values encode as JSON booleans. -// -// Floating point, integer, and Number values encode as JSON numbers. -// -// String values encode as JSON strings coerced to valid UTF-8, -// replacing invalid bytes with the Unicode replacement rune. -// The angle brackets "<" and ">" are escaped to "\u003c" and "\u003e" -// to keep some browsers from misinterpreting JSON output as HTML. -// Ampersand "&" is also escaped to "\u0026" for the same reason. -// -// Array and slice values encode as JSON arrays, except that -// []byte encodes as a base64-encoded string, and a nil slice -// encodes as the null JSON object. -// -// Struct values encode as JSON objects. Each exported struct field -// becomes a member of the object unless -// - the field's tag is "-", or -// - the field is empty and its tag specifies the "omitempty" option. -// The empty values are false, 0, any -// nil pointer or interface value, and any array, slice, map, or string of -// length zero. The object's default key string is the struct field name -// but can be specified in the struct field's tag value. The "json" key in -// the struct field's tag value is the key name, followed by an optional comma -// and options. Examples: -// -// // Field is ignored by this package. -// Field int `json:"-"` -// -// // Field appears in JSON as key "myName". -// Field int `json:"myName"` -// -// // Field appears in JSON as key "myName" and -// // the field is omitted from the object if its value is empty, -// // as defined above. -// Field int `json:"myName,omitempty"` -// -// // Field appears in JSON as key "Field" (the default), but -// // the field is skipped if empty. -// // Note the leading comma. -// Field int `json:",omitempty"` -// -// The "string" option signals that a field is stored as JSON inside a -// JSON-encoded string. It applies only to fields of string, floating point, -// integer, or boolean types. This extra level of encoding is sometimes used -// when communicating with JavaScript programs: -// -// Int64String int64 `json:",string"` -// -// The key name will be used if it's a non-empty string consisting of -// only Unicode letters, digits, dollar signs, percent signs, hyphens, -// underscores and slashes. -// -// Anonymous struct fields are usually marshaled as if their inner exported fields -// were fields in the outer struct, subject to the usual Go visibility rules amended -// as described in the next paragraph. -// An anonymous struct field with a name given in its JSON tag is treated as -// having that name, rather than being anonymous. -// An anonymous struct field of interface type is treated the same as having -// that type as its name, rather than being anonymous. -// -// The Go visibility rules for struct fields are amended for JSON when -// deciding which field to marshal or unmarshal. If there are -// multiple fields at the same level, and that level is the least -// nested (and would therefore be the nesting level selected by the -// usual Go rules), the following extra rules apply: -// -// 1) Of those fields, if any are JSON-tagged, only tagged fields are considered, -// even if there are multiple untagged fields that would otherwise conflict. -// 2) If there is exactly one field (tagged or not according to the first rule), that is selected. -// 3) Otherwise there are multiple fields, and all are ignored; no error occurs. -// -// Handling of anonymous struct fields is new in Go 1.1. -// Prior to Go 1.1, anonymous struct fields were ignored. To force ignoring of -// an anonymous struct field in both current and earlier versions, give the field -// a JSON tag of "-". -// -// Map values encode as JSON objects. -// The map's key type must be string; the map keys are used as JSON object -// keys, subject to the UTF-8 coercion described for string values above. -// -// Pointer values encode as the value pointed to. -// A nil pointer encodes as the null JSON object. -// -// Interface values encode as the value contained in the interface. -// A nil interface value encodes as the null JSON object. -// -// Channel, complex, and function values cannot be encoded in JSON. -// Attempting to encode such a value causes Marshal to return -// an UnsupportedTypeError. -// -// JSON cannot represent cyclic data structures and Marshal does not -// handle them. Passing cyclic structures to Marshal will result in -// an infinite recursion. -// -func Marshal(v interface{}) ([]byte, error) { - e := &encodeState{} - err := e.marshal(v) - if err != nil { - return nil, err - } - return e.Bytes(), nil -} - -// MarshalIndent is like Marshal but applies Indent to format the output. -func MarshalIndent(v interface{}, prefix, indent string) ([]byte, error) { - b, err := Marshal(v) - if err != nil { - return nil, err - } - var buf bytes.Buffer - err = Indent(&buf, b, prefix, indent) - if err != nil { - return nil, err - } - return buf.Bytes(), nil -} - -// HTMLEscape appends to dst the JSON-encoded src with <, >, &, U+2028 and U+2029 -// characters inside string literals changed to \u003c, \u003e, \u0026, \u2028, \u2029 -// so that the JSON will be safe to embed inside HTML