diff --git a/.travis.yml b/.travis.yml index 5097caa1d..b369adc45 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ sudo: false language: go go: - - 1.5.1 + - 1.5.2 - tip matrix: diff --git a/CHANGELOG.md b/CHANGELOG.md index d58821230..2f2bcc8a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,52 @@ -## 0.4.0 (Unreleased) +## 0.5.0 (Unreleased) + +DEPRECATIONS/BREAKING CHANGES: + * S3 physical backend: Environment variables are now preferred over + configuration values. This makes it behave similar to the rest of Vault, + which, in increasing order of preference, uses values from the configuration + file, environment variables, and CLI flags. [GH-871] + +FEATURES: + + * **Split Data/High Availability Physical Backends**: You can now configure + two separate physical backends: one to be used for High Availability + coordination and another to be used for encrypted data storage. See the + [configuration + documentation](https://vaultproject.io/docs/config/index.html) for details. + [GH-395] + +IMPROVEMENTS: + + * cli: Output secrets sorted by key name [GH-830] + * cli: Support YAML as an output format [GH-832] + * cli: Show an error if the output format is incorrect, rather than falling + back to an empty table [GH-849] + * cli: Allow setting the `advertise_addr` for HA via the + `VAULT_ADVERTISE_ADDR` environment variable [GH-581] + * helper/certutil: Add ability to parse PKCS#8 bundles [GH-829] + * logical/pki: Assign ExtKeyUsageAny to CA certs generated/signed with the + backend; this fixes the non-spec validation logic used in the Windows Crypto + API and Go's verification functions [GH-846] + * physical/etcd: Support basic auth [GH-859] + +BUG FIXES: + * api: Correct the HTTP verb used in the LookupSelf method [GH-887] + * core: When running in standalone mode, don't advertise that we are active + until post-unseal setup completes [GH-872] + * core: Update go-cleanhttp dependency to ensure idle connections aren't + leaked [GH-867] + * physical: Use square brackets when setting an IPv6-based advertise address + as the auto-detected advertise address [GH-883] + * physical/s3: Use an initialized client when using IAM roles to fix a + regression introduced against newer versions of the AWS Go SDK [GH-836] + +MISC: + + * Add `vault-java` to libraries [GH-851] + * Various minor documentation fixes and improvements [GH-839] [GH-854] + [GH-861] [GH-876] + +## 0.4.0 (December 10, 2015) DEPRECATIONS/BREAKING CHANGES: @@ -11,9 +59,25 @@ DEPRECATIONS/BREAKING CHANGES: * As noted below in the FEATURES section, if your Vault installation contains a policy called `default`, new tokens created will inherit this policy automatically. + * In the PKI backend there have been a few minor breaking changes: + * The token display name is no longer a valid option for providing a base + domain for issuance. Since this name is prepended with the name of the + authentication backend that issued it, it provided a faulty use-case at best + and a confusing experience at worst. We hope to figure out a better + per-token value in a future release. + * The `allowed_base_domain` parameter has been changed to `allowed_domains`, + which accepts a comma-separated list of domains. This allows issuing + certificates with DNS subjects across multiple domains. If you had a + configured `allowed_base_domain` parameter, it will be migrated + automatically when the role is read (either via a normal read, or via + issuing a certificate). FEATURES: + * **Significantly Enhanced PKI Backend**: The `pki` backend can now generate + and sign root CA certificates and intermediate CA CSRs. It can also now sign + submitted client CSRs, as well as a significant number of other + enhancements. See the updated documentation for the full API. [GH-666] * **CRL Checking for Certificate Authentication**: The `cert` backend now supports pushing CRLs into the mount and using the contained serial numbers for revocation checking. See the documentation for the `cert` backend for @@ -58,9 +122,12 @@ IMPROVEMENTS: * logical: Responses now contain a "warnings" key containing a list of warnings returned from the server. These are conditions that did not require failing an operation, but of which the client should be aware. [GH-676] - * physical/consul: Consul now uses a connection pool to limit the number of - outstanding operations, improving behavior when a lot of operations must - happen at once [GH-677] + * physical/(consul,etcd): Consul and etcd now use a connection pool to limit + the number of outstanding operations, improving behavior when a lot of + operations must happen at once [GH-677] [GH-780] + * physical/consul: The `datacenter` parameter was removed; It could not be + effective unless the Vault node (or the Consul node it was connecting to) + was in the datacenter specified, in which case it wasn't needed [GH-816] * physical/etcd: Support TLS-encrypted connections and use a connection pool to limit the number of outstanding operations [GH-780] * physical/s3: The S3 endpoint can now be configured, allowing using @@ -94,13 +161,15 @@ generate them, leading to client errors. * secret/generic: Validate given duration at write time, not just read time; if stored durations are not parseable, return a warning and the default duration rather than an error [GH-718] + * secret/generic: Return 400 instead of 500 when `generic` backend is written + to with no data fields [GH-825] * secret/postgresql: Revoke permissions before dropping a user or revocation may fail [GH-699] MISC: * Various documentation fixes and improvements [GH-685] [GH-688] [GH-697] - [GH-710] [GH-715] + [GH-710] [GH-715] [GH-831] ## 0.3.1 (October 6, 2015) diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 9e047ec8f..98508a188 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -1,6 +1,6 @@ { "ImportPath": "github.com/hashicorp/vault", - "GoVersion": "go1.5.1", + "GoVersion": "go1.5.2", "Packages": [ "./..." ], @@ -13,85 +13,90 @@ "ImportPath": "github.com/armon/go-radix", "Rev": "fbd82e84e2b13651f3abc5ffd26b65ba71bc8f93" }, + { + "ImportPath": "github.com/asaskevich/govalidator", + "Comment": "v2-37-gedd46cd", + "Rev": "edd46cdac249b001c7b7d88c6d43993ea875e8d8" + }, { "ImportPath": "github.com/aws/aws-sdk-go/aws", - "Comment": "v0.10.4-18-gce51895", - "Rev": "ce51895e994693d65ab997ae48032bf13a9290b7" + "Comment": "v1.0.4", + "Rev": "999b1591218c36d5050d1ba7266eba956e65965f" }, { "ImportPath": "github.com/aws/aws-sdk-go/private/endpoints", - "Comment": "v0.10.4-18-gce51895", - "Rev": "ce51895e994693d65ab997ae48032bf13a9290b7" + "Comment": "v1.0.4", + "Rev": "999b1591218c36d5050d1ba7266eba956e65965f" }, { "ImportPath": "github.com/aws/aws-sdk-go/private/protocol/ec2query", - "Comment": "v0.10.4-18-gce51895", - "Rev": "ce51895e994693d65ab997ae48032bf13a9290b7" + "Comment": "v1.0.4", + "Rev": "999b1591218c36d5050d1ba7266eba956e65965f" }, { "ImportPath": "github.com/aws/aws-sdk-go/private/protocol/query", - "Comment": "v0.10.4-18-gce51895", - "Rev": "ce51895e994693d65ab997ae48032bf13a9290b7" + "Comment": "v1.0.4", + "Rev": "999b1591218c36d5050d1ba7266eba956e65965f" }, { "ImportPath": "github.com/aws/aws-sdk-go/private/protocol/rest", - "Comment": "v0.10.4-18-gce51895", - "Rev": "ce51895e994693d65ab997ae48032bf13a9290b7" + "Comment": "v1.0.4", + "Rev": "999b1591218c36d5050d1ba7266eba956e65965f" }, { "ImportPath": "github.com/aws/aws-sdk-go/private/protocol/restxml", - "Comment": "v0.10.4-18-gce51895", - "Rev": "ce51895e994693d65ab997ae48032bf13a9290b7" + "Comment": "v1.0.4", + "Rev": "999b1591218c36d5050d1ba7266eba956e65965f" }, { "ImportPath": "github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil", - "Comment": "v0.10.4-18-gce51895", - "Rev": "ce51895e994693d65ab997ae48032bf13a9290b7" + "Comment": "v1.0.4", + "Rev": "999b1591218c36d5050d1ba7266eba956e65965f" }, { "ImportPath": "github.com/aws/aws-sdk-go/private/signer/v4", - "Comment": "v0.10.4-18-gce51895", - "Rev": "ce51895e994693d65ab997ae48032bf13a9290b7" + "Comment": "v1.0.4", + "Rev": "999b1591218c36d5050d1ba7266eba956e65965f" }, { "ImportPath": "github.com/aws/aws-sdk-go/private/waiter", - "Comment": "v0.10.4-18-gce51895", - "Rev": "ce51895e994693d65ab997ae48032bf13a9290b7" + "Comment": "v1.0.4", + "Rev": "999b1591218c36d5050d1ba7266eba956e65965f" }, { "ImportPath": "github.com/aws/aws-sdk-go/service/ec2", - "Comment": "v0.10.4-18-gce51895", - "Rev": "ce51895e994693d65ab997ae48032bf13a9290b7" + "Comment": "v1.0.4", + "Rev": "999b1591218c36d5050d1ba7266eba956e65965f" }, { "ImportPath": "github.com/aws/aws-sdk-go/service/iam", - "Comment": "v0.10.4-18-gce51895", - "Rev": "ce51895e994693d65ab997ae48032bf13a9290b7" + "Comment": "v1.0.4", + "Rev": "999b1591218c36d5050d1ba7266eba956e65965f" }, { "ImportPath": "github.com/aws/aws-sdk-go/service/s3", - "Comment": "v0.10.4-18-gce51895", - "Rev": "ce51895e994693d65ab997ae48032bf13a9290b7" + "Comment": "v1.0.4", + "Rev": "999b1591218c36d5050d1ba7266eba956e65965f" }, { "ImportPath": "github.com/coreos/etcd/client", - "Comment": "v2.3.0-alpha.0-64-gc4672ce", - "Rev": "c4672ced3e0a0dc2232af3194d00d869516866f1" + "Comment": "v2.3.0-alpha.0-117-g858857d", + "Rev": "858857d7013af3142310aa2cef9a29d6a2edb736" }, { "ImportPath": "github.com/coreos/etcd/pkg/pathutil", - "Comment": "v2.3.0-alpha.0-64-gc4672ce", - "Rev": "c4672ced3e0a0dc2232af3194d00d869516866f1" + "Comment": "v2.3.0-alpha.0-117-g858857d", + "Rev": "858857d7013af3142310aa2cef9a29d6a2edb736" }, { "ImportPath": "github.com/coreos/etcd/pkg/transport", - "Comment": "v2.3.0-alpha.0-64-gc4672ce", - "Rev": "c4672ced3e0a0dc2232af3194d00d869516866f1" + "Comment": "v2.3.0-alpha.0-117-g858857d", + "Rev": "858857d7013af3142310aa2cef9a29d6a2edb736" }, { "ImportPath": "github.com/coreos/etcd/pkg/types", - "Comment": "v2.3.0-alpha.0-64-gc4672ce", - "Rev": "c4672ced3e0a0dc2232af3194d00d869516866f1" + "Comment": "v2.3.0-alpha.0-117-g858857d", + "Rev": "858857d7013af3142310aa2cef9a29d6a2edb736" }, { "ImportPath": "github.com/duosecurity/duo_api_golang", @@ -99,17 +104,21 @@ }, { "ImportPath": "github.com/fatih/structs", - "Rev": "c701457aaa1ff6709d5e35fccb5c129448e0a37b" + "Rev": "9a7733345ff091c5457cb963f498a79ecd0bdbaa" + }, + { + "ImportPath": "github.com/ghodss/yaml", + "Rev": "73d445a93680fa1a78ae23a5839bad48f32ba1ee" }, { "ImportPath": "github.com/go-ini/ini", - "Comment": "v0-48-g060d7da", - "Rev": "060d7da055ba6ec5ea7a31f116332fe5efa04ce0" + "Comment": "v0-56-g03e0e7d", + "Rev": "03e0e7d51a13a91c765d8d0161246bc14a38001a" }, { "ImportPath": "github.com/go-ldap/ldap", - "Comment": "v2.1-8-ge983ad5", - "Rev": "e983ad52b3ab99bd12fc7cad94e31509a0a010cc" + "Comment": "v2.2", + "Rev": "e9a325d64989e2844be629682cb085d2c58eef8d" }, { "ImportPath": "github.com/go-sql-driver/mysql", @@ -118,8 +127,8 @@ }, { "ImportPath": "github.com/gocql/gocql", - "Comment": "1st_gen_framing-361-gf8da9df", - "Rev": "f8da9dfadd52ef498900e0050ee6578e0f58e8ce" + "Comment": "1st_gen_framing-383-g87cc185", + "Rev": "87cc1854b57c7a4d8f4ae1d0cc358ed6ecb0f8c3" }, { "ImportPath": "github.com/golang/snappy", @@ -127,7 +136,7 @@ }, { "ImportPath": "github.com/google/go-github/github", - "Rev": "6eb49d4ba5175412dcbb29b0031ebf02ab85a48d" + "Rev": "47f2593dad1971eec2f0a0971aa007fef5edbc50" }, { "ImportPath": "github.com/google/go-querystring/query", @@ -139,8 +148,8 @@ }, { "ImportPath": "github.com/hashicorp/consul/api", - "Comment": "v0.6.0-rc2-1-g402a366", - "Rev": "402a3666769ea796d3b5b779ae343bb8c59abc50" + "Comment": "v0.6.0-rc2-21-g86f20a3", + "Rev": "86f20a32e5afe1fbcd98129239cdea4bf8b0d5ba" }, { "ImportPath": "github.com/hashicorp/errwrap", @@ -148,7 +157,7 @@ }, { "ImportPath": "github.com/hashicorp/go-cleanhttp", - "Rev": "5df5ddc69534f1a4697289f1dca2193fbb40213f" + "Rev": "ce617e79981a8fff618bb643d155133a8f38db96" }, { "ImportPath": "github.com/hashicorp/go-multierror", @@ -158,9 +167,13 @@ "ImportPath": "github.com/hashicorp/go-syslog", "Rev": "42a2b573b664dbf281bd48c3cc12c086b17a39ba" }, + { + "ImportPath": "github.com/hashicorp/go-uuid", + "Rev": "2d537aea09f39d27f9aa33092154c51ebe277486" + }, { "ImportPath": "github.com/hashicorp/golang-lru", - "Rev": "a6091bb5d00e2e9c4a16a0e739e306f8a3071a3c" + "Rev": "b361c4c189a958f7d0ad435952611c140751afe2" }, { "ImportPath": "github.com/hashicorp/hcl", @@ -175,10 +188,6 @@ "Comment": "v0.6.4-145-ga72c045", "Rev": "a72c0453da2ba628a013e98bf323a76be4aa1443" }, - { - "ImportPath": "github.com/hashicorp/uuid", - "Rev": "2951e8b9707a040acdb49145ed9f36a088f3532e" - }, { "ImportPath": "github.com/jmespath/go-jmespath", "Comment": "0.2.2", @@ -186,12 +195,12 @@ }, { "ImportPath": "github.com/kardianos/osext", - "Rev": "345163ffe35aa66560a4cd7dddf00f3ae21c9fda" + "Rev": "10da29423eb9a6269092eebdc2be32209612d9d2" }, { "ImportPath": "github.com/lib/pq", - "Comment": "go1.0-cutoff-61-g83c4f41", - "Rev": "83c4f410d0aed80a0f44bac6a576a7f2435791f3" + "Comment": "go1.0-cutoff-63-g11fc39a", + "Rev": "11fc39a580a008f1f39bb3d11d984fb34ed778d9" }, { "ImportPath": "github.com/mitchellh/cli", @@ -228,31 +237,31 @@ }, { "ImportPath": "golang.org/x/crypto/bcrypt", - "Rev": "346896d57731cb5670b36c6178fc5519f3225980" + "Rev": "7b85b097bf7527677d54d3220065e966a0e3b613" }, { "ImportPath": "golang.org/x/crypto/blowfish", - "Rev": "346896d57731cb5670b36c6178fc5519f3225980" + "Rev": "7b85b097bf7527677d54d3220065e966a0e3b613" }, { "ImportPath": "golang.org/x/crypto/cast5", - "Rev": "346896d57731cb5670b36c6178fc5519f3225980" + "Rev": "7b85b097bf7527677d54d3220065e966a0e3b613" }, { "ImportPath": "golang.org/x/crypto/curve25519", - "Rev": "346896d57731cb5670b36c6178fc5519f3225980" + "Rev": "7b85b097bf7527677d54d3220065e966a0e3b613" }, { "ImportPath": "golang.org/x/crypto/openpgp", - "Rev": "346896d57731cb5670b36c6178fc5519f3225980" + "Rev": "7b85b097bf7527677d54d3220065e966a0e3b613" }, { "ImportPath": "golang.org/x/crypto/ssh", - "Rev": "346896d57731cb5670b36c6178fc5519f3225980" + "Rev": "7b85b097bf7527677d54d3220065e966a0e3b613" }, { "ImportPath": "golang.org/x/net/context", - "Rev": "1d9fd3b8333e891c0e7353e1adcfe8a612573033" + "Rev": "195180cfebf7362bd243a52477697895128c8777" }, { "ImportPath": "golang.org/x/oauth2", @@ -266,6 +275,10 @@ { "ImportPath": "gopkg.in/inf.v0", "Rev": "3887ee99ecf07df5b447e9b00d9c0b2adaa9f3e4" + }, + { + "ImportPath": "gopkg.in/yaml.v2", + "Rev": "53feefa2559fb8dfa8d81baad31be332c97d6c77" } ] } diff --git a/Godeps/_workspace/src/github.com/asaskevich/govalidator/.travis.yml b/Godeps/_workspace/src/github.com/asaskevich/govalidator/.travis.yml new file mode 100644 index 000000000..119d82948 --- /dev/null +++ b/Godeps/_workspace/src/github.com/asaskevich/govalidator/.travis.yml @@ -0,0 +1,10 @@ +language: go + +go: + - 1.1 + - 1.2 + - 1.3 + +notifications: + email: + - bwatas@gmail.com diff --git a/Godeps/_workspace/src/github.com/asaskevich/govalidator/LICENSE b/Godeps/_workspace/src/github.com/asaskevich/govalidator/LICENSE new file mode 100644 index 000000000..2f9a31fad --- /dev/null +++ b/Godeps/_workspace/src/github.com/asaskevich/govalidator/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2014 Alex Saskevich + +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. \ No newline at end of file diff --git a/Godeps/_workspace/src/github.com/asaskevich/govalidator/README.md b/Godeps/_workspace/src/github.com/asaskevich/govalidator/README.md new file mode 100644 index 000000000..eed636b71 --- /dev/null +++ b/Godeps/_workspace/src/github.com/asaskevich/govalidator/README.md @@ -0,0 +1,281 @@ +govalidator +=========== +[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/asaskevich/govalidator?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) [![GoDoc](https://godoc.org/github.com/asaskevich/govalidator?status.png)](https://godoc.org/github.com/asaskevich/govalidator) [![Coverage Status](https://img.shields.io/coveralls/asaskevich/govalidator.svg)](https://coveralls.io/r/asaskevich/govalidator?branch=master) [![views](https://sourcegraph.com/api/repos/github.com/asaskevich/govalidator/.counters/views.png)](https://sourcegraph.com/github.com/asaskevich/govalidator) +[![wercker status](https://app.wercker.com/status/1ec990b09ea86c910d5f08b0e02c6043/s "wercker status")](https://app.wercker.com/project/bykey/1ec990b09ea86c910d5f08b0e02c6043) +[![Build Status](https://travis-ci.org/asaskevich/govalidator.svg?branch=master)](https://travis-ci.org/asaskevich/govalidator) + +A package of validators and sanitizers for strings, structs and collections. Based on [validator.js](https://github.com/chriso/validator.js). + +#### Installation +Make sure that Go is installed on your computer. +Type the following command in your terminal: + + go get github.com/asaskevich/govalidator + +After it the package is ready to use. + +#### Import package in your project +Add following line in your `*.go` file: +```go +import "github.com/asaskevich/govalidator" +``` +If you unhappy to use long `govalidator`, you can do something like this: +```go +import ( + valid "github.com/asaskevich/govalidator" +) +``` + +#### List of functions: +```go +func Abs(value float64) float64 +func BlackList(str, chars string) string +func ByteLength(str string, params ...string) bool +func StringLength(str string, params ...string) bool +func CamelCaseToUnderscore(str string) string +func Contains(str, substring string) bool +func Count(array []interface{}, iterator ConditionIterator) int +func Each(array []interface{}, iterator Iterator) +func ErrorByField(e error, field string) string +func Filter(array []interface{}, iterator ConditionIterator) []interface{} +func Find(array []interface{}, iterator ConditionIterator) interface{} +func GetLine(s string, index int) (string, error) +func GetLines(s string) []string +func InRange(value, left, right float64) bool +func IsASCII(str string) bool +func IsAlpha(str string) bool +func IsAlphanumeric(str string) bool +func IsBase64(str string) bool +func IsByteLength(str string, min, max int) bool +func IsCreditCard(str string) bool +func IsDataURI(str string) bool +func IsDivisibleBy(str, num string) bool +func IsEmail(str string) bool +func IsFilePath(str string) (bool, int) +func IsFloat(str string) bool +func IsFullWidth(str string) bool +func IsHalfWidth(str string) bool +func IsHexadecimal(str string) bool +func IsHexcolor(str string) bool +func IsIP(str string) bool +func IsIPv4(str string) bool +func IsIPv6(str string) bool +func IsISBN(str string, version int) bool +func IsISBN10(str string) bool +func IsISBN13(str string) bool +func IsISO3166Alpha2(str string) bool +func IsISO3166Alpha3(str string) bool +func IsInt(str string) bool +func IsJSON(str string) bool +func IsLatitude(str string) bool +func IsLongitude(str string) bool +func IsLowerCase(str string) bool +func IsMAC(str string) bool +func IsMongoID(str string) bool +func IsMultibyte(str string) bool +func IsNatural(value float64) bool +func IsNegative(value float64) bool +func IsNonNegative(value float64) bool +func IsNonPositive(value float64) bool +func IsNull(str string) bool +func IsNumeric(str string) bool +func IsPositive(value float64) bool +func IsPrintableASCII(str string) bool +func IsRGBcolor(str string) bool +func IsRequestURI(rawurl string) bool +func IsRequestURL(rawurl string) bool +func IsSSN(str string) bool +func IsURL(str string) bool +func IsUTFDigit(str string) bool +func IsUTFLetter(str string) bool +func IsUTFLetterNumeric(str string) bool +func IsUTFNumeric(str string) bool +func IsUUID(str string) bool +func IsUUIDv3(str string) bool +func IsUUIDv4(str string) bool +func IsUUIDv5(str string) bool +func IsUpperCase(str string) bool +func IsVariableWidth(str string) bool +func IsWhole(value float64) bool +func LeftTrim(str, chars string) string +func Map(array []interface{}, iterator ResultIterator) []interface{} +func Matches(str, pattern string) bool +func NormalizeEmail(str string) (string, error) +func RemoveTags(s string) string +func ReplacePattern(str, pattern, replace string) string +func Reverse(s string) string +func RightTrim(str, chars string) string +func SafeFileName(str string) string +func Sign(value float64) float64 +func StripLow(str string, keepNewLines bool) string +func ToBoolean(str string) (bool, error) +func ToFloat(str string) (float64, error) +func ToInt(str string) (int64, error) +func ToJSON(obj interface{}) (string, error) +func ToString(obj interface{}) string +func Trim(str, chars string) string +func Truncate(str string, length int, ending string) string +func UnderscoreToCamelCase(s string) string +func ValidateStruct(s interface{}) (bool, error) +func WhiteList(str, chars string) string +type ConditionIterator +type Error +func (e Error) Error() string +type Errors +func (es Errors) Error() string +type ISO3166Entry +type Iterator +type ParamValidator +type ResultIterator +type UnsupportedTypeError +func (e *UnsupportedTypeError) Error() string +type Validator +``` + +#### Examples +###### IsURL +```go +println(govalidator.IsURL(`http://user@pass:domain.com/path/page`)) +``` +###### ToString +```go +type User struct { + FirstName string + LastName string +} + +str, _ := govalidator.ToString(&User{"John", "Juan"}) +println(str) +``` +###### Each, Map, Filter, Count for slices +Each iterates over the slice/array and calls Iterator for every item +```go +data := []interface{}{1, 2, 3, 4, 5} +var fn govalidator.Iterator = func(value interface{}, index int) { + println(value.(int)) +} +govalidator.Each(data, fn) +``` +```go +data := []interface{}{1, 2, 3, 4, 5} +var fn govalidator.ResultIterator = func(value interface{}, index int) interface{} { + return value.(int) * 3 +} +_ = govalidator.Map(data, fn) // result = []interface{}{1, 6, 9, 12, 15} +``` +```go +data := []interface{}{1, 2, 3, 4, 5, 6, 7, 8, 9, 10} +var fn govalidator.ConditionIterator = func(value interface{}, index int) bool { + return value.(int)%2 == 0 +} +_ = govalidator.Filter(data, fn) // result = []interface{}{2, 4, 6, 8, 10} +_ = govalidator.Count(data, fn) // result = 5 +``` +###### ValidateStruct [#2](https://github.com/asaskevich/govalidator/pull/2) +If you want to validate structs, you can use tag `valid` for any field in your structure. All validators used with this field in one tag are separated by comma. If you want to skip validation, place `-` in your tag. If you need a validator that is not on the list below, you can add it like this: +```go +govalidator.TagMap["duck"] = govalidator.Validator(func(str string) bool { + return str == "duck" +}) +``` +Here is a list of available validators for struct fields (validator - used function): +```go +"alpha": IsAlpha, +"alphanum": IsAlphanumeric, +"ascii": IsASCII, +"base64": IsBase64, +"creditcard": IsCreditCard, +"datauri": IsDataURI, +"email": IsEmail, +"float": IsFloat, +"fullwidth": IsFullWidth, +"halfwidth": IsHalfWidth, +"hexadecimal": IsHexadecimal, +"hexcolor": IsHexcolor, +"int": IsInt, +"ip": IsIP, +"ipv4": IsIPv4, +"ipv6": IsIPv6, +"isbn10": IsISBN10, +"isbn13": IsISBN13, +"json": IsJSON, +"latitude": IsLatitude, +"longitude": IsLongitude, +"lowercase": IsLowerCase, +"mac": IsMAC, +"multibyte": IsMultibyte, +"null": IsNull, +"numeric": IsNumeric, +"printableascii": IsPrintableASCII, +"requri": IsRequestURI, +"requrl": IsRequestURL, +"rgbcolor": IsRGBcolor, +"ssn": IsSSN +"uppercase": IsUpperCase, +"url": IsURL, +"utfdigit": IsUTFDigit, +"utfletter": IsUTFLetter, +"utfletternum": IsUTFLetterNumeric, +"utfnumeric": IsUTFNumeric, +"uuid": IsUUID, +"uuidv3": IsUUIDv3, +"uuidv4": IsUUIDv4, +"uuidv5": IsUUIDv5, +"variablewidth": IsVariableWidth, +``` +Validators with parameters + +```go +"length(min|max)": ByteLength, +``` + +And here is small example of usage: +```go +type Post struct { + Title string `valid:"alphanum,required"` + Message string `valid:"duck,ascii"` + AuthorIP string `valid:"ipv4"` + Date string `valid:"-"` +} +post := &Post{ + Title: "My Example Post", + Message: "duck", + AuthorIP: "123.234.54.3", +} + +// Add your own struct validation tags +govalidator.TagMap["duck"] = govalidator.Validator(func(str string) bool { + return str == "duck" +}) + +result, err := govalidator.ValidateStruct(post) +if err != nil { + println("error: " + err.Error()) +} +println(result) +``` +###### WhiteList +```go +// Remove all characters from string ignoring characters between "a" and "z" +println(govalidator.WhiteList("a3a43a5a4a3a2a23a4a5a4a3a4", "a-z") == "aaaaaaaaaaaa") +``` + +#### Notes +Documentation is available here: [godoc.org](https://godoc.org/github.com/asaskevich/govalidator). +Full information about code coverage is also available here: [govalidator on gocover.io](http://gocover.io/github.com/asaskevich/govalidator). + +#### Support +If you do have a contribution for the package feel free to put up a Pull Request or open Issue. + +#### Special thanks to [contributors](https://github.com/asaskevich/govalidator/graphs/contributors) +* [Attila Oláh](https://github.com/attilaolah) +* [Daniel Korner](https://github.com/Dadie) +* [Steven Wilkin](https://github.com/stevenwilkin) +* [Deiwin Sarjas](https://github.com/deiwin) +* [Noah Shibley](https://github.com/slugmobile) +* [Nathan Davies](https://github.com/nathj07) +* [Matt Sanford](https://github.com/mzsanford) +* [Simon ccl1115](https://github.com/ccl1115) + +[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/asaskevich/govalidator/trend.png)](https://bitdeli.com/free "Bitdeli Badge") + diff --git a/Godeps/_workspace/src/github.com/asaskevich/govalidator/arrays.go b/Godeps/_workspace/src/github.com/asaskevich/govalidator/arrays.go new file mode 100644 index 000000000..55b8aacd8 --- /dev/null +++ b/Godeps/_workspace/src/github.com/asaskevich/govalidator/arrays.go @@ -0,0 +1,58 @@ +package govalidator + +// Iterator is the function that accepts element of slice/array and its index +type Iterator func(interface{}, int) + +// ResultIterator is the function that accepts element of slice/array and its index and returns any result +type ResultIterator func(interface{}, int) interface{} + +// ConditionIterator is the function that accepts element of slice/array and its index and returns boolean +type ConditionIterator func(interface{}, int) bool + +// Each iterates over the slice and apply Iterator to every item +func Each(array []interface{}, iterator Iterator) { + for index, data := range array { + iterator(data, index) + } +} + +// Map iterates over the slice and apply ResultIterator to every item. Returns new slice as a result. +func Map(array []interface{}, iterator ResultIterator) []interface{} { + var result []interface{} = make([]interface{}, len(array)) + for index, data := range array { + result[index] = iterator(data, index) + } + return result +} + +// Find iterates over the slice and apply ConditionIterator to every item. Returns first item that meet ConditionIterator or nil otherwise. +func Find(array []interface{}, iterator ConditionIterator) interface{} { + for index, data := range array { + if iterator(data, index) { + return data + } + } + return nil +} + +// Filter iterates over the slice and apply ConditionIterator to every item. Returns new slice. +func Filter(array []interface{}, iterator ConditionIterator) []interface{} { + var result []interface{} = make([]interface{}, 0) + for index, data := range array { + if iterator(data, index) { + result = append(result, data) + } + } + return result +} + +// Count iterates over the slice and apply ConditionIterator to every item. Returns count of items that meets ConditionIterator. +func Count(array []interface{}, iterator ConditionIterator) int { + count := 0 + for index, data := range array { + if iterator(data, index) { + count = count + 1 + } + } + return count +} diff --git a/Godeps/_workspace/src/github.com/asaskevich/govalidator/converter.go b/Godeps/_workspace/src/github.com/asaskevich/govalidator/converter.go new file mode 100644 index 000000000..737a1f179 --- /dev/null +++ b/Godeps/_workspace/src/github.com/asaskevich/govalidator/converter.go @@ -0,0 +1,49 @@ +package govalidator + +import ( + "encoding/json" + "fmt" + "strconv" +) + +// ToString convert the input to a string. +func ToString(obj interface{}) string { + res := fmt.Sprintf("%v", obj) + return string(res) +} + +// ToJSON convert the input to a valid JSON string +func ToJSON(obj interface{}) (string, error) { + res, err := json.Marshal(obj) + if err != nil { + res = []byte("") + } + return string(res), err +} + +// ToFloat convert the input string to a float, or 0.0 if the input is not a float. +func ToFloat(str string) (float64, error) { + res, err := strconv.ParseFloat(str, 64) + if err != nil { + res = 0.0 + } + return res, err +} + +// ToInt convert the input string to an integer, or 0 if the input is not an integer. +func ToInt(str string) (int64, error) { + res, err := strconv.ParseInt(str, 0, 64) + if err != nil { + res = 0 + } + return res, err +} + +// ToBoolean convert the input string to a boolean. +func ToBoolean(str string) (bool, error) { + res, err := strconv.ParseBool(str) + if err != nil { + res = false + } + return res, err +} diff --git a/Godeps/_workspace/src/github.com/asaskevich/govalidator/error.go b/Godeps/_workspace/src/github.com/asaskevich/govalidator/error.go new file mode 100644 index 000000000..bdd5dc7c9 --- /dev/null +++ b/Godeps/_workspace/src/github.com/asaskevich/govalidator/error.go @@ -0,0 +1,24 @@ +package govalidator + +type Errors []error + +func (es Errors) Errors() []error { + return es +} + +func (es Errors) Error() string { + var err string + for _, e := range es { + err += e.Error() + ";" + } + return err +} + +type Error struct { + Name string + Err error +} + +func (e Error) Error() string { + return e.Name + ": " + e.Err.Error() +} diff --git a/Godeps/_workspace/src/github.com/asaskevich/govalidator/numerics.go b/Godeps/_workspace/src/github.com/asaskevich/govalidator/numerics.go new file mode 100644 index 000000000..737cd47ca --- /dev/null +++ b/Godeps/_workspace/src/github.com/asaskevich/govalidator/numerics.go @@ -0,0 +1,57 @@ +package govalidator + +import "math" + +// Abs returns absolute value of number +func Abs(value float64) float64 { + return value * Sign(value) +} + +// Sign returns signum of number: 1 in case of value > 0, -1 in case of value < 0, 0 otherwise +func Sign(value float64) float64 { + if value > 0 { + return 1 + } else if value < 0 { + return -1 + } else { + return 0 + } +} + +// IsNegative returns true if value < 0 +func IsNegative(value float64) bool { + return value < 0 +} + +// IsPositive returns true if value > 0 +func IsPositive(value float64) bool { + return value > 0 +} + +// IsNonNegative returns true if value >= 0 +func IsNonNegative(value float64) bool { + return value >= 0 +} + +// IsNonPositive returns true if value <= 0 +func IsNonPositive(value float64) bool { + return value <= 0 +} + +// InRange returns true if value lies between left and right border +func InRange(value, left, right float64) bool { + if left > right { + left, right = right, left + } + return value >= left && value <= right +} + +// IsWhole returns true if value is whole number +func IsWhole(value float64) bool { + return Abs(math.Remainder(value, 1)) == 0 +} + +// IsNatural returns true if value is natural number (positive and whole) +func IsNatural(value float64) bool { + return IsWhole(value) && IsPositive(value) +} diff --git a/Godeps/_workspace/src/github.com/asaskevich/govalidator/patterns.go b/Godeps/_workspace/src/github.com/asaskevich/govalidator/patterns.go new file mode 100644 index 000000000..cbd804575 --- /dev/null +++ b/Godeps/_workspace/src/github.com/asaskevich/govalidator/patterns.go @@ -0,0 +1,79 @@ +package govalidator + +import "regexp" + +// Basic regular expressions for validating strings +const ( + Email string = "^(((([a-zA-Z]|\\d|[!#\\$%&'\\*\\+\\-\\/=\\?\\^_`{\\|}~]|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])+(\\.([a-zA-Z]|\\d|[!#\\$%&'\\*\\+\\-\\/=\\?\\^_`{\\|}~]|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])+)*)|((\\x22)((((\\x20|\\x09)*(\\x0d\\x0a))?(\\x20|\\x09)+)?(([\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x7f]|\\x21|[\\x23-\\x5b]|[\\x5d-\\x7e]|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])|(\\([\\x01-\\x09\\x0b\\x0c\\x0d-\\x7f]|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}]))))*(((\\x20|\\x09)*(\\x0d\\x0a))?(\\x20|\\x09)+)?(\\x22)))@((([a-zA-Z]|\\d|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])|(([a-zA-Z]|\\d|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])([a-zA-Z]|\\d|-|\\.|_|~|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])*([a-zA-Z]|\\d|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])))\\.)+(([a-zA-Z]|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])|(([a-zA-Z]|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])([a-zA-Z]|\\d|-|\\.|_|~|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])*([a-zA-Z]|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])))\\.?$" + CreditCard string = "^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6(?:011|5[0-9][0-9])[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\\d{3})\\d{11})$" + ISBN10 string = "^(?:[0-9]{9}X|[0-9]{10})$" + ISBN13 string = "^(?:[0-9]{13})$" + UUID3 string = "^[0-9a-f]{8}-[0-9a-f]{4}-3[0-9a-f]{3}-[0-9a-f]{4}-[0-9a-f]{12}$" + UUID4 string = "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$" + UUID5 string = "^[0-9a-f]{8}-[0-9a-f]{4}-5[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$" + UUID string = "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$" + Alpha string = "^[a-zA-Z]+$" + Alphanumeric string = "^[a-zA-Z0-9]+$" + Numeric string = "^[-+]?[0-9]+$" + Int string = "^(?:[-+]?(?:0|[1-9][0-9]*))$" + Float string = "^(?:[-+]?(?:[0-9]+))?(?:\\.[0-9]*)?(?:[eE][\\+\\-]?(?:[0-9]+))?$" + Hexadecimal string = "^[0-9a-fA-F]+$" + Hexcolor string = "^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$" + RGBcolor string = "^rgb\\(\\s*(0|[1-9]\\d?|1\\d\\d?|2[0-4]\\d|25[0-5])\\s*,\\s*(0|[1-9]\\d?|1\\d\\d?|2[0-4]\\d|25[0-5])\\s*,\\s*(0|[1-9]\\d?|1\\d\\d?|2[0-4]\\d|25[0-5])\\s*\\)$" + ASCII string = "^[\x00-\x7F]+$" + Multibyte string = "[^\x00-\x7F]" + FullWidth string = "[^\u0020-\u007E\uFF61-\uFF9F\uFFA0-\uFFDC\uFFE8-\uFFEE0-9a-zA-Z]" + HalfWidth string = "[\u0020-\u007E\uFF61-\uFF9F\uFFA0-\uFFDC\uFFE8-\uFFEE0-9a-zA-Z]" + Base64 string = "^(?:[A-Za-z0-9+\\/]{4})*(?:[A-Za-z0-9+\\/]{2}==|[A-Za-z0-9+\\/]{3}=|[A-Za-z0-9+\\/]{4})$" + PrintableASCII string = "^[\x20-\x7E]+$" + DataURI string = "^data:.+\\/(.+);base64$" + Latitude string = "^[-+]?([1-8]?\\d(\\.\\d+)?|90(\\.0+)?)$" + Longitude string = "^[-+]?(180(\\.0+)?|((1[0-7]\\d)|([1-9]?\\d))(\\.\\d+)?)$" + URL string = `^((ftp|https?):\/\/)?(\S+(:\S*)?@)?((([1-9]\d?|1\d\d|2[01]\d|22[0-3])(\.(1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.([0-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(([a-zA-Z0-9]+([-\.][a-zA-Z0-9]+)*)|((www\.)?))?(([a-z\x{00a1}-\x{ffff}0-9]+-?-?)*[a-z\x{00a1}-\x{ffff}0-9]+)(?:\.([a-z\x{00a1}-\x{ffff}]{2,}))?))(:(\d{1,5}))?((\/|\?|#)[^\s]*)?$` + SSN string = `^\d{3}[- ]?\d{2}[- ]?\d{4}$` + WinPath string = `^[a-zA-Z]:\\(?:[^\\/:*?"<>|\r\n]+\\)*[^\\/:*?"<>|\r\n]*$` + UnixPath string = `^((?:\/[a-zA-Z0-9\.\:]+(?:_[a-zA-Z0-9\:\.]+)*(?:\-[\:a-zA-Z0-9\.]+)*)+\/?)$` + tagName string = "valid" +) + +// Used by IsFilePath func +const ( + // Unknown is unresolved OS type + Unknown = iota + // Win is Windows type + Win + // Unix is *nix OS types + Unix +) + +var ( + rxEmail = regexp.MustCompile(Email) + rxCreditCard = regexp.MustCompile(CreditCard) + rxISBN10 = regexp.MustCompile(ISBN10) + rxISBN13 = regexp.MustCompile(ISBN13) + rxUUID3 = regexp.MustCompile(UUID3) + rxUUID4 = regexp.MustCompile(UUID4) + rxUUID5 = regexp.MustCompile(UUID5) + rxUUID = regexp.MustCompile(UUID) + rxAlpha = regexp.MustCompile(Alpha) + rxAlphanumeric = regexp.MustCompile(Alphanumeric) + rxNumeric = regexp.MustCompile(Numeric) + rxInt = regexp.MustCompile(Int) + rxFloat = regexp.MustCompile(Float) + rxHexadecimal = regexp.MustCompile(Hexadecimal) + rxHexcolor = regexp.MustCompile(Hexcolor) + rxRGBcolor = regexp.MustCompile(RGBcolor) + rxASCII = regexp.MustCompile(ASCII) + rxPrintableASCII = regexp.MustCompile(PrintableASCII) + rxMultibyte = regexp.MustCompile(Multibyte) + rxFullWidth = regexp.MustCompile(FullWidth) + rxHalfWidth = regexp.MustCompile(HalfWidth) + rxBase64 = regexp.MustCompile(Base64) + rxDataURI = regexp.MustCompile(DataURI) + rxLatitude = regexp.MustCompile(Latitude) + rxLongitude = regexp.MustCompile(Longitude) + rxURL = regexp.MustCompile(URL) + rxSSN = regexp.MustCompile(SSN) + rxWinPath = regexp.MustCompile(WinPath) + rxUnixPath = regexp.MustCompile(UnixPath) +) diff --git a/Godeps/_workspace/src/github.com/asaskevich/govalidator/types.go b/Godeps/_workspace/src/github.com/asaskevich/govalidator/types.go new file mode 100644 index 000000000..1d9d93274 --- /dev/null +++ b/Godeps/_workspace/src/github.com/asaskevich/govalidator/types.go @@ -0,0 +1,349 @@ +package govalidator + +import ( + "reflect" + "regexp" +) + +// Validator is a wrapper for a validator function that returns bool and accepts string. +type Validator func(str string) bool + +// CustomTypeValidator is a wrapper for validator functions that returns bool and accepts any type. +type CustomTypeValidator func(i interface{}) bool + +// ParamValidator is a wrapper for validator functions that accepts additional parameters. +type ParamValidator func(str string, params ...string) bool +type tagOptions []string + +// UnsupportedTypeError is a wrapper for reflect.Type +type UnsupportedTypeError struct { + Type reflect.Type +} + +// stringValues is a slice of reflect.Value holding *reflect.StringValue. +// It implements the methods to sort by string. +type stringValues []reflect.Value + +// ParamTagMap is a map of functions accept variants parameters +var ParamTagMap = map[string]ParamValidator{ + "length": ByteLength, + "stringlength": StringLength, +} + +var ParamTagRegexMap = map[string]*regexp.Regexp{ + "length": regexp.MustCompile("^length\\((\\d+)\\|(\\d+)\\)$"), + "stringlength": regexp.MustCompile("^stringlength\\((\\d+)\\|(\\d+)\\)$"), +} + +// CustomTypeTagMap is a map of functions that can be used as tags for ValidateStruct function. +// Use this to validate compound or custom types that need to be handled as a whole, e.g. +// `type UUID [16]byte` (this would be handled as an array of bytes). +var CustomTypeTagMap = map[string]CustomTypeValidator{} + +// TagMap is a map of functions, that can be used as tags for ValidateStruct function. +var TagMap = map[string]Validator{ + "email": IsEmail, + "url": IsURL, + "requrl": IsRequestURL, + "requri": IsRequestURI, + "alpha": IsAlpha, + "utfletter": IsUTFLetter, + "alphanum": IsAlphanumeric, + "utfletternum": IsUTFLetterNumeric, + "numeric": IsNumeric, + "utfnumeric": IsUTFNumeric, + "utfdigit": IsUTFDigit, + "hexadecimal": IsHexadecimal, + "hexcolor": IsHexcolor, + "rgbcolor": IsRGBcolor, + "lowercase": IsLowerCase, + "uppercase": IsUpperCase, + "int": IsInt, + "float": IsFloat, + "null": IsNull, + "uuid": IsUUID, + "uuidv3": IsUUIDv3, + "uuidv4": IsUUIDv4, + "uuidv5": IsUUIDv5, + "creditcard": IsCreditCard, + "isbn10": IsISBN10, + "isbn13": IsISBN13, + "json": IsJSON, + "multibyte": IsMultibyte, + "ascii": IsASCII, + "printableascii": IsPrintableASCII, + "fullwidth": IsFullWidth, + "halfwidth": IsHalfWidth, + "variablewidth": IsVariableWidth, + "base64": IsBase64, + "datauri": IsDataURI, + "ip": IsIP, + "ipv4": IsIPv4, + "ipv6": IsIPv6, + "mac": IsMAC, + "latitude": IsLatitude, + "longitude": IsLongitude, + "ssn": IsSSN, +} + +// ISO3166Entry stores country codes +type ISO3166Entry struct { + EnglishShortName string + FrenchShortName string + Alpha2Code string + Alpha3Code string + Numeric string +} + +//ISO3166List based on https://www.iso.org/obp/ui/#search/code/ Code Type "Officially Assigned Codes" +var ISO3166List = []ISO3166Entry{ + {"Afghanistan", "Afghanistan (l')", "AF", "AFG", "004"}, + {"Albania", "Albanie (l')", "AL", "ALB", "008"}, + {"Antarctica", "Antarctique (l')", "AQ", "ATA", "010"}, + {"Algeria", "Algérie (l')", "DZ", "DZA", "012"}, + {"American Samoa", "Samoa américaines (les)", "AS", "ASM", "016"}, + {"Andorra", "Andorre (l')", "AD", "AND", "020"}, + {"Angola", "Angola (l')", "AO", "AGO", "024"}, + {"Antigua and Barbuda", "Antigua-et-Barbuda", "AG", "ATG", "028"}, + {"Azerbaijan", "Azerbaïdjan (l')", "AZ", "AZE", "031"}, + {"Argentina", "Argentine (l')", "AR", "ARG", "032"}, + {"Australia", "Australie (l')", "AU", "AUS", "036"}, + {"Austria", "Autriche (l')", "AT", "AUT", "040"}, + {"Bahamas (the)", "Bahamas (les)", "BS", "BHS", "044"}, + {"Bahrain", "Bahreïn", "BH", "BHR", "048"}, + {"Bangladesh", "Bangladesh (le)", "BD", "BGD", "050"}, + {"Armenia", "Arménie (l')", "AM", "ARM", "051"}, + {"Barbados", "Barbade (la)", "BB", "BRB", "052"}, + {"Belgium", "Belgique (la)", "BE", "BEL", "056"}, + {"Bermuda", "Bermudes (les)", "BM", "BMU", "060"}, + {"Bhutan", "Bhoutan (le)", "BT", "BTN", "064"}, + {"Bolivia (Plurinational State of)", "Bolivie (État plurinational de)", "BO", "BOL", "068"}, + {"Bosnia and Herzegovina", "Bosnie-Herzégovine (la)", "BA", "BIH", "070"}, + {"Botswana", "Botswana (le)", "BW", "BWA", "072"}, + {"Bouvet Island", "Bouvet (l'Île)", "BV", "BVT", "074"}, + {"Brazil", "Brésil (le)", "BR", "BRA", "076"}, + {"Belize", "Belize (le)", "BZ", "BLZ", "084"}, + {"British Indian Ocean Territory (the)", "Indien (le Territoire britannique de l'océan)", "IO", "IOT", "086"}, + {"Solomon Islands", "Salomon (Îles)", "SB", "SLB", "090"}, + {"Virgin Islands (British)", "Vierges britanniques (les Îles)", "VG", "VGB", "092"}, + {"Brunei Darussalam", "Brunéi Darussalam (le)", "BN", "BRN", "096"}, + {"Bulgaria", "Bulgarie (la)", "BG", "BGR", "100"}, + {"Myanmar", "Myanmar (le)", "MM", "MMR", "104"}, + {"Burundi", "Burundi (le)", "BI", "BDI", "108"}, + {"Belarus", "Bélarus (le)", "BY", "BLR", "112"}, + {"Cambodia", "Cambodge (le)", "KH", "KHM", "116"}, + {"Cameroon", "Cameroun (le)", "CM", "CMR", "120"}, + {"Canada", "Canada (le)", "CA", "CAN", "124"}, + {"Cabo Verde", "Cabo Verde", "CV", "CPV", "132"}, + {"Cayman Islands (the)", "Caïmans (les Îles)", "KY", "CYM", "136"}, + {"Central African Republic (the)", "République centrafricaine (la)", "CF", "CAF", "140"}, + {"Sri Lanka", "Sri Lanka", "LK", "LKA", "144"}, + {"Chad", "Tchad (le)", "TD", "TCD", "148"}, + {"Chile", "Chili (le)", "CL", "CHL", "152"}, + {"China", "Chine (la)", "CN", "CHN", "156"}, + {"Taiwan (Province of China)", "Taïwan (Province de Chine)", "TW", "TWN", "158"}, + {"Christmas Island", "Christmas (l'Île)", "CX", "CXR", "162"}, + {"Cocos (Keeling) Islands (the)", "Cocos (les Îles)/ Keeling (les Îles)", "CC", "CCK", "166"}, + {"Colombia", "Colombie (la)", "CO", "COL", "170"}, + {"Comoros (the)", "Comores (les)", "KM", "COM", "174"}, + {"Mayotte", "Mayotte", "YT", "MYT", "175"}, + {"Congo (the)", "Congo (le)", "CG", "COG", "178"}, + {"Congo (the Democratic Republic of the)", "Congo (la République démocratique du)", "CD", "COD", "180"}, + {"Cook Islands (the)", "Cook (les Îles)", "CK", "COK", "184"}, + {"Costa Rica", "Costa Rica (le)", "CR", "CRI", "188"}, + {"Croatia", "Croatie (la)", "HR", "HRV", "191"}, + {"Cuba", "Cuba", "CU", "CUB", "192"}, + {"Cyprus", "Chypre", "CY", "CYP", "196"}, + {"Czech Republic (the)", "tchèque (la République)", "CZ", "CZE", "203"}, + {"Benin", "Bénin (le)", "BJ", "BEN", "204"}, + {"Denmark", "Danemark (le)", "DK", "DNK", "208"}, + {"Dominica", "Dominique (la)", "DM", "DMA", "212"}, + {"Dominican Republic (the)", "dominicaine (la République)", "DO", "DOM", "214"}, + {"Ecuador", "Équateur (l')", "EC", "ECU", "218"}, + {"El Salvador", "El Salvador", "SV", "SLV", "222"}, + {"Equatorial Guinea", "Guinée équatoriale (la)", "GQ", "GNQ", "226"}, + {"Ethiopia", "Éthiopie (l')", "ET", "ETH", "231"}, + {"Eritrea", "Érythrée (l')", "ER", "ERI", "232"}, + {"Estonia", "Estonie (l')", "EE", "EST", "233"}, + {"Faroe Islands (the)", "Féroé (les Îles)", "FO", "FRO", "234"}, + {"Falkland Islands (the) [Malvinas]", "Falkland (les Îles)/Malouines (les Îles)", "FK", "FLK", "238"}, + {"South Georgia and the South Sandwich Islands", "Géorgie du Sud-et-les Îles Sandwich du Sud (la)", "GS", "SGS", "239"}, + {"Fiji", "Fidji (les)", "FJ", "FJI", "242"}, + {"Finland", "Finlande (la)", "FI", "FIN", "246"}, + {"Åland Islands", "Åland(les Îles)", "AX", "ALA", "248"}, + {"France", "France (la)", "FR", "FRA", "250"}, + {"French Guiana", "Guyane française (la )", "GF", "GUF", "254"}, + {"French Polynesia", "Polynésie française (la)", "PF", "PYF", "258"}, + {"French Southern Territories (the)", "Terres australes françaises (les)", "TF", "ATF", "260"}, + {"Djibouti", "Djibouti", "DJ", "DJI", "262"}, + {"Gabon", "Gabon (le)", "GA", "GAB", "266"}, + {"Georgia", "Géorgie (la)", "GE", "GEO", "268"}, + {"Gambia (the)", "Gambie (la)", "GM", "GMB", "270"}, + {"Palestine, State of", "Palestine, État de", "PS", "PSE", "275"}, + {"Germany", "Allemagne (l')", "DE", "DEU", "276"}, + {"Ghana", "Ghana (le)", "GH", "GHA", "288"}, + {"Gibraltar", "Gibraltar", "GI", "GIB", "292"}, + {"Kiribati", "Kiribati", "KI", "KIR", "296"}, + {"Greece", "Grèce (la)", "GR", "GRC", "300"}, + {"Greenland", "Groenland (le)", "GL", "GRL", "304"}, + {"Grenada", "Grenade (la)", "GD", "GRD", "308"}, + {"Guadeloupe", "Guadeloupe (la)", "GP", "GLP", "312"}, + {"Guam", "Guam", "GU", "GUM", "316"}, + {"Guatemala", "Guatemala (le)", "GT", "GTM", "320"}, + {"Guinea", "Guinée (la)", "GN", "GIN", "324"}, + {"Guyana", "Guyana (le)", "GY", "GUY", "328"}, + {"Haiti", "Haïti", "HT", "HTI", "332"}, + {"Heard Island and McDonald Islands", "Heard-et-Îles MacDonald (l'Île)", "HM", "HMD", "334"}, + {"Holy See (the)", "Saint-Siège (le)", "VA", "VAT", "336"}, + {"Honduras", "Honduras (le)", "HN", "HND", "340"}, + {"Hong Kong", "Hong Kong", "HK", "HKG", "344"}, + {"Hungary", "Hongrie (la)", "HU", "HUN", "348"}, + {"Iceland", "Islande (l')", "IS", "ISL", "352"}, + {"India", "Inde (l')", "IN", "IND", "356"}, + {"Indonesia", "Indonésie (l')", "ID", "IDN", "360"}, + {"Iran (Islamic Republic of)", "Iran (République Islamique d')", "IR", "IRN", "364"}, + {"Iraq", "Iraq (l')", "IQ", "IRQ", "368"}, + {"Ireland", "Irlande (l')", "IE", "IRL", "372"}, + {"Israel", "Israël", "IL", "ISR", "376"}, + {"Italy", "Italie (l')", "IT", "ITA", "380"}, + {"Côte d'Ivoire", "Côte d'Ivoire (la)", "CI", "CIV", "384"}, + {"Jamaica", "Jamaïque (la)", "JM", "JAM", "388"}, + {"Japan", "Japon (le)", "JP", "JPN", "392"}, + {"Kazakhstan", "Kazakhstan (le)", "KZ", "KAZ", "398"}, + {"Jordan", "Jordanie (la)", "JO", "JOR", "400"}, + {"Kenya", "Kenya (le)", "KE", "KEN", "404"}, + {"Korea (the Democratic People's Republic of)", "Corée (la République populaire démocratique de)", "KP", "PRK", "408"}, + {"Korea (the Republic of)", "Corée (la République de)", "KR", "KOR", "410"}, + {"Kuwait", "Koweït (le)", "KW", "KWT", "414"}, + {"Kyrgyzstan", "Kirghizistan (le)", "KG", "KGZ", "417"}, + {"Lao People's Democratic Republic (the)", "Lao, République démocratique populaire", "LA", "LAO", "418"}, + {"Lebanon", "Liban (le)", "LB", "LBN", "422"}, + {"Lesotho", "Lesotho (le)", "LS", "LSO", "426"}, + {"Latvia", "Lettonie (la)", "LV", "LVA", "428"}, + {"Liberia", "Libéria (le)", "LR", "LBR", "430"}, + {"Libya", "Libye (la)", "LY", "LBY", "434"}, + {"Liechtenstein", "Liechtenstein (le)", "LI", "LIE", "438"}, + {"Lithuania", "Lituanie (la)", "LT", "LTU", "440"}, + {"Luxembourg", "Luxembourg (le)", "LU", "LUX", "442"}, + {"Macao", "Macao", "MO", "MAC", "446"}, + {"Madagascar", "Madagascar", "MG", "MDG", "450"}, + {"Malawi", "Malawi (le)", "MW", "MWI", "454"}, + {"Malaysia", "Malaisie (la)", "MY", "MYS", "458"}, + {"Maldives", "Maldives (les)", "MV", "MDV", "462"}, + {"Mali", "Mali (le)", "ML", "MLI", "466"}, + {"Malta", "Malte", "MT", "MLT", "470"}, + {"Martinique", "Martinique (la)", "MQ", "MTQ", "474"}, + {"Mauritania", "Mauritanie (la)", "MR", "MRT", "478"}, + {"Mauritius", "Maurice", "MU", "MUS", "480"}, + {"Mexico", "Mexique (le)", "MX", "MEX", "484"}, + {"Monaco", "Monaco", "MC", "MCO", "492"}, + {"Mongolia", "Mongolie (la)", "MN", "MNG", "496"}, + {"Moldova (the Republic of)", "Moldova , République de", "MD", "MDA", "498"}, + {"Montenegro", "Monténégro (le)", "ME", "MNE", "499"}, + {"Montserrat", "Montserrat", "MS", "MSR", "500"}, + {"Morocco", "Maroc (le)", "MA", "MAR", "504"}, + {"Mozambique", "Mozambique (le)", "MZ", "MOZ", "508"}, + {"Oman", "Oman", "OM", "OMN", "512"}, + {"Namibia", "Namibie (la)", "NA", "NAM", "516"}, + {"Nauru", "Nauru", "NR", "NRU", "520"}, + {"Nepal", "Népal (le)", "NP", "NPL", "524"}, + {"Netherlands (the)", "Pays-Bas (les)", "NL", "NLD", "528"}, + {"Curaçao", "Curaçao", "CW", "CUW", "531"}, + {"Aruba", "Aruba", "AW", "ABW", "533"}, + {"Sint Maarten (Dutch part)", "Saint-Martin (partie néerlandaise)", "SX", "SXM", "534"}, + {"Bonaire, Sint Eustatius and Saba", "Bonaire, Saint-Eustache et Saba", "BQ", "BES", "535"}, + {"New Caledonia", "Nouvelle-Calédonie (la)", "NC", "NCL", "540"}, + {"Vanuatu", "Vanuatu (le)", "VU", "VUT", "548"}, + {"New Zealand", "Nouvelle-Zélande (la)", "NZ", "NZL", "554"}, + {"Nicaragua", "Nicaragua (le)", "NI", "NIC", "558"}, + {"Niger (the)", "Niger (le)", "NE", "NER", "562"}, + {"Nigeria", "Nigéria (le)", "NG", "NGA", "566"}, + {"Niue", "Niue", "NU", "NIU", "570"}, + {"Norfolk Island", "Norfolk (l'Île)", "NF", "NFK", "574"}, + {"Norway", "Norvège (la)", "NO", "NOR", "578"}, + {"Northern Mariana Islands (the)", "Mariannes du Nord (les Îles)", "MP", "MNP", "580"}, + {"United States Minor Outlying Islands (the)", "Îles mineures éloignées des États-Unis (les)", "UM", "UMI", "581"}, + {"Micronesia (Federated States of)", "Micronésie (États fédérés de)", "FM", "FSM", "583"}, + {"Marshall Islands (the)", "Marshall (Îles)", "MH", "MHL", "584"}, + {"Palau", "Palaos (les)", "PW", "PLW", "585"}, + {"Pakistan", "Pakistan (le)", "PK", "PAK", "586"}, + {"Panama", "Panama (le)", "PA", "PAN", "591"}, + {"Papua New Guinea", "Papouasie-Nouvelle-Guinée (la)", "PG", "PNG", "598"}, + {"Paraguay", "Paraguay (le)", "PY", "PRY", "600"}, + {"Peru", "Pérou (le)", "PE", "PER", "604"}, + {"Philippines (the)", "Philippines (les)", "PH", "PHL", "608"}, + {"Pitcairn", "Pitcairn", "PN", "PCN", "612"}, + {"Poland", "Pologne (la)", "PL", "POL", "616"}, + {"Portugal", "Portugal (le)", "PT", "PRT", "620"}, + {"Guinea-Bissau", "Guinée-Bissau (la)", "GW", "GNB", "624"}, + {"Timor-Leste", "Timor-Leste (le)", "TL", "TLS", "626"}, + {"Puerto Rico", "Porto Rico", "PR", "PRI", "630"}, + {"Qatar", "Qatar (le)", "QA", "QAT", "634"}, + {"Réunion", "Réunion (La)", "RE", "REU", "638"}, + {"Romania", "Roumanie (la)", "RO", "ROU", "642"}, + {"Russian Federation (the)", "Russie (la Fédération de)", "RU", "RUS", "643"}, + {"Rwanda", "Rwanda (le)", "RW", "RWA", "646"}, + {"Saint Barthélemy", "Saint-Barthélemy", "BL", "BLM", "652"}, + {"Saint Helena, Ascension and Tristan da Cunha", "Sainte-Hélène, Ascension et Tristan da Cunha", "SH", "SHN", "654"}, + {"Saint Kitts and Nevis", "Saint-Kitts-et-Nevis", "KN", "KNA", "659"}, + {"Anguilla", "Anguilla", "AI", "AIA", "660"}, + {"Saint Lucia", "Sainte-Lucie", "LC", "LCA", "662"}, + {"Saint Martin (French part)", "Saint-Martin (partie française)", "MF", "MAF", "663"}, + {"Saint Pierre and Miquelon", "Saint-Pierre-et-Miquelon", "PM", "SPM", "666"}, + {"Saint Vincent and the Grenadines", "Saint-Vincent-et-les Grenadines", "VC", "VCT", "670"}, + {"San Marino", "Saint-Marin", "SM", "SMR", "674"}, + {"Sao Tome and Principe", "Sao Tomé-et-Principe", "ST", "STP", "678"}, + {"Saudi Arabia", "Arabie saoudite (l')", "SA", "SAU", "682"}, + {"Senegal", "Sénégal (le)", "SN", "SEN", "686"}, + {"Serbia", "Serbie (la)", "RS", "SRB", "688"}, + {"Seychelles", "Seychelles (les)", "SC", "SYC", "690"}, + {"Sierra Leone", "Sierra Leone (la)", "SL", "SLE", "694"}, + {"Singapore", "Singapour", "SG", "SGP", "702"}, + {"Slovakia", "Slovaquie (la)", "SK", "SVK", "703"}, + {"Viet Nam", "Viet Nam (le)", "VN", "VNM", "704"}, + {"Slovenia", "Slovénie (la)", "SI", "SVN", "705"}, + {"Somalia", "Somalie (la)", "SO", "SOM", "706"}, + {"South Africa", "Afrique du Sud (l')", "ZA", "ZAF", "710"}, + {"Zimbabwe", "Zimbabwe (le)", "ZW", "ZWE", "716"}, + {"Spain", "Espagne (l')", "ES", "ESP", "724"}, + {"South Sudan", "Soudan du Sud (le)", "SS", "SSD", "728"}, + {"Sudan (the)", "Soudan (le)", "SD", "SDN", "729"}, + {"Western Sahara*", "Sahara occidental (le)*", "EH", "ESH", "732"}, + {"Suriname", "Suriname (le)", "SR", "SUR", "740"}, + {"Svalbard and Jan Mayen", "Svalbard et l'Île Jan Mayen (le)", "SJ", "SJM", "744"}, + {"Swaziland", "Swaziland (le)", "SZ", "SWZ", "748"}, + {"Sweden", "Suède (la)", "SE", "SWE", "752"}, + {"Switzerland", "Suisse (la)", "CH", "CHE", "756"}, + {"Syrian Arab Republic", "République arabe syrienne (la)", "SY", "SYR", "760"}, + {"Tajikistan", "Tadjikistan (le)", "TJ", "TJK", "762"}, + {"Thailand", "Thaïlande (la)", "TH", "THA", "764"}, + {"Togo", "Togo (le)", "TG", "TGO", "768"}, + {"Tokelau", "Tokelau (les)", "TK", "TKL", "772"}, + {"Tonga", "Tonga (les)", "TO", "TON", "776"}, + {"Trinidad and Tobago", "Trinité-et-Tobago (la)", "TT", "TTO", "780"}, + {"United Arab Emirates (the)", "Émirats arabes unis (les)", "AE", "ARE", "784"}, + {"Tunisia", "Tunisie (la)", "TN", "TUN", "788"}, + {"Turkey", "Turquie (la)", "TR", "TUR", "792"}, + {"Turkmenistan", "Turkménistan (le)", "TM", "TKM", "795"}, + {"Turks and Caicos Islands (the)", "Turks-et-Caïcos (les Îles)", "TC", "TCA", "796"}, + {"Tuvalu", "Tuvalu (les)", "TV", "TUV", "798"}, + {"Uganda", "Ouganda (l')", "UG", "UGA", "800"}, + {"Ukraine", "Ukraine (l')", "UA", "UKR", "804"}, + {"Macedonia (the former Yugoslav Republic of)", "Macédoine (l'ex‑République yougoslave de)", "MK", "MKD", "807"}, + {"Egypt", "Égypte (l')", "EG", "EGY", "818"}, + {"United Kingdom of Great Britain and Northern Ireland (the)", "Royaume-Uni de Grande-Bretagne et d'Irlande du Nord (le)", "GB", "GBR", "826"}, + {"Guernsey", "Guernesey", "GG", "GGY", "831"}, + {"Jersey", "Jersey", "JE", "JEY", "832"}, + {"Isle of Man", "Île de Man", "IM", "IMN", "833"}, + {"Tanzania, United Republic of", "Tanzanie, République-Unie de", "TZ", "TZA", "834"}, + {"United States of America (the)", "États-Unis d'Amérique (les)", "US", "USA", "840"}, + {"Virgin Islands (U.S.)", "Vierges des États-Unis (les Îles)", "VI", "VIR", "850"}, + {"Burkina Faso", "Burkina Faso (le)", "BF", "BFA", "854"}, + {"Uruguay", "Uruguay (l')", "UY", "URY", "858"}, + {"Uzbekistan", "Ouzbékistan (l')", "UZ", "UZB", "860"}, + {"Venezuela (Bolivarian Republic of)", "Venezuela (République bolivarienne du)", "VE", "VEN", "862"}, + {"Wallis and Futuna", "Wallis-et-Futuna", "WF", "WLF", "876"}, + {"Samoa", "Samoa (le)", "WS", "WSM", "882"}, + {"Yemen", "Yémen (le)", "YE", "YEM", "887"}, + {"Zambia", "Zambie (la)", "ZM", "ZMB", "894"}, +} diff --git a/Godeps/_workspace/src/github.com/asaskevich/govalidator/utils.go b/Godeps/_workspace/src/github.com/asaskevich/govalidator/utils.go new file mode 100644 index 000000000..0eff62f21 --- /dev/null +++ b/Godeps/_workspace/src/github.com/asaskevich/govalidator/utils.go @@ -0,0 +1,214 @@ +package govalidator + +import ( + "errors" + "fmt" + "html" + "path" + "regexp" + "strings" + "unicode" +) + +// Contains check if the string contains the substring. +func Contains(str, substring string) bool { + return strings.Contains(str, substring) +} + +// Matches check if string matches the pattern (pattern is regular expression) +// In case of error return false +func Matches(str, pattern string) bool { + match, _ := regexp.MatchString(pattern, str) + return match +} + +// LeftTrim trim characters from the left-side of the input. +// If second argument is empty, it's will be remove leading spaces. +func LeftTrim(str, chars string) string { + pattern := "" + if chars == "" { + pattern = "^\\s+" + } else { + pattern = "^[" + chars + "]+" + } + r, _ := regexp.Compile(pattern) + return string(r.ReplaceAll([]byte(str), []byte(""))) +} + +// RightTrim trim characters from the right-side of the input. +// If second argument is empty, it's will be remove spaces. +func RightTrim(str, chars string) string { + pattern := "" + if chars == "" { + pattern = "\\s+$" + } else { + pattern = "[" + chars + "]+$" + } + r, _ := regexp.Compile(pattern) + return string(r.ReplaceAll([]byte(str), []byte(""))) +} + +// Trim trim characters from both sides of the input. +// If second argument is empty, it's will be remove spaces. +func Trim(str, chars string) string { + return LeftTrim(RightTrim(str, chars), chars) +} + +// WhiteList remove characters that do not appear in the whitelist. +func WhiteList(str, chars string) string { + pattern := "[^" + chars + "]+" + r, _ := regexp.Compile(pattern) + return string(r.ReplaceAll([]byte(str), []byte(""))) +} + +// BlackList remove characters that appear in the blacklist. +func BlackList(str, chars string) string { + pattern := "[" + chars + "]+" + r, _ := regexp.Compile(pattern) + return string(r.ReplaceAll([]byte(str), []byte(""))) +} + +// StripLow remove characters with a numerical value < 32 and 127, mostly control characters. +// If keep_new_lines is true, newline characters are preserved (\n and \r, hex 0xA and 0xD). +func StripLow(str string, keepNewLines bool) string { + chars := "" + if keepNewLines { + chars = "\x00-\x09\x0B\x0C\x0E-\x1F\x7F" + } else { + chars = "\x00-\x1F\x7F" + } + return BlackList(str, chars) +} + +// ReplacePattern replace regular expression pattern in string +func ReplacePattern(str, pattern, replace string) string { + r, _ := regexp.Compile(pattern) + return string(r.ReplaceAll([]byte(str), []byte(replace))) +} + +// Escape replace <, >, & and " with HTML entities. +var Escape = html.EscapeString + +func addSegment(inrune, segment []rune) []rune { + if len(segment) == 0 { + return inrune + } + if len(inrune) != 0 { + inrune = append(inrune, '_') + } + inrune = append(inrune, segment...) + return inrune +} + +// UnderscoreToCamelCase converts from underscore separated form to camel case form. +// Ex.: my_func => MyFunc +func UnderscoreToCamelCase(s string) string { + return strings.Replace(strings.Title(strings.Replace(strings.ToLower(s), "_", " ", -1)), " ", "", -1) +} + +// CamelCaseToUnderscore converts from camel case form to underscore separated form. +// Ex.: MyFunc => my_func +func CamelCaseToUnderscore(str string) string { + var output []rune + var segment []rune + for _, r := range str { + if !unicode.IsLower(r) { + output = addSegment(output, segment) + segment = nil + } + segment = append(segment, unicode.ToLower(r)) + } + output = addSegment(output, segment) + return string(output) +} + +// Reverse return reversed string +func Reverse(s string) string { + r := []rune(s) + for i, j := 0, len(r)-1; i < j; i, j = i+1, j-1 { + r[i], r[j] = r[j], r[i] + } + return string(r) +} + +// GetLines split string by "\n" and return array of lines +func GetLines(s string) []string { + return strings.Split(s, "\n") +} + +// GetLine return specified line of multiline string +func GetLine(s string, index int) (string, error) { + lines := GetLines(s) + if index < 0 || index >= len(lines) { + return "", errors.New("line index out of bounds") + } + return lines[index], nil +} + +// RemoveTags remove all tags from HTML string +func RemoveTags(s string) string { + return ReplacePattern(s, "<[^>]*>", "") +} + +// SafeFileName return safe string that can be used in file names +func SafeFileName(str string) string { + name := strings.ToLower(str) + name = path.Clean(path.Base(name)) + name = strings.Trim(name, " ") + separators, err := regexp.Compile(`[ &_=+:]`) + if err == nil { + name = separators.ReplaceAllString(name, "-") + } + legal, err := regexp.Compile(`[^[:alnum:]-.]`) + if err == nil { + name = legal.ReplaceAllString(name, "") + } + for strings.Contains(name, "--") { + name = strings.Replace(name, "--", "-", -1) + } + return name +} + +// NormalizeEmail canonicalize an email address. +// The local part of the email address is lowercased for all domains; the hostname is always lowercased and +// the local part of the email address is always lowercased for hosts that are known to be case-insensitive (currently only GMail). +// Normalization follows special rules for known providers: currently, GMail addresses have dots removed in the local part and +// are stripped of tags (e.g. some.one+tag@gmail.com becomes someone@gmail.com) and all @googlemail.com addresses are +// normalized to @gmail.com. +func NormalizeEmail(str string) (string, error) { + if !IsEmail(str) { + return "", fmt.Errorf("%s is not an email", str) + } + parts := strings.Split(str, "@") + parts[0] = strings.ToLower(parts[0]) + parts[1] = strings.ToLower(parts[1]) + if parts[1] == "gmail.com" || parts[1] == "googlemail.com" { + parts[1] = "gmail.com" + parts[0] = strings.Split(ReplacePattern(parts[0], `\.`, ""), "+")[0] + } + return strings.Join(parts, "@"), nil +} + +// Will truncate a string closest length without breaking words. +func Truncate(str string, length int, ending string) string { + var aftstr, befstr string + if len(str) > length { + words := strings.Fields(str) + before, present := 0, 0 + for i := range words { + befstr = aftstr + before = present + aftstr = aftstr + words[i] + " " + present = len(aftstr) + if present > length && i != 0 { + if (length - before) < (present - length) { + return Trim(befstr, " /\\.,\"'#!?&@+-") + ending + } else { + return Trim(aftstr, " /\\.,\"'#!?&@+-") + ending + } + } + } + } + + return str +} diff --git a/Godeps/_workspace/src/github.com/asaskevich/govalidator/validator.go b/Godeps/_workspace/src/github.com/asaskevich/govalidator/validator.go new file mode 100644 index 000000000..5234fb9ee --- /dev/null +++ b/Godeps/_workspace/src/github.com/asaskevich/govalidator/validator.go @@ -0,0 +1,854 @@ +// Package govalidator is package of validators and sanitizers for strings, structs and collections. +package govalidator + +import ( + "encoding/json" + "fmt" + "net" + "net/url" + "reflect" + "regexp" + "sort" + "strings" + "unicode" + "unicode/utf8" +) + +var fieldsRequiredByDefault bool + +// SetFieldsRequiredByDefault causes validation to fail when struct fields +// do not include validations or are not explicitly marked as exempt (using `valid:"-"` or `valid:"email,optional"`). +// This struct definition will fail govalidator.ValidateStruct() (and the field values do not matter): +// type exampleStruct struct { +// Name string `` +// Email string `valid:"email"` +// This, however, will only fail when Email is empty or an invalid email address: +// type exampleStruct2 struct { +// Name string `valid:"-"` +// Email string `valid:"email"` +// Lastly, this will only fail when Email is an invalid email address but not when it's empty: +// type exampleStruct2 struct { +// Name string `valid:"-"` +// Email string `valid:"email,optional"` +func SetFieldsRequiredByDefault(value bool) { + fieldsRequiredByDefault = value +} + +// IsEmail check if the string is an email. +func IsEmail(str string) bool { + // TODO uppercase letters are not supported + return rxEmail.MatchString(str) +} + +// IsURL check if the string is an URL. +func IsURL(str string) bool { + if str == "" || len(str) >= 2083 || len(str) <= 3 || strings.HasPrefix(str, ".") { + return false + } + u, err := url.Parse(str) + if err != nil { + return false + } + if strings.HasPrefix(u.Host, ".") { + return false + } + if u.Host == "" && (u.Path != "" && !strings.Contains(u.Path, ".")) { + return false + } + return rxURL.MatchString(str) + +} + +// IsRequestURL check if the string rawurl, assuming +// it was recieved in an HTTP request, is a valid +// URL confirm to RFC 3986 +func IsRequestURL(rawurl string) bool { + url, err := url.ParseRequestURI(rawurl) + if err != nil { + return false //Couldn't even parse the rawurl + } + if len(url.Scheme) == 0 { + return false //No Scheme found + } + return true +} + +// IsRequestURI check if the string rawurl, assuming +// it was recieved in an HTTP request, is an +// absolute URI or an absolute path. +func IsRequestURI(rawurl string) bool { + _, err := url.ParseRequestURI(rawurl) + return err == nil +} + +// IsAlpha check if the string contains only letters (a-zA-Z). Empty string is valid. +func IsAlpha(str string) bool { + if IsNull(str) { + return true + } + return rxAlpha.MatchString(str) +} + +//IsUTFLetter check if the string contains only unicode letter characters. +//Similar to IsAlpha but for all languages. Empty string is valid. +func IsUTFLetter(str string) bool { + if IsNull(str) { + return true + } + + for _, c := range str { + if !unicode.IsLetter(c) { + return false + } + } + return true + +} + +// IsAlphanumeric check if the string contains only letters and numbers. Empty string is valid. +func IsAlphanumeric(str string) bool { + if IsNull(str) { + return true + } + return rxAlphanumeric.MatchString(str) +} + +// IsUTFLetterNumeric check if the string contains only unicode letters and numbers. Empty string is valid. +func IsUTFLetterNumeric(str string) bool { + if IsNull(str) { + return true + } + for _, c := range str { + if !unicode.IsLetter(c) && !unicode.IsNumber(c) { //letters && numbers are ok + return false + } + } + return true + +} + +// IsNumeric check if the string contains only numbers. Empty string is valid. +func IsNumeric(str string) bool { + if IsNull(str) { + return true + } + return rxNumeric.MatchString(str) +} + +// IsUTFNumeric check if the string contains only unicode numbers of any kind. +// Numbers can be 0-9 but also Fractions ¾,Roman Ⅸ and Hangzhou 〩. Empty string is valid. +func IsUTFNumeric(str string) bool { + if IsNull(str) { + return true + } + if strings.IndexAny(str, "+-") > 0 { + return false + } + if len(str) > 1 { + str = strings.TrimPrefix(str, "-") + str = strings.TrimPrefix(str, "+") + } + for _, c := range str { + if unicode.IsNumber(c) == false { //numbers && minus sign are ok + return false + } + } + return true + +} + +// IsUTFDigit check if the string contains only unicode radix-10 decimal digits. Empty string is valid. +func IsUTFDigit(str string) bool { + if IsNull(str) { + return true + } + if strings.IndexAny(str, "+-") > 0 { + return false + } + if len(str) > 1 { + str = strings.TrimPrefix(str, "-") + str = strings.TrimPrefix(str, "+") + } + for _, c := range str { + if !unicode.IsDigit(c) { //digits && minus sign are ok + return false + } + } + return true + +} + +// IsHexadecimal check if the string is a hexadecimal number. +func IsHexadecimal(str string) bool { + return rxHexadecimal.MatchString(str) +} + +// IsHexcolor check if the string is a hexadecimal color. +func IsHexcolor(str string) bool { + return rxHexcolor.MatchString(str) +} + +// IsRGBcolor check if the string is a valid RGB color in form rgb(RRR, GGG, BBB). +func IsRGBcolor(str string) bool { + return rxRGBcolor.MatchString(str) +} + +// IsLowerCase check if the string is lowercase. Empty string is valid. +func IsLowerCase(str string) bool { + if IsNull(str) { + return true + } + return str == strings.ToLower(str) +} + +// IsUpperCase check if the string is uppercase. Empty string is valid. +func IsUpperCase(str string) bool { + if IsNull(str) { + return true + } + return str == strings.ToUpper(str) +} + +// IsInt check if the string is an integer. Empty string is valid. +func IsInt(str string) bool { + if IsNull(str) { + return true + } + return rxInt.MatchString(str) +} + +// IsFloat check if the string is a float. +func IsFloat(str string) bool { + return str != "" && rxFloat.MatchString(str) +} + +// IsDivisibleBy check if the string is a number that's divisible by another. +// If second argument is not valid integer or zero, it's return false. +// Otherwise, if first argument is not valid integer or zero, it's return true (Invalid string converts to zero). +func IsDivisibleBy(str, num string) bool { + f, _ := ToFloat(str) + p := int64(f) + q, _ := ToInt(num) + if q == 0 { + return false + } + return (p == 0) || (p%q == 0) +} + +// IsNull check if the string is null. +func IsNull(str string) bool { + return len(str) == 0 +} + +// IsByteLength check if the string's length (in bytes) falls in a range. +func IsByteLength(str string, min, max int) bool { + return len(str) >= min && len(str) <= max +} + +// IsUUIDv3 check if the string is a UUID version 3. +func IsUUIDv3(str string) bool { + return rxUUID3.MatchString(str) +} + +// IsUUIDv4 check if the string is a UUID version 4. +func IsUUIDv4(str string) bool { + return rxUUID4.MatchString(str) +} + +// IsUUIDv5 check if the string is a UUID version 5. +func IsUUIDv5(str string) bool { + return rxUUID5.MatchString(str) +} + +// IsUUID check if the string is a UUID (version 3, 4 or 5). +func IsUUID(str string) bool { + return rxUUID.MatchString(str) +} + +// IsCreditCard check if the string is a credit card. +func IsCreditCard(str string) bool { + r, _ := regexp.Compile("[^0-9]+") + sanitized := r.ReplaceAll([]byte(str), []byte("")) + if !rxCreditCard.MatchString(string(sanitized)) { + return false + } + var sum int64 + var digit string + var tmpNum int64 + var shouldDouble bool + for i := len(sanitized) - 1; i >= 0; i-- { + digit = string(sanitized[i:(i + 1)]) + tmpNum, _ = ToInt(digit) + if shouldDouble { + tmpNum *= 2 + if tmpNum >= 10 { + sum += ((tmpNum % 10) + 1) + } else { + sum += tmpNum + } + } else { + sum += tmpNum + } + shouldDouble = !shouldDouble + } + + if sum%10 == 0 { + return true + } + return false +} + +// IsISBN10 check if the string is an ISBN version 10. +func IsISBN10(str string) bool { + return IsISBN(str, 10) +} + +// IsISBN13 check if the string is an ISBN version 13. +func IsISBN13(str string) bool { + return IsISBN(str, 13) +} + +// IsISBN check if the string is an ISBN (version 10 or 13). +// If version value is not equal to 10 or 13, it will be check both variants. +func IsISBN(str string, version int) bool { + r, _ := regexp.Compile("[\\s-]+") + sanitized := r.ReplaceAll([]byte(str), []byte("")) + var checksum int32 + var i int32 + if version == 10 { + if !rxISBN10.MatchString(string(sanitized)) { + return false + } + for i = 0; i < 9; i++ { + checksum += (i + 1) * int32(sanitized[i]-'0') + } + if sanitized[9] == 'X' { + checksum += 10 * 10 + } else { + checksum += 10 * int32(sanitized[9]-'0') + } + if checksum%11 == 0 { + return true + } + return false + } else if version == 13 { + if !rxISBN13.MatchString(string(sanitized)) { + return false + } + factor := []int32{1, 3} + for i = 0; i < 12; i++ { + checksum += factor[i%2] * int32(sanitized[i]-'0') + } + if (int32(sanitized[12]-'0'))-((10-(checksum%10))%10) == 0 { + return true + } + return false + } + return IsISBN(str, 10) || IsISBN(str, 13) +} + +// IsJSON check if the string is valid JSON (note: uses json.Unmarshal). +func IsJSON(str string) bool { + var js json.RawMessage + return json.Unmarshal([]byte(str), &js) == nil +} + +// IsMultibyte check if the string contains one or more multibyte chars. Empty string is valid. +func IsMultibyte(str string) bool { + if IsNull(str) { + return true + } + return rxMultibyte.MatchString(str) +} + +// IsASCII check if the string contains ASCII chars only. Empty string is valid. +func IsASCII(str string) bool { + if IsNull(str) { + return true + } + return rxASCII.MatchString(str) +} + +// IsPrintableASCII check if the string contains printable ASCII chars only. Empty string is valid. +func IsPrintableASCII(str string) bool { + if IsNull(str) { + return true + } + return rxPrintableASCII.MatchString(str) +} + +// IsFullWidth check if the string contains any full-width chars. Empty string is valid. +func IsFullWidth(str string) bool { + if IsNull(str) { + return true + } + return rxFullWidth.MatchString(str) +} + +// IsHalfWidth check if the string contains any half-width chars. Empty string is valid. +func IsHalfWidth(str string) bool { + if IsNull(str) { + return true + } + return rxHalfWidth.MatchString(str) +} + +// IsVariableWidth check if the string contains a mixture of full and half-width chars. Empty string is valid. +func IsVariableWidth(str string) bool { + if IsNull(str) { + return true + } + return rxHalfWidth.MatchString(str) && rxFullWidth.MatchString(str) +} + +// IsBase64 check if a string is base64 encoded. +func IsBase64(str string) bool { + return rxBase64.MatchString(str) +} + +// IsFilePath check is a string is Win or Unix file path and returns it's type. +func IsFilePath(str string) (bool, int) { + if rxWinPath.MatchString(str) { + //check windows path limit see: + // http://msdn.microsoft.com/en-us/library/aa365247(VS.85).aspx#maxpath + if len(str[3:]) > 32767 { + return false, Win + } + return true, Win + } else if rxUnixPath.MatchString(str) { + return true, Unix + } + return false, Unknown +} + +// IsDataURI checks if a string is base64 encoded data URI such as an image +func IsDataURI(str string) bool { + dataURI := strings.Split(str, ",") + if !rxDataURI.MatchString(dataURI[0]) { + return false + } + return IsBase64(dataURI[1]) +} + +// IsISO3166Alpha2 checks if a string is valid two-letter country code +func IsISO3166Alpha2(str string) bool { + for _, entry := range ISO3166List { + if str == entry.Alpha2Code { + return true + } + } + return false +} + +// IsISO3166Alpha3 checks if a string is valid three-letter country code +func IsISO3166Alpha3(str string) bool { + for _, entry := range ISO3166List { + if str == entry.Alpha3Code { + return true + } + } + return false +} + +// IsIP checks if a string is either IP version 4 or 6. +func IsIP(str string) bool { + return net.ParseIP(str) != nil +} + +// IsIPv4 check if the string is an IP version 4. +func IsIPv4(str string) bool { + ip := net.ParseIP(str) + return ip != nil && ip.To4() != nil +} + +// IsIPv6 check if the string is an IP version 6. +func IsIPv6(str string) bool { + ip := net.ParseIP(str) + return ip != nil && ip.To4() == nil +} + +// IsMAC check if a string is valid MAC address. +// Possible MAC formats: +// 01:23:45:67:89:ab +// 01:23:45:67:89:ab:cd:ef +// 01-23-45-67-89-ab +// 01-23-45-67-89-ab-cd-ef +// 0123.4567.89ab +// 0123.4567.89ab.cdef +func IsMAC(str string) bool { + _, err := net.ParseMAC(str) + return err == nil +} + +// IsMongoID check if the string is a valid hex-encoded representation of a MongoDB ObjectId. +func IsMongoID(str string) bool { + return rxHexadecimal.MatchString(str) && (len(str) == 24) +} + +// IsLatitude check if a string is valid latitude. +func IsLatitude(str string) bool { + return rxLatitude.MatchString(str) +} + +// IsLongitude check if a string is valid longitude. +func IsLongitude(str string) bool { + return rxLongitude.MatchString(str) +} + +// ValidateStruct use tags for fields +func ValidateStruct(s interface{}) (bool, error) { + if s == nil { + return true, nil + } + result := true + var err error + val := reflect.ValueOf(s) + if val.Kind() == reflect.Interface || val.Kind() == reflect.Ptr { + val = val.Elem() + } + // we only accept structs + if val.Kind() != reflect.Struct { + return false, fmt.Errorf("function only accepts structs; got %s", val.Kind()) + } + var errs Errors + for i := 0; i < val.NumField(); i++ { + valueField := val.Field(i) + typeField := val.Type().Field(i) + if typeField.PkgPath != "" { + continue // Private field + } + resultField, err := typeCheck(valueField, typeField) + if err != nil { + errs = append(errs, err) + } + result = result && resultField + } + if len(errs) > 0 { + err = errs + } + return result, err +} + +// parseTag splits a struct field's tag into its +// comma-separated options. +func parseTag(tag string) tagOptions { + split := strings.SplitN(tag, ",", -1) + return tagOptions(split) +} + +func isValidTag(s string) bool { + if s == "" { + return false + } + for _, c := range s { + switch { + case strings.ContainsRune("!#$%&()*+-./:<=>?@[]^_{|}~ ", c): + // Backslash and quote chars are reserved, but + // otherwise any punctuation chars are allowed + // in a tag name. + default: + if !unicode.IsLetter(c) && !unicode.IsDigit(c) { + return false + } + } + } + return true +} + +// IsSSN will validate the given string as a U.S. Social Security Number +func IsSSN(str string) bool { + if str == "" || len(str) != 11 { + return false + } + return rxSSN.MatchString(str) +} + +// ByteLength check string's length +func ByteLength(str string, params ...string) bool { + if len(params) == 2 { + min, _ := ToInt(params[0]) + max, _ := ToInt(params[1]) + return len(str) >= int(min) && len(str) <= int(max) + } + + return false +} + +// StringLength check string's length (including multi byte strings) +func StringLength(str string, params ...string) bool { + + if len(params) == 2 { + strLength := utf8.RuneCountInString(str) + min, _ := ToInt(params[0]) + max, _ := ToInt(params[1]) + return strLength >= int(min) && strLength <= int(max) + } + + return false +} + +// Contains returns whether checks that a comma-separated list of options +// contains a particular substr flag. substr must be surrounded by a +// string boundary or commas. +func (opts tagOptions) contains(optionName string) bool { + for i := range opts { + tagOpt := opts[i] + if tagOpt == optionName { + return true + } + } + return false +} + +func checkRequired(v reflect.Value, t reflect.StructField, options tagOptions) (bool, error) { + if options.contains("required") { + err := fmt.Errorf("non zero value required") + return false, Error{t.Name, err} + } else if fieldsRequiredByDefault && !options.contains("optional") { + err := fmt.Errorf("All fields are required to at least have one validation defined") + return false, Error{t.Name, err} + } + // not required and empty is valid + return true, nil +} + +func typeCheck(v reflect.Value, t reflect.StructField) (bool, error) { + if !v.IsValid() { + return false, nil + } + + tag := t.Tag.Get(tagName) + + // Check if the field should be ignored + switch tag { + case "": + if !fieldsRequiredByDefault { + return true, nil + } + err := fmt.Errorf("All fields are required to at least have one validation defined") + return false, Error{t.Name, err} + case "-": + return true, nil + } + + options := parseTag(tag) + for i := range options { + tagOpt := options[i] + if ok := isValidTag(tagOpt); !ok { + continue + } + if validatefunc, ok := CustomTypeTagMap[tagOpt]; ok { + options = append(options[:i], options[i+1:]...) // we found our custom validator, so remove it from the options + if result := validatefunc(v.Interface()); !result { + return false, Error{t.Name, fmt.Errorf("%s does not validate as %s", fmt.Sprint(v), tagOpt)} + } + return true, nil + } + } + + if isEmptyValue(v) { + // an empty value is not validated, check only required + return checkRequired(v, t, options) + } + + switch v.Kind() { + case reflect.Bool, + reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, + reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr, + reflect.Float32, reflect.Float64, + reflect.String: + // for each tag option check the map of validator functions + for i := range options { + tagOpt := options[i] + negate := false + // Check wether the tag looks like '!something' or 'something' + if len(tagOpt) > 0 && tagOpt[0] == '!' { + tagOpt = string(tagOpt[1:]) + negate = true + } + if ok := isValidTag(tagOpt); !ok { + err := fmt.Errorf("Unkown Validator %s", tagOpt) + return false, Error{t.Name, err} + } + + // Check for param validators + for key, value := range ParamTagRegexMap { + ps := value.FindStringSubmatch(tagOpt) + if len(ps) > 0 { + if validatefunc, ok := ParamTagMap[key]; ok { + switch v.Kind() { + case reflect.String: + field := fmt.Sprint(v) // make value into string, then validate with regex + if result := validatefunc(field, ps[1:]...); !result && !negate || result && negate { + var err error + if !negate { + err = fmt.Errorf("%s does not validate as %s", field, tagOpt) + } else { + err = fmt.Errorf("%s does validate as %s", field, tagOpt) + } + return false, Error{t.Name, err} + } + default: + //Not Yet Supported Types (Fail here!) + err := fmt.Errorf("Validator %s doesn't support kind %s", tagOpt, v.Kind()) + return false, Error{t.Name, err} + } + } + } + } + + if validatefunc, ok := TagMap[tagOpt]; ok { + switch v.Kind() { + case reflect.String: + field := fmt.Sprint(v) // make value into string, then validate with regex + if result := validatefunc(field); !result && !negate || result && negate { + var err error + if !negate { + err = fmt.Errorf("%s does not validate as %s", field, tagOpt) + } else { + err = fmt.Errorf("%s does validate as %s", field, tagOpt) + } + return false, Error{t.Name, err} + } + default: + //Not Yet Supported Types (Fail here!) + err := fmt.Errorf("Validator %s doesn't support kind %s for value %v", tagOpt, v.Kind(), v) + return false, Error{t.Name, err} + } + } + } + return true, nil + case reflect.Map: + if v.Type().Key().Kind() != reflect.String { + return false, &UnsupportedTypeError{v.Type()} + } + var sv stringValues + sv = v.MapKeys() + sort.Sort(sv) + result := true + for _, k := range sv { + resultItem, err := ValidateStruct(v.MapIndex(k).Interface()) + if err != nil { + return false, err + } + result = result && resultItem + } + return result, nil + case reflect.Slice: + result := true + for i := 0; i < v.Len(); i++ { + var resultItem bool + var err error + if v.Index(i).Kind() != reflect.Struct { + resultItem, err = typeCheck(v.Index(i), t) + if err != nil { + return false, err + } + } else { + resultItem, err = ValidateStruct(v.Index(i).Interface()) + if err != nil { + return false, err + } + } + result = result && resultItem + } + return result, nil + case reflect.Array: + result := true + for i := 0; i < v.Len(); i++ { + var resultItem bool + var err error + if v.Index(i).Kind() != reflect.Struct { + resultItem, err = typeCheck(v.Index(i), t) + if err != nil { + return false, err + } + } else { + resultItem, err = ValidateStruct(v.Index(i).Interface()) + if err != nil { + return false, err + } + } + result = result && resultItem + } + return result, nil + case reflect.Interface: + // If the value is an interface then encode its element + if v.IsNil() { + return true, nil + } + return ValidateStruct(v.Interface()) + case reflect.Ptr: + // If the value is a pointer then check its element + if v.IsNil() { + return true, nil + } + return typeCheck(v.Elem(), t) + case reflect.Struct: + return ValidateStruct(v.Interface()) + default: + return false, &UnsupportedTypeError{v.Type()} + } +} + +func isEmptyValue(v reflect.Value) bool { + switch v.Kind() { + case reflect.String, reflect.Array: + return v.Len() == 0 + case reflect.Map, reflect.Slice: + return v.Len() == 0 || v.IsNil() + case reflect.Bool: + return !v.Bool() + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + return v.Int() == 0 + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: + return v.Uint() == 0 + case reflect.Float32, reflect.Float64: + return v.Float() == 0 + case reflect.Interface, reflect.Ptr: + return v.IsNil() + } + + return reflect.DeepEqual(v.Interface(), reflect.Zero(v.Type()).Interface()) +} + +// ErrorByField returns error for specified field of the struct +// validated by ValidateStruct or empty string if there are no errors +// or this field doesn't exists or doesn't have any errors. +func ErrorByField(e error, field string) string { + if e == nil { + return "" + } + return ErrorsByField(e)[field] +} + +// ErrorsByField returns map of errors of the struct validated +// by ValidateStruct or empty map if there are no errors. +func ErrorsByField(e error) map[string]string { + m := make(map[string]string) + if e == nil { + return m + } + // prototype for ValidateStruct + + switch e.(type) { + case Error: + m[e.(Error).Name] = e.(Error).Err.Error() + case Errors: + for _, item := range e.(Errors).Errors() { + m[item.(Error).Name] = item.(Error).Err.Error() + } + } + + return m +} + +// Error returns string equivalent for reflect.Type +func (e *UnsupportedTypeError) Error() string { + return "validator: unsupported type: " + e.Type.String() +} + +func (sv stringValues) Len() int { return len(sv) } +func (sv stringValues) Swap(i, j int) { sv[i], sv[j] = sv[j], sv[i] } +func (sv stringValues) Less(i, j int) bool { return sv.get(i) < sv.get(j) } +func (sv stringValues) get(i int) string { return sv[i].String() } diff --git a/Godeps/_workspace/src/github.com/asaskevich/govalidator/wercker.yml b/Godeps/_workspace/src/github.com/asaskevich/govalidator/wercker.yml new file mode 100644 index 000000000..484044909 --- /dev/null +++ b/Godeps/_workspace/src/github.com/asaskevich/govalidator/wercker.yml @@ -0,0 +1,15 @@ +box: wercker/golang +build: + steps: + - setup-go-workspace + + - script: + name: go get + code: | + go version + go get -t ./... + + - script: + name: go test + code: | + go test -race ./... diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/awsutil/path_value.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/awsutil/path_value.go index 8c0dc2d8d..4d2a01e8c 100644 --- a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/awsutil/path_value.go +++ b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/awsutil/path_value.go @@ -13,11 +13,11 @@ var indexRe = regexp.MustCompile(`(.+)\[(-?\d+)?\]$`) // rValuesAtPath returns a slice of values found in value v. The values // in v are explored recursively so all nested values are collected. -func rValuesAtPath(v interface{}, path string, create bool, caseSensitive bool) []reflect.Value { +func rValuesAtPath(v interface{}, path string, createPath, caseSensitive, nilTerm bool) []reflect.Value { pathparts := strings.Split(path, "||") if len(pathparts) > 1 { for _, pathpart := range pathparts { - vals := rValuesAtPath(v, pathpart, create, caseSensitive) + vals := rValuesAtPath(v, pathpart, createPath, caseSensitive, nilTerm) if len(vals) > 0 { return vals } @@ -76,7 +76,16 @@ func rValuesAtPath(v interface{}, path string, create bool, caseSensitive bool) return false }) - if create && value.Kind() == reflect.Ptr && value.IsNil() { + if nilTerm && value.Kind() == reflect.Ptr && len(components[1:]) == 0 { + if !value.IsNil() { + value.Set(reflect.Zero(value.Type())) + } + return []reflect.Value{value} + } + + if createPath && value.Kind() == reflect.Ptr && value.IsNil() { + // TODO if the value is the terminus it should not be created + // if the value to be set to its position is nil. value.Set(reflect.New(value.Type().Elem())) value = value.Elem() } else { @@ -84,7 +93,7 @@ func rValuesAtPath(v interface{}, path string, create bool, caseSensitive bool) } if value.Kind() == reflect.Slice || value.Kind() == reflect.Map { - if !create && value.IsNil() { + if !createPath && value.IsNil() { value = reflect.ValueOf(nil) } } @@ -116,7 +125,7 @@ func rValuesAtPath(v interface{}, path string, create bool, caseSensitive bool) // pull out index i := int(*index) if i >= value.Len() { // check out of bounds - if create { + if createPath { // TODO resize slice } else { continue @@ -127,7 +136,7 @@ func rValuesAtPath(v interface{}, path string, create bool, caseSensitive bool) value = reflect.Indirect(value.Index(i)) if value.Kind() == reflect.Slice || value.Kind() == reflect.Map { - if !create && value.IsNil() { + if !createPath && value.IsNil() { value = reflect.ValueOf(nil) } } @@ -176,8 +185,11 @@ func ValuesAtPath(i interface{}, path string) ([]interface{}, error) { // SetValueAtPath sets a value at the case insensitive lexical path inside // of a structure. func SetValueAtPath(i interface{}, path string, v interface{}) { - if rvals := rValuesAtPath(i, path, true, false); rvals != nil { + if rvals := rValuesAtPath(i, path, true, false, v == nil); rvals != nil { for _, rval := range rvals { + if rval.Kind() == reflect.Ptr && rval.IsNil() { + continue + } setValue(rval, v) } } diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/client/client.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/client/client.go index 63ab805b9..e639ce040 100644 --- a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/client/client.go +++ b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/client/client.go @@ -41,11 +41,20 @@ func New(cfg aws.Config, info metadata.ClientInfo, handlers request.Handlers, op Handlers: handlers, } - maxRetries := aws.IntValue(cfg.MaxRetries) - if cfg.MaxRetries == nil || maxRetries == aws.UseServiceDefaultRetries { - maxRetries = 3 + switch retryer, ok := cfg.Retryer.(request.Retryer); { + case ok: + svc.Retryer = retryer + case cfg.Retryer != nil && cfg.Logger != nil: + s := fmt.Sprintf("WARNING: %T does not implement request.Retryer; using DefaultRetryer instead", cfg.Retryer) + cfg.Logger.Log(s) + fallthrough + default: + maxRetries := aws.IntValue(cfg.MaxRetries) + if cfg.MaxRetries == nil || maxRetries == aws.UseServiceDefaultRetries { + maxRetries = 3 + } + svc.Retryer = DefaultRetryer{NumMaxRetries: maxRetries} } - svc.Retryer = DefaultRetryer{NumMaxRetries: maxRetries} svc.AddDebugHandlers() diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/config.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/config.go index f157f8b3b..75fcc8284 100644 --- a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/config.go +++ b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/config.go @@ -12,6 +12,9 @@ import ( // is nil also. const UseServiceDefaultRetries = -1 +// RequestRetryer is an alias for a type that implements the request.Retryer interface. +type RequestRetryer interface{} + // A Config provides service configuration for service clients. By default, // all clients will use the {defaults.DefaultConfig} structure. type Config struct { @@ -59,6 +62,21 @@ type Config struct { // configuration. MaxRetries *int + // Retryer guides how HTTP requests should be retried in case of recoverable failures. + // + // When nil or the value does not implement the request.Retryer interface, + // the request.DefaultRetryer will be used. + // + // When both Retryer and MaxRetries are non-nil, the former is used and + // the latter ignored. + // + // To set the Retryer field in a type-safe manner and with chaining, use + // the request.WithRetryer helper function: + // + // cfg := request.WithRetryer(aws.NewConfig(), myRetryer) + // + Retryer RequestRetryer + // Disables semantic parameter validation, which validates input for missing // required fields and/or other semantic request input errors. DisableParamValidation *bool @@ -217,6 +235,10 @@ func mergeInConfig(dst *Config, other *Config) { dst.MaxRetries = other.MaxRetries } + if other.Retryer != nil { + dst.Retryer = other.Retryer + } + if other.DisableParamValidation != nil { dst.DisableParamValidation = other.DisableParamValidation } diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/credentials/chain_provider.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/credentials/chain_provider.go index 7f509ca83..115b40739 100644 --- a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/credentials/chain_provider.go +++ b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/credentials/chain_provider.go @@ -36,7 +36,9 @@ var ( // creds := NewChainCredentials( // []Provider{ // &EnvProvider{}, -// &EC2RoleProvider{}, +// &EC2RoleProvider{ +// Client: ec2metadata.New(sess), +// }, // }) // // // Usage of ChainCredentials with aws.Config diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/credentials/ec2rolecreds/ec2_role_provider.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/credentials/ec2rolecreds/ec2_role_provider.go index 80702c26f..04c8921a0 100644 --- a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/credentials/ec2rolecreds/ec2_role_provider.go +++ b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/credentials/ec2rolecreds/ec2_role_provider.go @@ -23,9 +23,10 @@ import ( // p := &ec2rolecreds.EC2RoleProvider{ // // Pass in a custom timeout to be used when requesting // // IAM EC2 Role credentials. -// Client: &http.Client{ -// Timeout: 10 * time.Second, -// }, +// Client: ec2metadata.New(sess, aws.Config{ +// HTTPClient: &http.Client{Timeout: 10 * time.Second}, +// }), +// // // Do not use early expiry of credentials. If a non zero value is // // specified the credentials will be expired early // ExpiryWindow: 0, diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/defaults/defaults.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/defaults/defaults.go index b746783be..50f831c8f 100644 --- a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/defaults/defaults.go +++ b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/defaults/defaults.go @@ -1,5 +1,10 @@ // Package defaults is a collection of helpers to retrieve the SDK's default // configuration and handlers. +// +// Generally this package shouldn't be used directly, but session.Session +// instead. This package is useful when you need to reset the defaults +// of a session or service client to the SDK defaults before setting +// additional parameters. package defaults import ( @@ -34,7 +39,13 @@ func Get() Defaults { } } -// Config returns the default configuration. +// Config returns the default configuration without credentials. +// To retrieve a config with credentials also included use +// `defaults.Get().Config` instead. +// +// Generally you shouldn't need to use this method directly, but +// is available if you need to reset the configuration of an +// existing service client or session. func Config() *aws.Config { return aws.NewConfig(). WithCredentials(credentials.AnonymousCredentials). @@ -47,6 +58,10 @@ func Config() *aws.Config { } // Handlers returns the default request handlers. +// +// Generally you shouldn't need to use this method directly, but +// is available if you need to reset the request handlers of an +// existing service client or session. func Handlers() request.Handlers { var handlers request.Handlers @@ -61,6 +76,10 @@ func Handlers() request.Handlers { } // CredChain returns the default credential chain. +// +// Generally you shouldn't need to use this method directly, but +// is available if you need to reset the credentials of an +// existing service client or session's Config. func CredChain(cfg *aws.Config, handlers request.Handlers) *credentials.Credentials { endpoint, signingRegion := endpoints.EndpointForRegion(ec2metadata.ServiceName, *cfg.Region, true) diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/request/request_pagination.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/request/request_pagination.go index b19fbd70b..2939ec473 100644 --- a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/request/request_pagination.go +++ b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/request/request_pagination.go @@ -44,12 +44,19 @@ func (r *Request) nextPageTokens() []interface{} { } tokens := []interface{}{} + tokenAdded := false for _, outToken := range r.Operation.OutputTokens { v, _ := awsutil.ValuesAtPath(r.Data, outToken) if len(v) > 0 { tokens = append(tokens, v[0]) + tokenAdded = true + } else { + tokens = append(tokens, nil) } } + if !tokenAdded { + return nil + } return tokens } @@ -85,9 +92,10 @@ func (r *Request) NextPage() *Request { // return true to keep iterating or false to stop. func (r *Request) EachPage(fn func(data interface{}, isLastPage bool) (shouldContinue bool)) error { for page := r; page != nil; page = page.NextPage() { - page.Send() - shouldContinue := fn(page.Data, !page.HasNextPage()) - if page.Error != nil || !shouldContinue { + if err := page.Send(); err != nil { + return err + } + if getNextPage := fn(page.Data, !page.HasNextPage()); !getNextPage { return page.Error } } diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/request/retryer.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/request/retryer.go index b06143b83..ab6fff5ac 100644 --- a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/request/retryer.go +++ b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/request/retryer.go @@ -3,6 +3,7 @@ package request import ( "time" + "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" ) @@ -15,6 +16,13 @@ type Retryer interface { MaxRetries() int } +// WithRetryer sets a config Retryer value to the given Config returning it +// for chaining. +func WithRetryer(cfg *aws.Config, retryer Retryer) *aws.Config { + cfg.Retryer = retryer + return cfg +} + // retryableCodes is a collection of service response codes which are retry-able // without any further action. var retryableCodes = map[string]struct{}{ diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/session/session.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/session/session.go index eb7fc2052..6a0f371a2 100644 --- a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/session/session.go +++ b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/session/session.go @@ -1,5 +1,11 @@ // Package session provides a way to create service clients with shared configuration // and handlers. +// +// Generally this package should be used instead of the `defaults` package. +// +// A session should be used to share configurations and request handlers between multiple +// service clients. When service clients need specific configuration aws.Config can be +// used to provide additional configuration directly to the service client. package session import ( diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/version.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/version.go index f4741adfb..107ee7e1c 100644 --- a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/version.go +++ b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/version.go @@ -5,4 +5,4 @@ package aws const SDKName = "aws-sdk-go" // SDKVersion is the version of this SDK -const SDKVersion = "0.10.4" +const SDKVersion = "1.0.4" diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/private/protocol/rest/build.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/private/protocol/rest/build.go index 87352bc60..ed3c2e039 100644 --- a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/private/protocol/rest/build.go +++ b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/private/protocol/rest/build.go @@ -93,7 +93,7 @@ func buildLocationElements(r *request.Request, v reflect.Value) { } func buildBody(r *request.Request, v reflect.Value) { - if field, ok := v.Type().FieldByName("SDKShapeTraits"); ok { + if field, ok := v.Type().FieldByName("_"); ok { if payloadName := field.Tag.Get("payload"); payloadName != "" { pfield, _ := v.Type().FieldByName(payloadName) if ptag := pfield.Tag.Get("type"); ptag != "" && ptag != "structure" { diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/private/protocol/rest/payload.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/private/protocol/rest/payload.go index 1f603bb71..4366de2e1 100644 --- a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/private/protocol/rest/payload.go +++ b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/private/protocol/rest/payload.go @@ -12,7 +12,7 @@ func PayloadMember(i interface{}) interface{} { if !v.IsValid() { return nil } - if field, ok := v.Type().FieldByName("SDKShapeTraits"); ok { + if field, ok := v.Type().FieldByName("_"); ok { if payloadName := field.Tag.Get("payload"); payloadName != "" { field, _ := v.Type().FieldByName(payloadName) if field.Tag.Get("type") != "structure" { @@ -34,7 +34,7 @@ func PayloadType(i interface{}) string { if !v.IsValid() { return "" } - if field, ok := v.Type().FieldByName("SDKShapeTraits"); ok { + if field, ok := v.Type().FieldByName("_"); ok { if payloadName := field.Tag.Get("payload"); payloadName != "" { if member, ok := v.Type().FieldByName(payloadName); ok { return member.Tag.Get("type") diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/private/protocol/rest/unmarshal.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/private/protocol/rest/unmarshal.go index 06d9accba..27f47b02c 100644 --- a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/private/protocol/rest/unmarshal.go +++ b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/private/protocol/rest/unmarshal.go @@ -33,7 +33,7 @@ func UnmarshalMeta(r *request.Request) { } func unmarshalBody(r *request.Request, v reflect.Value) { - if field, ok := v.Type().FieldByName("SDKShapeTraits"); ok { + if field, ok := v.Type().FieldByName("_"); ok { if payloadName := field.Tag.Get("payload"); payloadName != "" { pfield, _ := v.Type().FieldByName(payloadName) if ptag := pfield.Tag.Get("type"); ptag != "" && ptag != "structure" { diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/build.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/build.go index d3db25023..0d76dffbd 100644 --- a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/build.go +++ b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/build.go @@ -69,7 +69,7 @@ func (b *xmlBuilder) buildValue(value reflect.Value, current *XMLNode, tag refle switch t { case "structure": - if field, ok := value.Type().FieldByName("SDKShapeTraits"); ok { + if field, ok := value.Type().FieldByName("_"); ok { tag = tag + reflect.StructTag(" ") + field.Tag } return b.buildStruct(value, current, tag) diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/unmarshal.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/unmarshal.go index 5e4fe210b..49f291a85 100644 --- a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/unmarshal.go +++ b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/unmarshal.go @@ -59,7 +59,7 @@ func parse(r reflect.Value, node *XMLNode, tag reflect.StructTag) error { switch t { case "structure": - if field, ok := rtype.FieldByName("SDKShapeTraits"); ok { + if field, ok := rtype.FieldByName("_"); ok { tag = field.Tag } return parseStruct(r, node, tag) diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/private/waiter/waiter.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/private/waiter/waiter.go index 335af91dc..e5fb13666 100644 --- a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/private/waiter/waiter.go +++ b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/private/waiter/waiter.go @@ -5,6 +5,7 @@ import ( "reflect" "time" + "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/aws/awsutil" "github.com/aws/aws-sdk-go/aws/request" @@ -47,52 +48,74 @@ func (w *Waiter) Wait() error { res := method.Call([]reflect.Value{in}) req := res[0].Interface().(*request.Request) req.Handlers.Build.PushBack(request.MakeAddToUserAgentFreeFormHandler("Waiter")) - if err := req.Send(); err != nil { - return err - } + err := req.Send() for _, a := range w.Acceptors { + if err != nil && a.Matcher != "error" { + // Only matcher error is valid if there is a request error + continue + } + result := false + var vals []interface{} switch a.Matcher { - case "pathAll": - if vals, _ := awsutil.ValuesAtPath(req.Data, a.Argument); req.Error == nil && vals != nil { - result = true - for _, val := range vals { - if !awsutil.DeepEqual(val, a.Expected) { - result = false - break - } + case "pathAll", "path": + // Require all matches to be equal for result to match + vals, _ = awsutil.ValuesAtPath(req.Data, a.Argument) + result = true + for _, val := range vals { + if !awsutil.DeepEqual(val, a.Expected) { + result = false + break } } case "pathAny": - if vals, _ := awsutil.ValuesAtPath(req.Data, a.Argument); req.Error == nil && vals != nil { - for _, val := range vals { - if awsutil.DeepEqual(val, a.Expected) { - result = true - break - } + // Only a single match needs to equal for the result to match + vals, _ = awsutil.ValuesAtPath(req.Data, a.Argument) + for _, val := range vals { + if awsutil.DeepEqual(val, a.Expected) { + result = true + break } } case "status": s := a.Expected.(int) result = s == req.HTTPResponse.StatusCode + case "error": + if aerr, ok := err.(awserr.Error); ok { + result = aerr.Code() == a.Expected.(string) + } + case "pathList": + // ignored matcher + default: + logf(client, "WARNING: Waiter for %s encountered unexpected matcher: %s", + w.Config.Operation, a.Matcher) } - if result { - switch a.State { - case "success": - return nil // waiter completed - case "failure": - if req.Error == nil { - return awserr.New("ResourceNotReady", - fmt.Sprintf("failed waiting for successful resource state"), nil) - } - return req.Error // waiter failed - case "retry": - // do nothing, just retry - } - break + if !result { + // If there was no matching result found there is nothing more to do + // for this response, retry the request. + continue } + + switch a.State { + case "success": + // waiter completed + return nil + case "failure": + // Waiter failure state triggered + return awserr.New("ResourceNotReady", + fmt.Sprintf("failed waiting for successful resource state"), err) + case "retry": + // clear the error and retry the operation + err = nil + default: + logf(client, "WARNING: Waiter for %s encountered unexpected state: %s", + w.Config.Operation, a.State) + } + } + if err != nil { + return err } time.Sleep(time.Second * time.Duration(w.Delay)) @@ -101,3 +124,13 @@ func (w *Waiter) Wait() error { return awserr.New("ResourceNotReady", fmt.Sprintf("exceeded %d wait attempts", w.MaxAttempts), nil) } + +func logf(client reflect.Value, msg string, args ...interface{}) { + cfgVal := client.FieldByName("Config") + if !cfgVal.IsValid() { + return + } + if cfg, ok := cfgVal.Interface().(*aws.Config); ok && cfg.Logger != nil { + cfg.Logger.Log(fmt.Sprintf(msg, args...)) + } +} diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/service/ec2/api.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/service/ec2/api.go index 337392a86..e3979ae30 100644 --- a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/service/ec2/api.go +++ b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/service/ec2/api.go @@ -71,6 +71,35 @@ func (c *EC2) AllocateAddress(input *AllocateAddressInput) (*AllocateAddressOutp return out, err } +const opAllocateHosts = "AllocateHosts" + +// AllocateHostsRequest generates a request for the AllocateHosts operation. +func (c *EC2) AllocateHostsRequest(input *AllocateHostsInput) (req *request.Request, output *AllocateHostsOutput) { + op := &request.Operation{ + Name: opAllocateHosts, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &AllocateHostsInput{} + } + + req = c.newRequest(op, input, output) + output = &AllocateHostsOutput{} + req.Data = output + return +} + +// Allocates a Dedicated host to your account. At minimum you need to specify +// the instance size type, Availability Zone, and quantity of hosts you want +// to allocate. +func (c *EC2) AllocateHosts(input *AllocateHostsInput) (*AllocateHostsOutput, error) { + req, out := c.AllocateHostsRequest(input) + err := req.Send() + return out, err +} + const opAssignPrivateIpAddresses = "AssignPrivateIpAddresses" // AssignPrivateIpAddressesRequest generates a request for the AssignPrivateIpAddresses operation. @@ -664,7 +693,7 @@ func (c *EC2) CancelReservedInstancesListingRequest(input *CancelReservedInstanc return } -// Cancels the specified Reserved Instance listing in the Reserved Instance +// Cancels the specified Reserved instance listing in the Reserved Instance // Marketplace. // // For more information, see Reserved Instance Marketplace (http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ri-market-general.html) @@ -924,10 +953,10 @@ func (c *EC2) CreateDhcpOptionsRequest(input *CreateDhcpOptionsInput) (req *requ // individual DHCP options you can specify. For more information about the options, // see RFC 2132 (http://www.ietf.org/rfc/rfc2132.txt). // -// domain-name-servers - The IP addresses of up to four domain name servers, +// domain-name-servers - The IP addresses of up to four domain name servers, // or AmazonProvidedDNS. The default DHCP option set specifies AmazonProvidedDNS. // If specifying more than one domain name server, specify the IP addresses -// in a single parameter, separated by commas. domain-name - If you're using +// in a single parameter, separated by commas. domain-name - If you're using // AmazonProvidedDNS in us-east-1, specify ec2.internal. If you're using AmazonProvidedDNS // in another region, specify region.compute.internal (for example, ap-northeast-1.compute.internal). // Otherwise, specify a domain name (for example, MyCompany.com). Important: @@ -935,9 +964,9 @@ func (c *EC2) CreateDhcpOptionsRequest(input *CreateDhcpOptionsInput) (req *requ // However, Windows and other Linux operating systems treat the value as a single // domain, which results in unexpected behavior. If your DHCP options set is // associated with a VPC that has instances with multiple operating systems, -// specify only one domain name. ntp-servers - The IP addresses of up to four -// Network Time Protocol (NTP) servers. netbios-name-servers - The IP addresses -// of up to four NetBIOS name servers. netbios-node-type - The NetBIOS node +// specify only one domain name. ntp-servers - The IP addresses of up to four +// Network Time Protocol (NTP) servers. netbios-name-servers - The IP addresses +// of up to four NetBIOS name servers. netbios-node-type - The NetBIOS node // type (1, 2, 4, or 8). We recommend that you specify 2 (broadcast and multicast // are not currently supported). For more information about these node types, // see RFC 2132 (http://www.ietf.org/rfc/rfc2132.txt). Your VPC automatically @@ -1283,22 +1312,22 @@ func (c *EC2) CreateReservedInstancesListingRequest(input *CreateReservedInstanc return } -// Creates a listing for Amazon EC2 Reserved Instances to be sold in the Reserved -// Instance Marketplace. You can submit one Reserved Instance listing at a time. -// To get a list of your Reserved Instances, you can use the DescribeReservedInstances +// Creates a listing for Amazon EC2 Reserved instances to be sold in the Reserved +// Instance Marketplace. You can submit one Reserved instance listing at a time. +// To get a list of your Reserved instances, you can use the DescribeReservedInstances // operation. // // The Reserved Instance Marketplace matches sellers who want to resell Reserved -// Instance capacity that they no longer need with buyers who want to purchase -// additional capacity. Reserved Instances bought and sold through the Reserved -// Instance Marketplace work like any other Reserved Instances. +// instance capacity that they no longer need with buyers who want to purchase +// additional capacity. Reserved instances bought and sold through the Reserved +// Instance Marketplace work like any other Reserved instances. // -// To sell your Reserved Instances, you must first register as a seller in +// To sell your Reserved instances, you must first register as a seller in // the Reserved Instance Marketplace. After completing the registration process, // you can create a Reserved Instance Marketplace listing of some or all of // your Reserved Instances, and specify the upfront price to receive for them. -// Your Reserved Instance listings then become available for purchase. To view -// the details of your Reserved Instance listing, you can use the DescribeReservedInstancesListings +// Your Reserved instance listings then become available for purchase. To view +// the details of your Reserved instance listing, you can use the DescribeReservedInstancesListings // operation. // // For more information, see Reserved Instance Marketplace (http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ri-market-general.html) @@ -2902,6 +2931,78 @@ func (c *EC2) DescribeFlowLogs(input *DescribeFlowLogsInput) (*DescribeFlowLogsO return out, err } +const opDescribeHosts = "DescribeHosts" + +// DescribeHostsRequest generates a request for the DescribeHosts operation. +func (c *EC2) DescribeHostsRequest(input *DescribeHostsInput) (req *request.Request, output *DescribeHostsOutput) { + op := &request.Operation{ + Name: opDescribeHosts, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &DescribeHostsInput{} + } + + req = c.newRequest(op, input, output) + output = &DescribeHostsOutput{} + req.Data = output + return +} + +// Describes one or more of your Dedicated hosts. +// +// The results describe only the Dedicated hosts in the region you're currently +// using. All listed instances consume capacity on your Dedicated host. Dedicated +// hosts that have recently been released will be listed with the status "released". +func (c *EC2) DescribeHosts(input *DescribeHostsInput) (*DescribeHostsOutput, error) { + req, out := c.DescribeHostsRequest(input) + err := req.Send() + return out, err +} + +const opDescribeIdFormat = "DescribeIdFormat" + +// DescribeIdFormatRequest generates a request for the DescribeIdFormat operation. +func (c *EC2) DescribeIdFormatRequest(input *DescribeIdFormatInput) (req *request.Request, output *DescribeIdFormatOutput) { + op := &request.Operation{ + Name: opDescribeIdFormat, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &DescribeIdFormatInput{} + } + + req = c.newRequest(op, input, output) + output = &DescribeIdFormatOutput{} + req.Data = output + return +} + +// Important: This command is reserved for future use, and is currently not +// available for you to use. +// +// Describes the ID format settings for your resources, for example, to view +// which resource types are enabled for longer IDs. This request only returns +// information about resource types whose ID formats can be modified; it does +// not return information about other resource types. +// +// The following resource types support longer IDs: instance | reservation. +// +// These settings apply to the IAM user who makes the request; they do not +// apply to the entire AWS account. By default, an IAM user defaults to the +// same settings as the root user, unless they explicitly override the settings +// by running the ModifyIdFormat command. These settings are applied on a per-region +// basis. +func (c *EC2) DescribeIdFormat(input *DescribeIdFormatInput) (*DescribeIdFormatOutput, error) { + req, out := c.DescribeIdFormatRequest(input) + err := req.Send() + return out, err +} + const opDescribeImageAttribute = "DescribeImageAttribute" // DescribeImageAttributeRequest generates a request for the DescribeImageAttribute operation. @@ -3085,7 +3186,7 @@ func (c *EC2) DescribeInstanceStatusRequest(input *DescribeInstanceStatusInput) // and Troubleshooting Instances with Failed Status Checks (http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/TroubleshootingInstances.html) // in the Amazon Elastic Compute Cloud User Guide. // -// Scheduled events - Amazon EC2 can schedule events (such as reboot, stop, +// Scheduled events - Amazon EC2 can schedule events (such as reboot, stop, // or terminate) for your instances related to hardware issues, software updates, // or system maintenance. For more information, see Scheduled Events for Your // Instances (http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/monitoring-instances-status-check_sched.html) @@ -3440,9 +3541,9 @@ func (c *EC2) DescribeReservedInstancesRequest(input *DescribeReservedInstancesI return } -// Describes one or more of the Reserved Instances that you purchased. +// Describes one or more of the Reserved instances that you purchased. // -// For more information about Reserved Instances, see Reserved Instances (http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/concepts-on-demand-reserved-instances.html) +// For more information about Reserved instances, see Reserved Instances (http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/concepts-on-demand-reserved-instances.html) // in the Amazon Elastic Compute Cloud User Guide. func (c *EC2) DescribeReservedInstances(input *DescribeReservedInstancesInput) (*DescribeReservedInstancesOutput, error) { req, out := c.DescribeReservedInstancesRequest(input) @@ -3470,22 +3571,22 @@ func (c *EC2) DescribeReservedInstancesListingsRequest(input *DescribeReservedIn return } -// Describes your account's Reserved Instance listings in the Reserved Instance +// Describes your account's Reserved instance listings in the Reserved Instance // Marketplace. // // The Reserved Instance Marketplace matches sellers who want to resell Reserved -// Instance capacity that they no longer need with buyers who want to purchase -// additional capacity. Reserved Instances bought and sold through the Reserved +// instance capacity that they no longer need with buyers who want to purchase +// additional capacity. Reserved instances bought and sold through the Reserved // Instance Marketplace work like any other Reserved Instances. // -// As a seller, you choose to list some or all of your Reserved Instances, -// and you specify the upfront price to receive for them. Your Reserved Instances +// As a seller, you choose to list some or all of your Reserved instances, +// and you specify the upfront price to receive for them. Your Reserved instances // are then listed in the Reserved Instance Marketplace and are available for // purchase. // -// As a buyer, you specify the configuration of the Reserved Instance to purchase, +// As a buyer, you specify the configuration of the Reserved instance to purchase, // and the Marketplace matches what you're searching for with what's available. -// The Marketplace first sells the lowest priced Reserved Instances to you, +// The Marketplace first sells the lowest priced Reserved instances to you, // and continues to sell available Reserved Instance listings to you until your // demand is met. You are charged based on the total price of all of the listings // that you purchase. @@ -3524,7 +3625,7 @@ func (c *EC2) DescribeReservedInstancesModificationsRequest(input *DescribeReser return } -// Describes the modifications made to your Reserved Instances. If no parameter +// Describes the modifications made to your Reserved instances. If no parameter // is specified, information about all your Reserved Instances modification // requests is returned. If a modification ID is specified, only information // about the specific modification is returned. @@ -3571,8 +3672,8 @@ func (c *EC2) DescribeReservedInstancesOfferingsRequest(input *DescribeReservedI return } -// Describes Reserved Instance offerings that are available for purchase. With -// Reserved Instances, you purchase the right to launch instances for a period +// Describes Reserved instance offerings that are available for purchase. With +// Reserved instances, you purchase the right to launch instances for a period // of time. During that time period, you do not receive insufficient capacity // errors, and you pay a lower usage rate than the rate charged for On-Demand // instances for the actual time used. @@ -3726,13 +3827,13 @@ func (c *EC2) DescribeSnapshotsRequest(input *DescribeSnapshotsInput) (req *requ // // The create volume permissions fall into the following categories: // -// public: The owner of the snapshot granted create volume permissions for +// public: The owner of the snapshot granted create volume permissions for // the snapshot to the all group. All AWS accounts have create volume permissions -// for these snapshots. explicit: The owner of the snapshot granted create -// volume permissions to a specific AWS account. implicit: An AWS account has -// implicit create volume permissions for all snapshots it owns. The list of -// snapshots returned can be modified by specifying snapshot IDs, snapshot owners, -// or AWS accounts with create volume permissions. If no options are specified, +// for these snapshots. explicit: The owner of the snapshot granted create volume +// permissions to a specific AWS account. implicit: An AWS account has implicit +// create volume permissions for all snapshots it owns. The list of snapshots +// returned can be modified by specifying snapshot IDs, snapshot owners, or +// AWS accounts with create volume permissions. If no options are specified, // Amazon EC2 returns all snapshots for which you have create volume permissions. // // If you specify one or more snapshot IDs, only snapshots that have the specified @@ -5040,6 +5141,76 @@ func (c *EC2) ImportVolume(input *ImportVolumeInput) (*ImportVolumeOutput, error return out, err } +const opModifyHosts = "ModifyHosts" + +// ModifyHostsRequest generates a request for the ModifyHosts operation. +func (c *EC2) ModifyHostsRequest(input *ModifyHostsInput) (req *request.Request, output *ModifyHostsOutput) { + op := &request.Operation{ + Name: opModifyHosts, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &ModifyHostsInput{} + } + + req = c.newRequest(op, input, output) + output = &ModifyHostsOutput{} + req.Data = output + return +} + +// Modify the auto-placement setting of a Dedicated host. When auto-placement +// is enabled, AWS will place instances that you launch with a tenancy of host, +// but without targeting a specific host ID, onto any available Dedicated host +// in your account which has auto-placement enabled. When auto-placement is +// disabled, you need to provide a host ID if you want the instance to launch +// onto a specific host. If no host ID is provided, the instance will be launched +// onto a suitable host which has auto-placement enabled. +func (c *EC2) ModifyHosts(input *ModifyHostsInput) (*ModifyHostsOutput, error) { + req, out := c.ModifyHostsRequest(input) + err := req.Send() + return out, err +} + +const opModifyIdFormat = "ModifyIdFormat" + +// ModifyIdFormatRequest generates a request for the ModifyIdFormat operation. +func (c *EC2) ModifyIdFormatRequest(input *ModifyIdFormatInput) (req *request.Request, output *ModifyIdFormatOutput) { + op := &request.Operation{ + Name: opModifyIdFormat, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &ModifyIdFormatInput{} + } + + req = c.newRequest(op, input, output) + output = &ModifyIdFormatOutput{} + req.Data = output + return +} + +// Important: This command is reserved for future use, and is currently not +// available for you to use. +// +// Modifies the ID format for the specified resource. You can specify that +// resources should receive longer IDs (17-character IDs) when they are created. +// The following resource types support longer IDs: instance | reservation. +// +// This setting applies to the IAM user who makes the request; it does not +// apply to the entire AWS account. By default, an IAM user defaults to the +// same settings as the root user, unless they explicitly override the settings +// by running this request. These settings are applied on a per-region basis. +func (c *EC2) ModifyIdFormat(input *ModifyIdFormatInput) (*ModifyIdFormatOutput, error) { + req, out := c.ModifyIdFormatRequest(input) + err := req.Send() + return out, err +} + const opModifyImageAttribute = "ModifyImageAttribute" // ModifyImageAttributeRequest generates a request for the ModifyImageAttribute operation. @@ -5103,6 +5274,51 @@ func (c *EC2) ModifyInstanceAttribute(input *ModifyInstanceAttributeInput) (*Mod return out, err } +const opModifyInstancePlacement = "ModifyInstancePlacement" + +// ModifyInstancePlacementRequest generates a request for the ModifyInstancePlacement operation. +func (c *EC2) ModifyInstancePlacementRequest(input *ModifyInstancePlacementInput) (req *request.Request, output *ModifyInstancePlacementOutput) { + op := &request.Operation{ + Name: opModifyInstancePlacement, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &ModifyInstancePlacementInput{} + } + + req = c.newRequest(op, input, output) + output = &ModifyInstancePlacementOutput{} + req.Data = output + return +} + +// Set the instance affinity value for a specific stopped instance and modify +// the instance tenancy setting. +// +// Instance affinity is disabled by default. When instance affinity is host +// and it is not associated with a specific Dedicated host, the next time it +// is launched it will automatically be associated with the host it lands on. +// This relationship will persist if the instance is stopped/started, or rebooted. +// +// You can modify the host ID associated with a stopped instance. If a stopped +// instance has a new host ID association, the instance will target that host +// when restarted. +// +// You can modify the tenancy of a stopped instance with a tenancy of host +// or dedicated. +// +// Affinity, hostID, and tenancy are not required parameters, but at least +// one of them must be specified in the request. Affinity and tenancy can be +// modified in the same request, but tenancy can only be modified on instances +// that are stopped. +func (c *EC2) ModifyInstancePlacement(input *ModifyInstancePlacementInput) (*ModifyInstancePlacementOutput, error) { + req, out := c.ModifyInstancePlacementRequest(input) + err := req.Send() + return out, err +} + const opModifyNetworkInterfaceAttribute = "ModifyNetworkInterfaceAttribute" // ModifyNetworkInterfaceAttributeRequest generates a request for the ModifyNetworkInterfaceAttribute operation. @@ -5448,14 +5664,14 @@ func (c *EC2) PurchaseReservedInstancesOfferingRequest(input *PurchaseReservedIn return } -// Purchases a Reserved Instance for use with your account. With Amazon EC2 -// Reserved Instances, you obtain a capacity reservation for a certain instance +// Purchases a Reserved instance for use with your account. With Amazon EC2 +// Reserved instances, you obtain a capacity reservation for a certain instance // configuration over a specified period of time and pay a lower hourly rate -// compared to on-Demand Instance pricing. +// compared to On-Demand Instance pricing. // -// Use DescribeReservedInstancesOfferings to get a list of Reserved Instance +// Use DescribeReservedInstancesOfferings to get a list of Reserved instance // offerings that match your specifications. After you've purchased a Reserved -// Instance, you can check for your new Reserved Instance with DescribeReservedInstances. +// instance, you can check for your new Reserved instance with DescribeReservedInstances. // // For more information, see Reserved Instances (http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/concepts-on-demand-reserved-instances.html) // and Reserved Instance Marketplace (http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ri-market-general.html) @@ -5634,6 +5850,44 @@ func (c *EC2) ReleaseAddress(input *ReleaseAddressInput) (*ReleaseAddressOutput, return out, err } +const opReleaseHosts = "ReleaseHosts" + +// ReleaseHostsRequest generates a request for the ReleaseHosts operation. +func (c *EC2) ReleaseHostsRequest(input *ReleaseHostsInput) (req *request.Request, output *ReleaseHostsOutput) { + op := &request.Operation{ + Name: opReleaseHosts, + HTTPMethod: "POST", + HTTPPath: "/", + } + + if input == nil { + input = &ReleaseHostsInput{} + } + + req = c.newRequest(op, input, output) + output = &ReleaseHostsOutput{} + req.Data = output + return +} + +// When you no longer want to use a Dedicated host it can be released. On-Demand +// billing is stopped and the host goes into "released" state. The host ID of +// Dedicated hosts that have been released can no longer be specified in another +// request, e.g., ModifyHosts. You must stop or terminate all instances on a +// host before it can be released. +// +// When Dedicated hosts are released, it make take some time for them to stop +// counting toward your limit and you may receive capacity errors when trying +// to allocate new Dedicated hosts. Try waiting a few minutes, and then try +// again. +// +// Released hosts will still appear in a DescribeHosts response. +func (c *EC2) ReleaseHosts(input *ReleaseHostsInput) (*ReleaseHostsOutput, error) { + req, out := c.ReleaseHostsRequest(input) + err := req.Send() + return out, err +} + const opReplaceNetworkAclAssociation = "ReplaceNetworkAclAssociation" // ReplaceNetworkAclAssociationRequest generates a request for the ReplaceNetworkAclAssociation operation. @@ -6229,7 +6483,7 @@ func (c *EC2) StopInstancesRequest(input *StopInstancesInput) (req *request.Requ // from stopped to started, Amazon EC2 charges a full instance hour, even if // transitions happen multiple times within a single hour. // -// You can't start or stop Spot Instances. +// You can't start or stop Spot instances. // // Instances that use Amazon EBS volumes as their root devices can be quickly // stopped and started. When an instance is stopped, the compute resources are @@ -6367,6 +6621,8 @@ func (c *EC2) UnmonitorInstances(input *UnmonitorInstancesInput) (*UnmonitorInst } type AcceptVpcPeeringConnectionInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -6375,12 +6631,6 @@ type AcceptVpcPeeringConnectionInput struct { // The ID of the VPC peering connection. VpcPeeringConnectionId *string `locationName:"vpcPeeringConnectionId" type:"string"` - - metadataAcceptVpcPeeringConnectionInput `json:"-" xml:"-"` -} - -type metadataAcceptVpcPeeringConnectionInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -6394,14 +6644,10 @@ func (s AcceptVpcPeeringConnectionInput) GoString() string { } type AcceptVpcPeeringConnectionOutput struct { + _ struct{} `type:"structure"` + // Information about the VPC peering connection. VpcPeeringConnection *VpcPeeringConnection `locationName:"vpcPeeringConnection" type:"structure"` - - metadataAcceptVpcPeeringConnectionOutput `json:"-" xml:"-"` -} - -type metadataAcceptVpcPeeringConnectionOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -6416,17 +6662,13 @@ func (s AcceptVpcPeeringConnectionOutput) GoString() string { // Describes an account attribute. type AccountAttribute struct { + _ struct{} `type:"structure"` + // The name of the account attribute. AttributeName *string `locationName:"attributeName" type:"string"` // One or more values for the account attribute. AttributeValues []*AccountAttributeValue `locationName:"attributeValueSet" locationNameList:"item" type:"list"` - - metadataAccountAttribute `json:"-" xml:"-"` -} - -type metadataAccountAttribute struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -6441,14 +6683,10 @@ func (s AccountAttribute) GoString() string { // Describes a value of an account attribute. type AccountAttributeValue struct { + _ struct{} `type:"structure"` + // The value of the attribute. AttributeValue *string `locationName:"attributeValue" type:"string"` - - metadataAccountAttributeValue `json:"-" xml:"-"` -} - -type metadataAccountAttributeValue struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -6463,6 +6701,8 @@ func (s AccountAttributeValue) GoString() string { // Describes a running instance in a Spot fleet. type ActiveInstance struct { + _ struct{} `type:"structure"` + // The ID of the instance. InstanceId *string `locationName:"instanceId" type:"string"` @@ -6471,12 +6711,6 @@ type ActiveInstance struct { // The ID of the Spot instance request. SpotInstanceRequestId *string `locationName:"spotInstanceRequestId" type:"string"` - - metadataActiveInstance `json:"-" xml:"-"` -} - -type metadataActiveInstance struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -6491,6 +6725,8 @@ func (s ActiveInstance) GoString() string { // Describes an Elastic IP address. type Address struct { + _ struct{} `type:"structure"` + // The ID representing the allocation of the address for use with EC2-VPC. AllocationId *string `locationName:"allocationId" type:"string"` @@ -6516,12 +6752,6 @@ type Address struct { // The Elastic IP address. PublicIp *string `locationName:"publicIp" type:"string"` - - metadataAddress `json:"-" xml:"-"` -} - -type metadataAddress struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -6535,6 +6765,8 @@ func (s Address) GoString() string { } type AllocateAddressInput struct { + _ struct{} `type:"structure"` + // Set to vpc to allocate the address for use with instances in a VPC. // // Default: The address is for use with instances in EC2-Classic. @@ -6545,12 +6777,6 @@ type AllocateAddressInput struct { // the required permissions, the error response is DryRunOperation. Otherwise, // it is UnauthorizedOperation. DryRun *bool `locationName:"dryRun" type:"boolean"` - - metadataAllocateAddressInput `json:"-" xml:"-"` -} - -type metadataAllocateAddressInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -6564,6 +6790,8 @@ func (s AllocateAddressInput) GoString() string { } type AllocateAddressOutput struct { + _ struct{} `type:"structure"` + // [EC2-VPC] The ID that AWS assigns to represent the allocation of the Elastic // IP address for use with instances in a VPC. AllocationId *string `locationName:"allocationId" type:"string"` @@ -6574,12 +6802,6 @@ type AllocateAddressOutput struct { // The Elastic IP address. PublicIp *string `locationName:"publicIp" type:"string"` - - metadataAllocateAddressOutput `json:"-" xml:"-"` -} - -type metadataAllocateAddressOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -6592,7 +6814,65 @@ func (s AllocateAddressOutput) GoString() string { return s.String() } +type AllocateHostsInput struct { + _ struct{} `type:"structure"` + + // This is enabled by default. This property allows instances to be automatically + // placed onto available Dedicated hosts, when you are launching instances without + // specifying a host ID. + // + // Default: Enabled + AutoPlacement *string `locationName:"autoPlacement" type:"string" enum:"AutoPlacement"` + + // The Availability Zone for the Dedicated hosts. + AvailabilityZone *string `locationName:"availabilityZone" type:"string" required:"true"` + + // Unique, case-sensitive identifier you provide to ensure idempotency of the + // request. For more information, see How to Ensure Idempotency (http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Run_Instance_Idempotency.html) + // in the Amazon Elastic Compute Cloud User Guide. + ClientToken *string `locationName:"clientToken" type:"string"` + + // Specify the instance type that you want your Dedicated hosts to be configured + // for. When you specify the instance type, that is the only instance type that + // you can launch onto that host. + InstanceType *string `locationName:"instanceType" type:"string" required:"true"` + + // The number of Dedicated hosts you want to allocate to your account with these + // parameters. + Quantity *int64 `locationName:"quantity" type:"integer" required:"true"` +} + +// String returns the string representation +func (s AllocateHostsInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s AllocateHostsInput) GoString() string { + return s.String() +} + +type AllocateHostsOutput struct { + _ struct{} `type:"structure"` + + // The ID of the allocated Dedicated host. This is used when you want to launch + // an instance onto a specific host. + HostIds []*string `locationName:"hostIdSet" locationNameList:"item" type:"list"` +} + +// String returns the string representation +func (s AllocateHostsOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s AllocateHostsOutput) GoString() string { + return s.String() +} + type AssignPrivateIpAddressesInput struct { + _ struct{} `type:"structure"` + // Indicates whether to allow an IP address that is already assigned to another // network interface or instance to be reassigned to the specified network interface. AllowReassignment *bool `locationName:"allowReassignment" type:"boolean"` @@ -6611,12 +6891,6 @@ type AssignPrivateIpAddressesInput struct { // The number of secondary IP addresses to assign to the network interface. // You can't specify this parameter when also specifying private IP addresses. SecondaryPrivateIpAddressCount *int64 `locationName:"secondaryPrivateIpAddressCount" type:"integer"` - - metadataAssignPrivateIpAddressesInput `json:"-" xml:"-"` -} - -type metadataAssignPrivateIpAddressesInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -6630,11 +6904,7 @@ func (s AssignPrivateIpAddressesInput) GoString() string { } type AssignPrivateIpAddressesOutput struct { - metadataAssignPrivateIpAddressesOutput `json:"-" xml:"-"` -} - -type metadataAssignPrivateIpAddressesOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -6648,14 +6918,17 @@ func (s AssignPrivateIpAddressesOutput) GoString() string { } type AssociateAddressInput struct { + _ struct{} `type:"structure"` + // [EC2-VPC] The allocation ID. This is required for EC2-VPC. AllocationId *string `type:"string"` - // [EC2-VPC] Allows an Elastic IP address that is already associated with an - // instance or network interface to be re-associated with the specified instance - // or network interface. Otherwise, the operation fails. - // - // Default: false + // [EC2-VPC] For a VPC in an EC2-Classic account, specify true to allow an Elastic + // IP address that is already associated with an instance or network interface + // to be reassociated with the specified instance or network interface. Otherwise, + // the operation fails. In a VPC in an EC2-VPC-only account, reassociation is + // automatic, therefore you can specify false to ensure the operation fails + // if the Elastic IP address is already associated with another resource. AllowReassociation *bool `locationName:"allowReassociation" type:"boolean"` // Checks whether you have the required permissions for the action, without @@ -6681,12 +6954,6 @@ type AssociateAddressInput struct { // The Elastic IP address. This is required for EC2-Classic. PublicIp *string `type:"string"` - - metadataAssociateAddressInput `json:"-" xml:"-"` -} - -type metadataAssociateAddressInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -6700,15 +6967,11 @@ func (s AssociateAddressInput) GoString() string { } type AssociateAddressOutput struct { + _ struct{} `type:"structure"` + // [EC2-VPC] The ID that represents the association of the Elastic IP address // with an instance. AssociationId *string `locationName:"associationId" type:"string"` - - metadataAssociateAddressOutput `json:"-" xml:"-"` -} - -type metadataAssociateAddressOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -6722,6 +6985,8 @@ func (s AssociateAddressOutput) GoString() string { } type AssociateDhcpOptionsInput struct { + _ struct{} `type:"structure"` + // The ID of the DHCP options set, or default to associate no DHCP options with // the VPC. DhcpOptionsId *string `type:"string" required:"true"` @@ -6734,12 +6999,6 @@ type AssociateDhcpOptionsInput struct { // The ID of the VPC. VpcId *string `type:"string" required:"true"` - - metadataAssociateDhcpOptionsInput `json:"-" xml:"-"` -} - -type metadataAssociateDhcpOptionsInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -6753,11 +7012,7 @@ func (s AssociateDhcpOptionsInput) GoString() string { } type AssociateDhcpOptionsOutput struct { - metadataAssociateDhcpOptionsOutput `json:"-" xml:"-"` -} - -type metadataAssociateDhcpOptionsOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -6771,6 +7026,8 @@ func (s AssociateDhcpOptionsOutput) GoString() string { } type AssociateRouteTableInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -6782,12 +7039,6 @@ type AssociateRouteTableInput struct { // The ID of the subnet. SubnetId *string `locationName:"subnetId" type:"string" required:"true"` - - metadataAssociateRouteTableInput `json:"-" xml:"-"` -} - -type metadataAssociateRouteTableInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -6801,14 +7052,10 @@ func (s AssociateRouteTableInput) GoString() string { } type AssociateRouteTableOutput struct { + _ struct{} `type:"structure"` + // The route table association ID (needed to disassociate the route table). AssociationId *string `locationName:"associationId" type:"string"` - - metadataAssociateRouteTableOutput `json:"-" xml:"-"` -} - -type metadataAssociateRouteTableOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -6822,6 +7069,8 @@ func (s AssociateRouteTableOutput) GoString() string { } type AttachClassicLinkVpcInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -6837,12 +7086,6 @@ type AttachClassicLinkVpcInput struct { // The ID of a ClassicLink-enabled VPC. VpcId *string `locationName:"vpcId" type:"string" required:"true"` - - metadataAttachClassicLinkVpcInput `json:"-" xml:"-"` -} - -type metadataAttachClassicLinkVpcInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -6856,14 +7099,10 @@ func (s AttachClassicLinkVpcInput) GoString() string { } type AttachClassicLinkVpcOutput struct { + _ struct{} `type:"structure"` + // Returns true if the request succeeds; otherwise, it returns an error. Return *bool `locationName:"return" type:"boolean"` - - metadataAttachClassicLinkVpcOutput `json:"-" xml:"-"` -} - -type metadataAttachClassicLinkVpcOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -6877,6 +7116,8 @@ func (s AttachClassicLinkVpcOutput) GoString() string { } type AttachInternetGatewayInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -6888,12 +7129,6 @@ type AttachInternetGatewayInput struct { // The ID of the VPC. VpcId *string `locationName:"vpcId" type:"string" required:"true"` - - metadataAttachInternetGatewayInput `json:"-" xml:"-"` -} - -type metadataAttachInternetGatewayInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -6907,11 +7142,7 @@ func (s AttachInternetGatewayInput) GoString() string { } type AttachInternetGatewayOutput struct { - metadataAttachInternetGatewayOutput `json:"-" xml:"-"` -} - -type metadataAttachInternetGatewayOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -6925,6 +7156,8 @@ func (s AttachInternetGatewayOutput) GoString() string { } type AttachNetworkInterfaceInput struct { + _ struct{} `type:"structure"` + // The index of the device for the network interface attachment. DeviceIndex *int64 `locationName:"deviceIndex" type:"integer" required:"true"` @@ -6939,12 +7172,6 @@ type AttachNetworkInterfaceInput struct { // The ID of the network interface. NetworkInterfaceId *string `locationName:"networkInterfaceId" type:"string" required:"true"` - - metadataAttachNetworkInterfaceInput `json:"-" xml:"-"` -} - -type metadataAttachNetworkInterfaceInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -6958,14 +7185,10 @@ func (s AttachNetworkInterfaceInput) GoString() string { } type AttachNetworkInterfaceOutput struct { + _ struct{} `type:"structure"` + // The ID of the network interface attachment. AttachmentId *string `locationName:"attachmentId" type:"string"` - - metadataAttachNetworkInterfaceOutput `json:"-" xml:"-"` -} - -type metadataAttachNetworkInterfaceOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -6979,6 +7202,8 @@ func (s AttachNetworkInterfaceOutput) GoString() string { } type AttachVolumeInput struct { + _ struct{} `type:"structure"` + // The device name to expose to the instance (for example, /dev/sdh or xvdh). Device *string `type:"string" required:"true"` @@ -6994,12 +7219,6 @@ type AttachVolumeInput struct { // The ID of the EBS volume. The volume and instance must be within the same // Availability Zone. VolumeId *string `type:"string" required:"true"` - - metadataAttachVolumeInput `json:"-" xml:"-"` -} - -type metadataAttachVolumeInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -7013,6 +7232,8 @@ func (s AttachVolumeInput) GoString() string { } type AttachVpnGatewayInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -7024,12 +7245,6 @@ type AttachVpnGatewayInput struct { // The ID of the virtual private gateway. VpnGatewayId *string `type:"string" required:"true"` - - metadataAttachVpnGatewayInput `json:"-" xml:"-"` -} - -type metadataAttachVpnGatewayInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -7043,14 +7258,10 @@ func (s AttachVpnGatewayInput) GoString() string { } type AttachVpnGatewayOutput struct { + _ struct{} `type:"structure"` + // Information about the attachment. VpcAttachment *VpcAttachment `locationName:"attachment" type:"structure"` - - metadataAttachVpnGatewayOutput `json:"-" xml:"-"` -} - -type metadataAttachVpnGatewayOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -7065,14 +7276,10 @@ func (s AttachVpnGatewayOutput) GoString() string { // The value to use when a resource attribute accepts a Boolean value. type AttributeBooleanValue struct { + _ struct{} `type:"structure"` + // Valid values are true or false. Value *bool `locationName:"value" type:"boolean"` - - metadataAttributeBooleanValue `json:"-" xml:"-"` -} - -type metadataAttributeBooleanValue struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -7087,14 +7294,10 @@ func (s AttributeBooleanValue) GoString() string { // The value to use for a resource attribute. type AttributeValue struct { + _ struct{} `type:"structure"` + // Valid values are case-sensitive and vary by action. Value *string `locationName:"value" type:"string"` - - metadataAttributeValue `json:"-" xml:"-"` -} - -type metadataAttributeValue struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -7108,6 +7311,8 @@ func (s AttributeValue) GoString() string { } type AuthorizeSecurityGroupEgressInput struct { + _ struct{} `type:"structure"` + // The CIDR IP address range. You can't specify this parameter when specifying // a source security group. CidrIp *string `locationName:"cidrIp" type:"string"` @@ -7146,12 +7351,6 @@ type AuthorizeSecurityGroupEgressInput struct { // The end of port range for the TCP and UDP protocols, or an ICMP code number. // For the ICMP code number, use -1 to specify all ICMP codes for the ICMP type. ToPort *int64 `locationName:"toPort" type:"integer"` - - metadataAuthorizeSecurityGroupEgressInput `json:"-" xml:"-"` -} - -type metadataAuthorizeSecurityGroupEgressInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -7165,11 +7364,7 @@ func (s AuthorizeSecurityGroupEgressInput) GoString() string { } type AuthorizeSecurityGroupEgressOutput struct { - metadataAuthorizeSecurityGroupEgressOutput `json:"-" xml:"-"` -} - -type metadataAuthorizeSecurityGroupEgressOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -7183,6 +7378,8 @@ func (s AuthorizeSecurityGroupEgressOutput) GoString() string { } type AuthorizeSecurityGroupIngressInput struct { + _ struct{} `type:"structure"` + // The CIDR IP address range. You can't specify this parameter when specifying // a source security group. CidrIp *string `type:"string"` @@ -7230,12 +7427,6 @@ type AuthorizeSecurityGroupIngressInput struct { // The end of port range for the TCP and UDP protocols, or an ICMP code number. // For the ICMP code number, use -1 to specify all ICMP codes for the ICMP type. ToPort *int64 `type:"integer"` - - metadataAuthorizeSecurityGroupIngressInput `json:"-" xml:"-"` -} - -type metadataAuthorizeSecurityGroupIngressInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -7249,11 +7440,7 @@ func (s AuthorizeSecurityGroupIngressInput) GoString() string { } type AuthorizeSecurityGroupIngressOutput struct { - metadataAuthorizeSecurityGroupIngressOutput `json:"-" xml:"-"` -} - -type metadataAuthorizeSecurityGroupIngressOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -7268,6 +7455,8 @@ func (s AuthorizeSecurityGroupIngressOutput) GoString() string { // Describes an Availability Zone. type AvailabilityZone struct { + _ struct{} `type:"structure"` + // Any messages about the Availability Zone. Messages []*AvailabilityZoneMessage `locationName:"messageSet" locationNameList:"item" type:"list"` @@ -7279,12 +7468,6 @@ type AvailabilityZone struct { // The name of the Availability Zone. ZoneName *string `locationName:"zoneName" type:"string"` - - metadataAvailabilityZone `json:"-" xml:"-"` -} - -type metadataAvailabilityZone struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -7299,14 +7482,10 @@ func (s AvailabilityZone) GoString() string { // Describes a message about an Availability Zone. type AvailabilityZoneMessage struct { + _ struct{} `type:"structure"` + // The message about the Availability Zone. Message *string `locationName:"message" type:"string"` - - metadataAvailabilityZoneMessage `json:"-" xml:"-"` -} - -type metadataAvailabilityZoneMessage struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -7319,14 +7498,30 @@ func (s AvailabilityZoneMessage) GoString() string { return s.String() } -type BlobAttributeValue struct { - Value []byte `locationName:"value" type:"blob"` +type AvailableCapacity struct { + _ struct{} `type:"structure"` - metadataBlobAttributeValue `json:"-" xml:"-"` + // The total number of instances that the Dedicated host supports. + AvailableInstanceCapacity []*InstanceCapacity `locationName:"availableInstanceCapacity" locationNameList:"item" type:"list"` + + // The number of vCPUs available on the Dedicated host. + AvailableVCpus *int64 `locationName:"availableVCpus" type:"integer"` } -type metadataBlobAttributeValue struct { - SDKShapeTraits bool `type:"structure"` +// String returns the string representation +func (s AvailableCapacity) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s AvailableCapacity) GoString() string { + return s.String() +} + +type BlobAttributeValue struct { + _ struct{} `type:"structure"` + + Value []byte `locationName:"value" type:"blob"` } // String returns the string representation @@ -7341,6 +7536,8 @@ func (s BlobAttributeValue) GoString() string { // Describes a block device mapping. type BlockDeviceMapping struct { + _ struct{} `type:"structure"` + // The device name exposed to the instance (for example, /dev/sdh or xvdh). DeviceName *string `locationName:"deviceName" type:"string"` @@ -7363,12 +7560,6 @@ type BlockDeviceMapping struct { // we ignore any instance store volumes specified in the block device mapping // for the AMI. VirtualName *string `locationName:"virtualName" type:"string"` - - metadataBlockDeviceMapping `json:"-" xml:"-"` -} - -type metadataBlockDeviceMapping struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -7382,6 +7573,8 @@ func (s BlockDeviceMapping) GoString() string { } type BundleInstanceInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -7401,12 +7594,6 @@ type BundleInstanceInput struct { // own or a new bucket that Amazon EC2 creates on your behalf. If you specify // a bucket that belongs to someone else, Amazon EC2 returns an error. Storage *Storage `type:"structure" required:"true"` - - metadataBundleInstanceInput `json:"-" xml:"-"` -} - -type metadataBundleInstanceInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -7420,14 +7607,10 @@ func (s BundleInstanceInput) GoString() string { } type BundleInstanceOutput struct { + _ struct{} `type:"structure"` + // Information about the bundle task. BundleTask *BundleTask `locationName:"bundleInstanceTask" type:"structure"` - - metadataBundleInstanceOutput `json:"-" xml:"-"` -} - -type metadataBundleInstanceOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -7442,6 +7625,8 @@ func (s BundleInstanceOutput) GoString() string { // Describes a bundle task. type BundleTask struct { + _ struct{} `type:"structure"` + // The ID of the bundle task. BundleId *string `locationName:"bundleId" type:"string"` @@ -7465,12 +7650,6 @@ type BundleTask struct { // The time of the most recent update for the task. UpdateTime *time.Time `locationName:"updateTime" type:"timestamp" timestampFormat:"iso8601"` - - metadataBundleTask `json:"-" xml:"-"` -} - -type metadataBundleTask struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -7485,17 +7664,13 @@ func (s BundleTask) GoString() string { // Describes an error for BundleInstance. type BundleTaskError struct { + _ struct{} `type:"structure"` + // The error code. Code *string `locationName:"code" type:"string"` // The error message. Message *string `locationName:"message" type:"string"` - - metadataBundleTaskError `json:"-" xml:"-"` -} - -type metadataBundleTaskError struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -7509,6 +7684,8 @@ func (s BundleTaskError) GoString() string { } type CancelBundleTaskInput struct { + _ struct{} `type:"structure"` + // The ID of the bundle task. BundleId *string `type:"string" required:"true"` @@ -7517,12 +7694,6 @@ type CancelBundleTaskInput struct { // the required permissions, the error response is DryRunOperation. Otherwise, // it is UnauthorizedOperation. DryRun *bool `locationName:"dryRun" type:"boolean"` - - metadataCancelBundleTaskInput `json:"-" xml:"-"` -} - -type metadataCancelBundleTaskInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -7536,14 +7707,10 @@ func (s CancelBundleTaskInput) GoString() string { } type CancelBundleTaskOutput struct { + _ struct{} `type:"structure"` + // Information about the bundle task. BundleTask *BundleTask `locationName:"bundleInstanceTask" type:"structure"` - - metadataCancelBundleTaskOutput `json:"-" xml:"-"` -} - -type metadataCancelBundleTaskOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -7557,6 +7724,8 @@ func (s CancelBundleTaskOutput) GoString() string { } type CancelConversionTaskInput struct { + _ struct{} `type:"structure"` + // The ID of the conversion task. ConversionTaskId *string `locationName:"conversionTaskId" type:"string" required:"true"` @@ -7568,12 +7737,6 @@ type CancelConversionTaskInput struct { // The reason for canceling the conversion task. ReasonMessage *string `locationName:"reasonMessage" type:"string"` - - metadataCancelConversionTaskInput `json:"-" xml:"-"` -} - -type metadataCancelConversionTaskInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -7587,11 +7750,7 @@ func (s CancelConversionTaskInput) GoString() string { } type CancelConversionTaskOutput struct { - metadataCancelConversionTaskOutput `json:"-" xml:"-"` -} - -type metadataCancelConversionTaskOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -7605,14 +7764,10 @@ func (s CancelConversionTaskOutput) GoString() string { } type CancelExportTaskInput struct { + _ struct{} `type:"structure"` + // The ID of the export task. This is the ID returned by CreateInstanceExportTask. ExportTaskId *string `locationName:"exportTaskId" type:"string" required:"true"` - - metadataCancelExportTaskInput `json:"-" xml:"-"` -} - -type metadataCancelExportTaskInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -7626,11 +7781,7 @@ func (s CancelExportTaskInput) GoString() string { } type CancelExportTaskOutput struct { - metadataCancelExportTaskOutput `json:"-" xml:"-"` -} - -type metadataCancelExportTaskOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -7644,6 +7795,8 @@ func (s CancelExportTaskOutput) GoString() string { } type CancelImportTaskInput struct { + _ struct{} `type:"structure"` + // The reason for canceling the task. CancelReason *string `type:"string"` @@ -7655,12 +7808,6 @@ type CancelImportTaskInput struct { // The ID of the import image or import snapshot task to be canceled. ImportTaskId *string `type:"string"` - - metadataCancelImportTaskInput `json:"-" xml:"-"` -} - -type metadataCancelImportTaskInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -7674,6 +7821,8 @@ func (s CancelImportTaskInput) GoString() string { } type CancelImportTaskOutput struct { + _ struct{} `type:"structure"` + // The ID of the task being canceled. ImportTaskId *string `locationName:"importTaskId" type:"string"` @@ -7682,12 +7831,6 @@ type CancelImportTaskOutput struct { // The current state of the task being canceled. State *string `locationName:"state" type:"string"` - - metadataCancelImportTaskOutput `json:"-" xml:"-"` -} - -type metadataCancelImportTaskOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -7701,14 +7844,10 @@ func (s CancelImportTaskOutput) GoString() string { } type CancelReservedInstancesListingInput struct { - // The ID of the Reserved Instance listing. + _ struct{} `type:"structure"` + + // The ID of the Reserved instance listing. ReservedInstancesListingId *string `locationName:"reservedInstancesListingId" type:"string" required:"true"` - - metadataCancelReservedInstancesListingInput `json:"-" xml:"-"` -} - -type metadataCancelReservedInstancesListingInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -7722,14 +7861,10 @@ func (s CancelReservedInstancesListingInput) GoString() string { } type CancelReservedInstancesListingOutput struct { - // The Reserved Instance listing. + _ struct{} `type:"structure"` + + // The Reserved instance listing. ReservedInstancesListings []*ReservedInstancesListing `locationName:"reservedInstancesListingsSet" locationNameList:"item" type:"list"` - - metadataCancelReservedInstancesListingOutput `json:"-" xml:"-"` -} - -type metadataCancelReservedInstancesListingOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -7744,17 +7879,13 @@ func (s CancelReservedInstancesListingOutput) GoString() string { // Describes a Spot fleet error. type CancelSpotFleetRequestsError struct { + _ struct{} `type:"structure"` + // The error code. Code *string `locationName:"code" type:"string" required:"true" enum:"CancelBatchErrorCode"` // The description for the error code. Message *string `locationName:"message" type:"string" required:"true"` - - metadataCancelSpotFleetRequestsError `json:"-" xml:"-"` -} - -type metadataCancelSpotFleetRequestsError struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -7769,17 +7900,13 @@ func (s CancelSpotFleetRequestsError) GoString() string { // Describes a Spot fleet request that was not successfully canceled. type CancelSpotFleetRequestsErrorItem struct { + _ struct{} `type:"structure"` + // The error. Error *CancelSpotFleetRequestsError `locationName:"error" type:"structure" required:"true"` // The ID of the Spot fleet request. SpotFleetRequestId *string `locationName:"spotFleetRequestId" type:"string" required:"true"` - - metadataCancelSpotFleetRequestsErrorItem `json:"-" xml:"-"` -} - -type metadataCancelSpotFleetRequestsErrorItem struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -7794,6 +7921,8 @@ func (s CancelSpotFleetRequestsErrorItem) GoString() string { // Contains the parameters for CancelSpotFleetRequests. type CancelSpotFleetRequestsInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -7806,12 +7935,6 @@ type CancelSpotFleetRequestsInput struct { // Indicates whether to terminate instances for a Spot fleet request if it is // canceled successfully. TerminateInstances *bool `locationName:"terminateInstances" type:"boolean" required:"true"` - - metadataCancelSpotFleetRequestsInput `json:"-" xml:"-"` -} - -type metadataCancelSpotFleetRequestsInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -7826,17 +7949,13 @@ func (s CancelSpotFleetRequestsInput) GoString() string { // Contains the output of CancelSpotFleetRequests. type CancelSpotFleetRequestsOutput struct { + _ struct{} `type:"structure"` + // Information about the Spot fleet requests that are successfully canceled. SuccessfulFleetRequests []*CancelSpotFleetRequestsSuccessItem `locationName:"successfulFleetRequestSet" locationNameList:"item" type:"list"` // Information about the Spot fleet requests that are not successfully canceled. UnsuccessfulFleetRequests []*CancelSpotFleetRequestsErrorItem `locationName:"unsuccessfulFleetRequestSet" locationNameList:"item" type:"list"` - - metadataCancelSpotFleetRequestsOutput `json:"-" xml:"-"` -} - -type metadataCancelSpotFleetRequestsOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -7851,6 +7970,8 @@ func (s CancelSpotFleetRequestsOutput) GoString() string { // Describes a Spot fleet request that was successfully canceled. type CancelSpotFleetRequestsSuccessItem struct { + _ struct{} `type:"structure"` + // The current state of the Spot fleet request. CurrentSpotFleetRequestState *string `locationName:"currentSpotFleetRequestState" type:"string" required:"true" enum:"BatchState"` @@ -7859,12 +7980,6 @@ type CancelSpotFleetRequestsSuccessItem struct { // The ID of the Spot fleet request. SpotFleetRequestId *string `locationName:"spotFleetRequestId" type:"string" required:"true"` - - metadataCancelSpotFleetRequestsSuccessItem `json:"-" xml:"-"` -} - -type metadataCancelSpotFleetRequestsSuccessItem struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -7879,6 +7994,8 @@ func (s CancelSpotFleetRequestsSuccessItem) GoString() string { // Contains the parameters for CancelSpotInstanceRequests. type CancelSpotInstanceRequestsInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -7887,12 +8004,6 @@ type CancelSpotInstanceRequestsInput struct { // One or more Spot instance request IDs. SpotInstanceRequestIds []*string `locationName:"SpotInstanceRequestId" locationNameList:"SpotInstanceRequestId" type:"list" required:"true"` - - metadataCancelSpotInstanceRequestsInput `json:"-" xml:"-"` -} - -type metadataCancelSpotInstanceRequestsInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -7907,14 +8018,10 @@ func (s CancelSpotInstanceRequestsInput) GoString() string { // Contains the output of CancelSpotInstanceRequests. type CancelSpotInstanceRequestsOutput struct { + _ struct{} `type:"structure"` + // One or more Spot instance requests. CancelledSpotInstanceRequests []*CancelledSpotInstanceRequest `locationName:"spotInstanceRequestSet" locationNameList:"item" type:"list"` - - metadataCancelSpotInstanceRequestsOutput `json:"-" xml:"-"` -} - -type metadataCancelSpotInstanceRequestsOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -7929,17 +8036,13 @@ func (s CancelSpotInstanceRequestsOutput) GoString() string { // Describes a request to cancel a Spot instance. type CancelledSpotInstanceRequest struct { + _ struct{} `type:"structure"` + // The ID of the Spot instance request. SpotInstanceRequestId *string `locationName:"spotInstanceRequestId" type:"string"` // The state of the Spot instance request. State *string `locationName:"state" type:"string" enum:"CancelSpotInstanceRequestState"` - - metadataCancelledSpotInstanceRequest `json:"-" xml:"-"` -} - -type metadataCancelledSpotInstanceRequest struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -7954,6 +8057,8 @@ func (s CancelledSpotInstanceRequest) GoString() string { // Describes a linked EC2-Classic instance. type ClassicLinkInstance struct { + _ struct{} `type:"structure"` + // A list of security groups. Groups []*GroupIdentifier `locationName:"groupSet" locationNameList:"item" type:"list"` @@ -7965,12 +8070,6 @@ type ClassicLinkInstance struct { // The ID of the VPC. VpcId *string `locationName:"vpcId" type:"string"` - - metadataClassicLinkInstance `json:"-" xml:"-"` -} - -type metadataClassicLinkInstance struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -7985,6 +8084,8 @@ func (s ClassicLinkInstance) GoString() string { // Describes the client-specific data. type ClientData struct { + _ struct{} `type:"structure"` + // A user-defined comment about the disk upload. Comment *string `type:"string"` @@ -7996,12 +8097,6 @@ type ClientData struct { // The time that the disk upload starts. UploadStart *time.Time `type:"timestamp" timestampFormat:"iso8601"` - - metadataClientData `json:"-" xml:"-"` -} - -type metadataClientData struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -8015,6 +8110,8 @@ func (s ClientData) GoString() string { } type ConfirmProductInstanceInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -8026,12 +8123,6 @@ type ConfirmProductInstanceInput struct { // The product code. This must be a product code that you own. ProductCode *string `type:"string" required:"true"` - - metadataConfirmProductInstanceInput `json:"-" xml:"-"` -} - -type metadataConfirmProductInstanceInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -8045,6 +8136,8 @@ func (s ConfirmProductInstanceInput) GoString() string { } type ConfirmProductInstanceOutput struct { + _ struct{} `type:"structure"` + // The AWS account ID of the instance owner. This is only present if the product // code is attached to the instance. OwnerId *string `locationName:"ownerId" type:"string"` @@ -8052,12 +8145,6 @@ type ConfirmProductInstanceOutput struct { // The return value of the request. Returns true if the specified product code // is owned by the requester and associated with the specified instance. Return *bool `locationName:"return" type:"boolean"` - - metadataConfirmProductInstanceOutput `json:"-" xml:"-"` -} - -type metadataConfirmProductInstanceOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -8072,6 +8159,8 @@ func (s ConfirmProductInstanceOutput) GoString() string { // Describes a conversion task. type ConversionTask struct { + _ struct{} `type:"structure"` + // The ID of the conversion task. ConversionTaskId *string `locationName:"conversionTaskId" type:"string" required:"true"` @@ -8095,12 +8184,6 @@ type ConversionTask struct { // Any tags assigned to the task. Tags []*Tag `locationName:"tagSet" locationNameList:"item" type:"list"` - - metadataConversionTask `json:"-" xml:"-"` -} - -type metadataConversionTask struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -8114,6 +8197,8 @@ func (s ConversionTask) GoString() string { } type CopyImageInput struct { + _ struct{} `type:"structure"` + // Unique, case-sensitive identifier you provide to ensure idempotency of the // request. For more information, see How to Ensure Idempotency (http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Run_Instance_Idempotency.html) // in the Amazon Elastic Compute Cloud User Guide. @@ -8136,12 +8221,6 @@ type CopyImageInput struct { // The name of the region that contains the AMI to copy. SourceRegion *string `type:"string" required:"true"` - - metadataCopyImageInput `json:"-" xml:"-"` -} - -type metadataCopyImageInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -8155,14 +8234,10 @@ func (s CopyImageInput) GoString() string { } type CopyImageOutput struct { + _ struct{} `type:"structure"` + // The ID of the new AMI. ImageId *string `locationName:"imageId" type:"string"` - - metadataCopyImageOutput `json:"-" xml:"-"` -} - -type metadataCopyImageOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -8176,6 +8251,8 @@ func (s CopyImageOutput) GoString() string { } type CopySnapshotInput struct { + _ struct{} `type:"structure"` + // A description for the EBS snapshot. Description *string `type:"string"` @@ -8233,12 +8310,6 @@ type CopySnapshotInput struct { // The ID of the EBS snapshot to copy. SourceSnapshotId *string `type:"string" required:"true"` - - metadataCopySnapshotInput `json:"-" xml:"-"` -} - -type metadataCopySnapshotInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -8252,14 +8323,10 @@ func (s CopySnapshotInput) GoString() string { } type CopySnapshotOutput struct { + _ struct{} `type:"structure"` + // The ID of the new snapshot. SnapshotId *string `locationName:"snapshotId" type:"string"` - - metadataCopySnapshotOutput `json:"-" xml:"-"` -} - -type metadataCopySnapshotOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -8273,6 +8340,8 @@ func (s CopySnapshotOutput) GoString() string { } type CreateCustomerGatewayInput struct { + _ struct{} `type:"structure"` + // For devices that support BGP, the customer gateway's BGP ASN. // // Default: 65000 @@ -8290,12 +8359,6 @@ type CreateCustomerGatewayInput struct { // The type of VPN connection that this customer gateway supports (ipsec.1). Type *string `type:"string" required:"true" enum:"GatewayType"` - - metadataCreateCustomerGatewayInput `json:"-" xml:"-"` -} - -type metadataCreateCustomerGatewayInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -8309,14 +8372,10 @@ func (s CreateCustomerGatewayInput) GoString() string { } type CreateCustomerGatewayOutput struct { + _ struct{} `type:"structure"` + // Information about the customer gateway. CustomerGateway *CustomerGateway `locationName:"customerGateway" type:"structure"` - - metadataCreateCustomerGatewayOutput `json:"-" xml:"-"` -} - -type metadataCreateCustomerGatewayOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -8330,6 +8389,8 @@ func (s CreateCustomerGatewayOutput) GoString() string { } type CreateDhcpOptionsInput struct { + _ struct{} `type:"structure"` + // A DHCP configuration option. DhcpConfigurations []*NewDhcpConfiguration `locationName:"dhcpConfiguration" locationNameList:"item" type:"list" required:"true"` @@ -8338,12 +8399,6 @@ type CreateDhcpOptionsInput struct { // the required permissions, the error response is DryRunOperation. Otherwise, // it is UnauthorizedOperation. DryRun *bool `locationName:"dryRun" type:"boolean"` - - metadataCreateDhcpOptionsInput `json:"-" xml:"-"` -} - -type metadataCreateDhcpOptionsInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -8357,14 +8412,10 @@ func (s CreateDhcpOptionsInput) GoString() string { } type CreateDhcpOptionsOutput struct { + _ struct{} `type:"structure"` + // A set of DHCP options. DhcpOptions *DhcpOptions `locationName:"dhcpOptions" type:"structure"` - - metadataCreateDhcpOptionsOutput `json:"-" xml:"-"` -} - -type metadataCreateDhcpOptionsOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -8378,6 +8429,8 @@ func (s CreateDhcpOptionsOutput) GoString() string { } type CreateFlowLogsInput struct { + _ struct{} `type:"structure"` + // Unique, case-sensitive identifier you provide to ensure the idempotency of // the request. For more information, see How to Ensure Idempotency (http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Run_Instance_Idempotency.html). ClientToken *string `type:"string"` @@ -8397,12 +8450,6 @@ type CreateFlowLogsInput struct { // The type of traffic to log. TrafficType *string `type:"string" required:"true" enum:"TrafficType"` - - metadataCreateFlowLogsInput `json:"-" xml:"-"` -} - -type metadataCreateFlowLogsInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -8416,6 +8463,8 @@ func (s CreateFlowLogsInput) GoString() string { } type CreateFlowLogsOutput struct { + _ struct{} `type:"structure"` + // Unique, case-sensitive identifier you provide to ensure the idempotency of // the request. ClientToken *string `locationName:"clientToken" type:"string"` @@ -8425,12 +8474,6 @@ type CreateFlowLogsOutput struct { // Information about the flow logs that could not be created successfully. Unsuccessful []*UnsuccessfulItem `locationName:"unsuccessful" locationNameList:"item" type:"list"` - - metadataCreateFlowLogsOutput `json:"-" xml:"-"` -} - -type metadataCreateFlowLogsOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -8444,6 +8487,8 @@ func (s CreateFlowLogsOutput) GoString() string { } type CreateImageInput struct { + _ struct{} `type:"structure"` + // Information about one or more block device mappings. BlockDeviceMappings []*BlockDeviceMapping `locationName:"blockDeviceMapping" locationNameList:"BlockDeviceMapping" type:"list"` @@ -8472,12 +8517,6 @@ type CreateImageInput struct { // down the instance before creating the image. When this option is used, file // system integrity on the created image can't be guaranteed. NoReboot *bool `locationName:"noReboot" type:"boolean"` - - metadataCreateImageInput `json:"-" xml:"-"` -} - -type metadataCreateImageInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -8491,14 +8530,10 @@ func (s CreateImageInput) GoString() string { } type CreateImageOutput struct { + _ struct{} `type:"structure"` + // The ID of the new AMI. ImageId *string `locationName:"imageId" type:"string"` - - metadataCreateImageOutput `json:"-" xml:"-"` -} - -type metadataCreateImageOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -8512,6 +8547,8 @@ func (s CreateImageOutput) GoString() string { } type CreateInstanceExportTaskInput struct { + _ struct{} `type:"structure"` + // A description for the conversion task or the resource being exported. The // maximum length is 255 bytes. Description *string `locationName:"description" type:"string"` @@ -8524,12 +8561,6 @@ type CreateInstanceExportTaskInput struct { // The target virtualization environment. TargetEnvironment *string `locationName:"targetEnvironment" type:"string" enum:"ExportEnvironment"` - - metadataCreateInstanceExportTaskInput `json:"-" xml:"-"` -} - -type metadataCreateInstanceExportTaskInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -8543,14 +8574,10 @@ func (s CreateInstanceExportTaskInput) GoString() string { } type CreateInstanceExportTaskOutput struct { + _ struct{} `type:"structure"` + // Information about the instance export task. ExportTask *ExportTask `locationName:"exportTask" type:"structure"` - - metadataCreateInstanceExportTaskOutput `json:"-" xml:"-"` -} - -type metadataCreateInstanceExportTaskOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -8564,17 +8591,13 @@ func (s CreateInstanceExportTaskOutput) GoString() string { } type CreateInternetGatewayInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, // it is UnauthorizedOperation. DryRun *bool `locationName:"dryRun" type:"boolean"` - - metadataCreateInternetGatewayInput `json:"-" xml:"-"` -} - -type metadataCreateInternetGatewayInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -8588,14 +8611,10 @@ func (s CreateInternetGatewayInput) GoString() string { } type CreateInternetGatewayOutput struct { + _ struct{} `type:"structure"` + // Information about the Internet gateway. InternetGateway *InternetGateway `locationName:"internetGateway" type:"structure"` - - metadataCreateInternetGatewayOutput `json:"-" xml:"-"` -} - -type metadataCreateInternetGatewayOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -8609,6 +8628,8 @@ func (s CreateInternetGatewayOutput) GoString() string { } type CreateKeyPairInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -8619,12 +8640,6 @@ type CreateKeyPairInput struct { // // Constraints: Up to 255 ASCII characters KeyName *string `type:"string" required:"true"` - - metadataCreateKeyPairInput `json:"-" xml:"-"` -} - -type metadataCreateKeyPairInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -8639,6 +8654,8 @@ func (s CreateKeyPairInput) GoString() string { // Describes a key pair. type CreateKeyPairOutput struct { + _ struct{} `type:"structure"` + // The SHA-1 digest of the DER encoded private key. KeyFingerprint *string `locationName:"keyFingerprint" type:"string"` @@ -8647,12 +8664,6 @@ type CreateKeyPairOutput struct { // The name of the key pair. KeyName *string `locationName:"keyName" type:"string"` - - metadataCreateKeyPairOutput `json:"-" xml:"-"` -} - -type metadataCreateKeyPairOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -8666,6 +8677,8 @@ func (s CreateKeyPairOutput) GoString() string { } type CreateNetworkAclEntryInput struct { + _ struct{} `type:"structure"` + // The network range to allow or deny, in CIDR notation (for example 172.16.0.0/24). CidrBlock *string `locationName:"cidrBlock" type:"string" required:"true"` @@ -8700,12 +8713,6 @@ type CreateNetworkAclEntryInput struct { // // Constraints: Positive integer from 1 to 32766 RuleNumber *int64 `locationName:"ruleNumber" type:"integer" required:"true"` - - metadataCreateNetworkAclEntryInput `json:"-" xml:"-"` -} - -type metadataCreateNetworkAclEntryInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -8719,11 +8726,7 @@ func (s CreateNetworkAclEntryInput) GoString() string { } type CreateNetworkAclEntryOutput struct { - metadataCreateNetworkAclEntryOutput `json:"-" xml:"-"` -} - -type metadataCreateNetworkAclEntryOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -8737,6 +8740,8 @@ func (s CreateNetworkAclEntryOutput) GoString() string { } type CreateNetworkAclInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -8745,12 +8750,6 @@ type CreateNetworkAclInput struct { // The ID of the VPC. VpcId *string `locationName:"vpcId" type:"string" required:"true"` - - metadataCreateNetworkAclInput `json:"-" xml:"-"` -} - -type metadataCreateNetworkAclInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -8764,14 +8763,10 @@ func (s CreateNetworkAclInput) GoString() string { } type CreateNetworkAclOutput struct { + _ struct{} `type:"structure"` + // Information about the network ACL. NetworkAcl *NetworkAcl `locationName:"networkAcl" type:"structure"` - - metadataCreateNetworkAclOutput `json:"-" xml:"-"` -} - -type metadataCreateNetworkAclOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -8785,6 +8780,8 @@ func (s CreateNetworkAclOutput) GoString() string { } type CreateNetworkInterfaceInput struct { + _ struct{} `type:"structure"` + // A description for the network interface. Description *string `locationName:"description" type:"string"` @@ -8819,12 +8816,6 @@ type CreateNetworkInterfaceInput struct { // The ID of the subnet to associate with the network interface. SubnetId *string `locationName:"subnetId" type:"string" required:"true"` - - metadataCreateNetworkInterfaceInput `json:"-" xml:"-"` -} - -type metadataCreateNetworkInterfaceInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -8838,14 +8829,10 @@ func (s CreateNetworkInterfaceInput) GoString() string { } type CreateNetworkInterfaceOutput struct { + _ struct{} `type:"structure"` + // Information about the network interface. NetworkInterface *NetworkInterface `locationName:"networkInterface" type:"structure"` - - metadataCreateNetworkInterfaceOutput `json:"-" xml:"-"` -} - -type metadataCreateNetworkInterfaceOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -8859,6 +8846,8 @@ func (s CreateNetworkInterfaceOutput) GoString() string { } type CreatePlacementGroupInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -8872,12 +8861,6 @@ type CreatePlacementGroupInput struct { // The placement strategy. Strategy *string `locationName:"strategy" type:"string" required:"true" enum:"PlacementStrategy"` - - metadataCreatePlacementGroupInput `json:"-" xml:"-"` -} - -type metadataCreatePlacementGroupInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -8891,11 +8874,7 @@ func (s CreatePlacementGroupInput) GoString() string { } type CreatePlacementGroupOutput struct { - metadataCreatePlacementGroupOutput `json:"-" xml:"-"` -} - -type metadataCreatePlacementGroupOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -8909,29 +8888,25 @@ func (s CreatePlacementGroupOutput) GoString() string { } type CreateReservedInstancesListingInput struct { + _ struct{} `type:"structure"` + // Unique, case-sensitive identifier you provide to ensure idempotency of your // listings. This helps avoid duplicate listings. For more information, see // Ensuring Idempotency (http://docs.aws.amazon.com/AWSEC2/latest/APIReference/Run_Instance_Idempotency.html). ClientToken *string `locationName:"clientToken" type:"string" required:"true"` - // The number of instances that are a part of a Reserved Instance account to + // The number of instances that are a part of a Reserved instance account to // be listed in the Reserved Instance Marketplace. This number should be less - // than or equal to the instance count associated with the Reserved Instance + // than or equal to the instance count associated with the Reserved instance // ID specified in this call. InstanceCount *int64 `locationName:"instanceCount" type:"integer" required:"true"` - // A list specifying the price of the Reserved Instance for each month remaining - // in the Reserved Instance term. + // A list specifying the price of the Reserved instance for each month remaining + // in the Reserved instance term. PriceSchedules []*PriceScheduleSpecification `locationName:"priceSchedules" locationNameList:"item" type:"list" required:"true"` - // The ID of the active Reserved Instance. + // The ID of the active Reserved instance. ReservedInstancesId *string `locationName:"reservedInstancesId" type:"string" required:"true"` - - metadataCreateReservedInstancesListingInput `json:"-" xml:"-"` -} - -type metadataCreateReservedInstancesListingInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -8945,14 +8920,10 @@ func (s CreateReservedInstancesListingInput) GoString() string { } type CreateReservedInstancesListingOutput struct { - // Information about the Reserved Instances listing. + _ struct{} `type:"structure"` + + // Information about the Reserved instance listing. ReservedInstancesListings []*ReservedInstancesListing `locationName:"reservedInstancesListingsSet" locationNameList:"item" type:"list"` - - metadataCreateReservedInstancesListingOutput `json:"-" xml:"-"` -} - -type metadataCreateReservedInstancesListingOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -8966,6 +8937,8 @@ func (s CreateReservedInstancesListingOutput) GoString() string { } type CreateRouteInput struct { + _ struct{} `type:"structure"` + // The CIDR address block used for the destination match. Routing decisions // are based on the most specific match. DestinationCidrBlock *string `locationName:"destinationCidrBlock" type:"string" required:"true"` @@ -8992,12 +8965,6 @@ type CreateRouteInput struct { // The ID of a VPC peering connection. VpcPeeringConnectionId *string `locationName:"vpcPeeringConnectionId" type:"string"` - - metadataCreateRouteInput `json:"-" xml:"-"` -} - -type metadataCreateRouteInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -9011,14 +8978,10 @@ func (s CreateRouteInput) GoString() string { } type CreateRouteOutput struct { + _ struct{} `type:"structure"` + // Returns true if the request succeeds; otherwise, it returns an error. Return *bool `locationName:"return" type:"boolean"` - - metadataCreateRouteOutput `json:"-" xml:"-"` -} - -type metadataCreateRouteOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -9032,6 +8995,8 @@ func (s CreateRouteOutput) GoString() string { } type CreateRouteTableInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -9040,12 +9005,6 @@ type CreateRouteTableInput struct { // The ID of the VPC. VpcId *string `locationName:"vpcId" type:"string" required:"true"` - - metadataCreateRouteTableInput `json:"-" xml:"-"` -} - -type metadataCreateRouteTableInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -9059,14 +9018,10 @@ func (s CreateRouteTableInput) GoString() string { } type CreateRouteTableOutput struct { + _ struct{} `type:"structure"` + // Information about the route table. RouteTable *RouteTable `locationName:"routeTable" type:"structure"` - - metadataCreateRouteTableOutput `json:"-" xml:"-"` -} - -type metadataCreateRouteTableOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -9080,13 +9035,15 @@ func (s CreateRouteTableOutput) GoString() string { } type CreateSecurityGroupInput struct { + _ struct{} `type:"structure"` + // A description for the security group. This is informational only. // // Constraints: Up to 255 characters in length // // Constraints for EC2-Classic: ASCII characters // - // Constraints for EC2-VPC: a-z, A-Z, 0-9, spaces, and ._-:/()#,@[]+=&;{}!$* + // Constraints for EC2-VPC: a-z, A-Z, 0-9, spaces, and ._-:/()#,@[]+=;{}!$* Description *string `locationName:"GroupDescription" type:"string" required:"true"` // Checks whether you have the required permissions for the action, without @@ -9101,17 +9058,11 @@ type CreateSecurityGroupInput struct { // // Constraints for EC2-Classic: ASCII characters // - // Constraints for EC2-VPC: a-z, A-Z, 0-9, spaces, and ._-:/()#,@[]+=&;{}!$* + // Constraints for EC2-VPC: a-z, A-Z, 0-9, spaces, and ._-:/()#,@[]+=;{}!$* GroupName *string `type:"string" required:"true"` // [EC2-VPC] The ID of the VPC. Required for EC2-VPC. VpcId *string `type:"string"` - - metadataCreateSecurityGroupInput `json:"-" xml:"-"` -} - -type metadataCreateSecurityGroupInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -9125,14 +9076,10 @@ func (s CreateSecurityGroupInput) GoString() string { } type CreateSecurityGroupOutput struct { + _ struct{} `type:"structure"` + // The ID of the security group. GroupId *string `locationName:"groupId" type:"string"` - - metadataCreateSecurityGroupOutput `json:"-" xml:"-"` -} - -type metadataCreateSecurityGroupOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -9146,6 +9093,8 @@ func (s CreateSecurityGroupOutput) GoString() string { } type CreateSnapshotInput struct { + _ struct{} `type:"structure"` + // A description for the snapshot. Description *string `type:"string"` @@ -9157,12 +9106,6 @@ type CreateSnapshotInput struct { // The ID of the EBS volume. VolumeId *string `type:"string" required:"true"` - - metadataCreateSnapshotInput `json:"-" xml:"-"` -} - -type metadataCreateSnapshotInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -9177,6 +9120,8 @@ func (s CreateSnapshotInput) GoString() string { // Contains the parameters for CreateSpotDatafeedSubscription. type CreateSpotDatafeedSubscriptionInput struct { + _ struct{} `type:"structure"` + // The Amazon S3 bucket in which to store the Spot instance data feed. Bucket *string `locationName:"bucket" type:"string" required:"true"` @@ -9188,12 +9133,6 @@ type CreateSpotDatafeedSubscriptionInput struct { // A prefix for the data feed file names. Prefix *string `locationName:"prefix" type:"string"` - - metadataCreateSpotDatafeedSubscriptionInput `json:"-" xml:"-"` -} - -type metadataCreateSpotDatafeedSubscriptionInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -9208,14 +9147,10 @@ func (s CreateSpotDatafeedSubscriptionInput) GoString() string { // Contains the output of CreateSpotDatafeedSubscription. type CreateSpotDatafeedSubscriptionOutput struct { + _ struct{} `type:"structure"` + // The Spot instance data feed subscription. SpotDatafeedSubscription *SpotDatafeedSubscription `locationName:"spotDatafeedSubscription" type:"structure"` - - metadataCreateSpotDatafeedSubscriptionOutput `json:"-" xml:"-"` -} - -type metadataCreateSpotDatafeedSubscriptionOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -9229,6 +9164,8 @@ func (s CreateSpotDatafeedSubscriptionOutput) GoString() string { } type CreateSubnetInput struct { + _ struct{} `type:"structure"` + // The Availability Zone for the subnet. // // Default: AWS selects one for you. If you create more than one subnet in @@ -9246,12 +9183,6 @@ type CreateSubnetInput struct { // The ID of the VPC. VpcId *string `type:"string" required:"true"` - - metadataCreateSubnetInput `json:"-" xml:"-"` -} - -type metadataCreateSubnetInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -9265,14 +9196,10 @@ func (s CreateSubnetInput) GoString() string { } type CreateSubnetOutput struct { + _ struct{} `type:"structure"` + // Information about the subnet. Subnet *Subnet `locationName:"subnet" type:"structure"` - - metadataCreateSubnetOutput `json:"-" xml:"-"` -} - -type metadataCreateSubnetOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -9286,6 +9213,8 @@ func (s CreateSubnetOutput) GoString() string { } type CreateTagsInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -9299,12 +9228,6 @@ type CreateTagsInput struct { // the tag to have a value, specify the parameter with no value, and we set // the value to an empty string. Tags []*Tag `locationName:"Tag" locationNameList:"item" type:"list" required:"true"` - - metadataCreateTagsInput `json:"-" xml:"-"` -} - -type metadataCreateTagsInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -9318,11 +9241,7 @@ func (s CreateTagsInput) GoString() string { } type CreateTagsOutput struct { - metadataCreateTagsOutput `json:"-" xml:"-"` -} - -type metadataCreateTagsOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -9336,6 +9255,8 @@ func (s CreateTagsOutput) GoString() string { } type CreateVolumeInput struct { + _ struct{} `type:"structure"` + // The Availability Zone in which to create the volume. Use DescribeAvailabilityZones // to list the Availability Zones that are currently available to you. AvailabilityZone *string `type:"string" required:"true"` @@ -9389,12 +9310,6 @@ type CreateVolumeInput struct { // // Default: standard VolumeType *string `type:"string" enum:"VolumeType"` - - metadataCreateVolumeInput `json:"-" xml:"-"` -} - -type metadataCreateVolumeInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -9410,6 +9325,8 @@ func (s CreateVolumeInput) GoString() string { // Describes the user or group to be added or removed from the permissions for // a volume. type CreateVolumePermission struct { + _ struct{} `type:"structure"` + // The specific group that is to be added or removed from a volume's list of // create volume permissions. Group *string `locationName:"group" type:"string" enum:"PermissionGroup"` @@ -9417,12 +9334,6 @@ type CreateVolumePermission struct { // The specific AWS account ID that is to be added or removed from a volume's // list of create volume permissions. UserId *string `locationName:"userId" type:"string"` - - metadataCreateVolumePermission `json:"-" xml:"-"` -} - -type metadataCreateVolumePermission struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -9437,6 +9348,8 @@ func (s CreateVolumePermission) GoString() string { // Describes modifications to the permissions for a volume. type CreateVolumePermissionModifications struct { + _ struct{} `type:"structure"` + // Adds a specific AWS account ID or group to a volume's list of create volume // permissions. Add []*CreateVolumePermission `locationNameList:"item" type:"list"` @@ -9444,12 +9357,6 @@ type CreateVolumePermissionModifications struct { // Removes a specific AWS account ID or group from a volume's list of create // volume permissions. Remove []*CreateVolumePermission `locationNameList:"item" type:"list"` - - metadataCreateVolumePermissionModifications `json:"-" xml:"-"` -} - -type metadataCreateVolumePermissionModifications struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -9463,6 +9370,8 @@ func (s CreateVolumePermissionModifications) GoString() string { } type CreateVpcEndpointInput struct { + _ struct{} `type:"structure"` + // Unique, case-sensitive identifier you provide to ensure the idempotency of // the request. For more information, see How to Ensure Idempotency (http://docs.aws.amazon.com/AWSEC2/latest/APIReference/Run_Instance_Idempotency.html). ClientToken *string `type:"string"` @@ -9487,12 +9396,6 @@ type CreateVpcEndpointInput struct { // The ID of the VPC in which the endpoint will be used. VpcId *string `type:"string" required:"true"` - - metadataCreateVpcEndpointInput `json:"-" xml:"-"` -} - -type metadataCreateVpcEndpointInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -9506,18 +9409,14 @@ func (s CreateVpcEndpointInput) GoString() string { } type CreateVpcEndpointOutput struct { + _ struct{} `type:"structure"` + // Unique, case-sensitive identifier you provide to ensure the idempotency of // the request. ClientToken *string `locationName:"clientToken" type:"string"` // Information about the endpoint. VpcEndpoint *VpcEndpoint `locationName:"vpcEndpoint" type:"structure"` - - metadataCreateVpcEndpointOutput `json:"-" xml:"-"` -} - -type metadataCreateVpcEndpointOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -9531,6 +9430,8 @@ func (s CreateVpcEndpointOutput) GoString() string { } type CreateVpcInput struct { + _ struct{} `type:"structure"` + // The network range for the VPC, in CIDR notation. For example, 10.0.0.0/16. CidrBlock *string `type:"string" required:"true"` @@ -9546,14 +9447,11 @@ type CreateVpcInput struct { // tenancy instances regardless of the tenancy assigned to the instance at launch. // Dedicated tenancy instances run on single-tenant hardware. // + // Important: The host value cannot be used with this parameter. Use the default + // or dedicated values only. + // // Default: default InstanceTenancy *string `locationName:"instanceTenancy" type:"string" enum:"Tenancy"` - - metadataCreateVpcInput `json:"-" xml:"-"` -} - -type metadataCreateVpcInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -9567,14 +9465,10 @@ func (s CreateVpcInput) GoString() string { } type CreateVpcOutput struct { + _ struct{} `type:"structure"` + // Information about the VPC. Vpc *Vpc `locationName:"vpc" type:"structure"` - - metadataCreateVpcOutput `json:"-" xml:"-"` -} - -type metadataCreateVpcOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -9588,6 +9482,8 @@ func (s CreateVpcOutput) GoString() string { } type CreateVpcPeeringConnectionInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -9604,12 +9500,6 @@ type CreateVpcPeeringConnectionInput struct { // The ID of the requester VPC. VpcId *string `locationName:"vpcId" type:"string"` - - metadataCreateVpcPeeringConnectionInput `json:"-" xml:"-"` -} - -type metadataCreateVpcPeeringConnectionInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -9623,14 +9513,10 @@ func (s CreateVpcPeeringConnectionInput) GoString() string { } type CreateVpcPeeringConnectionOutput struct { + _ struct{} `type:"structure"` + // Information about the VPC peering connection. VpcPeeringConnection *VpcPeeringConnection `locationName:"vpcPeeringConnection" type:"structure"` - - metadataCreateVpcPeeringConnectionOutput `json:"-" xml:"-"` -} - -type metadataCreateVpcPeeringConnectionOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -9644,6 +9530,8 @@ func (s CreateVpcPeeringConnectionOutput) GoString() string { } type CreateVpnConnectionInput struct { + _ struct{} `type:"structure"` + // The ID of the customer gateway. CustomerGatewayId *string `type:"string" required:"true"` @@ -9665,12 +9553,6 @@ type CreateVpnConnectionInput struct { // The ID of the virtual private gateway. VpnGatewayId *string `type:"string" required:"true"` - - metadataCreateVpnConnectionInput `json:"-" xml:"-"` -} - -type metadataCreateVpnConnectionInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -9684,14 +9566,10 @@ func (s CreateVpnConnectionInput) GoString() string { } type CreateVpnConnectionOutput struct { + _ struct{} `type:"structure"` + // Information about the VPN connection. VpnConnection *VpnConnection `locationName:"vpnConnection" type:"structure"` - - metadataCreateVpnConnectionOutput `json:"-" xml:"-"` -} - -type metadataCreateVpnConnectionOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -9705,17 +9583,13 @@ func (s CreateVpnConnectionOutput) GoString() string { } type CreateVpnConnectionRouteInput struct { + _ struct{} `type:"structure"` + // The CIDR block associated with the local subnet of the customer network. DestinationCidrBlock *string `type:"string" required:"true"` // The ID of the VPN connection. VpnConnectionId *string `type:"string" required:"true"` - - metadataCreateVpnConnectionRouteInput `json:"-" xml:"-"` -} - -type metadataCreateVpnConnectionRouteInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -9729,11 +9603,7 @@ func (s CreateVpnConnectionRouteInput) GoString() string { } type CreateVpnConnectionRouteOutput struct { - metadataCreateVpnConnectionRouteOutput `json:"-" xml:"-"` -} - -type metadataCreateVpnConnectionRouteOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -9747,6 +9617,8 @@ func (s CreateVpnConnectionRouteOutput) GoString() string { } type CreateVpnGatewayInput struct { + _ struct{} `type:"structure"` + // The Availability Zone for the virtual private gateway. AvailabilityZone *string `type:"string"` @@ -9758,12 +9630,6 @@ type CreateVpnGatewayInput struct { // The type of VPN connection this virtual private gateway supports. Type *string `type:"string" required:"true" enum:"GatewayType"` - - metadataCreateVpnGatewayInput `json:"-" xml:"-"` -} - -type metadataCreateVpnGatewayInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -9777,14 +9643,10 @@ func (s CreateVpnGatewayInput) GoString() string { } type CreateVpnGatewayOutput struct { + _ struct{} `type:"structure"` + // Information about the virtual private gateway. VpnGateway *VpnGateway `locationName:"vpnGateway" type:"structure"` - - metadataCreateVpnGatewayOutput `json:"-" xml:"-"` -} - -type metadataCreateVpnGatewayOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -9799,6 +9661,8 @@ func (s CreateVpnGatewayOutput) GoString() string { // Describes a customer gateway. type CustomerGateway struct { + _ struct{} `type:"structure"` + // The customer gateway's Border Gateway Protocol (BGP) Autonomous System Number // (ASN). BgpAsn *string `locationName:"bgpAsn" type:"string"` @@ -9818,12 +9682,6 @@ type CustomerGateway struct { // The type of VPN connection the customer gateway supports (ipsec.1). Type *string `locationName:"type" type:"string"` - - metadataCustomerGateway `json:"-" xml:"-"` -} - -type metadataCustomerGateway struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -9837,6 +9695,8 @@ func (s CustomerGateway) GoString() string { } type DeleteCustomerGatewayInput struct { + _ struct{} `type:"structure"` + // The ID of the customer gateway. CustomerGatewayId *string `type:"string" required:"true"` @@ -9845,12 +9705,6 @@ type DeleteCustomerGatewayInput struct { // the required permissions, the error response is DryRunOperation. Otherwise, // it is UnauthorizedOperation. DryRun *bool `locationName:"dryRun" type:"boolean"` - - metadataDeleteCustomerGatewayInput `json:"-" xml:"-"` -} - -type metadataDeleteCustomerGatewayInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -9864,11 +9718,7 @@ func (s DeleteCustomerGatewayInput) GoString() string { } type DeleteCustomerGatewayOutput struct { - metadataDeleteCustomerGatewayOutput `json:"-" xml:"-"` -} - -type metadataDeleteCustomerGatewayOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -9882,6 +9732,8 @@ func (s DeleteCustomerGatewayOutput) GoString() string { } type DeleteDhcpOptionsInput struct { + _ struct{} `type:"structure"` + // The ID of the DHCP options set. DhcpOptionsId *string `type:"string" required:"true"` @@ -9890,12 +9742,6 @@ type DeleteDhcpOptionsInput struct { // the required permissions, the error response is DryRunOperation. Otherwise, // it is UnauthorizedOperation. DryRun *bool `locationName:"dryRun" type:"boolean"` - - metadataDeleteDhcpOptionsInput `json:"-" xml:"-"` -} - -type metadataDeleteDhcpOptionsInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -9909,11 +9755,7 @@ func (s DeleteDhcpOptionsInput) GoString() string { } type DeleteDhcpOptionsOutput struct { - metadataDeleteDhcpOptionsOutput `json:"-" xml:"-"` -} - -type metadataDeleteDhcpOptionsOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -9927,14 +9769,10 @@ func (s DeleteDhcpOptionsOutput) GoString() string { } type DeleteFlowLogsInput struct { + _ struct{} `type:"structure"` + // One or more flow log IDs. FlowLogIds []*string `locationName:"FlowLogId" locationNameList:"item" type:"list" required:"true"` - - metadataDeleteFlowLogsInput `json:"-" xml:"-"` -} - -type metadataDeleteFlowLogsInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -9948,14 +9786,10 @@ func (s DeleteFlowLogsInput) GoString() string { } type DeleteFlowLogsOutput struct { + _ struct{} `type:"structure"` + // Information about the flow logs that could not be deleted successfully. Unsuccessful []*UnsuccessfulItem `locationName:"unsuccessful" locationNameList:"item" type:"list"` - - metadataDeleteFlowLogsOutput `json:"-" xml:"-"` -} - -type metadataDeleteFlowLogsOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -9969,6 +9803,8 @@ func (s DeleteFlowLogsOutput) GoString() string { } type DeleteInternetGatewayInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -9977,12 +9813,6 @@ type DeleteInternetGatewayInput struct { // The ID of the Internet gateway. InternetGatewayId *string `locationName:"internetGatewayId" type:"string" required:"true"` - - metadataDeleteInternetGatewayInput `json:"-" xml:"-"` -} - -type metadataDeleteInternetGatewayInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -9996,11 +9826,7 @@ func (s DeleteInternetGatewayInput) GoString() string { } type DeleteInternetGatewayOutput struct { - metadataDeleteInternetGatewayOutput `json:"-" xml:"-"` -} - -type metadataDeleteInternetGatewayOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -10014,6 +9840,8 @@ func (s DeleteInternetGatewayOutput) GoString() string { } type DeleteKeyPairInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -10022,12 +9850,6 @@ type DeleteKeyPairInput struct { // The name of the key pair. KeyName *string `type:"string" required:"true"` - - metadataDeleteKeyPairInput `json:"-" xml:"-"` -} - -type metadataDeleteKeyPairInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -10041,11 +9863,7 @@ func (s DeleteKeyPairInput) GoString() string { } type DeleteKeyPairOutput struct { - metadataDeleteKeyPairOutput `json:"-" xml:"-"` -} - -type metadataDeleteKeyPairOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -10059,6 +9877,8 @@ func (s DeleteKeyPairOutput) GoString() string { } type DeleteNetworkAclEntryInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -10073,12 +9893,6 @@ type DeleteNetworkAclEntryInput struct { // The rule number of the entry to delete. RuleNumber *int64 `locationName:"ruleNumber" type:"integer" required:"true"` - - metadataDeleteNetworkAclEntryInput `json:"-" xml:"-"` -} - -type metadataDeleteNetworkAclEntryInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -10092,11 +9906,7 @@ func (s DeleteNetworkAclEntryInput) GoString() string { } type DeleteNetworkAclEntryOutput struct { - metadataDeleteNetworkAclEntryOutput `json:"-" xml:"-"` -} - -type metadataDeleteNetworkAclEntryOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -10110,6 +9920,8 @@ func (s DeleteNetworkAclEntryOutput) GoString() string { } type DeleteNetworkAclInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -10118,12 +9930,6 @@ type DeleteNetworkAclInput struct { // The ID of the network ACL. NetworkAclId *string `locationName:"networkAclId" type:"string" required:"true"` - - metadataDeleteNetworkAclInput `json:"-" xml:"-"` -} - -type metadataDeleteNetworkAclInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -10137,11 +9943,7 @@ func (s DeleteNetworkAclInput) GoString() string { } type DeleteNetworkAclOutput struct { - metadataDeleteNetworkAclOutput `json:"-" xml:"-"` -} - -type metadataDeleteNetworkAclOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -10155,6 +9957,8 @@ func (s DeleteNetworkAclOutput) GoString() string { } type DeleteNetworkInterfaceInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -10163,12 +9967,6 @@ type DeleteNetworkInterfaceInput struct { // The ID of the network interface. NetworkInterfaceId *string `locationName:"networkInterfaceId" type:"string" required:"true"` - - metadataDeleteNetworkInterfaceInput `json:"-" xml:"-"` -} - -type metadataDeleteNetworkInterfaceInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -10182,11 +9980,7 @@ func (s DeleteNetworkInterfaceInput) GoString() string { } type DeleteNetworkInterfaceOutput struct { - metadataDeleteNetworkInterfaceOutput `json:"-" xml:"-"` -} - -type metadataDeleteNetworkInterfaceOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -10200,6 +9994,8 @@ func (s DeleteNetworkInterfaceOutput) GoString() string { } type DeletePlacementGroupInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -10208,12 +10004,6 @@ type DeletePlacementGroupInput struct { // The name of the placement group. GroupName *string `locationName:"groupName" type:"string" required:"true"` - - metadataDeletePlacementGroupInput `json:"-" xml:"-"` -} - -type metadataDeletePlacementGroupInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -10227,11 +10017,7 @@ func (s DeletePlacementGroupInput) GoString() string { } type DeletePlacementGroupOutput struct { - metadataDeletePlacementGroupOutput `json:"-" xml:"-"` -} - -type metadataDeletePlacementGroupOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -10245,6 +10031,8 @@ func (s DeletePlacementGroupOutput) GoString() string { } type DeleteRouteInput struct { + _ struct{} `type:"structure"` + // The CIDR range for the route. The value you specify must match the CIDR for // the route exactly. DestinationCidrBlock *string `locationName:"destinationCidrBlock" type:"string" required:"true"` @@ -10257,12 +10045,6 @@ type DeleteRouteInput struct { // The ID of the route table. RouteTableId *string `locationName:"routeTableId" type:"string" required:"true"` - - metadataDeleteRouteInput `json:"-" xml:"-"` -} - -type metadataDeleteRouteInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -10276,11 +10058,7 @@ func (s DeleteRouteInput) GoString() string { } type DeleteRouteOutput struct { - metadataDeleteRouteOutput `json:"-" xml:"-"` -} - -type metadataDeleteRouteOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -10294,6 +10072,8 @@ func (s DeleteRouteOutput) GoString() string { } type DeleteRouteTableInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -10302,12 +10082,6 @@ type DeleteRouteTableInput struct { // The ID of the route table. RouteTableId *string `locationName:"routeTableId" type:"string" required:"true"` - - metadataDeleteRouteTableInput `json:"-" xml:"-"` -} - -type metadataDeleteRouteTableInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -10321,11 +10095,7 @@ func (s DeleteRouteTableInput) GoString() string { } type DeleteRouteTableOutput struct { - metadataDeleteRouteTableOutput `json:"-" xml:"-"` -} - -type metadataDeleteRouteTableOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -10339,6 +10109,8 @@ func (s DeleteRouteTableOutput) GoString() string { } type DeleteSecurityGroupInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -10351,12 +10123,6 @@ type DeleteSecurityGroupInput struct { // [EC2-Classic, default VPC] The name of the security group. You can specify // either the security group name or the security group ID. GroupName *string `type:"string"` - - metadataDeleteSecurityGroupInput `json:"-" xml:"-"` -} - -type metadataDeleteSecurityGroupInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -10370,11 +10136,7 @@ func (s DeleteSecurityGroupInput) GoString() string { } type DeleteSecurityGroupOutput struct { - metadataDeleteSecurityGroupOutput `json:"-" xml:"-"` -} - -type metadataDeleteSecurityGroupOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -10388,6 +10150,8 @@ func (s DeleteSecurityGroupOutput) GoString() string { } type DeleteSnapshotInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -10396,12 +10160,6 @@ type DeleteSnapshotInput struct { // The ID of the EBS snapshot. SnapshotId *string `type:"string" required:"true"` - - metadataDeleteSnapshotInput `json:"-" xml:"-"` -} - -type metadataDeleteSnapshotInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -10415,11 +10173,7 @@ func (s DeleteSnapshotInput) GoString() string { } type DeleteSnapshotOutput struct { - metadataDeleteSnapshotOutput `json:"-" xml:"-"` -} - -type metadataDeleteSnapshotOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -10434,17 +10188,13 @@ func (s DeleteSnapshotOutput) GoString() string { // Contains the parameters for DeleteSpotDatafeedSubscription. type DeleteSpotDatafeedSubscriptionInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, // it is UnauthorizedOperation. DryRun *bool `locationName:"dryRun" type:"boolean"` - - metadataDeleteSpotDatafeedSubscriptionInput `json:"-" xml:"-"` -} - -type metadataDeleteSpotDatafeedSubscriptionInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -10458,11 +10208,7 @@ func (s DeleteSpotDatafeedSubscriptionInput) GoString() string { } type DeleteSpotDatafeedSubscriptionOutput struct { - metadataDeleteSpotDatafeedSubscriptionOutput `json:"-" xml:"-"` -} - -type metadataDeleteSpotDatafeedSubscriptionOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -10476,6 +10222,8 @@ func (s DeleteSpotDatafeedSubscriptionOutput) GoString() string { } type DeleteSubnetInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -10484,12 +10232,6 @@ type DeleteSubnetInput struct { // The ID of the subnet. SubnetId *string `type:"string" required:"true"` - - metadataDeleteSubnetInput `json:"-" xml:"-"` -} - -type metadataDeleteSubnetInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -10503,11 +10245,7 @@ func (s DeleteSubnetInput) GoString() string { } type DeleteSubnetOutput struct { - metadataDeleteSubnetOutput `json:"-" xml:"-"` -} - -type metadataDeleteSubnetOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -10521,6 +10259,8 @@ func (s DeleteSubnetOutput) GoString() string { } type DeleteTagsInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -10535,12 +10275,6 @@ type DeleteTagsInput struct { // tag regardless of its value. If you specify this parameter with an empty // string as the value, we delete the key only if its value is an empty string. Tags []*Tag `locationName:"tag" locationNameList:"item" type:"list"` - - metadataDeleteTagsInput `json:"-" xml:"-"` -} - -type metadataDeleteTagsInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -10554,11 +10288,7 @@ func (s DeleteTagsInput) GoString() string { } type DeleteTagsOutput struct { - metadataDeleteTagsOutput `json:"-" xml:"-"` -} - -type metadataDeleteTagsOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -10572,6 +10302,8 @@ func (s DeleteTagsOutput) GoString() string { } type DeleteVolumeInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -10580,12 +10312,6 @@ type DeleteVolumeInput struct { // The ID of the volume. VolumeId *string `type:"string" required:"true"` - - metadataDeleteVolumeInput `json:"-" xml:"-"` -} - -type metadataDeleteVolumeInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -10599,11 +10325,7 @@ func (s DeleteVolumeInput) GoString() string { } type DeleteVolumeOutput struct { - metadataDeleteVolumeOutput `json:"-" xml:"-"` -} - -type metadataDeleteVolumeOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -10617,6 +10339,8 @@ func (s DeleteVolumeOutput) GoString() string { } type DeleteVpcEndpointsInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -10625,12 +10349,6 @@ type DeleteVpcEndpointsInput struct { // One or more endpoint IDs. VpcEndpointIds []*string `locationName:"VpcEndpointId" locationNameList:"item" type:"list" required:"true"` - - metadataDeleteVpcEndpointsInput `json:"-" xml:"-"` -} - -type metadataDeleteVpcEndpointsInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -10644,14 +10362,10 @@ func (s DeleteVpcEndpointsInput) GoString() string { } type DeleteVpcEndpointsOutput struct { + _ struct{} `type:"structure"` + // Information about the endpoints that were not successfully deleted. Unsuccessful []*UnsuccessfulItem `locationName:"unsuccessful" locationNameList:"item" type:"list"` - - metadataDeleteVpcEndpointsOutput `json:"-" xml:"-"` -} - -type metadataDeleteVpcEndpointsOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -10665,6 +10379,8 @@ func (s DeleteVpcEndpointsOutput) GoString() string { } type DeleteVpcInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -10673,12 +10389,6 @@ type DeleteVpcInput struct { // The ID of the VPC. VpcId *string `type:"string" required:"true"` - - metadataDeleteVpcInput `json:"-" xml:"-"` -} - -type metadataDeleteVpcInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -10692,11 +10402,7 @@ func (s DeleteVpcInput) GoString() string { } type DeleteVpcOutput struct { - metadataDeleteVpcOutput `json:"-" xml:"-"` -} - -type metadataDeleteVpcOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -10710,6 +10416,8 @@ func (s DeleteVpcOutput) GoString() string { } type DeleteVpcPeeringConnectionInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -10718,12 +10426,6 @@ type DeleteVpcPeeringConnectionInput struct { // The ID of the VPC peering connection. VpcPeeringConnectionId *string `locationName:"vpcPeeringConnectionId" type:"string" required:"true"` - - metadataDeleteVpcPeeringConnectionInput `json:"-" xml:"-"` -} - -type metadataDeleteVpcPeeringConnectionInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -10737,14 +10439,10 @@ func (s DeleteVpcPeeringConnectionInput) GoString() string { } type DeleteVpcPeeringConnectionOutput struct { + _ struct{} `type:"structure"` + // Returns true if the request succeeds; otherwise, it returns an error. Return *bool `locationName:"return" type:"boolean"` - - metadataDeleteVpcPeeringConnectionOutput `json:"-" xml:"-"` -} - -type metadataDeleteVpcPeeringConnectionOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -10758,6 +10456,8 @@ func (s DeleteVpcPeeringConnectionOutput) GoString() string { } type DeleteVpnConnectionInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -10766,12 +10466,6 @@ type DeleteVpnConnectionInput struct { // The ID of the VPN connection. VpnConnectionId *string `type:"string" required:"true"` - - metadataDeleteVpnConnectionInput `json:"-" xml:"-"` -} - -type metadataDeleteVpnConnectionInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -10785,11 +10479,7 @@ func (s DeleteVpnConnectionInput) GoString() string { } type DeleteVpnConnectionOutput struct { - metadataDeleteVpnConnectionOutput `json:"-" xml:"-"` -} - -type metadataDeleteVpnConnectionOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -10803,17 +10493,13 @@ func (s DeleteVpnConnectionOutput) GoString() string { } type DeleteVpnConnectionRouteInput struct { + _ struct{} `type:"structure"` + // The CIDR block associated with the local subnet of the customer network. DestinationCidrBlock *string `type:"string" required:"true"` // The ID of the VPN connection. VpnConnectionId *string `type:"string" required:"true"` - - metadataDeleteVpnConnectionRouteInput `json:"-" xml:"-"` -} - -type metadataDeleteVpnConnectionRouteInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -10827,11 +10513,7 @@ func (s DeleteVpnConnectionRouteInput) GoString() string { } type DeleteVpnConnectionRouteOutput struct { - metadataDeleteVpnConnectionRouteOutput `json:"-" xml:"-"` -} - -type metadataDeleteVpnConnectionRouteOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -10845,6 +10527,8 @@ func (s DeleteVpnConnectionRouteOutput) GoString() string { } type DeleteVpnGatewayInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -10853,12 +10537,6 @@ type DeleteVpnGatewayInput struct { // The ID of the virtual private gateway. VpnGatewayId *string `type:"string" required:"true"` - - metadataDeleteVpnGatewayInput `json:"-" xml:"-"` -} - -type metadataDeleteVpnGatewayInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -10872,11 +10550,7 @@ func (s DeleteVpnGatewayInput) GoString() string { } type DeleteVpnGatewayOutput struct { - metadataDeleteVpnGatewayOutput `json:"-" xml:"-"` -} - -type metadataDeleteVpnGatewayOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -10890,6 +10564,8 @@ func (s DeleteVpnGatewayOutput) GoString() string { } type DeregisterImageInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -10898,12 +10574,6 @@ type DeregisterImageInput struct { // The ID of the AMI. ImageId *string `type:"string" required:"true"` - - metadataDeregisterImageInput `json:"-" xml:"-"` -} - -type metadataDeregisterImageInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -10917,11 +10587,7 @@ func (s DeregisterImageInput) GoString() string { } type DeregisterImageOutput struct { - metadataDeregisterImageOutput `json:"-" xml:"-"` -} - -type metadataDeregisterImageOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -10935,6 +10601,8 @@ func (s DeregisterImageOutput) GoString() string { } type DescribeAccountAttributesInput struct { + _ struct{} `type:"structure"` + // One or more account attribute names. AttributeNames []*string `locationName:"attributeName" locationNameList:"attributeName" type:"list"` @@ -10943,12 +10611,6 @@ type DescribeAccountAttributesInput struct { // the required permissions, the error response is DryRunOperation. Otherwise, // it is UnauthorizedOperation. DryRun *bool `locationName:"dryRun" type:"boolean"` - - metadataDescribeAccountAttributesInput `json:"-" xml:"-"` -} - -type metadataDescribeAccountAttributesInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -10962,14 +10624,10 @@ func (s DescribeAccountAttributesInput) GoString() string { } type DescribeAccountAttributesOutput struct { + _ struct{} `type:"structure"` + // Information about one or more account attributes. AccountAttributes []*AccountAttribute `locationName:"accountAttributeSet" locationNameList:"item" type:"list"` - - metadataDescribeAccountAttributesOutput `json:"-" xml:"-"` -} - -type metadataDescribeAccountAttributesOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -10983,6 +10641,8 @@ func (s DescribeAccountAttributesOutput) GoString() string { } type DescribeAddressesInput struct { + _ struct{} `type:"structure"` + // [EC2-VPC] One or more allocation IDs. // // Default: Describes all your Elastic IP addresses. @@ -11021,12 +10681,6 @@ type DescribeAddressesInput struct { // // Default: Describes all your Elastic IP addresses. PublicIps []*string `locationName:"PublicIp" locationNameList:"PublicIp" type:"list"` - - metadataDescribeAddressesInput `json:"-" xml:"-"` -} - -type metadataDescribeAddressesInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -11040,14 +10694,10 @@ func (s DescribeAddressesInput) GoString() string { } type DescribeAddressesOutput struct { + _ struct{} `type:"structure"` + // Information about one or more Elastic IP addresses. Addresses []*Address `locationName:"addressesSet" locationNameList:"item" type:"list"` - - metadataDescribeAddressesOutput `json:"-" xml:"-"` -} - -type metadataDescribeAddressesOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -11061,6 +10711,8 @@ func (s DescribeAddressesOutput) GoString() string { } type DescribeAvailabilityZonesInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -11082,12 +10734,6 @@ type DescribeAvailabilityZonesInput struct { // The names of one or more Availability Zones. ZoneNames []*string `locationName:"ZoneName" locationNameList:"ZoneName" type:"list"` - - metadataDescribeAvailabilityZonesInput `json:"-" xml:"-"` -} - -type metadataDescribeAvailabilityZonesInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -11101,14 +10747,10 @@ func (s DescribeAvailabilityZonesInput) GoString() string { } type DescribeAvailabilityZonesOutput struct { + _ struct{} `type:"structure"` + // Information about one or more Availability Zones. AvailabilityZones []*AvailabilityZone `locationName:"availabilityZoneInfo" locationNameList:"item" type:"list"` - - metadataDescribeAvailabilityZonesOutput `json:"-" xml:"-"` -} - -type metadataDescribeAvailabilityZonesOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -11122,6 +10764,8 @@ func (s DescribeAvailabilityZonesOutput) GoString() string { } type DescribeBundleTasksInput struct { + _ struct{} `type:"structure"` + // One or more bundle task IDs. // // Default: Describes all your bundle tasks. @@ -11157,12 +10801,6 @@ type DescribeBundleTasksInput struct { // // update-time - The time of the most recent update for the task. Filters []*Filter `locationName:"Filter" locationNameList:"Filter" type:"list"` - - metadataDescribeBundleTasksInput `json:"-" xml:"-"` -} - -type metadataDescribeBundleTasksInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -11176,14 +10814,10 @@ func (s DescribeBundleTasksInput) GoString() string { } type DescribeBundleTasksOutput struct { + _ struct{} `type:"structure"` + // Information about one or more bundle tasks. BundleTasks []*BundleTask `locationName:"bundleInstanceTasksSet" locationNameList:"item" type:"list"` - - metadataDescribeBundleTasksOutput `json:"-" xml:"-"` -} - -type metadataDescribeBundleTasksOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -11197,6 +10831,8 @@ func (s DescribeBundleTasksOutput) GoString() string { } type DescribeClassicLinkInstancesInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -11239,12 +10875,6 @@ type DescribeClassicLinkInstancesInput struct { // The token to retrieve the next page of results. NextToken *string `locationName:"nextToken" type:"string"` - - metadataDescribeClassicLinkInstancesInput `json:"-" xml:"-"` -} - -type metadataDescribeClassicLinkInstancesInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -11258,18 +10888,14 @@ func (s DescribeClassicLinkInstancesInput) GoString() string { } type DescribeClassicLinkInstancesOutput struct { + _ struct{} `type:"structure"` + // Information about one or more linked EC2-Classic instances. Instances []*ClassicLinkInstance `locationName:"instancesSet" locationNameList:"item" type:"list"` // The token to use to retrieve the next page of results. This value is null // when there are no more results to return. NextToken *string `locationName:"nextToken" type:"string"` - - metadataDescribeClassicLinkInstancesOutput `json:"-" xml:"-"` -} - -type metadataDescribeClassicLinkInstancesOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -11283,6 +10909,8 @@ func (s DescribeClassicLinkInstancesOutput) GoString() string { } type DescribeConversionTasksInput struct { + _ struct{} `type:"structure"` + // One or more conversion task IDs. ConversionTaskIds []*string `locationName:"conversionTaskId" locationNameList:"item" type:"list"` @@ -11294,12 +10922,6 @@ type DescribeConversionTasksInput struct { // One or more filters. Filters []*Filter `locationName:"filter" locationNameList:"Filter" type:"list"` - - metadataDescribeConversionTasksInput `json:"-" xml:"-"` -} - -type metadataDescribeConversionTasksInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -11313,14 +10935,10 @@ func (s DescribeConversionTasksInput) GoString() string { } type DescribeConversionTasksOutput struct { + _ struct{} `type:"structure"` + // Information about the conversion tasks. ConversionTasks []*ConversionTask `locationName:"conversionTasks" locationNameList:"item" type:"list"` - - metadataDescribeConversionTasksOutput `json:"-" xml:"-"` -} - -type metadataDescribeConversionTasksOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -11334,6 +10952,8 @@ func (s DescribeConversionTasksOutput) GoString() string { } type DescribeCustomerGatewaysInput struct { + _ struct{} `type:"structure"` + // One or more customer gateway IDs. // // Default: Describes all your customer gateways. @@ -11373,12 +10993,6 @@ type DescribeCustomerGatewaysInput struct { // tag-value - The value of a tag assigned to the resource. This filter is // independent of the tag-key filter. Filters []*Filter `locationName:"Filter" locationNameList:"Filter" type:"list"` - - metadataDescribeCustomerGatewaysInput `json:"-" xml:"-"` -} - -type metadataDescribeCustomerGatewaysInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -11392,14 +11006,10 @@ func (s DescribeCustomerGatewaysInput) GoString() string { } type DescribeCustomerGatewaysOutput struct { + _ struct{} `type:"structure"` + // Information about one or more customer gateways. CustomerGateways []*CustomerGateway `locationName:"customerGatewaySet" locationNameList:"item" type:"list"` - - metadataDescribeCustomerGatewaysOutput `json:"-" xml:"-"` -} - -type metadataDescribeCustomerGatewaysOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -11413,6 +11023,8 @@ func (s DescribeCustomerGatewaysOutput) GoString() string { } type DescribeDhcpOptionsInput struct { + _ struct{} `type:"structure"` + // The IDs of one or more DHCP options sets. // // Default: Describes all your DHCP options sets. @@ -11444,12 +11056,6 @@ type DescribeDhcpOptionsInput struct { // tag-value - The value of a tag assigned to the resource. This filter is // independent of the tag-key filter. Filters []*Filter `locationName:"Filter" locationNameList:"Filter" type:"list"` - - metadataDescribeDhcpOptionsInput `json:"-" xml:"-"` -} - -type metadataDescribeDhcpOptionsInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -11463,14 +11069,10 @@ func (s DescribeDhcpOptionsInput) GoString() string { } type DescribeDhcpOptionsOutput struct { + _ struct{} `type:"structure"` + // Information about one or more DHCP options sets. DhcpOptions []*DhcpOptions `locationName:"dhcpOptionsSet" locationNameList:"item" type:"list"` - - metadataDescribeDhcpOptionsOutput `json:"-" xml:"-"` -} - -type metadataDescribeDhcpOptionsOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -11484,14 +11086,10 @@ func (s DescribeDhcpOptionsOutput) GoString() string { } type DescribeExportTasksInput struct { + _ struct{} `type:"structure"` + // One or more export task IDs. ExportTaskIds []*string `locationName:"exportTaskId" locationNameList:"ExportTaskId" type:"list"` - - metadataDescribeExportTasksInput `json:"-" xml:"-"` -} - -type metadataDescribeExportTasksInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -11505,14 +11103,10 @@ func (s DescribeExportTasksInput) GoString() string { } type DescribeExportTasksOutput struct { + _ struct{} `type:"structure"` + // Information about the export tasks. ExportTasks []*ExportTask `locationName:"exportTaskSet" locationNameList:"item" type:"list"` - - metadataDescribeExportTasksOutput `json:"-" xml:"-"` -} - -type metadataDescribeExportTasksOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -11526,6 +11120,8 @@ func (s DescribeExportTasksOutput) GoString() string { } type DescribeFlowLogsInput struct { + _ struct{} `type:"structure"` + // One or more filters. // // deliver-log-status - The status of the logs delivery (SUCCESS | FAILED). @@ -11551,12 +11147,6 @@ type DescribeFlowLogsInput struct { // The token to retrieve the next page of results. NextToken *string `type:"string"` - - metadataDescribeFlowLogsInput `json:"-" xml:"-"` -} - -type metadataDescribeFlowLogsInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -11570,18 +11160,14 @@ func (s DescribeFlowLogsInput) GoString() string { } type DescribeFlowLogsOutput struct { + _ struct{} `type:"structure"` + // Information about the flow logs. FlowLogs []*FlowLog `locationName:"flowLogSet" locationNameList:"item" type:"list"` // The token to use to retrieve the next page of results. This value is null // when there are no more results to return. NextToken *string `locationName:"nextToken" type:"string"` - - metadataDescribeFlowLogsOutput `json:"-" xml:"-"` -} - -type metadataDescribeFlowLogsOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -11594,7 +11180,109 @@ func (s DescribeFlowLogsOutput) GoString() string { return s.String() } +type DescribeHostsInput struct { + _ struct{} `type:"structure"` + + // One or more filters. + // + // instance-type - The instance type size that the Dedicated host is configured + // to support. + // + // auto-placement - Whether auto-placement is enabled or disabled (on | off). + // + // host-reservation-id - The ID of the reservation associated with this host. + // + // client-token - The idempotency token you provided when you launched the + // instance + // + // state- The allocation state of the Dedicated host (available | under-assessment + // | permanent-failure | released | released-permanent-failure). + // + // availability-zone - The Availability Zone of the host. + Filter []*Filter `locationName:"filter" locationNameList:"Filter" type:"list"` + + // The IDs of the Dedicated hosts. The IDs are used for targeted instance launches. + HostIds []*string `locationName:"hostId" locationNameList:"item" type:"list"` + + // The maximum number of results to return for the request in a single page. + // The remaining results can be seen by sending another request with the returned + // nextToken value. This value can be between 5 and 500; if maxResults is given + // a larger value than 500, you will receive an error. You cannot specify this + // parameter and the host IDs parameter in the same request. + MaxResults *int64 `locationName:"maxResults" type:"integer"` + + // The token to retrieve the next page of results. + NextToken *string `locationName:"nextToken" type:"string"` +} + +// String returns the string representation +func (s DescribeHostsInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DescribeHostsInput) GoString() string { + return s.String() +} + +type DescribeHostsOutput struct { + _ struct{} `type:"structure"` + + // Information about the Dedicated hosts. + Hosts []*Host `locationName:"hostSet" locationNameList:"item" type:"list"` + + // The token to use to retrieve the next page of results. This value is null + // when there are no more results to return. + NextToken *string `locationName:"nextToken" type:"string"` +} + +// String returns the string representation +func (s DescribeHostsOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DescribeHostsOutput) GoString() string { + return s.String() +} + +type DescribeIdFormatInput struct { + _ struct{} `type:"structure"` + + // The type of resource. + Resource *string `type:"string"` +} + +// String returns the string representation +func (s DescribeIdFormatInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DescribeIdFormatInput) GoString() string { + return s.String() +} + +type DescribeIdFormatOutput struct { + _ struct{} `type:"structure"` + + // Information about the ID format for the resource. + Statuses []*IdFormat `locationName:"statusSet" locationNameList:"item" type:"list"` +} + +// String returns the string representation +func (s DescribeIdFormatOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s DescribeIdFormatOutput) GoString() string { + return s.String() +} + type DescribeImageAttributeInput struct { + _ struct{} `type:"structure"` + // The AMI attribute. // // Note: Depending on your account privileges, the blockDeviceMapping attribute @@ -11610,12 +11298,6 @@ type DescribeImageAttributeInput struct { // The ID of the AMI. ImageId *string `type:"string" required:"true"` - - metadataDescribeImageAttributeInput `json:"-" xml:"-"` -} - -type metadataDescribeImageAttributeInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -11630,6 +11312,8 @@ func (s DescribeImageAttributeInput) GoString() string { // Describes an image attribute. type DescribeImageAttributeOutput struct { + _ struct{} `type:"structure"` + // One or more block device mapping entries. BlockDeviceMappings []*BlockDeviceMapping `locationName:"blockDeviceMapping" locationNameList:"item" type:"list"` @@ -11653,12 +11337,6 @@ type DescribeImageAttributeOutput struct { // The value to use for a resource attribute. SriovNetSupport *AttributeValue `locationName:"sriovNetSupport" type:"structure"` - - metadataDescribeImageAttributeOutput `json:"-" xml:"-"` -} - -type metadataDescribeImageAttributeOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -11672,6 +11350,8 @@ func (s DescribeImageAttributeOutput) GoString() string { } type DescribeImagesInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -11764,12 +11444,6 @@ type DescribeImagesInput struct { // sender of the request). Omitting this option returns all images for which // you have launch permissions, regardless of ownership. Owners []*string `locationName:"Owner" locationNameList:"Owner" type:"list"` - - metadataDescribeImagesInput `json:"-" xml:"-"` -} - -type metadataDescribeImagesInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -11783,14 +11457,10 @@ func (s DescribeImagesInput) GoString() string { } type DescribeImagesOutput struct { + _ struct{} `type:"structure"` + // Information about one or more images. Images []*Image `locationName:"imagesSet" locationNameList:"item" type:"list"` - - metadataDescribeImagesOutput `json:"-" xml:"-"` -} - -type metadataDescribeImagesOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -11804,6 +11474,8 @@ func (s DescribeImagesOutput) GoString() string { } type DescribeImportImageTasksInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -11821,12 +11493,6 @@ type DescribeImportImageTasksInput struct { // A token that indicates the next page of results. NextToken *string `type:"string"` - - metadataDescribeImportImageTasksInput `json:"-" xml:"-"` -} - -type metadataDescribeImportImageTasksInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -11840,6 +11506,8 @@ func (s DescribeImportImageTasksInput) GoString() string { } type DescribeImportImageTasksOutput struct { + _ struct{} `type:"structure"` + // A list of zero or more import image tasks that are currently active or were // completed or canceled in the previous 7 days. ImportImageTasks []*ImportImageTask `locationName:"importImageTaskSet" locationNameList:"item" type:"list"` @@ -11847,12 +11515,6 @@ type DescribeImportImageTasksOutput struct { // The token to use to get the next page of results. This value is null when // there are no more results to return. NextToken *string `locationName:"nextToken" type:"string"` - - metadataDescribeImportImageTasksOutput `json:"-" xml:"-"` -} - -type metadataDescribeImportImageTasksOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -11866,6 +11528,8 @@ func (s DescribeImportImageTasksOutput) GoString() string { } type DescribeImportSnapshotTasksInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -11883,12 +11547,6 @@ type DescribeImportSnapshotTasksInput struct { // A token that indicates the next page of results. NextToken *string `type:"string"` - - metadataDescribeImportSnapshotTasksInput `json:"-" xml:"-"` -} - -type metadataDescribeImportSnapshotTasksInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -11902,6 +11560,8 @@ func (s DescribeImportSnapshotTasksInput) GoString() string { } type DescribeImportSnapshotTasksOutput struct { + _ struct{} `type:"structure"` + // A list of zero or more import snapshot tasks that are currently active or // were completed or canceled in the previous 7 days. ImportSnapshotTasks []*ImportSnapshotTask `locationName:"importSnapshotTaskSet" locationNameList:"item" type:"list"` @@ -11909,12 +11569,6 @@ type DescribeImportSnapshotTasksOutput struct { // The token to use to get the next page of results. This value is null when // there are no more results to return. NextToken *string `locationName:"nextToken" type:"string"` - - metadataDescribeImportSnapshotTasksOutput `json:"-" xml:"-"` -} - -type metadataDescribeImportSnapshotTasksOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -11928,6 +11582,8 @@ func (s DescribeImportSnapshotTasksOutput) GoString() string { } type DescribeInstanceAttributeInput struct { + _ struct{} `type:"structure"` + // The instance attribute. Attribute *string `locationName:"attribute" type:"string" required:"true" enum:"InstanceAttributeName"` @@ -11939,12 +11595,6 @@ type DescribeInstanceAttributeInput struct { // The ID of the instance. InstanceId *string `locationName:"instanceId" type:"string" required:"true"` - - metadataDescribeInstanceAttributeInput `json:"-" xml:"-"` -} - -type metadataDescribeInstanceAttributeInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -11959,6 +11609,8 @@ func (s DescribeInstanceAttributeInput) GoString() string { // Describes an instance attribute. type DescribeInstanceAttributeOutput struct { + _ struct{} `type:"structure"` + // The block device mapping of the instance. BlockDeviceMappings []*InstanceBlockDeviceMapping `locationName:"blockDeviceMapping" locationNameList:"item" type:"list"` @@ -12004,12 +11656,6 @@ type DescribeInstanceAttributeOutput struct { // The Base64-encoded MIME user data. UserData *AttributeValue `locationName:"userData" type:"structure"` - - metadataDescribeInstanceAttributeOutput `json:"-" xml:"-"` -} - -type metadataDescribeInstanceAttributeOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -12023,6 +11669,8 @@ func (s DescribeInstanceAttributeOutput) GoString() string { } type DescribeInstanceStatusInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -12089,12 +11737,6 @@ type DescribeInstanceStatusInput struct { // The token to retrieve the next page of results. NextToken *string `type:"string"` - - metadataDescribeInstanceStatusInput `json:"-" xml:"-"` -} - -type metadataDescribeInstanceStatusInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -12108,18 +11750,14 @@ func (s DescribeInstanceStatusInput) GoString() string { } type DescribeInstanceStatusOutput struct { + _ struct{} `type:"structure"` + // One or more instance status descriptions. InstanceStatuses []*InstanceStatus `locationName:"instanceStatusSet" locationNameList:"item" type:"list"` // The token to use to retrieve the next page of results. This value is null // when there are no more results to return. NextToken *string `locationName:"nextToken" type:"string"` - - metadataDescribeInstanceStatusOutput `json:"-" xml:"-"` -} - -type metadataDescribeInstanceStatusOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -12133,6 +11771,8 @@ func (s DescribeInstanceStatusOutput) GoString() string { } type DescribeInstancesInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -12254,7 +11894,7 @@ type DescribeInstancesInput struct { // checking is disabled. The value must be false for the instance to perform // network address translation (NAT) in your VPC. // - // spot-instance-request-id - The ID of the Spot Instance request. + // spot-instance-request-id - The ID of the Spot instance request. // // state-reason-code - The reason code for the state change. // @@ -12379,12 +12019,6 @@ type DescribeInstancesInput struct { // The token to request the next page of results. NextToken *string `locationName:"nextToken" type:"string"` - - metadataDescribeInstancesInput `json:"-" xml:"-"` -} - -type metadataDescribeInstancesInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -12398,18 +12032,14 @@ func (s DescribeInstancesInput) GoString() string { } type DescribeInstancesOutput struct { + _ struct{} `type:"structure"` + // The token to use to retrieve the next page of results. This value is null // when there are no more results to return. NextToken *string `locationName:"nextToken" type:"string"` - // One or more reservations. + // Zero or more reservations. Reservations []*Reservation `locationName:"reservationSet" locationNameList:"item" type:"list"` - - metadataDescribeInstancesOutput `json:"-" xml:"-"` -} - -type metadataDescribeInstancesOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -12423,6 +12053,8 @@ func (s DescribeInstancesOutput) GoString() string { } type DescribeInternetGatewaysInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -12455,12 +12087,6 @@ type DescribeInternetGatewaysInput struct { // // Default: Describes all your Internet gateways. InternetGatewayIds []*string `locationName:"internetGatewayId" locationNameList:"item" type:"list"` - - metadataDescribeInternetGatewaysInput `json:"-" xml:"-"` -} - -type metadataDescribeInternetGatewaysInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -12474,14 +12100,10 @@ func (s DescribeInternetGatewaysInput) GoString() string { } type DescribeInternetGatewaysOutput struct { + _ struct{} `type:"structure"` + // Information about one or more Internet gateways. InternetGateways []*InternetGateway `locationName:"internetGatewaySet" locationNameList:"item" type:"list"` - - metadataDescribeInternetGatewaysOutput `json:"-" xml:"-"` -} - -type metadataDescribeInternetGatewaysOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -12495,6 +12117,8 @@ func (s DescribeInternetGatewaysOutput) GoString() string { } type DescribeKeyPairsInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -12512,12 +12136,6 @@ type DescribeKeyPairsInput struct { // // Default: Describes all your key pairs. KeyNames []*string `locationName:"KeyName" locationNameList:"KeyName" type:"list"` - - metadataDescribeKeyPairsInput `json:"-" xml:"-"` -} - -type metadataDescribeKeyPairsInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -12531,14 +12149,10 @@ func (s DescribeKeyPairsInput) GoString() string { } type DescribeKeyPairsOutput struct { + _ struct{} `type:"structure"` + // Information about one or more key pairs. KeyPairs []*KeyPairInfo `locationName:"keySet" locationNameList:"item" type:"list"` - - metadataDescribeKeyPairsOutput `json:"-" xml:"-"` -} - -type metadataDescribeKeyPairsOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -12552,6 +12166,8 @@ func (s DescribeKeyPairsOutput) GoString() string { } type DescribeMovingAddressesInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -12576,12 +12192,6 @@ type DescribeMovingAddressesInput struct { // One or more Elastic IP addresses. PublicIps []*string `locationName:"publicIp" locationNameList:"item" type:"list"` - - metadataDescribeMovingAddressesInput `json:"-" xml:"-"` -} - -type metadataDescribeMovingAddressesInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -12595,18 +12205,14 @@ func (s DescribeMovingAddressesInput) GoString() string { } type DescribeMovingAddressesOutput struct { + _ struct{} `type:"structure"` + // The status for each Elastic IP address. MovingAddressStatuses []*MovingAddressStatus `locationName:"movingAddressStatusSet" locationNameList:"item" type:"list"` // The token to use to retrieve the next page of results. This value is null // when there are no more results to return. NextToken *string `locationName:"nextToken" type:"string"` - - metadataDescribeMovingAddressesOutput `json:"-" xml:"-"` -} - -type metadataDescribeMovingAddressesOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -12620,6 +12226,8 @@ func (s DescribeMovingAddressesOutput) GoString() string { } type DescribeNetworkAclsInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -12679,12 +12287,6 @@ type DescribeNetworkAclsInput struct { // // Default: Describes all your network ACLs. NetworkAclIds []*string `locationName:"NetworkAclId" locationNameList:"item" type:"list"` - - metadataDescribeNetworkAclsInput `json:"-" xml:"-"` -} - -type metadataDescribeNetworkAclsInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -12698,14 +12300,10 @@ func (s DescribeNetworkAclsInput) GoString() string { } type DescribeNetworkAclsOutput struct { + _ struct{} `type:"structure"` + // Information about one or more network ACLs. NetworkAcls []*NetworkAcl `locationName:"networkAclSet" locationNameList:"item" type:"list"` - - metadataDescribeNetworkAclsOutput `json:"-" xml:"-"` -} - -type metadataDescribeNetworkAclsOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -12719,6 +12317,8 @@ func (s DescribeNetworkAclsOutput) GoString() string { } type DescribeNetworkInterfaceAttributeInput struct { + _ struct{} `type:"structure"` + // The attribute of the network interface. Attribute *string `locationName:"attribute" type:"string" enum:"NetworkInterfaceAttribute"` @@ -12730,12 +12330,6 @@ type DescribeNetworkInterfaceAttributeInput struct { // The ID of the network interface. NetworkInterfaceId *string `locationName:"networkInterfaceId" type:"string" required:"true"` - - metadataDescribeNetworkInterfaceAttributeInput `json:"-" xml:"-"` -} - -type metadataDescribeNetworkInterfaceAttributeInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -12749,6 +12343,8 @@ func (s DescribeNetworkInterfaceAttributeInput) GoString() string { } type DescribeNetworkInterfaceAttributeOutput struct { + _ struct{} `type:"structure"` + // The attachment (if any) of the network interface. Attachment *NetworkInterfaceAttachment `locationName:"attachment" type:"structure"` @@ -12763,12 +12359,6 @@ type DescribeNetworkInterfaceAttributeOutput struct { // Indicates whether source/destination checking is enabled. SourceDestCheck *AttributeBooleanValue `locationName:"sourceDestCheck" type:"structure"` - - metadataDescribeNetworkInterfaceAttributeOutput `json:"-" xml:"-"` -} - -type metadataDescribeNetworkInterfaceAttributeOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -12782,6 +12372,8 @@ func (s DescribeNetworkInterfaceAttributeOutput) GoString() string { } type DescribeNetworkInterfacesInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -12893,12 +12485,6 @@ type DescribeNetworkInterfacesInput struct { // // Default: Describes all your network interfaces. NetworkInterfaceIds []*string `locationName:"NetworkInterfaceId" locationNameList:"item" type:"list"` - - metadataDescribeNetworkInterfacesInput `json:"-" xml:"-"` -} - -type metadataDescribeNetworkInterfacesInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -12912,14 +12498,10 @@ func (s DescribeNetworkInterfacesInput) GoString() string { } type DescribeNetworkInterfacesOutput struct { + _ struct{} `type:"structure"` + // Information about one or more network interfaces. NetworkInterfaces []*NetworkInterface `locationName:"networkInterfaceSet" locationNameList:"item" type:"list"` - - metadataDescribeNetworkInterfacesOutput `json:"-" xml:"-"` -} - -type metadataDescribeNetworkInterfacesOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -12933,6 +12515,8 @@ func (s DescribeNetworkInterfacesOutput) GoString() string { } type DescribePlacementGroupsInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -12953,12 +12537,6 @@ type DescribePlacementGroupsInput struct { // // Default: Describes all your placement groups, or only those otherwise specified. GroupNames []*string `locationName:"groupName" type:"list"` - - metadataDescribePlacementGroupsInput `json:"-" xml:"-"` -} - -type metadataDescribePlacementGroupsInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -12972,14 +12550,10 @@ func (s DescribePlacementGroupsInput) GoString() string { } type DescribePlacementGroupsOutput struct { + _ struct{} `type:"structure"` + // One or more placement groups. PlacementGroups []*PlacementGroup `locationName:"placementGroupSet" locationNameList:"item" type:"list"` - - metadataDescribePlacementGroupsOutput `json:"-" xml:"-"` -} - -type metadataDescribePlacementGroupsOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -12993,6 +12567,8 @@ func (s DescribePlacementGroupsOutput) GoString() string { } type DescribePrefixListsInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -13020,12 +12596,6 @@ type DescribePrefixListsInput struct { // One or more prefix list IDs. PrefixListIds []*string `locationName:"PrefixListId" locationNameList:"item" type:"list"` - - metadataDescribePrefixListsInput `json:"-" xml:"-"` -} - -type metadataDescribePrefixListsInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -13039,18 +12609,14 @@ func (s DescribePrefixListsInput) GoString() string { } type DescribePrefixListsOutput struct { + _ struct{} `type:"structure"` + // The token to use when requesting the next set of items. If there are no additional // items to return, the string is empty. NextToken *string `locationName:"nextToken" type:"string"` // All available prefix lists. PrefixLists []*PrefixList `locationName:"prefixListSet" locationNameList:"item" type:"list"` - - metadataDescribePrefixListsOutput `json:"-" xml:"-"` -} - -type metadataDescribePrefixListsOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -13064,6 +12630,8 @@ func (s DescribePrefixListsOutput) GoString() string { } type DescribeRegionsInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -13079,12 +12647,6 @@ type DescribeRegionsInput struct { // The names of one or more regions. RegionNames []*string `locationName:"RegionName" locationNameList:"RegionName" type:"list"` - - metadataDescribeRegionsInput `json:"-" xml:"-"` -} - -type metadataDescribeRegionsInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -13098,14 +12660,10 @@ func (s DescribeRegionsInput) GoString() string { } type DescribeRegionsOutput struct { + _ struct{} `type:"structure"` + // Information about one or more regions. Regions []*Region `locationName:"regionInfo" locationNameList:"item" type:"list"` - - metadataDescribeRegionsOutput `json:"-" xml:"-"` -} - -type metadataDescribeRegionsOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -13119,6 +12677,8 @@ func (s DescribeRegionsOutput) GoString() string { } type DescribeReservedInstancesInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -13127,21 +12687,21 @@ type DescribeReservedInstancesInput struct { // One or more filters. // - // availability-zone - The Availability Zone where the Reserved Instance + // availability-zone - The Availability Zone where the Reserved instance // can be used. // - // duration - The duration of the Reserved Instance (one year or three years), + // duration - The duration of the Reserved instance (one year or three years), // in seconds (31536000 | 94608000). // - // end - The time when the Reserved Instance expires (for example, 2015-08-07T11:54:42.000Z). + // end - The time when the Reserved instance expires (for example, 2015-08-07T11:54:42.000Z). // - // fixed-price - The purchase price of the Reserved Instance (for example, + // fixed-price - The purchase price of the Reserved instance (for example, // 9800.0). // - // instance-type - The instance type on which the Reserved Instance can be + // instance-type - The instance type on which the Reserved instance can be // used. // - // product-description - The Reserved Instance product platform description. + // product-description - The Reserved instance product platform description. // Instances that include (Amazon VPC) in the product platform description will // only be displayed to EC2-Classic account holders and are for use with Amazon // VPC. (Linux/UNIX | Linux/UNIX (Amazon VPC) | SUSE Linux | SUSE Linux (Amazon @@ -13151,12 +12711,12 @@ type DescribeReservedInstancesInput struct { // with SQL Server Web (Amazon VPC) | Windows with SQL Server Enterprise | Windows // with SQL Server Enterprise (Amazon VPC)). // - // reserved-instances-id - The ID of the Reserved Instance. + // reserved-instances-id - The ID of the Reserved instance. // - // start - The time at which the Reserved Instance purchase request was placed + // start - The time at which the Reserved instance purchase request was placed // (for example, 2014-08-07T11:54:42.000Z). // - // state - The state of the Reserved Instance (payment-pending | active | + // state - The state of the Reserved instance (payment-pending | active | // payment-failed | retired). // // tag:key=value - The key/value combination of a tag assigned to the resource. @@ -13171,26 +12731,20 @@ type DescribeReservedInstancesInput struct { // tag-value - The value of a tag assigned to the resource. This filter is // independent of the tag-key filter. // - // usage-price - The usage price of the Reserved Instance, per hour (for + // usage-price - The usage price of the Reserved instance, per hour (for // example, 0.84). Filters []*Filter `locationName:"Filter" locationNameList:"Filter" type:"list"` - // The Reserved Instance offering type. If you are using tools that predate + // The Reserved instance offering type. If you are using tools that predate // the 2011-11-01 API version, you only have access to the Medium Utilization - // Reserved Instance offering type. + // Reserved instance offering type. OfferingType *string `locationName:"offeringType" type:"string" enum:"OfferingTypeValues"` - // One or more Reserved Instance IDs. + // One or more Reserved instance IDs. // - // Default: Describes all your Reserved Instances, or only those otherwise + // Default: Describes all your Reserved instances, or only those otherwise // specified. ReservedInstancesIds []*string `locationName:"ReservedInstancesId" locationNameList:"ReservedInstancesId" type:"list"` - - metadataDescribeReservedInstancesInput `json:"-" xml:"-"` -} - -type metadataDescribeReservedInstancesInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -13204,29 +12758,25 @@ func (s DescribeReservedInstancesInput) GoString() string { } type DescribeReservedInstancesListingsInput struct { + _ struct{} `type:"structure"` + // One or more filters. // - // reserved-instances-id - The ID of the Reserved Instances. + // reserved-instances-id - The ID of the Reserved instances. // - // reserved-instances-listing-id - The ID of the Reserved Instances listing. + // reserved-instances-listing-id - The ID of the Reserved instances listing. // - // status - The status of the Reserved Instance listing (pending | active + // status - The status of the Reserved instance listing (pending | active // | cancelled | closed). // // status-message - The reason for the status. Filters []*Filter `locationName:"filters" locationNameList:"Filter" type:"list"` - // One or more Reserved Instance IDs. + // One or more Reserved instance IDs. ReservedInstancesId *string `locationName:"reservedInstancesId" type:"string"` - // One or more Reserved Instance Listing IDs. + // One or more Reserved instance Listing IDs. ReservedInstancesListingId *string `locationName:"reservedInstancesListingId" type:"string"` - - metadataDescribeReservedInstancesListingsInput `json:"-" xml:"-"` -} - -type metadataDescribeReservedInstancesListingsInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -13240,14 +12790,10 @@ func (s DescribeReservedInstancesListingsInput) GoString() string { } type DescribeReservedInstancesListingsOutput struct { - // Information about the Reserved Instance listing. + _ struct{} `type:"structure"` + + // Information about the Reserved instance listing. ReservedInstancesListings []*ReservedInstancesListing `locationName:"reservedInstancesListingsSet" locationNameList:"item" type:"list"` - - metadataDescribeReservedInstancesListingsOutput `json:"-" xml:"-"` -} - -type metadataDescribeReservedInstancesListingsOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -13261,6 +12807,8 @@ func (s DescribeReservedInstancesListingsOutput) GoString() string { } type DescribeReservedInstancesModificationsInput struct { + _ struct{} `type:"structure"` + // One or more filters. // // client-token - The idempotency token for the modification request. @@ -13269,27 +12817,27 @@ type DescribeReservedInstancesModificationsInput struct { // // effective-date - The time when the modification becomes effective. // - // modification-result.reserved-instances-id - The ID for the Reserved Instances + // modification-result.reserved-instances-id - The ID for the Reserved instances // created as part of the modification request. This ID is only available when // the status of the modification is fulfilled. // // modification-result.target-configuration.availability-zone - The Availability - // Zone for the new Reserved Instances. + // Zone for the new Reserved instances. // // modification-result.target-configuration.instance-count - The number - // of new Reserved Instances. + // of new Reserved instances. // // modification-result.target-configuration.instance-type - The instance - // type of the new Reserved Instances. + // type of the new Reserved instances. // // modification-result.target-configuration.platform - The network platform - // of the new Reserved Instances (EC2-Classic | EC2-VPC). + // of the new Reserved instances (EC2-Classic | EC2-VPC). // - // reserved-instances-id - The ID of the Reserved Instances modified. + // reserved-instances-id - The ID of the Reserved instances modified. // // reserved-instances-modification-id - The ID of the modification request. // - // status - The status of the Reserved Instances modification request (processing + // status - The status of the Reserved instances modification request (processing // | fulfilled | failed). // // status-message - The reason for the status. @@ -13302,12 +12850,6 @@ type DescribeReservedInstancesModificationsInput struct { // IDs for the submitted modification request. ReservedInstancesModificationIds []*string `locationName:"ReservedInstancesModificationId" locationNameList:"ReservedInstancesModificationId" type:"list"` - - metadataDescribeReservedInstancesModificationsInput `json:"-" xml:"-"` -} - -type metadataDescribeReservedInstancesModificationsInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -13321,18 +12863,14 @@ func (s DescribeReservedInstancesModificationsInput) GoString() string { } type DescribeReservedInstancesModificationsOutput struct { + _ struct{} `type:"structure"` + // The token to use to retrieve the next page of results. This value is null // when there are no more results to return. NextToken *string `locationName:"nextToken" type:"string"` - // The Reserved Instance modification information. + // The Reserved instance modification information. ReservedInstancesModifications []*ReservedInstancesModification `locationName:"reservedInstancesModificationsSet" locationNameList:"item" type:"list"` - - metadataDescribeReservedInstancesModificationsOutput `json:"-" xml:"-"` -} - -type metadataDescribeReservedInstancesModificationsOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -13346,7 +12884,9 @@ func (s DescribeReservedInstancesModificationsOutput) GoString() string { } type DescribeReservedInstancesOfferingsInput struct { - // The Availability Zone in which the Reserved Instance can be used. + _ struct{} `type:"structure"` + + // The Availability Zone in which the Reserved instance can be used. AvailabilityZone *string `type:"string"` // Checks whether you have the required permissions for the action, without @@ -13357,23 +12897,23 @@ type DescribeReservedInstancesOfferingsInput struct { // One or more filters. // - // availability-zone - The Availability Zone where the Reserved Instance + // availability-zone - The Availability Zone where the Reserved instance // can be used. // - // duration - The duration of the Reserved Instance (for example, one year + // duration - The duration of the Reserved instance (for example, one year // or three years), in seconds (31536000 | 94608000). // - // fixed-price - The purchase price of the Reserved Instance (for example, + // fixed-price - The purchase price of the Reserved instance (for example, // 9800.0). // - // instance-type - The instance type on which the Reserved Instance can be + // instance-type - The instance type on which the Reserved instance can be // used. // // marketplace - Set to true to show only Reserved Instance Marketplace offerings. // When this filter is not used, which is the default behavior, all offerings // from AWS and Reserved Instance Marketplace are listed. // - // product-description - The Reserved Instance product platform description. + // product-description - The Reserved instance product platform description. // Instances that include (Amazon VPC) in the product platform description will // only be displayed to EC2-Classic account holders and are for use with Amazon // VPC. (Linux/UNIX | Linux/UNIX (Amazon VPC) | SUSE Linux | SUSE Linux (Amazon @@ -13383,23 +12923,23 @@ type DescribeReservedInstancesOfferingsInput struct { // with SQL Server Web (Amazon VPC) | Windows with SQL Server Enterprise | Windows // with SQL Server Enterprise (Amazon VPC)) // - // reserved-instances-offering-id - The Reserved Instances offering ID. + // reserved-instances-offering-id - The Reserved instances offering ID. // - // usage-price - The usage price of the Reserved Instance, per hour (for + // usage-price - The usage price of the Reserved instance, per hour (for // example, 0.84). Filters []*Filter `locationName:"Filter" locationNameList:"Filter" type:"list"` - // Include Marketplace offerings in the response. + // Include Reserved Instance Marketplace offerings in the response. IncludeMarketplace *bool `type:"boolean"` - // The tenancy of the Reserved Instance offering. A Reserved Instance with dedicated - // tenancy runs on single-tenant hardware and can only be launched within a - // VPC. + // The tenancy of the Reserved instance offering. A Reserved instance with dedicated + // tenancy is applied to instances that run on single-tenant hardware and can + // only be launched within a VPC. // // Default: default InstanceTenancy *string `locationName:"instanceTenancy" type:"string" enum:"Tenancy"` - // The instance type on which the Reserved Instance can be used. For more information, + // The instance type on which the Reserved instance can be used. For more information, // see Instance Types (http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-types.html) // in the Amazon Elastic Compute Cloud User Guide. InstanceType *string `type:"string" enum:"InstanceType"` @@ -13429,23 +12969,17 @@ type DescribeReservedInstancesOfferingsInput struct { // The token to retrieve the next page of results. NextToken *string `locationName:"nextToken" type:"string"` - // The Reserved Instance offering type. If you are using tools that predate + // The Reserved instance offering type. If you are using tools that predate // the 2011-11-01 API version, you only have access to the Medium Utilization - // Reserved Instance offering type. + // Reserved instance offering type. OfferingType *string `locationName:"offeringType" type:"string" enum:"OfferingTypeValues"` - // The Reserved Instance product platform description. Instances that include + // The Reserved instance product platform description. Instances that include // (Amazon VPC) in the description are for use with Amazon VPC. ProductDescription *string `type:"string" enum:"RIProductDescription"` - // One or more Reserved Instances offering IDs. + // One or more Reserved instances offering IDs. ReservedInstancesOfferingIds []*string `locationName:"ReservedInstancesOfferingId" type:"list"` - - metadataDescribeReservedInstancesOfferingsInput `json:"-" xml:"-"` -} - -type metadataDescribeReservedInstancesOfferingsInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -13459,18 +12993,14 @@ func (s DescribeReservedInstancesOfferingsInput) GoString() string { } type DescribeReservedInstancesOfferingsOutput struct { + _ struct{} `type:"structure"` + // The token to use to retrieve the next page of results. This value is null // when there are no more results to return. NextToken *string `locationName:"nextToken" type:"string"` - // A list of Reserved Instances offerings. + // A list of Reserved instances offerings. ReservedInstancesOfferings []*ReservedInstancesOffering `locationName:"reservedInstancesOfferingsSet" locationNameList:"item" type:"list"` - - metadataDescribeReservedInstancesOfferingsOutput `json:"-" xml:"-"` -} - -type metadataDescribeReservedInstancesOfferingsOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -13484,14 +13014,10 @@ func (s DescribeReservedInstancesOfferingsOutput) GoString() string { } type DescribeReservedInstancesOutput struct { - // A list of Reserved Instances. + _ struct{} `type:"structure"` + + // A list of Reserved instances. ReservedInstances []*ReservedInstances `locationName:"reservedInstancesSet" locationNameList:"item" type:"list"` - - metadataDescribeReservedInstancesOutput `json:"-" xml:"-"` -} - -type metadataDescribeReservedInstancesOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -13505,6 +13031,8 @@ func (s DescribeReservedInstancesOutput) GoString() string { } type DescribeRouteTablesInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -13522,7 +13050,7 @@ type DescribeRouteTablesInput struct { // association.subnet-id - The ID of the subnet involved in the association. // // association.main - Indicates whether the route table is the main route - // table for the VPC. + // table for the VPC (true | false). // // route-table-id - The ID of the route table. // @@ -13570,12 +13098,6 @@ type DescribeRouteTablesInput struct { // // Default: Describes all your route tables. RouteTableIds []*string `locationName:"RouteTableId" locationNameList:"item" type:"list"` - - metadataDescribeRouteTablesInput `json:"-" xml:"-"` -} - -type metadataDescribeRouteTablesInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -13589,14 +13111,10 @@ func (s DescribeRouteTablesInput) GoString() string { } type DescribeRouteTablesOutput struct { + _ struct{} `type:"structure"` + // Information about one or more route tables. RouteTables []*RouteTable `locationName:"routeTableSet" locationNameList:"item" type:"list"` - - metadataDescribeRouteTablesOutput `json:"-" xml:"-"` -} - -type metadataDescribeRouteTablesOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -13610,6 +13128,8 @@ func (s DescribeRouteTablesOutput) GoString() string { } type DescribeSecurityGroupsInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -13671,12 +13191,6 @@ type DescribeSecurityGroupsInput struct { // // Default: Describes all your security groups. GroupNames []*string `locationName:"GroupName" locationNameList:"GroupName" type:"list"` - - metadataDescribeSecurityGroupsInput `json:"-" xml:"-"` -} - -type metadataDescribeSecurityGroupsInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -13690,14 +13204,10 @@ func (s DescribeSecurityGroupsInput) GoString() string { } type DescribeSecurityGroupsOutput struct { + _ struct{} `type:"structure"` + // Information about one or more security groups. SecurityGroups []*SecurityGroup `locationName:"securityGroupInfo" locationNameList:"item" type:"list"` - - metadataDescribeSecurityGroupsOutput `json:"-" xml:"-"` -} - -type metadataDescribeSecurityGroupsOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -13711,6 +13221,8 @@ func (s DescribeSecurityGroupsOutput) GoString() string { } type DescribeSnapshotAttributeInput struct { + _ struct{} `type:"structure"` + // The snapshot attribute you would like to view. Attribute *string `type:"string" required:"true" enum:"SnapshotAttributeName"` @@ -13722,12 +13234,6 @@ type DescribeSnapshotAttributeInput struct { // The ID of the EBS snapshot. SnapshotId *string `type:"string" required:"true"` - - metadataDescribeSnapshotAttributeInput `json:"-" xml:"-"` -} - -type metadataDescribeSnapshotAttributeInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -13741,6 +13247,8 @@ func (s DescribeSnapshotAttributeInput) GoString() string { } type DescribeSnapshotAttributeOutput struct { + _ struct{} `type:"structure"` + // A list of permissions for creating volumes from the snapshot. CreateVolumePermissions []*CreateVolumePermission `locationName:"createVolumePermission" locationNameList:"item" type:"list"` @@ -13749,12 +13257,6 @@ type DescribeSnapshotAttributeOutput struct { // The ID of the EBS snapshot. SnapshotId *string `locationName:"snapshotId" type:"string"` - - metadataDescribeSnapshotAttributeOutput `json:"-" xml:"-"` -} - -type metadataDescribeSnapshotAttributeOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -13768,6 +13270,8 @@ func (s DescribeSnapshotAttributeOutput) GoString() string { } type DescribeSnapshotsInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -13838,12 +13342,6 @@ type DescribeSnapshotsInput struct { // // Default: Describes snapshots for which you have launch permissions. SnapshotIds []*string `locationName:"SnapshotId" locationNameList:"SnapshotId" type:"list"` - - metadataDescribeSnapshotsInput `json:"-" xml:"-"` -} - -type metadataDescribeSnapshotsInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -13857,6 +13355,8 @@ func (s DescribeSnapshotsInput) GoString() string { } type DescribeSnapshotsOutput struct { + _ struct{} `type:"structure"` + // The NextToken value to include in a future DescribeSnapshots request. When // the results of a DescribeSnapshots request exceed MaxResults, this value // can be used to retrieve the next page of results. This value is null when @@ -13865,12 +13365,6 @@ type DescribeSnapshotsOutput struct { // Information about the snapshots. Snapshots []*Snapshot `locationName:"snapshotSet" locationNameList:"item" type:"list"` - - metadataDescribeSnapshotsOutput `json:"-" xml:"-"` -} - -type metadataDescribeSnapshotsOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -13885,17 +13379,13 @@ func (s DescribeSnapshotsOutput) GoString() string { // Contains the parameters for DescribeSpotDatafeedSubscription. type DescribeSpotDatafeedSubscriptionInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, // it is UnauthorizedOperation. DryRun *bool `locationName:"dryRun" type:"boolean"` - - metadataDescribeSpotDatafeedSubscriptionInput `json:"-" xml:"-"` -} - -type metadataDescribeSpotDatafeedSubscriptionInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -13910,14 +13400,10 @@ func (s DescribeSpotDatafeedSubscriptionInput) GoString() string { // Contains the output of DescribeSpotDatafeedSubscription. type DescribeSpotDatafeedSubscriptionOutput struct { + _ struct{} `type:"structure"` + // The Spot instance data feed subscription. SpotDatafeedSubscription *SpotDatafeedSubscription `locationName:"spotDatafeedSubscription" type:"structure"` - - metadataDescribeSpotDatafeedSubscriptionOutput `json:"-" xml:"-"` -} - -type metadataDescribeSpotDatafeedSubscriptionOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -13932,6 +13418,8 @@ func (s DescribeSpotDatafeedSubscriptionOutput) GoString() string { // Contains the parameters for DescribeSpotFleetInstances. type DescribeSpotFleetInstancesInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -13948,12 +13436,6 @@ type DescribeSpotFleetInstancesInput struct { // The ID of the Spot fleet request. SpotFleetRequestId *string `locationName:"spotFleetRequestId" type:"string" required:"true"` - - metadataDescribeSpotFleetInstancesInput `json:"-" xml:"-"` -} - -type metadataDescribeSpotFleetInstancesInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -13968,6 +13450,8 @@ func (s DescribeSpotFleetInstancesInput) GoString() string { // Contains the output of DescribeSpotFleetInstances. type DescribeSpotFleetInstancesOutput struct { + _ struct{} `type:"structure"` + // The running instances. Note that this list is refreshed periodically and // might be out of date. ActiveInstances []*ActiveInstance `locationName:"activeInstanceSet" locationNameList:"item" type:"list" required:"true"` @@ -13978,12 +13462,6 @@ type DescribeSpotFleetInstancesOutput struct { // The ID of the Spot fleet request. SpotFleetRequestId *string `locationName:"spotFleetRequestId" type:"string" required:"true"` - - metadataDescribeSpotFleetInstancesOutput `json:"-" xml:"-"` -} - -type metadataDescribeSpotFleetInstancesOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -13998,6 +13476,8 @@ func (s DescribeSpotFleetInstancesOutput) GoString() string { // Contains the parameters for DescribeSpotFleetRequestHistory. type DescribeSpotFleetRequestHistoryInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -14020,12 +13500,6 @@ type DescribeSpotFleetRequestHistoryInput struct { // The starting date and time for the events, in UTC format (for example, YYYY-MM-DDTHH:MM:SSZ). StartTime *time.Time `locationName:"startTime" type:"timestamp" timestampFormat:"iso8601" required:"true"` - - metadataDescribeSpotFleetRequestHistoryInput `json:"-" xml:"-"` -} - -type metadataDescribeSpotFleetRequestHistoryInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -14040,6 +13514,8 @@ func (s DescribeSpotFleetRequestHistoryInput) GoString() string { // Contains the output of DescribeSpotFleetRequestHistory. type DescribeSpotFleetRequestHistoryOutput struct { + _ struct{} `type:"structure"` + // Information about the events in the history of the Spot fleet request. HistoryRecords []*HistoryRecord `locationName:"historyRecordSet" locationNameList:"item" type:"list" required:"true"` @@ -14058,12 +13534,6 @@ type DescribeSpotFleetRequestHistoryOutput struct { // The starting date and time for the events, in UTC format (for example, YYYY-MM-DDTHH:MM:SSZ). StartTime *time.Time `locationName:"startTime" type:"timestamp" timestampFormat:"iso8601" required:"true"` - - metadataDescribeSpotFleetRequestHistoryOutput `json:"-" xml:"-"` -} - -type metadataDescribeSpotFleetRequestHistoryOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -14078,6 +13548,8 @@ func (s DescribeSpotFleetRequestHistoryOutput) GoString() string { // Contains the parameters for DescribeSpotFleetRequests. type DescribeSpotFleetRequestsInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -14094,12 +13566,6 @@ type DescribeSpotFleetRequestsInput struct { // The IDs of the Spot fleet requests. SpotFleetRequestIds []*string `locationName:"spotFleetRequestId" locationNameList:"item" type:"list"` - - metadataDescribeSpotFleetRequestsInput `json:"-" xml:"-"` -} - -type metadataDescribeSpotFleetRequestsInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -14114,18 +13580,14 @@ func (s DescribeSpotFleetRequestsInput) GoString() string { // Contains the output of DescribeSpotFleetRequests. type DescribeSpotFleetRequestsOutput struct { + _ struct{} `type:"structure"` + // The token required to retrieve the next set of results. This value is null // when there are no more results to return. NextToken *string `locationName:"nextToken" type:"string"` // Information about the configuration of your Spot fleet. SpotFleetRequestConfigs []*SpotFleetRequestConfig `locationName:"spotFleetRequestConfigSet" locationNameList:"item" type:"list" required:"true"` - - metadataDescribeSpotFleetRequestsOutput `json:"-" xml:"-"` -} - -type metadataDescribeSpotFleetRequestsOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -14140,6 +13602,8 @@ func (s DescribeSpotFleetRequestsOutput) GoString() string { // Contains the parameters for DescribeSpotInstanceRequests. type DescribeSpotInstanceRequestsInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -14258,12 +13722,6 @@ type DescribeSpotInstanceRequestsInput struct { // One or more Spot instance request IDs. SpotInstanceRequestIds []*string `locationName:"SpotInstanceRequestId" locationNameList:"SpotInstanceRequestId" type:"list"` - - metadataDescribeSpotInstanceRequestsInput `json:"-" xml:"-"` -} - -type metadataDescribeSpotInstanceRequestsInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -14278,14 +13736,10 @@ func (s DescribeSpotInstanceRequestsInput) GoString() string { // Contains the output of DescribeSpotInstanceRequests. type DescribeSpotInstanceRequestsOutput struct { + _ struct{} `type:"structure"` + // One or more Spot instance requests. SpotInstanceRequests []*SpotInstanceRequest `locationName:"spotInstanceRequestSet" locationNameList:"item" type:"list"` - - metadataDescribeSpotInstanceRequestsOutput `json:"-" xml:"-"` -} - -type metadataDescribeSpotInstanceRequestsOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -14300,6 +13754,8 @@ func (s DescribeSpotInstanceRequestsOutput) GoString() string { // Contains the parameters for DescribeSpotPriceHistory. type DescribeSpotPriceHistoryInput struct { + _ struct{} `type:"structure"` + // Filters the results by the specified Availability Zone. AvailabilityZone *string `locationName:"availabilityZone" type:"string"` @@ -14348,12 +13804,6 @@ type DescribeSpotPriceHistoryInput struct { // The date and time, up to the past 90 days, from which to start retrieving // the price history data, in UTC format (for example, YYYY-MM-DDTHH:MM:SSZ). StartTime *time.Time `locationName:"startTime" type:"timestamp" timestampFormat:"iso8601"` - - metadataDescribeSpotPriceHistoryInput `json:"-" xml:"-"` -} - -type metadataDescribeSpotPriceHistoryInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -14368,18 +13818,14 @@ func (s DescribeSpotPriceHistoryInput) GoString() string { // Contains the output of DescribeSpotPriceHistory. type DescribeSpotPriceHistoryOutput struct { + _ struct{} `type:"structure"` + // The token required to retrieve the next set of results. This value is null // when there are no more results to return. NextToken *string `locationName:"nextToken" type:"string"` // The historical Spot prices. SpotPriceHistory []*SpotPrice `locationName:"spotPriceHistorySet" locationNameList:"item" type:"list"` - - metadataDescribeSpotPriceHistoryOutput `json:"-" xml:"-"` -} - -type metadataDescribeSpotPriceHistoryOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -14393,6 +13839,8 @@ func (s DescribeSpotPriceHistoryOutput) GoString() string { } type DescribeSubnetsInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -14437,12 +13885,6 @@ type DescribeSubnetsInput struct { // // Default: Describes all your subnets. SubnetIds []*string `locationName:"SubnetId" locationNameList:"SubnetId" type:"list"` - - metadataDescribeSubnetsInput `json:"-" xml:"-"` -} - -type metadataDescribeSubnetsInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -14456,14 +13898,10 @@ func (s DescribeSubnetsInput) GoString() string { } type DescribeSubnetsOutput struct { + _ struct{} `type:"structure"` + // Information about one or more subnets. Subnets []*Subnet `locationName:"subnetSet" locationNameList:"item" type:"list"` - - metadataDescribeSubnetsOutput `json:"-" xml:"-"` -} - -type metadataDescribeSubnetsOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -14477,6 +13915,8 @@ func (s DescribeSubnetsOutput) GoString() string { } type DescribeTagsInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -14506,12 +13946,6 @@ type DescribeTagsInput struct { // The token to retrieve the next page of results. NextToken *string `locationName:"nextToken" type:"string"` - - metadataDescribeTagsInput `json:"-" xml:"-"` -} - -type metadataDescribeTagsInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -14525,18 +13959,14 @@ func (s DescribeTagsInput) GoString() string { } type DescribeTagsOutput struct { + _ struct{} `type:"structure"` + // The token to use to retrieve the next page of results. This value is null // when there are no more results to return.. NextToken *string `locationName:"nextToken" type:"string"` // A list of tags. Tags []*TagDescription `locationName:"tagSet" locationNameList:"item" type:"list"` - - metadataDescribeTagsOutput `json:"-" xml:"-"` -} - -type metadataDescribeTagsOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -14550,6 +13980,8 @@ func (s DescribeTagsOutput) GoString() string { } type DescribeVolumeAttributeInput struct { + _ struct{} `type:"structure"` + // The instance attribute. Attribute *string `type:"string" enum:"VolumeAttributeName"` @@ -14561,12 +13993,6 @@ type DescribeVolumeAttributeInput struct { // The ID of the volume. VolumeId *string `type:"string" required:"true"` - - metadataDescribeVolumeAttributeInput `json:"-" xml:"-"` -} - -type metadataDescribeVolumeAttributeInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -14580,6 +14006,8 @@ func (s DescribeVolumeAttributeInput) GoString() string { } type DescribeVolumeAttributeOutput struct { + _ struct{} `type:"structure"` + // The state of autoEnableIO attribute. AutoEnableIO *AttributeBooleanValue `locationName:"autoEnableIO" type:"structure"` @@ -14588,12 +14016,6 @@ type DescribeVolumeAttributeOutput struct { // The ID of the volume. VolumeId *string `locationName:"volumeId" type:"string"` - - metadataDescribeVolumeAttributeOutput `json:"-" xml:"-"` -} - -type metadataDescribeVolumeAttributeOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -14607,6 +14029,8 @@ func (s DescribeVolumeAttributeOutput) GoString() string { } type DescribeVolumeStatusInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -14666,12 +14090,6 @@ type DescribeVolumeStatusInput struct { // // Default: Describes all your volumes. VolumeIds []*string `locationName:"VolumeId" locationNameList:"VolumeId" type:"list"` - - metadataDescribeVolumeStatusInput `json:"-" xml:"-"` -} - -type metadataDescribeVolumeStatusInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -14685,18 +14103,14 @@ func (s DescribeVolumeStatusInput) GoString() string { } type DescribeVolumeStatusOutput struct { + _ struct{} `type:"structure"` + // The token to use to retrieve the next page of results. This value is null // when there are no more results to return. NextToken *string `locationName:"nextToken" type:"string"` // A list of volumes. VolumeStatuses []*VolumeStatusItem `locationName:"volumeStatusSet" locationNameList:"item" type:"list"` - - metadataDescribeVolumeStatusOutput `json:"-" xml:"-"` -} - -type metadataDescribeVolumeStatusOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -14710,6 +14124,8 @@ func (s DescribeVolumeStatusOutput) GoString() string { } type DescribeVolumesInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -14783,12 +14199,6 @@ type DescribeVolumesInput struct { // One or more volume IDs. VolumeIds []*string `locationName:"VolumeId" locationNameList:"VolumeId" type:"list"` - - metadataDescribeVolumesInput `json:"-" xml:"-"` -} - -type metadataDescribeVolumesInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -14802,6 +14212,8 @@ func (s DescribeVolumesInput) GoString() string { } type DescribeVolumesOutput struct { + _ struct{} `type:"structure"` + // The NextToken value to include in a future DescribeVolumes request. When // the results of a DescribeVolumes request exceed MaxResults, this value can // be used to retrieve the next page of results. This value is null when there @@ -14810,12 +14222,6 @@ type DescribeVolumesOutput struct { // Information about the volumes. Volumes []*Volume `locationName:"volumeSet" locationNameList:"item" type:"list"` - - metadataDescribeVolumesOutput `json:"-" xml:"-"` -} - -type metadataDescribeVolumesOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -14829,6 +14235,8 @@ func (s DescribeVolumesOutput) GoString() string { } type DescribeVpcAttributeInput struct { + _ struct{} `type:"structure"` + // The VPC attribute. Attribute *string `type:"string" enum:"VpcAttributeName"` @@ -14840,12 +14248,6 @@ type DescribeVpcAttributeInput struct { // The ID of the VPC. VpcId *string `type:"string" required:"true"` - - metadataDescribeVpcAttributeInput `json:"-" xml:"-"` -} - -type metadataDescribeVpcAttributeInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -14859,6 +14261,8 @@ func (s DescribeVpcAttributeInput) GoString() string { } type DescribeVpcAttributeOutput struct { + _ struct{} `type:"structure"` + // Indicates whether the instances launched in the VPC get DNS hostnames. If // this attribute is true, instances in the VPC get DNS hostnames; otherwise, // they do not. @@ -14871,12 +14275,6 @@ type DescribeVpcAttributeOutput struct { // The ID of the VPC. VpcId *string `locationName:"vpcId" type:"string"` - - metadataDescribeVpcAttributeOutput `json:"-" xml:"-"` -} - -type metadataDescribeVpcAttributeOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -14890,6 +14288,8 @@ func (s DescribeVpcAttributeOutput) GoString() string { } type DescribeVpcClassicLinkInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -14916,12 +14316,6 @@ type DescribeVpcClassicLinkInput struct { // One or more VPCs for which you want to describe the ClassicLink status. VpcIds []*string `locationName:"VpcId" locationNameList:"VpcId" type:"list"` - - metadataDescribeVpcClassicLinkInput `json:"-" xml:"-"` -} - -type metadataDescribeVpcClassicLinkInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -14935,14 +14329,10 @@ func (s DescribeVpcClassicLinkInput) GoString() string { } type DescribeVpcClassicLinkOutput struct { + _ struct{} `type:"structure"` + // The ClassicLink status of one or more VPCs. Vpcs []*VpcClassicLink `locationName:"vpcSet" locationNameList:"item" type:"list"` - - metadataDescribeVpcClassicLinkOutput `json:"-" xml:"-"` -} - -type metadataDescribeVpcClassicLinkOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -14956,6 +14346,8 @@ func (s DescribeVpcClassicLinkOutput) GoString() string { } type DescribeVpcEndpointServicesInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -14972,12 +14364,6 @@ type DescribeVpcEndpointServicesInput struct { // The token for the next set of items to return. (You received this token from // a prior call.) NextToken *string `type:"string"` - - metadataDescribeVpcEndpointServicesInput `json:"-" xml:"-"` -} - -type metadataDescribeVpcEndpointServicesInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -14991,18 +14377,14 @@ func (s DescribeVpcEndpointServicesInput) GoString() string { } type DescribeVpcEndpointServicesOutput struct { + _ struct{} `type:"structure"` + // The token to use when requesting the next set of items. If there are no additional // items to return, the string is empty. NextToken *string `locationName:"nextToken" type:"string"` // A list of supported AWS services. ServiceNames []*string `locationName:"serviceNameSet" locationNameList:"item" type:"list"` - - metadataDescribeVpcEndpointServicesOutput `json:"-" xml:"-"` -} - -type metadataDescribeVpcEndpointServicesOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -15016,6 +14398,8 @@ func (s DescribeVpcEndpointServicesOutput) GoString() string { } type DescribeVpcEndpointsInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -15047,12 +14431,6 @@ type DescribeVpcEndpointsInput struct { // One or more endpoint IDs. VpcEndpointIds []*string `locationName:"VpcEndpointId" locationNameList:"item" type:"list"` - - metadataDescribeVpcEndpointsInput `json:"-" xml:"-"` -} - -type metadataDescribeVpcEndpointsInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -15066,18 +14444,14 @@ func (s DescribeVpcEndpointsInput) GoString() string { } type DescribeVpcEndpointsOutput struct { + _ struct{} `type:"structure"` + // The token to use when requesting the next set of items. If there are no additional // items to return, the string is empty. NextToken *string `locationName:"nextToken" type:"string"` // Information about the endpoints. VpcEndpoints []*VpcEndpoint `locationName:"vpcEndpointSet" locationNameList:"item" type:"list"` - - metadataDescribeVpcEndpointsOutput `json:"-" xml:"-"` -} - -type metadataDescribeVpcEndpointsOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -15091,6 +14465,8 @@ func (s DescribeVpcEndpointsOutput) GoString() string { } type DescribeVpcPeeringConnectionsInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -15140,12 +14516,6 @@ type DescribeVpcPeeringConnectionsInput struct { // // Default: Describes all your VPC peering connections. VpcPeeringConnectionIds []*string `locationName:"VpcPeeringConnectionId" locationNameList:"item" type:"list"` - - metadataDescribeVpcPeeringConnectionsInput `json:"-" xml:"-"` -} - -type metadataDescribeVpcPeeringConnectionsInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -15159,14 +14529,10 @@ func (s DescribeVpcPeeringConnectionsInput) GoString() string { } type DescribeVpcPeeringConnectionsOutput struct { + _ struct{} `type:"structure"` + // Information about the VPC peering connections. VpcPeeringConnections []*VpcPeeringConnection `locationName:"vpcPeeringConnectionSet" locationNameList:"item" type:"list"` - - metadataDescribeVpcPeeringConnectionsOutput `json:"-" xml:"-"` -} - -type metadataDescribeVpcPeeringConnectionsOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -15180,6 +14546,8 @@ func (s DescribeVpcPeeringConnectionsOutput) GoString() string { } type DescribeVpcsInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -15217,12 +14585,6 @@ type DescribeVpcsInput struct { // // Default: Describes all your VPCs. VpcIds []*string `locationName:"VpcId" locationNameList:"VpcId" type:"list"` - - metadataDescribeVpcsInput `json:"-" xml:"-"` -} - -type metadataDescribeVpcsInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -15236,14 +14598,10 @@ func (s DescribeVpcsInput) GoString() string { } type DescribeVpcsOutput struct { + _ struct{} `type:"structure"` + // Information about one or more VPCs. Vpcs []*Vpc `locationName:"vpcSet" locationNameList:"item" type:"list"` - - metadataDescribeVpcsOutput `json:"-" xml:"-"` -} - -type metadataDescribeVpcsOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -15257,6 +14615,8 @@ func (s DescribeVpcsOutput) GoString() string { } type DescribeVpnConnectionsInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -15309,12 +14669,6 @@ type DescribeVpnConnectionsInput struct { // // Default: Describes your VPN connections. VpnConnectionIds []*string `locationName:"VpnConnectionId" locationNameList:"VpnConnectionId" type:"list"` - - metadataDescribeVpnConnectionsInput `json:"-" xml:"-"` -} - -type metadataDescribeVpnConnectionsInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -15328,14 +14682,10 @@ func (s DescribeVpnConnectionsInput) GoString() string { } type DescribeVpnConnectionsOutput struct { + _ struct{} `type:"structure"` + // Information about one or more VPN connections. VpnConnections []*VpnConnection `locationName:"vpnConnectionSet" locationNameList:"item" type:"list"` - - metadataDescribeVpnConnectionsOutput `json:"-" xml:"-"` -} - -type metadataDescribeVpnConnectionsOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -15349,6 +14699,8 @@ func (s DescribeVpnConnectionsOutput) GoString() string { } type DescribeVpnGatewaysInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -15389,12 +14741,6 @@ type DescribeVpnGatewaysInput struct { // // Default: Describes all your virtual private gateways. VpnGatewayIds []*string `locationName:"VpnGatewayId" locationNameList:"VpnGatewayId" type:"list"` - - metadataDescribeVpnGatewaysInput `json:"-" xml:"-"` -} - -type metadataDescribeVpnGatewaysInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -15408,14 +14754,10 @@ func (s DescribeVpnGatewaysInput) GoString() string { } type DescribeVpnGatewaysOutput struct { + _ struct{} `type:"structure"` + // Information about one or more virtual private gateways. VpnGateways []*VpnGateway `locationName:"vpnGatewaySet" locationNameList:"item" type:"list"` - - metadataDescribeVpnGatewaysOutput `json:"-" xml:"-"` -} - -type metadataDescribeVpnGatewaysOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -15429,6 +14771,8 @@ func (s DescribeVpnGatewaysOutput) GoString() string { } type DetachClassicLinkVpcInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -15440,12 +14784,6 @@ type DetachClassicLinkVpcInput struct { // The ID of the VPC to which the instance is linked. VpcId *string `locationName:"vpcId" type:"string" required:"true"` - - metadataDetachClassicLinkVpcInput `json:"-" xml:"-"` -} - -type metadataDetachClassicLinkVpcInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -15459,14 +14797,10 @@ func (s DetachClassicLinkVpcInput) GoString() string { } type DetachClassicLinkVpcOutput struct { + _ struct{} `type:"structure"` + // Returns true if the request succeeds; otherwise, it returns an error. Return *bool `locationName:"return" type:"boolean"` - - metadataDetachClassicLinkVpcOutput `json:"-" xml:"-"` -} - -type metadataDetachClassicLinkVpcOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -15480,6 +14814,8 @@ func (s DetachClassicLinkVpcOutput) GoString() string { } type DetachInternetGatewayInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -15491,12 +14827,6 @@ type DetachInternetGatewayInput struct { // The ID of the VPC. VpcId *string `locationName:"vpcId" type:"string" required:"true"` - - metadataDetachInternetGatewayInput `json:"-" xml:"-"` -} - -type metadataDetachInternetGatewayInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -15510,11 +14840,7 @@ func (s DetachInternetGatewayInput) GoString() string { } type DetachInternetGatewayOutput struct { - metadataDetachInternetGatewayOutput `json:"-" xml:"-"` -} - -type metadataDetachInternetGatewayOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -15528,6 +14854,8 @@ func (s DetachInternetGatewayOutput) GoString() string { } type DetachNetworkInterfaceInput struct { + _ struct{} `type:"structure"` + // The ID of the attachment. AttachmentId *string `locationName:"attachmentId" type:"string" required:"true"` @@ -15539,12 +14867,6 @@ type DetachNetworkInterfaceInput struct { // Specifies whether to force a detachment. Force *bool `locationName:"force" type:"boolean"` - - metadataDetachNetworkInterfaceInput `json:"-" xml:"-"` -} - -type metadataDetachNetworkInterfaceInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -15558,11 +14880,7 @@ func (s DetachNetworkInterfaceInput) GoString() string { } type DetachNetworkInterfaceOutput struct { - metadataDetachNetworkInterfaceOutput `json:"-" xml:"-"` -} - -type metadataDetachNetworkInterfaceOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -15576,6 +14894,8 @@ func (s DetachNetworkInterfaceOutput) GoString() string { } type DetachVolumeInput struct { + _ struct{} `type:"structure"` + // The device name. Device *string `type:"string"` @@ -15599,12 +14919,6 @@ type DetachVolumeInput struct { // The ID of the volume. VolumeId *string `type:"string" required:"true"` - - metadataDetachVolumeInput `json:"-" xml:"-"` -} - -type metadataDetachVolumeInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -15618,6 +14932,8 @@ func (s DetachVolumeInput) GoString() string { } type DetachVpnGatewayInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -15629,12 +14945,6 @@ type DetachVpnGatewayInput struct { // The ID of the virtual private gateway. VpnGatewayId *string `type:"string" required:"true"` - - metadataDetachVpnGatewayInput `json:"-" xml:"-"` -} - -type metadataDetachVpnGatewayInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -15648,11 +14958,7 @@ func (s DetachVpnGatewayInput) GoString() string { } type DetachVpnGatewayOutput struct { - metadataDetachVpnGatewayOutput `json:"-" xml:"-"` -} - -type metadataDetachVpnGatewayOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -15667,17 +14973,13 @@ func (s DetachVpnGatewayOutput) GoString() string { // Describes a DHCP configuration option. type DhcpConfiguration struct { + _ struct{} `type:"structure"` + // The name of a DHCP option. Key *string `locationName:"key" type:"string"` // One or more values for the DHCP option. Values []*AttributeValue `locationName:"valueSet" locationNameList:"item" type:"list"` - - metadataDhcpConfiguration `json:"-" xml:"-"` -} - -type metadataDhcpConfiguration struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -15692,6 +14994,8 @@ func (s DhcpConfiguration) GoString() string { // Describes a set of DHCP options. type DhcpOptions struct { + _ struct{} `type:"structure"` + // One or more DHCP options in the set. DhcpConfigurations []*DhcpConfiguration `locationName:"dhcpConfigurationSet" locationNameList:"item" type:"list"` @@ -15700,12 +15004,6 @@ type DhcpOptions struct { // Any tags assigned to the DHCP options set. Tags []*Tag `locationName:"tagSet" locationNameList:"item" type:"list"` - - metadataDhcpOptions `json:"-" xml:"-"` -} - -type metadataDhcpOptions struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -15719,17 +15017,13 @@ func (s DhcpOptions) GoString() string { } type DisableVgwRoutePropagationInput struct { + _ struct{} `type:"structure"` + // The ID of the virtual private gateway. GatewayId *string `type:"string" required:"true"` // The ID of the route table. RouteTableId *string `type:"string" required:"true"` - - metadataDisableVgwRoutePropagationInput `json:"-" xml:"-"` -} - -type metadataDisableVgwRoutePropagationInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -15743,11 +15037,7 @@ func (s DisableVgwRoutePropagationInput) GoString() string { } type DisableVgwRoutePropagationOutput struct { - metadataDisableVgwRoutePropagationOutput `json:"-" xml:"-"` -} - -type metadataDisableVgwRoutePropagationOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -15761,6 +15051,8 @@ func (s DisableVgwRoutePropagationOutput) GoString() string { } type DisableVpcClassicLinkInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -15769,12 +15061,6 @@ type DisableVpcClassicLinkInput struct { // The ID of the VPC. VpcId *string `locationName:"vpcId" type:"string" required:"true"` - - metadataDisableVpcClassicLinkInput `json:"-" xml:"-"` -} - -type metadataDisableVpcClassicLinkInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -15788,14 +15074,10 @@ func (s DisableVpcClassicLinkInput) GoString() string { } type DisableVpcClassicLinkOutput struct { + _ struct{} `type:"structure"` + // Returns true if the request succeeds; otherwise, it returns an error. Return *bool `locationName:"return" type:"boolean"` - - metadataDisableVpcClassicLinkOutput `json:"-" xml:"-"` -} - -type metadataDisableVpcClassicLinkOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -15809,6 +15091,8 @@ func (s DisableVpcClassicLinkOutput) GoString() string { } type DisassociateAddressInput struct { + _ struct{} `type:"structure"` + // [EC2-VPC] The association ID. Required for EC2-VPC. AssociationId *string `type:"string"` @@ -15820,12 +15104,6 @@ type DisassociateAddressInput struct { // [EC2-Classic] The Elastic IP address. Required for EC2-Classic. PublicIp *string `type:"string"` - - metadataDisassociateAddressInput `json:"-" xml:"-"` -} - -type metadataDisassociateAddressInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -15839,11 +15117,7 @@ func (s DisassociateAddressInput) GoString() string { } type DisassociateAddressOutput struct { - metadataDisassociateAddressOutput `json:"-" xml:"-"` -} - -type metadataDisassociateAddressOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -15857,6 +15131,8 @@ func (s DisassociateAddressOutput) GoString() string { } type DisassociateRouteTableInput struct { + _ struct{} `type:"structure"` + // The association ID representing the current association between the route // table and subnet. AssociationId *string `locationName:"associationId" type:"string" required:"true"` @@ -15866,12 +15142,6 @@ type DisassociateRouteTableInput struct { // the required permissions, the error response is DryRunOperation. Otherwise, // it is UnauthorizedOperation. DryRun *bool `locationName:"dryRun" type:"boolean"` - - metadataDisassociateRouteTableInput `json:"-" xml:"-"` -} - -type metadataDisassociateRouteTableInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -15885,11 +15155,7 @@ func (s DisassociateRouteTableInput) GoString() string { } type DisassociateRouteTableOutput struct { - metadataDisassociateRouteTableOutput `json:"-" xml:"-"` -} - -type metadataDisassociateRouteTableOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -15904,6 +15170,8 @@ func (s DisassociateRouteTableOutput) GoString() string { // Describes a disk image. type DiskImage struct { + _ struct{} `type:"structure"` + // A description of the disk image. Description *string `type:"string"` @@ -15912,12 +15180,6 @@ type DiskImage struct { // Information about the volume. Volume *VolumeDetail `type:"structure"` - - metadataDiskImage `json:"-" xml:"-"` -} - -type metadataDiskImage struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -15932,6 +15194,8 @@ func (s DiskImage) GoString() string { // Describes a disk image. type DiskImageDescription struct { + _ struct{} `type:"structure"` + // The checksum computed for the disk image. Checksum *string `locationName:"checksum" type:"string"` @@ -15947,12 +15211,6 @@ type DiskImageDescription struct { // The size of the disk image, in GiB. Size *int64 `locationName:"size" type:"long" required:"true"` - - metadataDiskImageDescription `json:"-" xml:"-"` -} - -type metadataDiskImageDescription struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -15967,6 +15225,8 @@ func (s DiskImageDescription) GoString() string { // Describes a disk image. type DiskImageDetail struct { + _ struct{} `type:"structure"` + // The size of the disk image, in GiB. Bytes *int64 `locationName:"bytes" type:"long" required:"true"` @@ -15979,12 +15239,6 @@ type DiskImageDetail struct { // Alternative" section of the Authenticating REST Requests (http://docs.aws.amazon.com/AmazonS3/latest/dev/RESTAuthentication.html) // topic in the Amazon Simple Storage Service Developer Guide. ImportManifestUrl *string `locationName:"importManifestUrl" type:"string" required:"true"` - - metadataDiskImageDetail `json:"-" xml:"-"` -} - -type metadataDiskImageDetail struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -15999,17 +15253,13 @@ func (s DiskImageDetail) GoString() string { // Describes a disk image volume. type DiskImageVolumeDescription struct { + _ struct{} `type:"structure"` + // The volume identifier. Id *string `locationName:"id" type:"string" required:"true"` // The size of the volume, in GiB. Size *int64 `locationName:"size" type:"long"` - - metadataDiskImageVolumeDescription `json:"-" xml:"-"` -} - -type metadataDiskImageVolumeDescription struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -16024,6 +15274,8 @@ func (s DiskImageVolumeDescription) GoString() string { // Describes a block device for an EBS volume. type EbsBlockDevice struct { + _ struct{} `type:"structure"` + // Indicates whether the EBS volume is deleted on instance termination. DeleteOnTermination *bool `locationName:"deleteOnTermination" type:"boolean"` @@ -16064,12 +15316,6 @@ type EbsBlockDevice struct { // // Default: standard VolumeType *string `locationName:"volumeType" type:"string" enum:"VolumeType"` - - metadataEbsBlockDevice `json:"-" xml:"-"` -} - -type metadataEbsBlockDevice struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -16084,6 +15330,8 @@ func (s EbsBlockDevice) GoString() string { // Describes a parameter used to set up an EBS volume in a block device mapping. type EbsInstanceBlockDevice struct { + _ struct{} `type:"structure"` + // The time stamp when the attachment initiated. AttachTime *time.Time `locationName:"attachTime" type:"timestamp" timestampFormat:"iso8601"` @@ -16095,12 +15343,6 @@ type EbsInstanceBlockDevice struct { // The ID of the EBS volume. VolumeId *string `locationName:"volumeId" type:"string"` - - metadataEbsInstanceBlockDevice `json:"-" xml:"-"` -} - -type metadataEbsInstanceBlockDevice struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -16114,17 +15356,13 @@ func (s EbsInstanceBlockDevice) GoString() string { } type EbsInstanceBlockDeviceSpecification struct { + _ struct{} `type:"structure"` + // Indicates whether the volume is deleted on instance termination. DeleteOnTermination *bool `locationName:"deleteOnTermination" type:"boolean"` // The ID of the EBS volume. VolumeId *string `locationName:"volumeId" type:"string"` - - metadataEbsInstanceBlockDeviceSpecification `json:"-" xml:"-"` -} - -type metadataEbsInstanceBlockDeviceSpecification struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -16138,17 +15376,13 @@ func (s EbsInstanceBlockDeviceSpecification) GoString() string { } type EnableVgwRoutePropagationInput struct { + _ struct{} `type:"structure"` + // The ID of the virtual private gateway. GatewayId *string `type:"string" required:"true"` // The ID of the route table. RouteTableId *string `type:"string" required:"true"` - - metadataEnableVgwRoutePropagationInput `json:"-" xml:"-"` -} - -type metadataEnableVgwRoutePropagationInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -16162,11 +15396,7 @@ func (s EnableVgwRoutePropagationInput) GoString() string { } type EnableVgwRoutePropagationOutput struct { - metadataEnableVgwRoutePropagationOutput `json:"-" xml:"-"` -} - -type metadataEnableVgwRoutePropagationOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -16180,6 +15410,8 @@ func (s EnableVgwRoutePropagationOutput) GoString() string { } type EnableVolumeIOInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -16188,12 +15420,6 @@ type EnableVolumeIOInput struct { // The ID of the volume. VolumeId *string `locationName:"volumeId" type:"string" required:"true"` - - metadataEnableVolumeIOInput `json:"-" xml:"-"` -} - -type metadataEnableVolumeIOInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -16207,11 +15433,7 @@ func (s EnableVolumeIOInput) GoString() string { } type EnableVolumeIOOutput struct { - metadataEnableVolumeIOOutput `json:"-" xml:"-"` -} - -type metadataEnableVolumeIOOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -16225,6 +15447,8 @@ func (s EnableVolumeIOOutput) GoString() string { } type EnableVpcClassicLinkInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -16233,12 +15457,6 @@ type EnableVpcClassicLinkInput struct { // The ID of the VPC. VpcId *string `locationName:"vpcId" type:"string" required:"true"` - - metadataEnableVpcClassicLinkInput `json:"-" xml:"-"` -} - -type metadataEnableVpcClassicLinkInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -16252,14 +15470,10 @@ func (s EnableVpcClassicLinkInput) GoString() string { } type EnableVpcClassicLinkOutput struct { + _ struct{} `type:"structure"` + // Returns true if the request succeeds; otherwise, it returns an error. Return *bool `locationName:"return" type:"boolean"` - - metadataEnableVpcClassicLinkOutput `json:"-" xml:"-"` -} - -type metadataEnableVpcClassicLinkOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -16274,6 +15488,8 @@ func (s EnableVpcClassicLinkOutput) GoString() string { // Describes a Spot fleet event. type EventInformation struct { + _ struct{} `type:"structure"` + // The description of the event. EventDescription *string `locationName:"eventDescription" type:"string"` @@ -16334,12 +15550,6 @@ type EventInformation struct { // The ID of the instance. This information is available only for instanceChange // events. InstanceId *string `locationName:"instanceId" type:"string"` - - metadataEventInformation `json:"-" xml:"-"` -} - -type metadataEventInformation struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -16354,6 +15564,8 @@ func (s EventInformation) GoString() string { // Describes an instance export task. type ExportTask struct { + _ struct{} `type:"structure"` + // A description of the resource being exported. Description *string `locationName:"description" type:"string"` @@ -16371,12 +15583,6 @@ type ExportTask struct { // The status message related to the export task. StatusMessage *string `locationName:"statusMessage" type:"string"` - - metadataExportTask `json:"-" xml:"-"` -} - -type metadataExportTask struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -16391,6 +15597,8 @@ func (s ExportTask) GoString() string { // Describes the format and location for an instance export task. type ExportToS3Task struct { + _ struct{} `type:"structure"` + // The container format used to combine disk images with metadata (such as OVF). // If absent, only the disk image is exported. ContainerFormat *string `locationName:"containerFormat" type:"string" enum:"ContainerFormat"` @@ -16404,12 +15612,6 @@ type ExportToS3Task struct { // The encryption key for your S3 bucket. S3Key *string `locationName:"s3Key" type:"string"` - - metadataExportToS3Task `json:"-" xml:"-"` -} - -type metadataExportToS3Task struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -16424,6 +15626,8 @@ func (s ExportToS3Task) GoString() string { // Describes an instance export task. type ExportToS3TaskSpecification struct { + _ struct{} `type:"structure"` + // The container format used to combine disk images with metadata (such as OVF). // If absent, only the disk image is exported. ContainerFormat *string `locationName:"containerFormat" type:"string" enum:"ContainerFormat"` @@ -16438,12 +15642,6 @@ type ExportToS3TaskSpecification struct { // The image is written to a single object in the S3 bucket at the S3 key s3prefix // + exportTaskId + '.' + diskImageFormat. S3Prefix *string `locationName:"s3Prefix" type:"string"` - - metadataExportToS3TaskSpecification `json:"-" xml:"-"` -} - -type metadataExportToS3TaskSpecification struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -16460,17 +15658,13 @@ func (s ExportToS3TaskSpecification) GoString() string { // of results. Filters can be used to match a set of resources by various criteria, // such as tags, attributes, or IDs. type Filter struct { + _ struct{} `type:"structure"` + // The name of the filter. Filter names are case-sensitive. Name *string `type:"string"` // One or more filter values. Filter values are case-sensitive. Values []*string `locationName:"Value" locationNameList:"item" type:"list"` - - metadataFilter `json:"-" xml:"-"` -} - -type metadataFilter struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -16485,6 +15679,8 @@ func (s Filter) GoString() string { // Describes a flow log. type FlowLog struct { + _ struct{} `type:"structure"` + // The date and time the flow log was created. CreationTime *time.Time `locationName:"creationTime" type:"timestamp" timestampFormat:"iso8601"` @@ -16515,12 +15711,6 @@ type FlowLog struct { // The type of traffic captured for the flow log. TrafficType *string `locationName:"trafficType" type:"string" enum:"TrafficType"` - - metadataFlowLog `json:"-" xml:"-"` -} - -type metadataFlowLog struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -16534,6 +15724,8 @@ func (s FlowLog) GoString() string { } type GetConsoleOutputInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -16542,12 +15734,6 @@ type GetConsoleOutputInput struct { // The ID of the instance. InstanceId *string `type:"string" required:"true"` - - metadataGetConsoleOutputInput `json:"-" xml:"-"` -} - -type metadataGetConsoleOutputInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -16561,6 +15747,8 @@ func (s GetConsoleOutputInput) GoString() string { } type GetConsoleOutputOutput struct { + _ struct{} `type:"structure"` + // The ID of the instance. InstanceId *string `locationName:"instanceId" type:"string"` @@ -16569,12 +15757,6 @@ type GetConsoleOutputOutput struct { // The time the output was last updated. Timestamp *time.Time `locationName:"timestamp" type:"timestamp" timestampFormat:"iso8601"` - - metadataGetConsoleOutputOutput `json:"-" xml:"-"` -} - -type metadataGetConsoleOutputOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -16588,6 +15770,8 @@ func (s GetConsoleOutputOutput) GoString() string { } type GetPasswordDataInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -16596,12 +15780,6 @@ type GetPasswordDataInput struct { // The ID of the Windows instance. InstanceId *string `type:"string" required:"true"` - - metadataGetPasswordDataInput `json:"-" xml:"-"` -} - -type metadataGetPasswordDataInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -16615,6 +15793,8 @@ func (s GetPasswordDataInput) GoString() string { } type GetPasswordDataOutput struct { + _ struct{} `type:"structure"` + // The ID of the Windows instance. InstanceId *string `locationName:"instanceId" type:"string"` @@ -16623,12 +15803,6 @@ type GetPasswordDataOutput struct { // The time the data was last updated. Timestamp *time.Time `locationName:"timestamp" type:"timestamp" timestampFormat:"iso8601"` - - metadataGetPasswordDataOutput `json:"-" xml:"-"` -} - -type metadataGetPasswordDataOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -16643,17 +15817,13 @@ func (s GetPasswordDataOutput) GoString() string { // Describes a security group. type GroupIdentifier struct { + _ struct{} `type:"structure"` + // The ID of the security group. GroupId *string `locationName:"groupId" type:"string"` // The name of the security group. GroupName *string `locationName:"groupName" type:"string"` - - metadataGroupIdentifier `json:"-" xml:"-"` -} - -type metadataGroupIdentifier struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -16668,6 +15838,8 @@ func (s GroupIdentifier) GoString() string { // Describes an event in the history of the Spot fleet request. type HistoryRecord struct { + _ struct{} `type:"structure"` + // Information about the event. EventInformation *EventInformation `locationName:"eventInformation" type:"structure" required:"true"` @@ -16683,12 +15855,6 @@ type HistoryRecord struct { // The date and time of the event, in UTC format (for example, YYYY-MM-DDTHH:MM:SSZ). Timestamp *time.Time `locationName:"timestamp" type:"timestamp" timestampFormat:"iso8601" required:"true"` - - metadataHistoryRecord `json:"-" xml:"-"` -} - -type metadataHistoryRecord struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -16701,19 +15867,105 @@ func (s HistoryRecord) GoString() string { return s.String() } +type Host struct { + _ struct{} `type:"structure"` + + // Whether auto-placement is on or off. + AutoPlacement *string `locationName:"autoPlacement" type:"string" enum:"AutoPlacement"` + + // The Availability Zone of the Dedicated host. + AvailabilityZone *string `locationName:"availabilityZone" type:"string"` + + // The number of new instances that can be launched onto the Dedicated host. + AvailableCapacity *AvailableCapacity `locationName:"availableCapacity" type:"structure"` + + // Unique, case-sensitive identifier you provide to ensure idempotency of the + // request. For more information, see How to Ensure Idempotency (http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Run_Instance_Idempotency.html) + // in the Amazon Elastic Compute Cloud User Guide. + ClientToken *string `locationName:"clientToken" type:"string"` + + // The ID of the Dedicated host. + HostId *string `locationName:"hostId" type:"string"` + + // The hardware specifications of the Dedicated host. + HostProperties *HostProperties `locationName:"hostProperties" type:"structure"` + + // The reservation ID of the Dedicated host. This returns a "null" response + // if the Dedicated host doesn't have an associated reservation. + HostReservationId *string `locationName:"hostReservationId" type:"string"` + + // The IDs and instance type that are currently running on the Dedicated host. + Instances []*HostInstance `locationName:"instances" locationNameList:"item" type:"list"` + + // The Dedicated host's state. Can be "available", "under assessment, or "released". + State *string `locationName:"state" type:"string" enum:"AllocationState"` +} + +// String returns the string representation +func (s Host) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s Host) GoString() string { + return s.String() +} + +type HostInstance struct { + _ struct{} `type:"structure"` + + // the IDs of instances that are running on the Dedicated host. + InstanceId *string `locationName:"instanceId" type:"string"` + + // The instance type size (e.g., m3.medium) of the running instance. + InstanceType *string `locationName:"instanceType" type:"string"` +} + +// String returns the string representation +func (s HostInstance) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s HostInstance) GoString() string { + return s.String() +} + +type HostProperties struct { + _ struct{} `type:"structure"` + + // The number of cores on the Dedicated host. + Cores *int64 `locationName:"cores" type:"integer"` + + // The instance type size that the Dedicated host supports (e.g., m3.medium). + InstanceType *string `locationName:"instanceType" type:"string"` + + // The number of sockets on the Dedicated host. + Sockets *int64 `locationName:"sockets" type:"integer"` + + // The number of vCPUs on the Dedicated host. + TotalVCpus *int64 `locationName:"totalVCpus" type:"integer"` +} + +// String returns the string representation +func (s HostProperties) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s HostProperties) GoString() string { + return s.String() +} + // Describes an IAM instance profile. type IamInstanceProfile struct { + _ struct{} `type:"structure"` + // The Amazon Resource Name (ARN) of the instance profile. Arn *string `locationName:"arn" type:"string"` // The ID of the instance profile. Id *string `locationName:"id" type:"string"` - - metadataIamInstanceProfile `json:"-" xml:"-"` -} - -type metadataIamInstanceProfile struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -16728,17 +15980,13 @@ func (s IamInstanceProfile) GoString() string { // Describes an IAM instance profile. type IamInstanceProfileSpecification struct { + _ struct{} `type:"structure"` + // The Amazon Resource Name (ARN) of the instance profile. Arn *string `locationName:"arn" type:"string"` // The name of the instance profile. Name *string `locationName:"name" type:"string"` - - metadataIamInstanceProfileSpecification `json:"-" xml:"-"` -} - -type metadataIamInstanceProfileSpecification struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -16753,17 +16001,13 @@ func (s IamInstanceProfileSpecification) GoString() string { // Describes the ICMP type and code. type IcmpTypeCode struct { + _ struct{} `type:"structure"` + // The ICMP type. A value of -1 means all types. Code *int64 `locationName:"code" type:"integer"` // The ICMP code. A value of -1 means all codes for the specified ICMP type. Type *int64 `locationName:"type" type:"integer"` - - metadataIcmpTypeCode `json:"-" xml:"-"` -} - -type metadataIcmpTypeCode struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -16776,8 +16020,35 @@ func (s IcmpTypeCode) GoString() string { return s.String() } +// Describes the ID format for a resource. +type IdFormat struct { + _ struct{} `type:"structure"` + + // The date in UTC at which you are permanently switched over to using longer + // IDs. + Deadline *time.Time `locationName:"deadline" type:"timestamp" timestampFormat:"iso8601"` + + // The type of resource. + Resource *string `locationName:"resource" type:"string"` + + // Indicates whether longer IDs (17-character IDs) are enabled for the resource. + UseLongIds *bool `locationName:"useLongIds" type:"boolean"` +} + +// String returns the string representation +func (s IdFormat) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s IdFormat) GoString() string { + return s.String() +} + // Describes an image. type Image struct { + _ struct{} `type:"structure"` + // The architecture of the image. Architecture *string `locationName:"architecture" type:"string" enum:"ArchitectureValues"` @@ -16853,12 +16124,6 @@ type Image struct { // The type of virtualization of the AMI. VirtualizationType *string `locationName:"virtualizationType" type:"string" enum:"VirtualizationType"` - - metadataImage `json:"-" xml:"-"` -} - -type metadataImage struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -16873,6 +16138,8 @@ func (s Image) GoString() string { // Describes the disk container object for an import image task. type ImageDiskContainer struct { + _ struct{} `type:"structure"` + // The description of the disk image. Description *string `type:"string"` @@ -16893,12 +16160,6 @@ type ImageDiskContainer struct { // The S3 bucket for the disk image. UserBucket *UserBucket `type:"structure"` - - metadataImageDiskContainer `json:"-" xml:"-"` -} - -type metadataImageDiskContainer struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -16912,6 +16173,8 @@ func (s ImageDiskContainer) GoString() string { } type ImportImageInput struct { + _ struct{} `type:"structure"` + // The architecture of the virtual machine. // // Valid values: i386 | x86_64 @@ -16957,12 +16220,6 @@ type ImportImageInput struct { // The name of the role to use when not using the default role, 'vmimport'. RoleName *string `type:"string"` - - metadataImportImageInput `json:"-" xml:"-"` -} - -type metadataImportImageInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -16976,6 +16233,8 @@ func (s ImportImageInput) GoString() string { } type ImportImageOutput struct { + _ struct{} `type:"structure"` + // The architecture of the virtual machine. Architecture *string `locationName:"architecture" type:"string"` @@ -17008,12 +16267,6 @@ type ImportImageOutput struct { // A detailed status message of the import task. StatusMessage *string `locationName:"statusMessage" type:"string"` - - metadataImportImageOutput `json:"-" xml:"-"` -} - -type metadataImportImageOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -17028,6 +16281,8 @@ func (s ImportImageOutput) GoString() string { // Describes an import image task. type ImportImageTask struct { + _ struct{} `type:"structure"` + // The architecture of the virtual machine. // // Valid values: i386 | x86_64 @@ -17064,12 +16319,6 @@ type ImportImageTask struct { // A descriptive status message for the import image task. StatusMessage *string `locationName:"statusMessage" type:"string"` - - metadataImportImageTask `json:"-" xml:"-"` -} - -type metadataImportImageTask struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -17083,6 +16332,8 @@ func (s ImportImageTask) GoString() string { } type ImportInstanceInput struct { + _ struct{} `type:"structure"` + // A description for the instance being imported. Description *string `locationName:"description" type:"string"` @@ -17100,12 +16351,6 @@ type ImportInstanceInput struct { // The instance operating system. Platform *string `locationName:"platform" type:"string" required:"true" enum:"PlatformValues"` - - metadataImportInstanceInput `json:"-" xml:"-"` -} - -type metadataImportInstanceInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -17120,6 +16365,8 @@ func (s ImportInstanceInput) GoString() string { // Describes the launch specification for VM import. type ImportInstanceLaunchSpecification struct { + _ struct{} `type:"structure"` + // Reserved. AdditionalInfo *string `locationName:"additionalInfo" type:"string"` @@ -17155,12 +16402,6 @@ type ImportInstanceLaunchSpecification struct { // The Base64-encoded MIME user data to be made available to the instance. UserData *UserData `locationName:"userData" type:"structure"` - - metadataImportInstanceLaunchSpecification `json:"-" xml:"-"` -} - -type metadataImportInstanceLaunchSpecification struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -17174,14 +16415,10 @@ func (s ImportInstanceLaunchSpecification) GoString() string { } type ImportInstanceOutput struct { + _ struct{} `type:"structure"` + // Information about the conversion task. ConversionTask *ConversionTask `locationName:"conversionTask" type:"structure"` - - metadataImportInstanceOutput `json:"-" xml:"-"` -} - -type metadataImportInstanceOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -17196,6 +16433,8 @@ func (s ImportInstanceOutput) GoString() string { // Describes an import instance task. type ImportInstanceTaskDetails struct { + _ struct{} `type:"structure"` + // A description of the task. Description *string `locationName:"description" type:"string"` @@ -17207,12 +16446,6 @@ type ImportInstanceTaskDetails struct { // One or more volumes. Volumes []*ImportInstanceVolumeDetailItem `locationName:"volumes" locationNameList:"item" type:"list" required:"true"` - - metadataImportInstanceTaskDetails `json:"-" xml:"-"` -} - -type metadataImportInstanceTaskDetails struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -17227,6 +16460,8 @@ func (s ImportInstanceTaskDetails) GoString() string { // Describes an import volume task. type ImportInstanceVolumeDetailItem struct { + _ struct{} `type:"structure"` + // The Availability Zone where the resulting instance will reside. AvailabilityZone *string `locationName:"availabilityZone" type:"string" required:"true"` @@ -17247,12 +16482,6 @@ type ImportInstanceVolumeDetailItem struct { // The volume. Volume *DiskImageVolumeDescription `locationName:"volume" type:"structure" required:"true"` - - metadataImportInstanceVolumeDetailItem `json:"-" xml:"-"` -} - -type metadataImportInstanceVolumeDetailItem struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -17266,6 +16495,8 @@ func (s ImportInstanceVolumeDetailItem) GoString() string { } type ImportKeyPairInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -17278,12 +16509,6 @@ type ImportKeyPairInput struct { // The public key. You must base64 encode the public key material before sending // it to AWS. PublicKeyMaterial []byte `locationName:"publicKeyMaterial" type:"blob" required:"true"` - - metadataImportKeyPairInput `json:"-" xml:"-"` -} - -type metadataImportKeyPairInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -17297,17 +16522,13 @@ func (s ImportKeyPairInput) GoString() string { } type ImportKeyPairOutput struct { + _ struct{} `type:"structure"` + // The MD5 public key fingerprint as specified in section 4 of RFC 4716. KeyFingerprint *string `locationName:"keyFingerprint" type:"string"` // The key pair name you provided. KeyName *string `locationName:"keyName" type:"string"` - - metadataImportKeyPairOutput `json:"-" xml:"-"` -} - -type metadataImportKeyPairOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -17321,6 +16542,8 @@ func (s ImportKeyPairOutput) GoString() string { } type ImportSnapshotInput struct { + _ struct{} `type:"structure"` + // The client-specific data. ClientData *ClientData `type:"structure"` @@ -17341,12 +16564,6 @@ type ImportSnapshotInput struct { // The name of the role to use when not using the default role, 'vmimport'. RoleName *string `type:"string"` - - metadataImportSnapshotInput `json:"-" xml:"-"` -} - -type metadataImportSnapshotInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -17360,6 +16577,8 @@ func (s ImportSnapshotInput) GoString() string { } type ImportSnapshotOutput struct { + _ struct{} `type:"structure"` + // A description of the import snapshot task. Description *string `locationName:"description" type:"string"` @@ -17368,12 +16587,6 @@ type ImportSnapshotOutput struct { // Information about the import snapshot task. SnapshotTaskDetail *SnapshotTaskDetail `locationName:"snapshotTaskDetail" type:"structure"` - - metadataImportSnapshotOutput `json:"-" xml:"-"` -} - -type metadataImportSnapshotOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -17388,6 +16601,8 @@ func (s ImportSnapshotOutput) GoString() string { // Describes an import snapshot task. type ImportSnapshotTask struct { + _ struct{} `type:"structure"` + // A description of the import snapshot task. Description *string `locationName:"description" type:"string"` @@ -17396,12 +16611,6 @@ type ImportSnapshotTask struct { // Describes an import snapshot task. SnapshotTaskDetail *SnapshotTaskDetail `locationName:"snapshotTaskDetail" type:"structure"` - - metadataImportSnapshotTask `json:"-" xml:"-"` -} - -type metadataImportSnapshotTask struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -17415,6 +16624,8 @@ func (s ImportSnapshotTask) GoString() string { } type ImportVolumeInput struct { + _ struct{} `type:"structure"` + // The Availability Zone for the resulting EBS volume. AvailabilityZone *string `locationName:"availabilityZone" type:"string" required:"true"` @@ -17432,12 +16643,6 @@ type ImportVolumeInput struct { // The volume size. Volume *VolumeDetail `locationName:"volume" type:"structure" required:"true"` - - metadataImportVolumeInput `json:"-" xml:"-"` -} - -type metadataImportVolumeInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -17451,14 +16656,10 @@ func (s ImportVolumeInput) GoString() string { } type ImportVolumeOutput struct { + _ struct{} `type:"structure"` + // Information about the conversion task. ConversionTask *ConversionTask `locationName:"conversionTask" type:"structure"` - - metadataImportVolumeOutput `json:"-" xml:"-"` -} - -type metadataImportVolumeOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -17473,6 +16674,8 @@ func (s ImportVolumeOutput) GoString() string { // Describes an import volume task. type ImportVolumeTaskDetails struct { + _ struct{} `type:"structure"` + // The Availability Zone where the resulting volume will reside. AvailabilityZone *string `locationName:"availabilityZone" type:"string" required:"true"` @@ -17487,12 +16690,6 @@ type ImportVolumeTaskDetails struct { // The volume. Volume *DiskImageVolumeDescription `locationName:"volume" type:"structure" required:"true"` - - metadataImportVolumeTaskDetails `json:"-" xml:"-"` -} - -type metadataImportVolumeTaskDetails struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -17507,6 +16704,8 @@ func (s ImportVolumeTaskDetails) GoString() string { // Describes an instance. type Instance struct { + _ struct{} `type:"structure"` + // The AMI launch index, which can be used to find this instance in the launch // group. AmiLaunchIndex *int64 `locationName:"amiLaunchIndex" type:"integer"` @@ -17539,7 +16738,7 @@ type Instance struct { // The ID of the instance. InstanceId *string `locationName:"instanceId" type:"string"` - // Indicates whether this is a Spot Instance. + // Indicates whether this is a Spot instance. InstanceLifecycle *string `locationName:"instanceLifecycle" type:"string" enum:"InstanceLifecycleType"` // The instance type. @@ -17634,12 +16833,6 @@ type Instance struct { // [EC2-VPC] The ID of the VPC in which the instance is running. VpcId *string `locationName:"vpcId" type:"string"` - - metadataInstance `json:"-" xml:"-"` -} - -type metadataInstance struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -17654,18 +16847,14 @@ func (s Instance) GoString() string { // Describes a block device mapping. type InstanceBlockDeviceMapping struct { + _ struct{} `type:"structure"` + // The device name exposed to the instance (for example, /dev/sdh or xvdh). DeviceName *string `locationName:"deviceName" type:"string"` // Parameters used to automatically set up EBS volumes when the instance is // launched. Ebs *EbsInstanceBlockDevice `locationName:"ebs" type:"structure"` - - metadataInstanceBlockDeviceMapping `json:"-" xml:"-"` -} - -type metadataInstanceBlockDeviceMapping struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -17680,6 +16869,8 @@ func (s InstanceBlockDeviceMapping) GoString() string { // Describes a block device mapping entry. type InstanceBlockDeviceMappingSpecification struct { + _ struct{} `type:"structure"` + // The device name exposed to the instance (for example, /dev/sdh or xvdh). DeviceName *string `locationName:"deviceName" type:"string"` @@ -17692,12 +16883,6 @@ type InstanceBlockDeviceMappingSpecification struct { // The virtual device name. VirtualName *string `locationName:"virtualName" type:"string"` - - metadataInstanceBlockDeviceMappingSpecification `json:"-" xml:"-"` -} - -type metadataInstanceBlockDeviceMappingSpecification struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -17710,19 +16895,38 @@ func (s InstanceBlockDeviceMappingSpecification) GoString() string { return s.String() } -// Describes a Reserved Instance listing state. -type InstanceCount struct { - // The number of listed Reserved Instances in the state specified by the state. - InstanceCount *int64 `locationName:"instanceCount" type:"integer"` +type InstanceCapacity struct { + _ struct{} `type:"structure"` - // The states of the listed Reserved Instances. - State *string `locationName:"state" type:"string" enum:"ListingState"` + // The number of instances that can still be launched onto the Dedicated host. + AvailableCapacity *int64 `locationName:"availableCapacity" type:"integer"` - metadataInstanceCount `json:"-" xml:"-"` + // The instance type size supported by the Dedicated host. + InstanceType *string `locationName:"instanceType" type:"string"` + + // The total number of instances that can be launched onto the Dedicated host. + TotalCapacity *int64 `locationName:"totalCapacity" type:"integer"` } -type metadataInstanceCount struct { - SDKShapeTraits bool `type:"structure"` +// String returns the string representation +func (s InstanceCapacity) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s InstanceCapacity) GoString() string { + return s.String() +} + +// Describes a Reserved instance listing state. +type InstanceCount struct { + _ struct{} `type:"structure"` + + // The number of listed Reserved instances in the state specified by the state. + InstanceCount *int64 `locationName:"instanceCount" type:"integer"` + + // The states of the listed Reserved instances. + State *string `locationName:"state" type:"string" enum:"ListingState"` } // String returns the string representation @@ -17737,17 +16941,13 @@ func (s InstanceCount) GoString() string { // Describes an instance to export. type InstanceExportDetails struct { + _ struct{} `type:"structure"` + // The ID of the resource being exported. InstanceId *string `locationName:"instanceId" type:"string"` // The target virtualization environment. TargetEnvironment *string `locationName:"targetEnvironment" type:"string" enum:"ExportEnvironment"` - - metadataInstanceExportDetails `json:"-" xml:"-"` -} - -type metadataInstanceExportDetails struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -17762,17 +16962,13 @@ func (s InstanceExportDetails) GoString() string { // Describes the monitoring information of the instance. type InstanceMonitoring struct { + _ struct{} `type:"structure"` + // The ID of the instance. InstanceId *string `locationName:"instanceId" type:"string"` // The monitoring information. Monitoring *Monitoring `locationName:"monitoring" type:"structure"` - - metadataInstanceMonitoring `json:"-" xml:"-"` -} - -type metadataInstanceMonitoring struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -17787,6 +16983,8 @@ func (s InstanceMonitoring) GoString() string { // Describes a network interface. type InstanceNetworkInterface struct { + _ struct{} `type:"structure"` + // The association information for an Elastic IP associated with the network // interface. Association *InstanceNetworkInterfaceAssociation `locationName:"association" type:"structure"` @@ -17829,12 +17027,6 @@ type InstanceNetworkInterface struct { // The ID of the VPC. VpcId *string `locationName:"vpcId" type:"string"` - - metadataInstanceNetworkInterface `json:"-" xml:"-"` -} - -type metadataInstanceNetworkInterface struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -17849,6 +17041,8 @@ func (s InstanceNetworkInterface) GoString() string { // Describes association information for an Elastic IP address. type InstanceNetworkInterfaceAssociation struct { + _ struct{} `type:"structure"` + // The ID of the owner of the Elastic IP address. IpOwnerId *string `locationName:"ipOwnerId" type:"string"` @@ -17857,12 +17051,6 @@ type InstanceNetworkInterfaceAssociation struct { // The public IP address or Elastic IP address bound to the network interface. PublicIp *string `locationName:"publicIp" type:"string"` - - metadataInstanceNetworkInterfaceAssociation `json:"-" xml:"-"` -} - -type metadataInstanceNetworkInterfaceAssociation struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -17877,6 +17065,8 @@ func (s InstanceNetworkInterfaceAssociation) GoString() string { // Describes a network interface attachment. type InstanceNetworkInterfaceAttachment struct { + _ struct{} `type:"structure"` + // The time stamp when the attachment initiated. AttachTime *time.Time `locationName:"attachTime" type:"timestamp" timestampFormat:"iso8601"` @@ -17891,12 +17081,6 @@ type InstanceNetworkInterfaceAttachment struct { // The attachment state. Status *string `locationName:"status" type:"string" enum:"AttachmentStatus"` - - metadataInstanceNetworkInterfaceAttachment `json:"-" xml:"-"` -} - -type metadataInstanceNetworkInterfaceAttachment struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -17911,6 +17095,8 @@ func (s InstanceNetworkInterfaceAttachment) GoString() string { // Describes a network interface. type InstanceNetworkInterfaceSpecification struct { + _ struct{} `type:"structure"` + // Indicates whether to assign a public IP address to an instance you launch // in a VPC. The public IP address can only be assigned to a network interface // for eth0, and can only be assigned to a new network interface, not an existing @@ -17955,12 +17141,6 @@ type InstanceNetworkInterfaceSpecification struct { // The ID of the subnet associated with the network string. Applies only if // creating a network interface when launching an instance. SubnetId *string `locationName:"subnetId" type:"string"` - - metadataInstanceNetworkInterfaceSpecification `json:"-" xml:"-"` -} - -type metadataInstanceNetworkInterfaceSpecification struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -17975,6 +17155,8 @@ func (s InstanceNetworkInterfaceSpecification) GoString() string { // Describes a private IP address. type InstancePrivateIpAddress struct { + _ struct{} `type:"structure"` + // The association information for an Elastic IP address for the network interface. Association *InstanceNetworkInterfaceAssociation `locationName:"association" type:"structure"` @@ -17987,12 +17169,6 @@ type InstancePrivateIpAddress struct { // The private IP address of the network interface. PrivateIpAddress *string `locationName:"privateIpAddress" type:"string"` - - metadataInstancePrivateIpAddress `json:"-" xml:"-"` -} - -type metadataInstancePrivateIpAddress struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -18007,6 +17183,8 @@ func (s InstancePrivateIpAddress) GoString() string { // Describes the current state of the instance. type InstanceState struct { + _ struct{} `type:"structure"` + // The low byte represents the state. The high byte is an opaque internal value // and should be ignored. // @@ -18025,12 +17203,6 @@ type InstanceState struct { // The current state of the instance. Name *string `locationName:"name" type:"string" enum:"InstanceStateName"` - - metadataInstanceState `json:"-" xml:"-"` -} - -type metadataInstanceState struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -18045,6 +17217,8 @@ func (s InstanceState) GoString() string { // Describes an instance state change. type InstanceStateChange struct { + _ struct{} `type:"structure"` + // The current state of the instance. CurrentState *InstanceState `locationName:"currentState" type:"structure"` @@ -18053,12 +17227,6 @@ type InstanceStateChange struct { // The previous state of the instance. PreviousState *InstanceState `locationName:"previousState" type:"structure"` - - metadataInstanceStateChange `json:"-" xml:"-"` -} - -type metadataInstanceStateChange struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -18073,6 +17241,8 @@ func (s InstanceStateChange) GoString() string { // Describes the status of an instance. type InstanceStatus struct { + _ struct{} `type:"structure"` + // The Availability Zone of the instance. AvailabilityZone *string `locationName:"availabilityZone" type:"string"` @@ -18094,12 +17264,6 @@ type InstanceStatus struct { // that support an instance, such as hardware failures and network connectivity // problems. SystemStatus *InstanceStatusSummary `locationName:"systemStatus" type:"structure"` - - metadataInstanceStatus `json:"-" xml:"-"` -} - -type metadataInstanceStatus struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -18114,6 +17278,8 @@ func (s InstanceStatus) GoString() string { // Describes the instance status. type InstanceStatusDetails struct { + _ struct{} `type:"structure"` + // The time when a status check failed. For an instance that was launched and // impaired, this is the time when the instance was launched. ImpairedSince *time.Time `locationName:"impairedSince" type:"timestamp" timestampFormat:"iso8601"` @@ -18123,12 +17289,6 @@ type InstanceStatusDetails struct { // The status. Status *string `locationName:"status" type:"string" enum:"StatusType"` - - metadataInstanceStatusDetails `json:"-" xml:"-"` -} - -type metadataInstanceStatusDetails struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -18143,6 +17303,8 @@ func (s InstanceStatusDetails) GoString() string { // Describes a scheduled event for an instance. type InstanceStatusEvent struct { + _ struct{} `type:"structure"` + // The event code. Code *string `locationName:"code" type:"string" enum:"EventCode"` @@ -18158,12 +17320,6 @@ type InstanceStatusEvent struct { // The earliest scheduled start time for the event. NotBefore *time.Time `locationName:"notBefore" type:"timestamp" timestampFormat:"iso8601"` - - metadataInstanceStatusEvent `json:"-" xml:"-"` -} - -type metadataInstanceStatusEvent struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -18178,17 +17334,13 @@ func (s InstanceStatusEvent) GoString() string { // Describes the status of an instance. type InstanceStatusSummary struct { + _ struct{} `type:"structure"` + // The system instance health or application instance health. Details []*InstanceStatusDetails `locationName:"details" locationNameList:"item" type:"list"` // The status. Status *string `locationName:"status" type:"string" enum:"SummaryStatus"` - - metadataInstanceStatusSummary `json:"-" xml:"-"` -} - -type metadataInstanceStatusSummary struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -18203,6 +17355,8 @@ func (s InstanceStatusSummary) GoString() string { // Describes an Internet gateway. type InternetGateway struct { + _ struct{} `type:"structure"` + // Any VPCs attached to the Internet gateway. Attachments []*InternetGatewayAttachment `locationName:"attachmentSet" locationNameList:"item" type:"list"` @@ -18211,12 +17365,6 @@ type InternetGateway struct { // Any tags assigned to the Internet gateway. Tags []*Tag `locationName:"tagSet" locationNameList:"item" type:"list"` - - metadataInternetGateway `json:"-" xml:"-"` -} - -type metadataInternetGateway struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -18231,17 +17379,13 @@ func (s InternetGateway) GoString() string { // Describes the attachment of a VPC to an Internet gateway. type InternetGatewayAttachment struct { + _ struct{} `type:"structure"` + // The current state of the attachment. State *string `locationName:"state" type:"string" enum:"AttachmentStatus"` // The ID of the VPC. VpcId *string `locationName:"vpcId" type:"string"` - - metadataInternetGatewayAttachment `json:"-" xml:"-"` -} - -type metadataInternetGatewayAttachment struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -18256,6 +17400,8 @@ func (s InternetGatewayAttachment) GoString() string { // Describes a security group rule. type IpPermission struct { + _ struct{} `type:"structure"` + // The start of port range for the TCP and UDP protocols, or an ICMP type number. // A value of -1 indicates all ICMP types. FromPort *int64 `locationName:"fromPort" type:"integer"` @@ -18285,12 +17431,6 @@ type IpPermission struct { // One or more security group and AWS account ID pairs. UserIdGroupPairs []*UserIdGroupPair `locationName:"groups" locationNameList:"item" type:"list"` - - metadataIpPermission `json:"-" xml:"-"` -} - -type metadataIpPermission struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -18305,15 +17445,11 @@ func (s IpPermission) GoString() string { // Describes an IP range. type IpRange struct { + _ struct{} `type:"structure"` + // The CIDR range. You can either specify a CIDR range or a source security // group, not both. CidrIp *string `locationName:"cidrIp" type:"string"` - - metadataIpRange `json:"-" xml:"-"` -} - -type metadataIpRange struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -18328,6 +17464,8 @@ func (s IpRange) GoString() string { // Describes a key pair. type KeyPairInfo struct { + _ struct{} `type:"structure"` + // If you used CreateKeyPair to create the key pair, this is the SHA-1 digest // of the DER encoded private key. If you used ImportKeyPair to provide AWS // the public key, this is the MD5 public key fingerprint as specified in section @@ -18336,12 +17474,6 @@ type KeyPairInfo struct { // The name of the key pair. KeyName *string `locationName:"keyName" type:"string"` - - metadataKeyPairInfo `json:"-" xml:"-"` -} - -type metadataKeyPairInfo struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -18356,17 +17488,13 @@ func (s KeyPairInfo) GoString() string { // Describes a launch permission. type LaunchPermission struct { + _ struct{} `type:"structure"` + // The name of the group. Group *string `locationName:"group" type:"string" enum:"PermissionGroup"` // The AWS account ID. UserId *string `locationName:"userId" type:"string"` - - metadataLaunchPermission `json:"-" xml:"-"` -} - -type metadataLaunchPermission struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -18381,18 +17509,14 @@ func (s LaunchPermission) GoString() string { // Describes a launch permission modification. type LaunchPermissionModifications struct { + _ struct{} `type:"structure"` + // The AWS account ID to add to the list of launch permissions for the AMI. Add []*LaunchPermission `locationNameList:"item" type:"list"` // The AWS account ID to remove from the list of launch permissions for the // AMI. Remove []*LaunchPermission `locationNameList:"item" type:"list"` - - metadataLaunchPermissionModifications `json:"-" xml:"-"` -} - -type metadataLaunchPermissionModifications struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -18407,6 +17531,8 @@ func (s LaunchPermissionModifications) GoString() string { // Describes the launch specification for an instance. type LaunchSpecification struct { + _ struct{} `type:"structure"` + // Deprecated. AddressingType *string `locationName:"addressingType" type:"string"` @@ -18459,12 +17585,6 @@ type LaunchSpecification struct { // The Base64-encoded MIME user data to make available to the instances. UserData *string `locationName:"userData" type:"string"` - - metadataLaunchSpecification `json:"-" xml:"-"` -} - -type metadataLaunchSpecification struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -18477,7 +17597,84 @@ func (s LaunchSpecification) GoString() string { return s.String() } +type ModifyHostsInput struct { + _ struct{} `type:"structure"` + + // Specify whether to enable or disable auto-placement. + AutoPlacement *string `locationName:"autoPlacement" type:"string" required:"true" enum:"AutoPlacement"` + + // The host IDs of the Dedicated hosts you want to modify. + HostIds []*string `locationName:"hostId" locationNameList:"item" type:"list" required:"true"` +} + +// String returns the string representation +func (s ModifyHostsInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ModifyHostsInput) GoString() string { + return s.String() +} + +type ModifyHostsOutput struct { + _ struct{} `type:"structure"` + + // The IDs of the Dedicated hosts that were successfully modified. + Successful []*string `locationName:"successful" locationNameList:"item" type:"list"` + + // The IDs of the Dedicated hosts that could not be modified. Check whether + // the setting you requested can be used. + Unsuccessful []*UnsuccessfulItem `locationName:"unsuccessful" locationNameList:"item" type:"list"` +} + +// String returns the string representation +func (s ModifyHostsOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ModifyHostsOutput) GoString() string { + return s.String() +} + +type ModifyIdFormatInput struct { + _ struct{} `type:"structure"` + + // The type of resource. + Resource *string `type:"string" required:"true"` + + // Indicate whether the resource should use longer IDs (17-character IDs). + UseLongIds *bool `type:"boolean" required:"true"` +} + +// String returns the string representation +func (s ModifyIdFormatInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ModifyIdFormatInput) GoString() string { + return s.String() +} + +type ModifyIdFormatOutput struct { + _ struct{} `type:"structure"` +} + +// String returns the string representation +func (s ModifyIdFormatOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ModifyIdFormatOutput) GoString() string { + return s.String() +} + type ModifyImageAttributeInput struct { + _ struct{} `type:"structure"` + // The name of the attribute to modify. Attribute *string `type:"string"` @@ -18514,12 +17711,6 @@ type ModifyImageAttributeInput struct { // The value of the attribute being modified. This is only valid when modifying // the description attribute. Value *string `type:"string"` - - metadataModifyImageAttributeInput `json:"-" xml:"-"` -} - -type metadataModifyImageAttributeInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -18533,11 +17724,7 @@ func (s ModifyImageAttributeInput) GoString() string { } type ModifyImageAttributeOutput struct { - metadataModifyImageAttributeOutput `json:"-" xml:"-"` -} - -type metadataModifyImageAttributeOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -18551,6 +17738,8 @@ func (s ModifyImageAttributeOutput) GoString() string { } type ModifyInstanceAttributeInput struct { + _ struct{} `type:"structure"` + // The name of the attribute. Attribute *string `locationName:"attribute" type:"string" enum:"InstanceAttributeName"` @@ -18629,12 +17818,6 @@ type ModifyInstanceAttributeInput struct { // A new value for the attribute. Use only with the kernel, ramdisk, userData, // disableApiTermination, or instanceInitiatedShutdownBehavior attribute. Value *string `locationName:"value" type:"string"` - - metadataModifyInstanceAttributeInput `json:"-" xml:"-"` -} - -type metadataModifyInstanceAttributeInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -18648,11 +17831,7 @@ func (s ModifyInstanceAttributeInput) GoString() string { } type ModifyInstanceAttributeOutput struct { - metadataModifyInstanceAttributeOutput `json:"-" xml:"-"` -} - -type metadataModifyInstanceAttributeOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -18665,7 +17844,52 @@ func (s ModifyInstanceAttributeOutput) GoString() string { return s.String() } +type ModifyInstancePlacementInput struct { + _ struct{} `type:"structure"` + + // The new affinity setting for the instance. + Affinity *string `locationName:"affinity" type:"string" enum:"Affinity"` + + // The ID of the Dedicated host that the instance will have affinity with. + HostId *string `locationName:"hostId" type:"string"` + + // The ID of the instance that you are modifying. + InstanceId *string `locationName:"instanceId" type:"string" required:"true"` + + // The tenancy of the instance that you are modifying. + Tenancy *string `locationName:"tenancy" type:"string" enum:"HostTenancy"` +} + +// String returns the string representation +func (s ModifyInstancePlacementInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ModifyInstancePlacementInput) GoString() string { + return s.String() +} + +type ModifyInstancePlacementOutput struct { + _ struct{} `type:"structure"` + + // Is true if the request succeeds, and an error otherwise. + Return *bool `locationName:"return" type:"boolean"` +} + +// String returns the string representation +func (s ModifyInstancePlacementOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ModifyInstancePlacementOutput) GoString() string { + return s.String() +} + type ModifyNetworkInterfaceAttributeInput struct { + _ struct{} `type:"structure"` + // Information about the interface attachment. If modifying the 'delete on termination' // attribute, you must specify the ID of the interface attachment. Attachment *NetworkInterfaceAttachmentChanges `locationName:"attachment" type:"structure"` @@ -18694,12 +17918,6 @@ type ModifyNetworkInterfaceAttributeInput struct { // NAT Instances (http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/VPC_NAT_Instance.html) // in the Amazon Virtual Private Cloud User Guide. SourceDestCheck *AttributeBooleanValue `locationName:"sourceDestCheck" type:"structure"` - - metadataModifyNetworkInterfaceAttributeInput `json:"-" xml:"-"` -} - -type metadataModifyNetworkInterfaceAttributeInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -18713,11 +17931,7 @@ func (s ModifyNetworkInterfaceAttributeInput) GoString() string { } type ModifyNetworkInterfaceAttributeOutput struct { - metadataModifyNetworkInterfaceAttributeOutput `json:"-" xml:"-"` -} - -type metadataModifyNetworkInterfaceAttributeOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -18731,21 +17945,17 @@ func (s ModifyNetworkInterfaceAttributeOutput) GoString() string { } type ModifyReservedInstancesInput struct { + _ struct{} `type:"structure"` + // A unique, case-sensitive token you provide to ensure idempotency of your // modification request. For more information, see Ensuring Idempotency (http://docs.aws.amazon.com/AWSEC2/latest/APIReference/Run_Instance_Idempotency.html). ClientToken *string `locationName:"clientToken" type:"string"` - // The IDs of the Reserved Instances to modify. + // The IDs of the Reserved instances to modify. ReservedInstancesIds []*string `locationName:"ReservedInstancesId" locationNameList:"ReservedInstancesId" type:"list" required:"true"` - // The configuration settings for the Reserved Instances to modify. + // The configuration settings for the Reserved instances to modify. TargetConfigurations []*ReservedInstancesConfiguration `locationName:"ReservedInstancesConfigurationSetItemType" locationNameList:"item" type:"list" required:"true"` - - metadataModifyReservedInstancesInput `json:"-" xml:"-"` -} - -type metadataModifyReservedInstancesInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -18759,14 +17969,10 @@ func (s ModifyReservedInstancesInput) GoString() string { } type ModifyReservedInstancesOutput struct { + _ struct{} `type:"structure"` + // The ID for the modification. ReservedInstancesModificationId *string `locationName:"reservedInstancesModificationId" type:"string"` - - metadataModifyReservedInstancesOutput `json:"-" xml:"-"` -} - -type metadataModifyReservedInstancesOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -18780,6 +17986,8 @@ func (s ModifyReservedInstancesOutput) GoString() string { } type ModifySnapshotAttributeInput struct { + _ struct{} `type:"structure"` + // The snapshot attribute to modify. // // Only volume creation permissions may be modified at the customer level. @@ -18805,12 +18013,6 @@ type ModifySnapshotAttributeInput struct { // The account ID to modify for the snapshot. UserIds []*string `locationName:"UserId" locationNameList:"UserId" type:"list"` - - metadataModifySnapshotAttributeInput `json:"-" xml:"-"` -} - -type metadataModifySnapshotAttributeInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -18824,11 +18026,7 @@ func (s ModifySnapshotAttributeInput) GoString() string { } type ModifySnapshotAttributeOutput struct { - metadataModifySnapshotAttributeOutput `json:"-" xml:"-"` -} - -type metadataModifySnapshotAttributeOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -18843,6 +18041,8 @@ func (s ModifySnapshotAttributeOutput) GoString() string { // Contains the parameters for ModifySpotFleetRequest. type ModifySpotFleetRequestInput struct { + _ struct{} `type:"structure"` + // Indicates whether running Spot instances should be terminated if the target // capacity of the Spot fleet request is decreased below the current size of // the Spot fleet. @@ -18853,12 +18053,6 @@ type ModifySpotFleetRequestInput struct { // The size of the fleet. TargetCapacity *int64 `locationName:"targetCapacity" type:"integer"` - - metadataModifySpotFleetRequestInput `json:"-" xml:"-"` -} - -type metadataModifySpotFleetRequestInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -18873,14 +18067,10 @@ func (s ModifySpotFleetRequestInput) GoString() string { // Contains the output of ModifySpotFleetRequest. type ModifySpotFleetRequestOutput struct { + _ struct{} `type:"structure"` + // Is true if the request succeeds, and an error otherwise. Return *bool `locationName:"return" type:"boolean"` - - metadataModifySpotFleetRequestOutput `json:"-" xml:"-"` -} - -type metadataModifySpotFleetRequestOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -18894,18 +18084,14 @@ func (s ModifySpotFleetRequestOutput) GoString() string { } type ModifySubnetAttributeInput struct { + _ struct{} `type:"structure"` + // Specify true to indicate that instances launched into the specified subnet // should be assigned public IP address. MapPublicIpOnLaunch *AttributeBooleanValue `type:"structure"` // The ID of the subnet. SubnetId *string `locationName:"subnetId" type:"string" required:"true"` - - metadataModifySubnetAttributeInput `json:"-" xml:"-"` -} - -type metadataModifySubnetAttributeInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -18919,11 +18105,7 @@ func (s ModifySubnetAttributeInput) GoString() string { } type ModifySubnetAttributeOutput struct { - metadataModifySubnetAttributeOutput `json:"-" xml:"-"` -} - -type metadataModifySubnetAttributeOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -18937,6 +18119,8 @@ func (s ModifySubnetAttributeOutput) GoString() string { } type ModifyVolumeAttributeInput struct { + _ struct{} `type:"structure"` + // Indicates whether the volume should be auto-enabled for I/O operations. AutoEnableIO *AttributeBooleanValue `type:"structure"` @@ -18948,12 +18132,6 @@ type ModifyVolumeAttributeInput struct { // The ID of the volume. VolumeId *string `type:"string" required:"true"` - - metadataModifyVolumeAttributeInput `json:"-" xml:"-"` -} - -type metadataModifyVolumeAttributeInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -18967,11 +18145,7 @@ func (s ModifyVolumeAttributeInput) GoString() string { } type ModifyVolumeAttributeOutput struct { - metadataModifyVolumeAttributeOutput `json:"-" xml:"-"` -} - -type metadataModifyVolumeAttributeOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -18985,6 +18159,8 @@ func (s ModifyVolumeAttributeOutput) GoString() string { } type ModifyVpcAttributeInput struct { + _ struct{} `type:"structure"` + // Indicates whether the instances launched in the VPC get DNS hostnames. If // enabled, instances in the VPC get DNS hostnames; otherwise, they do not. // @@ -19005,12 +18181,6 @@ type ModifyVpcAttributeInput struct { // The ID of the VPC. VpcId *string `locationName:"vpcId" type:"string" required:"true"` - - metadataModifyVpcAttributeInput `json:"-" xml:"-"` -} - -type metadataModifyVpcAttributeInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -19024,11 +18194,7 @@ func (s ModifyVpcAttributeInput) GoString() string { } type ModifyVpcAttributeOutput struct { - metadataModifyVpcAttributeOutput `json:"-" xml:"-"` -} - -type metadataModifyVpcAttributeOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -19042,6 +18208,8 @@ func (s ModifyVpcAttributeOutput) GoString() string { } type ModifyVpcEndpointInput struct { + _ struct{} `type:"structure"` + // One or more route tables IDs to associate with the endpoint. AddRouteTableIds []*string `locationName:"AddRouteTableId" locationNameList:"item" type:"list"` @@ -19064,12 +18232,6 @@ type ModifyVpcEndpointInput struct { // The ID of the endpoint. VpcEndpointId *string `type:"string" required:"true"` - - metadataModifyVpcEndpointInput `json:"-" xml:"-"` -} - -type metadataModifyVpcEndpointInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -19083,14 +18245,10 @@ func (s ModifyVpcEndpointInput) GoString() string { } type ModifyVpcEndpointOutput struct { + _ struct{} `type:"structure"` + // Returns true if the request succeeds; otherwise, it returns an error. Return *bool `locationName:"return" type:"boolean"` - - metadataModifyVpcEndpointOutput `json:"-" xml:"-"` -} - -type metadataModifyVpcEndpointOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -19104,6 +18262,8 @@ func (s ModifyVpcEndpointOutput) GoString() string { } type MonitorInstancesInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -19112,12 +18272,6 @@ type MonitorInstancesInput struct { // One or more instance IDs. InstanceIds []*string `locationName:"InstanceId" locationNameList:"InstanceId" type:"list" required:"true"` - - metadataMonitorInstancesInput `json:"-" xml:"-"` -} - -type metadataMonitorInstancesInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -19131,14 +18285,10 @@ func (s MonitorInstancesInput) GoString() string { } type MonitorInstancesOutput struct { + _ struct{} `type:"structure"` + // Monitoring information for one or more instances. InstanceMonitorings []*InstanceMonitoring `locationName:"instancesSet" locationNameList:"item" type:"list"` - - metadataMonitorInstancesOutput `json:"-" xml:"-"` -} - -type metadataMonitorInstancesOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -19153,14 +18303,10 @@ func (s MonitorInstancesOutput) GoString() string { // Describes the monitoring for the instance. type Monitoring struct { + _ struct{} `type:"structure"` + // Indicates whether monitoring is enabled for the instance. State *string `locationName:"state" type:"string" enum:"MonitoringState"` - - metadataMonitoring `json:"-" xml:"-"` -} - -type metadataMonitoring struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -19174,6 +18320,8 @@ func (s Monitoring) GoString() string { } type MoveAddressToVpcInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -19182,12 +18330,6 @@ type MoveAddressToVpcInput struct { // The Elastic IP address. PublicIp *string `locationName:"publicIp" type:"string" required:"true"` - - metadataMoveAddressToVpcInput `json:"-" xml:"-"` -} - -type metadataMoveAddressToVpcInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -19201,17 +18343,13 @@ func (s MoveAddressToVpcInput) GoString() string { } type MoveAddressToVpcOutput struct { + _ struct{} `type:"structure"` + // The allocation ID for the Elastic IP address. AllocationId *string `locationName:"allocationId" type:"string"` // The status of the move of the IP address. Status *string `locationName:"status" type:"string" enum:"Status"` - - metadataMoveAddressToVpcOutput `json:"-" xml:"-"` -} - -type metadataMoveAddressToVpcOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -19226,18 +18364,14 @@ func (s MoveAddressToVpcOutput) GoString() string { // Describes the status of a moving Elastic IP address. type MovingAddressStatus struct { + _ struct{} `type:"structure"` + // The status of the Elastic IP address that's being moved to the EC2-VPC platform, // or restored to the EC2-Classic platform. MoveStatus *string `locationName:"moveStatus" type:"string" enum:"MoveStatus"` // The Elastic IP address. PublicIp *string `locationName:"publicIp" type:"string"` - - metadataMovingAddressStatus `json:"-" xml:"-"` -} - -type metadataMovingAddressStatus struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -19252,6 +18386,8 @@ func (s MovingAddressStatus) GoString() string { // Describes a network ACL. type NetworkAcl struct { + _ struct{} `type:"structure"` + // Any associations between the network ACL and one or more subnets Associations []*NetworkAclAssociation `locationName:"associationSet" locationNameList:"item" type:"list"` @@ -19269,12 +18405,6 @@ type NetworkAcl struct { // The ID of the VPC for the network ACL. VpcId *string `locationName:"vpcId" type:"string"` - - metadataNetworkAcl `json:"-" xml:"-"` -} - -type metadataNetworkAcl struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -19289,6 +18419,8 @@ func (s NetworkAcl) GoString() string { // Describes an association between a network ACL and a subnet. type NetworkAclAssociation struct { + _ struct{} `type:"structure"` + // The ID of the association between a network ACL and a subnet. NetworkAclAssociationId *string `locationName:"networkAclAssociationId" type:"string"` @@ -19297,12 +18429,6 @@ type NetworkAclAssociation struct { // The ID of the subnet. SubnetId *string `locationName:"subnetId" type:"string"` - - metadataNetworkAclAssociation `json:"-" xml:"-"` -} - -type metadataNetworkAclAssociation struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -19317,6 +18443,8 @@ func (s NetworkAclAssociation) GoString() string { // Describes an entry in a network ACL. type NetworkAclEntry struct { + _ struct{} `type:"structure"` + // The network range to allow or deny, in CIDR notation. CidrBlock *string `locationName:"cidrBlock" type:"string"` @@ -19339,12 +18467,6 @@ type NetworkAclEntry struct { // The rule number for the entry. ACL entries are processed in ascending order // by rule number. RuleNumber *int64 `locationName:"ruleNumber" type:"integer"` - - metadataNetworkAclEntry `json:"-" xml:"-"` -} - -type metadataNetworkAclEntry struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -19359,6 +18481,8 @@ func (s NetworkAclEntry) GoString() string { // Describes a network interface. type NetworkInterface struct { + _ struct{} `type:"structure"` + // The association information for an Elastic IP associated with the network // interface. Association *NetworkInterfaceAssociation `locationName:"association" type:"structure"` @@ -19414,12 +18538,6 @@ type NetworkInterface struct { // The ID of the VPC. VpcId *string `locationName:"vpcId" type:"string"` - - metadataNetworkInterface `json:"-" xml:"-"` -} - -type metadataNetworkInterface struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -19434,6 +18552,8 @@ func (s NetworkInterface) GoString() string { // Describes association information for an Elastic IP address. type NetworkInterfaceAssociation struct { + _ struct{} `type:"structure"` + // The allocation ID. AllocationId *string `locationName:"allocationId" type:"string"` @@ -19448,12 +18568,6 @@ type NetworkInterfaceAssociation struct { // The address of the Elastic IP address bound to the network interface. PublicIp *string `locationName:"publicIp" type:"string"` - - metadataNetworkInterfaceAssociation `json:"-" xml:"-"` -} - -type metadataNetworkInterfaceAssociation struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -19468,6 +18582,8 @@ func (s NetworkInterfaceAssociation) GoString() string { // Describes a network interface attachment. type NetworkInterfaceAttachment struct { + _ struct{} `type:"structure"` + // The timestamp indicating when the attachment initiated. AttachTime *time.Time `locationName:"attachTime" type:"timestamp" timestampFormat:"iso8601"` @@ -19488,12 +18604,6 @@ type NetworkInterfaceAttachment struct { // The attachment state. Status *string `locationName:"status" type:"string" enum:"AttachmentStatus"` - - metadataNetworkInterfaceAttachment `json:"-" xml:"-"` -} - -type metadataNetworkInterfaceAttachment struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -19508,17 +18618,13 @@ func (s NetworkInterfaceAttachment) GoString() string { // Describes an attachment change. type NetworkInterfaceAttachmentChanges struct { + _ struct{} `type:"structure"` + // The ID of the network interface attachment. AttachmentId *string `locationName:"attachmentId" type:"string"` // Indicates whether the network interface is deleted when the instance is terminated. DeleteOnTermination *bool `locationName:"deleteOnTermination" type:"boolean"` - - metadataNetworkInterfaceAttachmentChanges `json:"-" xml:"-"` -} - -type metadataNetworkInterfaceAttachmentChanges struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -19533,6 +18639,8 @@ func (s NetworkInterfaceAttachmentChanges) GoString() string { // Describes the private IP address of a network interface. type NetworkInterfacePrivateIpAddress struct { + _ struct{} `type:"structure"` + // The association information for an Elastic IP address associated with the // network interface. Association *NetworkInterfaceAssociation `locationName:"association" type:"structure"` @@ -19546,12 +18654,6 @@ type NetworkInterfacePrivateIpAddress struct { // The private IP address. PrivateIpAddress *string `locationName:"privateIpAddress" type:"string"` - - metadataNetworkInterfacePrivateIpAddress `json:"-" xml:"-"` -} - -type metadataNetworkInterfacePrivateIpAddress struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -19565,15 +18667,11 @@ func (s NetworkInterfacePrivateIpAddress) GoString() string { } type NewDhcpConfiguration struct { + _ struct{} `type:"structure"` + Key *string `locationName:"key" type:"string"` Values []*string `locationName:"Value" locationNameList:"item" type:"list"` - - metadataNewDhcpConfiguration `json:"-" xml:"-"` -} - -type metadataNewDhcpConfiguration struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -19588,21 +18686,26 @@ func (s NewDhcpConfiguration) GoString() string { // Describes the placement for the instance. type Placement struct { + _ struct{} `type:"structure"` + + // The affinity setting for the instance on the Dedicated host. This parameter + // is not supported for the ImportInstance command. + Affinity *string `locationName:"affinity" type:"string"` + // The Availability Zone of the instance. AvailabilityZone *string `locationName:"availabilityZone" type:"string"` // The name of the placement group the instance is in (for cluster compute instances). GroupName *string `locationName:"groupName" type:"string"` + // The ID of the Dedicted host on which the instance resides. This parameter + // is not support for the ImportInstance command. + HostId *string `locationName:"hostId" type:"string"` + // The tenancy of the instance (if the instance is running in a VPC). An instance - // with a tenancy of dedicated runs on single-tenant hardware. + // with a tenancy of dedicated runs on single-tenant hardware. The host tenancy + // is not supported for the ImportInstance command. Tenancy *string `locationName:"tenancy" type:"string" enum:"Tenancy"` - - metadataPlacement `json:"-" xml:"-"` -} - -type metadataPlacement struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -19617,6 +18720,8 @@ func (s Placement) GoString() string { // Describes a placement group. type PlacementGroup struct { + _ struct{} `type:"structure"` + // The name of the placement group. GroupName *string `locationName:"groupName" type:"string"` @@ -19625,12 +18730,6 @@ type PlacementGroup struct { // The placement strategy. Strategy *string `locationName:"strategy" type:"string" enum:"PlacementStrategy"` - - metadataPlacementGroup `json:"-" xml:"-"` -} - -type metadataPlacementGroup struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -19645,17 +18744,13 @@ func (s PlacementGroup) GoString() string { // Describes a range of ports. type PortRange struct { + _ struct{} `type:"structure"` + // The first port in the range. From *int64 `locationName:"from" type:"integer"` // The last port in the range. To *int64 `locationName:"to" type:"integer"` - - metadataPortRange `json:"-" xml:"-"` -} - -type metadataPortRange struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -19670,6 +18765,8 @@ func (s PortRange) GoString() string { // Describes prefixes for AWS services. type PrefixList struct { + _ struct{} `type:"structure"` + // The IP address range of the AWS service. Cidrs []*string `locationName:"cidrSet" locationNameList:"item" type:"list"` @@ -19678,12 +18775,6 @@ type PrefixList struct { // The name of the prefix. PrefixListName *string `locationName:"prefixListName" type:"string"` - - metadataPrefixList `json:"-" xml:"-"` -} - -type metadataPrefixList struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -19698,14 +18789,10 @@ func (s PrefixList) GoString() string { // The ID of the prefix. type PrefixListId struct { + _ struct{} `type:"structure"` + // The ID of the prefix. PrefixListId *string `locationName:"prefixListId" type:"string"` - - metadataPrefixListId `json:"-" xml:"-"` -} - -type metadataPrefixListId struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -19718,8 +18805,10 @@ func (s PrefixListId) GoString() string { return s.String() } -// Describes the price for a Reserved Instance. +// Describes the price for a Reserved instance. type PriceSchedule struct { + _ struct{} `type:"structure"` + // The current price schedule, as determined by the term remaining for the Reserved // Instance in the listing. // @@ -19732,7 +18821,7 @@ type PriceSchedule struct { // be active for months 2 and 1. Active *bool `locationName:"active" type:"boolean"` - // The currency for transacting the Reserved Instance resale. At this time, + // The currency for transacting the Reserved instance resale. At this time, // the only supported currency is USD. CurrencyCode *string `locationName:"currencyCode" type:"string" enum:"CurrencyCodeValues"` @@ -19742,12 +18831,6 @@ type PriceSchedule struct { // The number of months remaining in the reservation. For example, 2 is the // second to the last month before the capacity reservation expires. Term *int64 `locationName:"term" type:"long"` - - metadataPriceSchedule `json:"-" xml:"-"` -} - -type metadataPriceSchedule struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -19760,9 +18843,11 @@ func (s PriceSchedule) GoString() string { return s.String() } -// Describes the price for a Reserved Instance. +// Describes the price for a Reserved instance. type PriceScheduleSpecification struct { - // The currency for transacting the Reserved Instance resale. At this time, + _ struct{} `type:"structure"` + + // The currency for transacting the Reserved instance resale. At this time, // the only supported currency is USD. CurrencyCode *string `locationName:"currencyCode" type:"string" enum:"CurrencyCodeValues"` @@ -19772,12 +18857,6 @@ type PriceScheduleSpecification struct { // The number of months remaining in the reservation. For example, 2 is the // second to the last month before the capacity reservation expires. Term *int64 `locationName:"term" type:"long"` - - metadataPriceScheduleSpecification `json:"-" xml:"-"` -} - -type metadataPriceScheduleSpecification struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -19790,19 +18869,15 @@ func (s PriceScheduleSpecification) GoString() string { return s.String() } -// Describes a Reserved Instance offering. +// Describes a Reserved instance offering. type PricingDetail struct { + _ struct{} `type:"structure"` + // The number of instances available for the price. Count *int64 `locationName:"count" type:"integer"` // The price per instance. Price *float64 `locationName:"price" type:"double"` - - metadataPricingDetail `json:"-" xml:"-"` -} - -type metadataPricingDetail struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -19817,18 +18892,14 @@ func (s PricingDetail) GoString() string { // Describes a secondary private IP address for a network interface. type PrivateIpAddressSpecification struct { + _ struct{} `type:"structure"` + // Indicates whether the private IP address is the primary private IP address. // Only one IP address can be designated as primary. Primary *bool `locationName:"primary" type:"boolean"` // The private IP addresses. PrivateIpAddress *string `locationName:"privateIpAddress" type:"string" required:"true"` - - metadataPrivateIpAddressSpecification `json:"-" xml:"-"` -} - -type metadataPrivateIpAddressSpecification struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -19843,17 +18914,13 @@ func (s PrivateIpAddressSpecification) GoString() string { // Describes a product code. type ProductCode struct { + _ struct{} `type:"structure"` + // The product code. ProductCodeId *string `locationName:"productCode" type:"string"` // The type of product code. ProductCodeType *string `locationName:"type" type:"string" enum:"ProductCodeValues"` - - metadataProductCode `json:"-" xml:"-"` -} - -type metadataProductCode struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -19868,14 +18935,10 @@ func (s ProductCode) GoString() string { // Describes a virtual private gateway propagating route. type PropagatingVgw struct { + _ struct{} `type:"structure"` + // The ID of the virtual private gateway (VGW). GatewayId *string `locationName:"gatewayId" type:"string"` - - metadataPropagatingVgw `json:"-" xml:"-"` -} - -type metadataPropagatingVgw struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -19889,28 +18952,24 @@ func (s PropagatingVgw) GoString() string { } type PurchaseReservedInstancesOfferingInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, // it is UnauthorizedOperation. DryRun *bool `locationName:"dryRun" type:"boolean"` - // The number of Reserved Instances to purchase. + // The number of Reserved instances to purchase. InstanceCount *int64 `type:"integer" required:"true"` // Specified for Reserved Instance Marketplace offerings to limit the total - // order and ensure that the Reserved Instances are not purchased at unexpected + // order and ensure that the Reserved instances are not purchased at unexpected // prices. LimitPrice *ReservedInstanceLimitPrice `locationName:"limitPrice" type:"structure"` - // The ID of the Reserved Instance offering to purchase. + // The ID of the Reserved instance offering to purchase. ReservedInstancesOfferingId *string `type:"string" required:"true"` - - metadataPurchaseReservedInstancesOfferingInput `json:"-" xml:"-"` -} - -type metadataPurchaseReservedInstancesOfferingInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -19924,14 +18983,10 @@ func (s PurchaseReservedInstancesOfferingInput) GoString() string { } type PurchaseReservedInstancesOfferingOutput struct { - // The IDs of the purchased Reserved Instances. + _ struct{} `type:"structure"` + + // The IDs of the purchased Reserved instances. ReservedInstancesId *string `locationName:"reservedInstancesId" type:"string"` - - metadataPurchaseReservedInstancesOfferingOutput `json:"-" xml:"-"` -} - -type metadataPurchaseReservedInstancesOfferingOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -19945,6 +19000,8 @@ func (s PurchaseReservedInstancesOfferingOutput) GoString() string { } type RebootInstancesInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -19953,12 +19010,6 @@ type RebootInstancesInput struct { // One or more instance IDs. InstanceIds []*string `locationName:"InstanceId" locationNameList:"InstanceId" type:"list" required:"true"` - - metadataRebootInstancesInput `json:"-" xml:"-"` -} - -type metadataRebootInstancesInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -19972,11 +19023,7 @@ func (s RebootInstancesInput) GoString() string { } type RebootInstancesOutput struct { - metadataRebootInstancesOutput `json:"-" xml:"-"` -} - -type metadataRebootInstancesOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -19991,17 +19038,13 @@ func (s RebootInstancesOutput) GoString() string { // Describes a recurring charge. type RecurringCharge struct { + _ struct{} `type:"structure"` + // The amount of the recurring charge. Amount *float64 `locationName:"amount" type:"double"` // The frequency of the recurring charge. Frequency *string `locationName:"frequency" type:"string" enum:"RecurringChargeFrequency"` - - metadataRecurringCharge `json:"-" xml:"-"` -} - -type metadataRecurringCharge struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -20016,17 +19059,13 @@ func (s RecurringCharge) GoString() string { // Describes a region. type Region struct { + _ struct{} `type:"structure"` + // The region service endpoint. Endpoint *string `locationName:"regionEndpoint" type:"string"` // The name of the region. RegionName *string `locationName:"regionName" type:"string"` - - metadataRegion `json:"-" xml:"-"` -} - -type metadataRegion struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -20040,6 +19079,8 @@ func (s Region) GoString() string { } type RegisterImageInput struct { + _ struct{} `type:"structure"` + // The architecture of the AMI. // // Default: For Amazon EBS-backed AMIs, i386. For instance store-backed AMIs, @@ -20090,12 +19131,6 @@ type RegisterImageInput struct { // // Default: paravirtual VirtualizationType *string `locationName:"virtualizationType" type:"string"` - - metadataRegisterImageInput `json:"-" xml:"-"` -} - -type metadataRegisterImageInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -20109,14 +19144,10 @@ func (s RegisterImageInput) GoString() string { } type RegisterImageOutput struct { + _ struct{} `type:"structure"` + // The ID of the newly registered AMI. ImageId *string `locationName:"imageId" type:"string"` - - metadataRegisterImageOutput `json:"-" xml:"-"` -} - -type metadataRegisterImageOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -20130,6 +19161,8 @@ func (s RegisterImageOutput) GoString() string { } type RejectVpcPeeringConnectionInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -20138,12 +19171,6 @@ type RejectVpcPeeringConnectionInput struct { // The ID of the VPC peering connection. VpcPeeringConnectionId *string `locationName:"vpcPeeringConnectionId" type:"string" required:"true"` - - metadataRejectVpcPeeringConnectionInput `json:"-" xml:"-"` -} - -type metadataRejectVpcPeeringConnectionInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -20157,14 +19184,10 @@ func (s RejectVpcPeeringConnectionInput) GoString() string { } type RejectVpcPeeringConnectionOutput struct { + _ struct{} `type:"structure"` + // Returns true if the request succeeds; otherwise, it returns an error. Return *bool `locationName:"return" type:"boolean"` - - metadataRejectVpcPeeringConnectionOutput `json:"-" xml:"-"` -} - -type metadataRejectVpcPeeringConnectionOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -20178,6 +19201,8 @@ func (s RejectVpcPeeringConnectionOutput) GoString() string { } type ReleaseAddressInput struct { + _ struct{} `type:"structure"` + // [EC2-VPC] The allocation ID. Required for EC2-VPC. AllocationId *string `type:"string"` @@ -20189,12 +19214,6 @@ type ReleaseAddressInput struct { // [EC2-Classic] The Elastic IP address. Required for EC2-Classic. PublicIp *string `type:"string"` - - metadataReleaseAddressInput `json:"-" xml:"-"` -} - -type metadataReleaseAddressInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -20208,11 +19227,7 @@ func (s ReleaseAddressInput) GoString() string { } type ReleaseAddressOutput struct { - metadataReleaseAddressOutput `json:"-" xml:"-"` -} - -type metadataReleaseAddressOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -20225,7 +19240,47 @@ func (s ReleaseAddressOutput) GoString() string { return s.String() } +type ReleaseHostsInput struct { + _ struct{} `type:"structure"` + + // The IDs of the Dedicated hosts you want to release. + HostIds []*string `locationName:"hostId" locationNameList:"item" type:"list" required:"true"` +} + +// String returns the string representation +func (s ReleaseHostsInput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ReleaseHostsInput) GoString() string { + return s.String() +} + +type ReleaseHostsOutput struct { + _ struct{} `type:"structure"` + + // The IDs of the Dedicated hosts that were successfully released. + Successful []*string `locationName:"successful" locationNameList:"item" type:"list"` + + // The IDs of the Dedicated hosts that could not be released, including an error + // message. + Unsuccessful []*UnsuccessfulItem `locationName:"unsuccessful" locationNameList:"item" type:"list"` +} + +// String returns the string representation +func (s ReleaseHostsOutput) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation +func (s ReleaseHostsOutput) GoString() string { + return s.String() +} + type ReplaceNetworkAclAssociationInput struct { + _ struct{} `type:"structure"` + // The ID of the current association between the original network ACL and the // subnet. AssociationId *string `locationName:"associationId" type:"string" required:"true"` @@ -20238,12 +19293,6 @@ type ReplaceNetworkAclAssociationInput struct { // The ID of the new network ACL to associate with the subnet. NetworkAclId *string `locationName:"networkAclId" type:"string" required:"true"` - - metadataReplaceNetworkAclAssociationInput `json:"-" xml:"-"` -} - -type metadataReplaceNetworkAclAssociationInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -20257,14 +19306,10 @@ func (s ReplaceNetworkAclAssociationInput) GoString() string { } type ReplaceNetworkAclAssociationOutput struct { + _ struct{} `type:"structure"` + // The ID of the new association. NewAssociationId *string `locationName:"newAssociationId" type:"string"` - - metadataReplaceNetworkAclAssociationOutput `json:"-" xml:"-"` -} - -type metadataReplaceNetworkAclAssociationOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -20278,6 +19323,8 @@ func (s ReplaceNetworkAclAssociationOutput) GoString() string { } type ReplaceNetworkAclEntryInput struct { + _ struct{} `type:"structure"` + // The network range to allow or deny, in CIDR notation. CidrBlock *string `locationName:"cidrBlock" type:"string" required:"true"` @@ -20311,12 +19358,6 @@ type ReplaceNetworkAclEntryInput struct { // The rule number of the entry to replace. RuleNumber *int64 `locationName:"ruleNumber" type:"integer" required:"true"` - - metadataReplaceNetworkAclEntryInput `json:"-" xml:"-"` -} - -type metadataReplaceNetworkAclEntryInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -20330,11 +19371,7 @@ func (s ReplaceNetworkAclEntryInput) GoString() string { } type ReplaceNetworkAclEntryOutput struct { - metadataReplaceNetworkAclEntryOutput `json:"-" xml:"-"` -} - -type metadataReplaceNetworkAclEntryOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -20348,6 +19385,8 @@ func (s ReplaceNetworkAclEntryOutput) GoString() string { } type ReplaceRouteInput struct { + _ struct{} `type:"structure"` + // The CIDR address block used for the destination match. The value you provide // must match the CIDR of an existing route in the table. DestinationCidrBlock *string `locationName:"destinationCidrBlock" type:"string" required:"true"` @@ -20372,12 +19411,6 @@ type ReplaceRouteInput struct { // The ID of a VPC peering connection. VpcPeeringConnectionId *string `locationName:"vpcPeeringConnectionId" type:"string"` - - metadataReplaceRouteInput `json:"-" xml:"-"` -} - -type metadataReplaceRouteInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -20391,11 +19424,7 @@ func (s ReplaceRouteInput) GoString() string { } type ReplaceRouteOutput struct { - metadataReplaceRouteOutput `json:"-" xml:"-"` -} - -type metadataReplaceRouteOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -20409,6 +19438,8 @@ func (s ReplaceRouteOutput) GoString() string { } type ReplaceRouteTableAssociationInput struct { + _ struct{} `type:"structure"` + // The association ID. AssociationId *string `locationName:"associationId" type:"string" required:"true"` @@ -20420,12 +19451,6 @@ type ReplaceRouteTableAssociationInput struct { // The ID of the new route table to associate with the subnet. RouteTableId *string `locationName:"routeTableId" type:"string" required:"true"` - - metadataReplaceRouteTableAssociationInput `json:"-" xml:"-"` -} - -type metadataReplaceRouteTableAssociationInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -20439,14 +19464,10 @@ func (s ReplaceRouteTableAssociationInput) GoString() string { } type ReplaceRouteTableAssociationOutput struct { + _ struct{} `type:"structure"` + // The ID of the new association. NewAssociationId *string `locationName:"newAssociationId" type:"string"` - - metadataReplaceRouteTableAssociationOutput `json:"-" xml:"-"` -} - -type metadataReplaceRouteTableAssociationOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -20460,6 +19481,8 @@ func (s ReplaceRouteTableAssociationOutput) GoString() string { } type ReportInstanceStatusInput struct { + _ struct{} `type:"structure"` + // Descriptive text about the health state of your instance. Description *string `locationName:"description" type:"string"` @@ -20504,12 +19527,6 @@ type ReportInstanceStatusInput struct { // The status of all instances listed. Status *string `locationName:"status" type:"string" required:"true" enum:"ReportStatusType"` - - metadataReportInstanceStatusInput `json:"-" xml:"-"` -} - -type metadataReportInstanceStatusInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -20523,11 +19540,7 @@ func (s ReportInstanceStatusInput) GoString() string { } type ReportInstanceStatusOutput struct { - metadataReportInstanceStatusOutput `json:"-" xml:"-"` -} - -type metadataReportInstanceStatusOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -20542,6 +19555,8 @@ func (s ReportInstanceStatusOutput) GoString() string { // Contains the parameters for RequestSpotFleet. type RequestSpotFleetInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -20550,12 +19565,6 @@ type RequestSpotFleetInput struct { // The configuration for the Spot fleet request. SpotFleetRequestConfig *SpotFleetRequestConfigData `locationName:"spotFleetRequestConfig" type:"structure" required:"true"` - - metadataRequestSpotFleetInput `json:"-" xml:"-"` -} - -type metadataRequestSpotFleetInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -20570,14 +19579,10 @@ func (s RequestSpotFleetInput) GoString() string { // Contains the output of RequestSpotFleet. type RequestSpotFleetOutput struct { + _ struct{} `type:"structure"` + // The ID of the Spot fleet request. SpotFleetRequestId *string `locationName:"spotFleetRequestId" type:"string" required:"true"` - - metadataRequestSpotFleetOutput `json:"-" xml:"-"` -} - -type metadataRequestSpotFleetOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -20592,6 +19597,8 @@ func (s RequestSpotFleetOutput) GoString() string { // Contains the parameters for RequestSpotInstances. type RequestSpotInstancesInput struct { + _ struct{} `type:"structure"` + // The user-specified name for a logical grouping of bids. // // When you specify an Availability Zone group in a Spot Instance request, @@ -20675,12 +19682,6 @@ type RequestSpotInstancesInput struct { // // Default: The request is effective indefinitely. ValidUntil *time.Time `locationName:"validUntil" type:"timestamp" timestampFormat:"iso8601"` - - metadataRequestSpotInstancesInput `json:"-" xml:"-"` -} - -type metadataRequestSpotInstancesInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -20695,14 +19696,10 @@ func (s RequestSpotInstancesInput) GoString() string { // Contains the output of RequestSpotInstances. type RequestSpotInstancesOutput struct { + _ struct{} `type:"structure"` + // One or more Spot instance requests. SpotInstanceRequests []*SpotInstanceRequest `locationName:"spotInstanceRequestSet" locationNameList:"item" type:"list"` - - metadataRequestSpotInstancesOutput `json:"-" xml:"-"` -} - -type metadataRequestSpotInstancesOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -20717,6 +19714,8 @@ func (s RequestSpotInstancesOutput) GoString() string { // Describes the launch specification for an instance. type RequestSpotLaunchSpecification struct { + _ struct{} `type:"structure"` + // Deprecated. AddressingType *string `locationName:"addressingType" type:"string"` @@ -20768,12 +19767,6 @@ type RequestSpotLaunchSpecification struct { // The Base64-encoded MIME user data to make available to the instances. UserData *string `locationName:"userData" type:"string"` - - metadataRequestSpotLaunchSpecification `json:"-" xml:"-"` -} - -type metadataRequestSpotLaunchSpecification struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -20788,6 +19781,8 @@ func (s RequestSpotLaunchSpecification) GoString() string { // Describes a reservation. type Reservation struct { + _ struct{} `type:"structure"` + // One or more security groups. Groups []*GroupIdentifier `locationName:"groupSet" locationNameList:"item" type:"list"` @@ -20803,12 +19798,6 @@ type Reservation struct { // The ID of the reservation. ReservationId *string `locationName:"reservationId" type:"string"` - - metadataReservation `json:"-" xml:"-"` -} - -type metadataReservation struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -20821,8 +19810,10 @@ func (s Reservation) GoString() string { return s.String() } -// Describes the limit price of a Reserved Instance offering. +// Describes the limit price of a Reserved instance offering. type ReservedInstanceLimitPrice struct { + _ struct{} `type:"structure"` + // Used for Reserved Instance Marketplace offerings. Specifies the limit price // on the total order (instanceCount * price). Amount *float64 `locationName:"amount" type:"double"` @@ -20830,12 +19821,6 @@ type ReservedInstanceLimitPrice struct { // The currency in which the limitPrice amount is specified. At this time, the // only supported currency is USD. CurrencyCode *string `locationName:"currencyCode" type:"string" enum:"CurrencyCodeValues"` - - metadataReservedInstanceLimitPrice `json:"-" xml:"-"` -} - -type metadataReservedInstanceLimitPrice struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -20848,62 +19833,58 @@ func (s ReservedInstanceLimitPrice) GoString() string { return s.String() } -// Describes a Reserved Instance. +// Describes a Reserved instance. type ReservedInstances struct { - // The Availability Zone in which the Reserved Instance can be used. + _ struct{} `type:"structure"` + + // The Availability Zone in which the Reserved instance can be used. AvailabilityZone *string `locationName:"availabilityZone" type:"string"` - // The currency of the Reserved Instance. It's specified using ISO 4217 standard + // The currency of the Reserved instance. It's specified using ISO 4217 standard // currency codes. At this time, the only supported currency is USD. CurrencyCode *string `locationName:"currencyCode" type:"string" enum:"CurrencyCodeValues"` - // The duration of the Reserved Instance, in seconds. + // The duration of the Reserved instance, in seconds. Duration *int64 `locationName:"duration" type:"long"` - // The time when the Reserved Instance expires. + // The time when the Reserved instance expires. End *time.Time `locationName:"end" type:"timestamp" timestampFormat:"iso8601"` - // The purchase price of the Reserved Instance. + // The purchase price of the Reserved instance. FixedPrice *float64 `locationName:"fixedPrice" type:"float"` - // The number of Reserved Instances purchased. + // The number of Reserved instances purchased. InstanceCount *int64 `locationName:"instanceCount" type:"integer"` // The tenancy of the reserved instance. InstanceTenancy *string `locationName:"instanceTenancy" type:"string" enum:"Tenancy"` - // The instance type on which the Reserved Instance can be used. + // The instance type on which the Reserved instance can be used. InstanceType *string `locationName:"instanceType" type:"string" enum:"InstanceType"` - // The Reserved Instance offering type. + // The Reserved instance offering type. OfferingType *string `locationName:"offeringType" type:"string" enum:"OfferingTypeValues"` - // The Reserved Instance product platform description. + // The Reserved instance product platform description. ProductDescription *string `locationName:"productDescription" type:"string" enum:"RIProductDescription"` // The recurring charge tag assigned to the resource. RecurringCharges []*RecurringCharge `locationName:"recurringCharges" locationNameList:"item" type:"list"` - // The ID of the Reserved Instance. + // The ID of the Reserved instance. ReservedInstancesId *string `locationName:"reservedInstancesId" type:"string"` - // The date and time the Reserved Instance started. + // The date and time the Reserved instance started. Start *time.Time `locationName:"start" type:"timestamp" timestampFormat:"iso8601"` - // The state of the Reserved Instance purchase. + // The state of the Reserved instance purchase. State *string `locationName:"state" type:"string" enum:"ReservedInstanceState"` // Any tags assigned to the resource. Tags []*Tag `locationName:"tagSet" locationNameList:"item" type:"list"` - // The usage price of the Reserved Instance, per hour. + // The usage price of the Reserved instance, per hour. UsagePrice *float64 `locationName:"usagePrice" type:"float"` - - metadataReservedInstances `json:"-" xml:"-"` -} - -type metadataReservedInstances struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -20916,26 +19897,22 @@ func (s ReservedInstances) GoString() string { return s.String() } -// Describes the configuration settings for the modified Reserved Instances. +// Describes the configuration settings for the modified Reserved instances. type ReservedInstancesConfiguration struct { - // The Availability Zone for the modified Reserved Instances. + _ struct{} `type:"structure"` + + // The Availability Zone for the modified Reserved instances. AvailabilityZone *string `locationName:"availabilityZone" type:"string"` - // The number of modified Reserved Instances. + // The number of modified Reserved instances. InstanceCount *int64 `locationName:"instanceCount" type:"integer"` - // The instance type for the modified Reserved Instances. + // The instance type for the modified Reserved instances. InstanceType *string `locationName:"instanceType" type:"string" enum:"InstanceType"` - // The network platform of the modified Reserved Instances, which is either + // The network platform of the modified Reserved instances, which is either // EC2-Classic or EC2-VPC. Platform *string `locationName:"platform" type:"string"` - - metadataReservedInstancesConfiguration `json:"-" xml:"-"` -} - -type metadataReservedInstancesConfiguration struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -20948,16 +19925,12 @@ func (s ReservedInstancesConfiguration) GoString() string { return s.String() } -// Describes the ID of a Reserved Instance. +// Describes the ID of a Reserved instance. type ReservedInstancesId struct { - // The ID of the Reserved Instance. + _ struct{} `type:"structure"` + + // The ID of the Reserved instance. ReservedInstancesId *string `locationName:"reservedInstancesId" type:"string"` - - metadataReservedInstancesId `json:"-" xml:"-"` -} - -type metadataReservedInstancesId struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -20970,8 +19943,10 @@ func (s ReservedInstancesId) GoString() string { return s.String() } -// Describes a Reserved Instance listing. +// Describes a Reserved instance listing. type ReservedInstancesListing struct { + _ struct{} `type:"structure"` + // A unique, case-sensitive key supplied by the client to ensure that the request // is idempotent. For more information, see Ensuring Idempotency (http://docs.aws.amazon.com/AWSEC2/latest/APIReference/Run_Instance_Idempotency.html). ClientToken *string `locationName:"clientToken" type:"string"` @@ -20982,19 +19957,19 @@ type ReservedInstancesListing struct { // The number of instances in this state. InstanceCounts []*InstanceCount `locationName:"instanceCounts" locationNameList:"item" type:"list"` - // The price of the Reserved Instance listing. + // The price of the Reserved instance listing. PriceSchedules []*PriceSchedule `locationName:"priceSchedules" locationNameList:"item" type:"list"` - // The ID of the Reserved Instance. + // The ID of the Reserved instance. ReservedInstancesId *string `locationName:"reservedInstancesId" type:"string"` - // The ID of the Reserved Instance listing. + // The ID of the Reserved instance listing. ReservedInstancesListingId *string `locationName:"reservedInstancesListingId" type:"string"` - // The status of the Reserved Instance listing. + // The status of the Reserved instance listing. Status *string `locationName:"status" type:"string" enum:"ListingStatus"` - // The reason for the current status of the Reserved Instance listing. The response + // The reason for the current status of the Reserved instance listing. The response // can be blank. StatusMessage *string `locationName:"statusMessage" type:"string"` @@ -21003,12 +19978,6 @@ type ReservedInstancesListing struct { // The last modified timestamp of the listing. UpdateDate *time.Time `locationName:"updateDate" type:"timestamp" timestampFormat:"iso8601"` - - metadataReservedInstancesListing `json:"-" xml:"-"` -} - -type metadataReservedInstancesListing struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -21021,8 +19990,10 @@ func (s ReservedInstancesListing) GoString() string { return s.String() } -// Describes a Reserved Instance modification. +// Describes a Reserved instance modification. type ReservedInstancesModification struct { + _ struct{} `type:"structure"` + // A unique, case-sensitive key supplied by the client to ensure that the request // is idempotent. For more information, see Ensuring Idempotency (http://docs.aws.amazon.com/AWSEC2/latest/APIReference/Run_Instance_Idempotency.html). ClientToken *string `locationName:"clientToken" type:"string"` @@ -21034,16 +20005,16 @@ type ReservedInstancesModification struct { EffectiveDate *time.Time `locationName:"effectiveDate" type:"timestamp" timestampFormat:"iso8601"` // Contains target configurations along with their corresponding new Reserved - // Instance IDs. + // instance IDs. ModificationResults []*ReservedInstancesModificationResult `locationName:"modificationResultSet" locationNameList:"item" type:"list"` - // The IDs of one or more Reserved Instances. + // The IDs of one or more Reserved instances. ReservedInstancesIds []*ReservedInstancesId `locationName:"reservedInstancesSet" locationNameList:"item" type:"list"` - // A unique ID for the Reserved Instance modification. + // A unique ID for the Reserved instance modification. ReservedInstancesModificationId *string `locationName:"reservedInstancesModificationId" type:"string"` - // The status of the Reserved Instances modification request. + // The status of the Reserved instances modification request. Status *string `locationName:"status" type:"string"` // The reason for the status. @@ -21051,12 +20022,6 @@ type ReservedInstancesModification struct { // The time when the modification request was last updated. UpdateDate *time.Time `locationName:"updateDate" type:"timestamp" timestampFormat:"iso8601"` - - metadataReservedInstancesModification `json:"-" xml:"-"` -} - -type metadataReservedInstancesModification struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -21070,19 +20035,15 @@ func (s ReservedInstancesModification) GoString() string { } type ReservedInstancesModificationResult struct { - // The ID for the Reserved Instances that were created as part of the modification + _ struct{} `type:"structure"` + + // The ID for the Reserved instances that were created as part of the modification // request. This field is only available when the modification is fulfilled. ReservedInstancesId *string `locationName:"reservedInstancesId" type:"string"` - // The target Reserved Instances configurations supplied as part of the modification + // The target Reserved instances configurations supplied as part of the modification // request. TargetConfiguration *ReservedInstancesConfiguration `locationName:"targetConfiguration" type:"structure"` - - metadataReservedInstancesModificationResult `json:"-" xml:"-"` -} - -type metadataReservedInstancesModificationResult struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -21095,26 +20056,28 @@ func (s ReservedInstancesModificationResult) GoString() string { return s.String() } -// Describes a Reserved Instance offering. +// Describes a Reserved instance offering. type ReservedInstancesOffering struct { - // The Availability Zone in which the Reserved Instance can be used. + _ struct{} `type:"structure"` + + // The Availability Zone in which the Reserved instance can be used. AvailabilityZone *string `locationName:"availabilityZone" type:"string"` - // The currency of the Reserved Instance offering you are purchasing. It's specified + // The currency of the Reserved instance offering you are purchasing. It's specified // using ISO 4217 standard currency codes. At this time, the only supported // currency is USD. CurrencyCode *string `locationName:"currencyCode" type:"string" enum:"CurrencyCodeValues"` - // The duration of the Reserved Instance, in seconds. + // The duration of the Reserved instance, in seconds. Duration *int64 `locationName:"duration" type:"long"` - // The purchase price of the Reserved Instance. + // The purchase price of the Reserved instance. FixedPrice *float64 `locationName:"fixedPrice" type:"float"` // The tenancy of the reserved instance. InstanceTenancy *string `locationName:"instanceTenancy" type:"string" enum:"Tenancy"` - // The instance type on which the Reserved Instance can be used. + // The instance type on which the Reserved instance can be used. InstanceType *string `locationName:"instanceType" type:"string" enum:"InstanceType"` // Indicates whether the offering is available through the Reserved Instance @@ -21122,29 +20085,23 @@ type ReservedInstancesOffering struct { // this is true. Marketplace *bool `locationName:"marketplace" type:"boolean"` - // The Reserved Instance offering type. + // The Reserved instance offering type. OfferingType *string `locationName:"offeringType" type:"string" enum:"OfferingTypeValues"` - // The pricing details of the Reserved Instance offering. + // The pricing details of the Reserved instance offering. PricingDetails []*PricingDetail `locationName:"pricingDetailsSet" locationNameList:"item" type:"list"` - // The Reserved Instance product platform description. + // The Reserved instance product platform description. ProductDescription *string `locationName:"productDescription" type:"string" enum:"RIProductDescription"` // The recurring charge tag assigned to the resource. RecurringCharges []*RecurringCharge `locationName:"recurringCharges" locationNameList:"item" type:"list"` - // The ID of the Reserved Instance offering. + // The ID of the Reserved instance offering. ReservedInstancesOfferingId *string `locationName:"reservedInstancesOfferingId" type:"string"` - // The usage price of the Reserved Instance, per hour. + // The usage price of the Reserved instance, per hour. UsagePrice *float64 `locationName:"usagePrice" type:"float"` - - metadataReservedInstancesOffering `json:"-" xml:"-"` -} - -type metadataReservedInstancesOffering struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -21158,6 +20115,8 @@ func (s ReservedInstancesOffering) GoString() string { } type ResetImageAttributeInput struct { + _ struct{} `type:"structure"` + // The attribute to reset (currently you can only reset the launch permission // attribute). Attribute *string `type:"string" required:"true" enum:"ResetImageAttributeName"` @@ -21170,12 +20129,6 @@ type ResetImageAttributeInput struct { // The ID of the AMI. ImageId *string `type:"string" required:"true"` - - metadataResetImageAttributeInput `json:"-" xml:"-"` -} - -type metadataResetImageAttributeInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -21189,11 +20142,7 @@ func (s ResetImageAttributeInput) GoString() string { } type ResetImageAttributeOutput struct { - metadataResetImageAttributeOutput `json:"-" xml:"-"` -} - -type metadataResetImageAttributeOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -21207,6 +20156,8 @@ func (s ResetImageAttributeOutput) GoString() string { } type ResetInstanceAttributeInput struct { + _ struct{} `type:"structure"` + // The attribute to reset. Attribute *string `locationName:"attribute" type:"string" required:"true" enum:"InstanceAttributeName"` @@ -21218,12 +20169,6 @@ type ResetInstanceAttributeInput struct { // The ID of the instance. InstanceId *string `locationName:"instanceId" type:"string" required:"true"` - - metadataResetInstanceAttributeInput `json:"-" xml:"-"` -} - -type metadataResetInstanceAttributeInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -21237,11 +20182,7 @@ func (s ResetInstanceAttributeInput) GoString() string { } type ResetInstanceAttributeOutput struct { - metadataResetInstanceAttributeOutput `json:"-" xml:"-"` -} - -type metadataResetInstanceAttributeOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -21255,6 +20196,8 @@ func (s ResetInstanceAttributeOutput) GoString() string { } type ResetNetworkInterfaceAttributeInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -21266,12 +20209,6 @@ type ResetNetworkInterfaceAttributeInput struct { // The source/destination checking attribute. Resets the value to true. SourceDestCheck *string `locationName:"sourceDestCheck" type:"string"` - - metadataResetNetworkInterfaceAttributeInput `json:"-" xml:"-"` -} - -type metadataResetNetworkInterfaceAttributeInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -21285,11 +20222,7 @@ func (s ResetNetworkInterfaceAttributeInput) GoString() string { } type ResetNetworkInterfaceAttributeOutput struct { - metadataResetNetworkInterfaceAttributeOutput `json:"-" xml:"-"` -} - -type metadataResetNetworkInterfaceAttributeOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -21303,6 +20236,8 @@ func (s ResetNetworkInterfaceAttributeOutput) GoString() string { } type ResetSnapshotAttributeInput struct { + _ struct{} `type:"structure"` + // The attribute to reset. Currently, only the attribute for permission to create // volumes can be reset. Attribute *string `type:"string" required:"true" enum:"SnapshotAttributeName"` @@ -21315,12 +20250,6 @@ type ResetSnapshotAttributeInput struct { // The ID of the snapshot. SnapshotId *string `type:"string" required:"true"` - - metadataResetSnapshotAttributeInput `json:"-" xml:"-"` -} - -type metadataResetSnapshotAttributeInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -21334,11 +20263,7 @@ func (s ResetSnapshotAttributeInput) GoString() string { } type ResetSnapshotAttributeOutput struct { - metadataResetSnapshotAttributeOutput `json:"-" xml:"-"` -} - -type metadataResetSnapshotAttributeOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -21352,6 +20277,8 @@ func (s ResetSnapshotAttributeOutput) GoString() string { } type RestoreAddressToClassicInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -21360,12 +20287,6 @@ type RestoreAddressToClassicInput struct { // The Elastic IP address. PublicIp *string `locationName:"publicIp" type:"string" required:"true"` - - metadataRestoreAddressToClassicInput `json:"-" xml:"-"` -} - -type metadataRestoreAddressToClassicInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -21379,17 +20300,13 @@ func (s RestoreAddressToClassicInput) GoString() string { } type RestoreAddressToClassicOutput struct { + _ struct{} `type:"structure"` + // The Elastic IP address. PublicIp *string `locationName:"publicIp" type:"string"` // The move status for the IP address. Status *string `locationName:"status" type:"string" enum:"Status"` - - metadataRestoreAddressToClassicOutput `json:"-" xml:"-"` -} - -type metadataRestoreAddressToClassicOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -21403,6 +20320,8 @@ func (s RestoreAddressToClassicOutput) GoString() string { } type RevokeSecurityGroupEgressInput struct { + _ struct{} `type:"structure"` + // The CIDR IP address range. You can't specify this parameter when specifying // a source security group. CidrIp *string `locationName:"cidrIp" type:"string"` @@ -21441,12 +20360,6 @@ type RevokeSecurityGroupEgressInput struct { // The end of port range for the TCP and UDP protocols, or an ICMP code number. // For the ICMP code number, use -1 to specify all ICMP codes for the ICMP type. ToPort *int64 `locationName:"toPort" type:"integer"` - - metadataRevokeSecurityGroupEgressInput `json:"-" xml:"-"` -} - -type metadataRevokeSecurityGroupEgressInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -21460,11 +20373,7 @@ func (s RevokeSecurityGroupEgressInput) GoString() string { } type RevokeSecurityGroupEgressOutput struct { - metadataRevokeSecurityGroupEgressOutput `json:"-" xml:"-"` -} - -type metadataRevokeSecurityGroupEgressOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -21478,6 +20387,8 @@ func (s RevokeSecurityGroupEgressOutput) GoString() string { } type RevokeSecurityGroupIngressInput struct { + _ struct{} `type:"structure"` + // The CIDR IP address range. You can't specify this parameter when specifying // a source security group. CidrIp *string `type:"string"` @@ -21525,12 +20436,6 @@ type RevokeSecurityGroupIngressInput struct { // The end of port range for the TCP and UDP protocols, or an ICMP code number. // For the ICMP code number, use -1 to specify all ICMP codes for the ICMP type. ToPort *int64 `type:"integer"` - - metadataRevokeSecurityGroupIngressInput `json:"-" xml:"-"` -} - -type metadataRevokeSecurityGroupIngressInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -21544,11 +20449,7 @@ func (s RevokeSecurityGroupIngressInput) GoString() string { } type RevokeSecurityGroupIngressOutput struct { - metadataRevokeSecurityGroupIngressOutput `json:"-" xml:"-"` -} - -type metadataRevokeSecurityGroupIngressOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -21563,6 +20464,8 @@ func (s RevokeSecurityGroupIngressOutput) GoString() string { // Describes a route in a route table. type Route struct { + _ struct{} `type:"structure"` + // The CIDR block used for the destination match. DestinationCidrBlock *string `locationName:"destinationCidrBlock" type:"string"` @@ -21583,9 +20486,9 @@ type Route struct { // Describes how the route was created. // - // CreateRouteTable indicates that route was automatically created when the - // route table was created. CreateRoute indicates that the route was manually - // added to the route table. EnableVgwRoutePropagation indicates that the route + // CreateRouteTable indicates that route was automatically created when the + // route table was created. CreateRoute indicates that the route was manually + // added to the route table. EnableVgwRoutePropagation indicates that the route // was propagated by route propagation. Origin *string `locationName:"origin" type:"string" enum:"RouteOrigin"` @@ -21596,12 +20499,6 @@ type Route struct { // The ID of the VPC peering connection. VpcPeeringConnectionId *string `locationName:"vpcPeeringConnectionId" type:"string"` - - metadataRoute `json:"-" xml:"-"` -} - -type metadataRoute struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -21616,6 +20513,8 @@ func (s Route) GoString() string { // Describes a route table. type RouteTable struct { + _ struct{} `type:"structure"` + // The associations between the route table and one or more subnets. Associations []*RouteTableAssociation `locationName:"associationSet" locationNameList:"item" type:"list"` @@ -21633,12 +20532,6 @@ type RouteTable struct { // The ID of the VPC. VpcId *string `locationName:"vpcId" type:"string"` - - metadataRouteTable `json:"-" xml:"-"` -} - -type metadataRouteTable struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -21653,6 +20546,8 @@ func (s RouteTable) GoString() string { // Describes an association between a route table and a subnet. type RouteTableAssociation struct { + _ struct{} `type:"structure"` + // Indicates whether this is the main route table. Main *bool `locationName:"main" type:"boolean"` @@ -21664,12 +20559,6 @@ type RouteTableAssociation struct { // The ID of the subnet. A subnet ID is not returned for an implicit association. SubnetId *string `locationName:"subnetId" type:"string"` - - metadataRouteTableAssociation `json:"-" xml:"-"` -} - -type metadataRouteTableAssociation struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -21683,6 +20572,8 @@ func (s RouteTableAssociation) GoString() string { } type RunInstancesInput struct { + _ struct{} `type:"structure"` + // Reserved. AdditionalInfo *string `locationName:"additionalInfo" type:"string"` @@ -21815,12 +20706,6 @@ type RunInstancesInput struct { // The Base64-encoded MIME user data for the instances. UserData *string `type:"string"` - - metadataRunInstancesInput `json:"-" xml:"-"` -} - -type metadataRunInstancesInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -21835,14 +20720,10 @@ func (s RunInstancesInput) GoString() string { // Describes the monitoring for the instance. type RunInstancesMonitoringEnabled struct { + _ struct{} `type:"structure"` + // Indicates whether monitoring is enabled for the instance. Enabled *bool `locationName:"enabled" type:"boolean" required:"true"` - - metadataRunInstancesMonitoringEnabled `json:"-" xml:"-"` -} - -type metadataRunInstancesMonitoringEnabled struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -21858,6 +20739,8 @@ func (s RunInstancesMonitoringEnabled) GoString() string { // Describes the storage parameters for S3 and S3 buckets for an instance store-backed // AMI. type S3Storage struct { + _ struct{} `type:"structure"` + // The access key ID of the owner of the bucket. Before you specify a value // for your access key ID, review and follow the guidance in Best Practices // for Managing AWS Access Keys (http://docs.aws.amazon.com/general/latest/gr/aws-access-keys-best-practices.html). @@ -21877,12 +20760,6 @@ type S3Storage struct { // The signature of the Base64 encoded JSON document. UploadPolicySignature *string `locationName:"uploadPolicySignature" type:"string"` - - metadataS3Storage `json:"-" xml:"-"` -} - -type metadataS3Storage struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -21897,6 +20774,8 @@ func (s S3Storage) GoString() string { // Describes a security group type SecurityGroup struct { + _ struct{} `type:"structure"` + // A description of the security group. Description *string `locationName:"groupDescription" type:"string"` @@ -21920,12 +20799,6 @@ type SecurityGroup struct { // [EC2-VPC] The ID of the VPC for the security group. VpcId *string `locationName:"vpcId" type:"string"` - - metadataSecurityGroup `json:"-" xml:"-"` -} - -type metadataSecurityGroup struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -21940,6 +20813,8 @@ func (s SecurityGroup) GoString() string { // Describes a snapshot. type Snapshot struct { + _ struct{} `type:"structure"` + // The data encryption key identifier for the snapshot. This value is a unique // identifier that corresponds to the data encryption key that was used to encrypt // the original volume or snapshot copy. Because data encryption keys are inherited @@ -21994,12 +20869,6 @@ type Snapshot struct { // The size of the volume, in GiB. VolumeSize *int64 `locationName:"volumeSize" type:"integer"` - - metadataSnapshot `json:"-" xml:"-"` -} - -type metadataSnapshot struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -22014,6 +20883,8 @@ func (s Snapshot) GoString() string { // Describes the snapshot created from the imported disk. type SnapshotDetail struct { + _ struct{} `type:"structure"` + // A description for the snapshot. Description *string `locationName:"description" type:"string"` @@ -22043,12 +20914,6 @@ type SnapshotDetail struct { // Describes the S3 bucket for the disk image. UserBucket *UserBucketDetails `locationName:"userBucket" type:"structure"` - - metadataSnapshotDetail `json:"-" xml:"-"` -} - -type metadataSnapshotDetail struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -22063,6 +20928,8 @@ func (s SnapshotDetail) GoString() string { // The disk container object for the import snapshot request. type SnapshotDiskContainer struct { + _ struct{} `type:"structure"` + // The description of the disk image being imported. Description *string `type:"string"` @@ -22077,12 +20944,6 @@ type SnapshotDiskContainer struct { // Describes the S3 bucket for the disk image. UserBucket *UserBucket `type:"structure"` - - metadataSnapshotDiskContainer `json:"-" xml:"-"` -} - -type metadataSnapshotDiskContainer struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -22097,6 +20958,8 @@ func (s SnapshotDiskContainer) GoString() string { // Details about the import snapshot task. type SnapshotTaskDetail struct { + _ struct{} `type:"structure"` + // The description of the snapshot. Description *string `locationName:"description" type:"string"` @@ -22123,12 +20986,6 @@ type SnapshotTaskDetail struct { // The S3 bucket for the disk image. UserBucket *UserBucketDetails `locationName:"userBucket" type:"structure"` - - metadataSnapshotTaskDetail `json:"-" xml:"-"` -} - -type metadataSnapshotTaskDetail struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -22143,6 +21000,8 @@ func (s SnapshotTaskDetail) GoString() string { // Describes the data feed for a Spot instance. type SpotDatafeedSubscription struct { + _ struct{} `type:"structure"` + // The Amazon S3 bucket where the Spot instance data feed is located. Bucket *string `locationName:"bucket" type:"string"` @@ -22157,12 +21016,6 @@ type SpotDatafeedSubscription struct { // The state of the Spot instance data feed subscription. State *string `locationName:"state" type:"string" enum:"DatafeedSubscriptionState"` - - metadataSpotDatafeedSubscription `json:"-" xml:"-"` -} - -type metadataSpotDatafeedSubscription struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -22177,6 +21030,8 @@ func (s SpotDatafeedSubscription) GoString() string { // Describes the launch specification for one or more Spot instances. type SpotFleetLaunchSpecification struct { + _ struct{} `type:"structure"` + // Deprecated. AddressingType *string `locationName:"addressingType" type:"string"` @@ -22244,12 +21099,6 @@ type SpotFleetLaunchSpecification struct { // the number of instances to the next whole number. If this value is not specified, // the default is 1. WeightedCapacity *float64 `locationName:"weightedCapacity" type:"double"` - - metadataSpotFleetLaunchSpecification `json:"-" xml:"-"` -} - -type metadataSpotFleetLaunchSpecification struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -22264,16 +21113,12 @@ func (s SpotFleetLaunchSpecification) GoString() string { // Describes whether monitoring is enabled. type SpotFleetMonitoring struct { + _ struct{} `type:"structure"` + // Enables monitoring for the instance. // // Default: false Enabled *bool `locationName:"enabled" type:"boolean"` - - metadataSpotFleetMonitoring `json:"-" xml:"-"` -} - -type metadataSpotFleetMonitoring struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -22288,6 +21133,8 @@ func (s SpotFleetMonitoring) GoString() string { // Describes a Spot fleet request. type SpotFleetRequestConfig struct { + _ struct{} `type:"structure"` + // The creation date and time of the request. CreateTime *time.Time `locationName:"createTime" type:"timestamp" timestampFormat:"iso8601" required:"true"` @@ -22299,12 +21146,6 @@ type SpotFleetRequestConfig struct { // The state of the Spot fleet request. SpotFleetRequestState *string `locationName:"spotFleetRequestState" type:"string" required:"true" enum:"BatchState"` - - metadataSpotFleetRequestConfig `json:"-" xml:"-"` -} - -type metadataSpotFleetRequestConfig struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -22319,6 +21160,8 @@ func (s SpotFleetRequestConfig) GoString() string { // Describes the configuration of a Spot fleet request. type SpotFleetRequestConfigData struct { + _ struct{} `type:"structure"` + // Indicates how to allocate the target capacity across the Spot pools specified // by the Spot fleet request. The default is lowestPrice. AllocationStrategy *string `locationName:"allocationStrategy" type:"string" enum:"AllocationStrategy"` @@ -22361,12 +21204,6 @@ type SpotFleetRequestConfigData struct { // At this point, no new Spot instance requests are placed or enabled to fulfill // the request. ValidUntil *time.Time `locationName:"validUntil" type:"timestamp" timestampFormat:"iso8601"` - - metadataSpotFleetRequestConfigData `json:"-" xml:"-"` -} - -type metadataSpotFleetRequestConfigData struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -22381,6 +21218,8 @@ func (s SpotFleetRequestConfigData) GoString() string { // Describes a Spot instance request. type SpotInstanceRequest struct { + _ struct{} `type:"structure"` + // If you specified a duration and your Spot instance request was fulfilled, // this is the fixed hourly price in effect for the Spot instance while it runs. ActualBlockHourlyPrice *string `locationName:"actualBlockHourlyPrice" type:"string"` @@ -22448,12 +21287,6 @@ type SpotInstanceRequest struct { // the request is canceled, or this date is reached. If the request is persistent, // it remains active until it is canceled or this date is reached. ValidUntil *time.Time `locationName:"validUntil" type:"timestamp" timestampFormat:"iso8601"` - - metadataSpotInstanceRequest `json:"-" xml:"-"` -} - -type metadataSpotInstanceRequest struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -22468,17 +21301,13 @@ func (s SpotInstanceRequest) GoString() string { // Describes a Spot instance state change. type SpotInstanceStateFault struct { + _ struct{} `type:"structure"` + // The reason code for the Spot instance state change. Code *string `locationName:"code" type:"string"` // The message for the Spot instance state change. Message *string `locationName:"message" type:"string"` - - metadataSpotInstanceStateFault `json:"-" xml:"-"` -} - -type metadataSpotInstanceStateFault struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -22493,6 +21322,8 @@ func (s SpotInstanceStateFault) GoString() string { // Describes the status of a Spot instance request. type SpotInstanceStatus struct { + _ struct{} `type:"structure"` + // The status code. For a list of status codes, see Spot Bid Status Codes (http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/spot-bid-status.html#spot-instance-bid-status-understand) // in the Amazon Elastic Compute Cloud User Guide. Code *string `locationName:"code" type:"string"` @@ -22503,12 +21334,6 @@ type SpotInstanceStatus struct { // The date and time of the most recent status update, in UTC format (for example, // YYYY-MM-DDTHH:MM:SSZ). UpdateTime *time.Time `locationName:"updateTime" type:"timestamp" timestampFormat:"iso8601"` - - metadataSpotInstanceStatus `json:"-" xml:"-"` -} - -type metadataSpotInstanceStatus struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -22523,17 +21348,13 @@ func (s SpotInstanceStatus) GoString() string { // Describes Spot instance placement. type SpotPlacement struct { + _ struct{} `type:"structure"` + // The Availability Zone. AvailabilityZone *string `locationName:"availabilityZone" type:"string"` // The name of the placement group (for cluster instances). GroupName *string `locationName:"groupName" type:"string"` - - metadataSpotPlacement `json:"-" xml:"-"` -} - -type metadataSpotPlacement struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -22549,6 +21370,8 @@ func (s SpotPlacement) GoString() string { // Describes the maximum hourly price (bid) for any Spot instance launched to // fulfill the request. type SpotPrice struct { + _ struct{} `type:"structure"` + // The Availability Zone. AvailabilityZone *string `locationName:"availabilityZone" type:"string"` @@ -22563,12 +21386,6 @@ type SpotPrice struct { // The date and time the request was created, in UTC format (for example, YYYY-MM-DDTHH:MM:SSZ). Timestamp *time.Time `locationName:"timestamp" type:"timestamp" timestampFormat:"iso8601"` - - metadataSpotPrice `json:"-" xml:"-"` -} - -type metadataSpotPrice struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -22582,6 +21399,8 @@ func (s SpotPrice) GoString() string { } type StartInstancesInput struct { + _ struct{} `type:"structure"` + // Reserved. AdditionalInfo *string `locationName:"additionalInfo" type:"string"` @@ -22593,12 +21412,6 @@ type StartInstancesInput struct { // One or more instance IDs. InstanceIds []*string `locationName:"InstanceId" locationNameList:"InstanceId" type:"list" required:"true"` - - metadataStartInstancesInput `json:"-" xml:"-"` -} - -type metadataStartInstancesInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -22612,14 +21425,10 @@ func (s StartInstancesInput) GoString() string { } type StartInstancesOutput struct { + _ struct{} `type:"structure"` + // Information about one or more started instances. StartingInstances []*InstanceStateChange `locationName:"instancesSet" locationNameList:"item" type:"list"` - - metadataStartInstancesOutput `json:"-" xml:"-"` -} - -type metadataStartInstancesOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -22634,12 +21443,14 @@ func (s StartInstancesOutput) GoString() string { // Describes a state change. type StateReason struct { + _ struct{} `type:"structure"` + // The reason code for the state change. Code *string `locationName:"code" type:"string"` // The message for the state change. // - // Server.SpotInstanceTermination: A Spot Instance was terminated due to an + // Server.SpotInstanceTermination: A Spot instance was terminated due to an // increase in the market price. // // Server.InternalError: An internal error occurred during instance launch, @@ -22661,12 +21472,6 @@ type StateReason struct { // // Client.InvalidSnapshot.NotFound: The specified snapshot was not found. Message *string `locationName:"message" type:"string"` - - metadataStateReason `json:"-" xml:"-"` -} - -type metadataStateReason struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -22680,6 +21485,8 @@ func (s StateReason) GoString() string { } type StopInstancesInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -22696,12 +21503,6 @@ type StopInstancesInput struct { // One or more instance IDs. InstanceIds []*string `locationName:"InstanceId" locationNameList:"InstanceId" type:"list" required:"true"` - - metadataStopInstancesInput `json:"-" xml:"-"` -} - -type metadataStopInstancesInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -22715,14 +21516,10 @@ func (s StopInstancesInput) GoString() string { } type StopInstancesOutput struct { + _ struct{} `type:"structure"` + // Information about one or more stopped instances. StoppingInstances []*InstanceStateChange `locationName:"instancesSet" locationNameList:"item" type:"list"` - - metadataStopInstancesOutput `json:"-" xml:"-"` -} - -type metadataStopInstancesOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -22737,14 +21534,10 @@ func (s StopInstancesOutput) GoString() string { // Describes the storage location for an instance store-backed AMI. type Storage struct { + _ struct{} `type:"structure"` + // An Amazon S3 storage location. S3 *S3Storage `type:"structure"` - - metadataStorage `json:"-" xml:"-"` -} - -type metadataStorage struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -22759,6 +21552,8 @@ func (s Storage) GoString() string { // Describes a subnet. type Subnet struct { + _ struct{} `type:"structure"` + // The Availability Zone of the subnet. AvailabilityZone *string `locationName:"availabilityZone" type:"string"` @@ -22786,12 +21581,6 @@ type Subnet struct { // The ID of the VPC the subnet is in. VpcId *string `locationName:"vpcId" type:"string"` - - metadataSubnet `json:"-" xml:"-"` -} - -type metadataSubnet struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -22806,6 +21595,8 @@ func (s Subnet) GoString() string { // Describes a tag. type Tag struct { + _ struct{} `type:"structure"` + // The key of the tag. // // Constraints: Tag keys are case-sensitive and accept a maximum of 127 Unicode @@ -22817,12 +21608,6 @@ type Tag struct { // Constraints: Tag values are case-sensitive and accept a maximum of 255 Unicode // characters. Value *string `locationName:"value" type:"string"` - - metadataTag `json:"-" xml:"-"` -} - -type metadataTag struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -22837,6 +21622,8 @@ func (s Tag) GoString() string { // Describes a tag. type TagDescription struct { + _ struct{} `type:"structure"` + // The tag key. Key *string `locationName:"key" type:"string"` @@ -22848,12 +21635,6 @@ type TagDescription struct { // The tag value. Value *string `locationName:"value" type:"string"` - - metadataTagDescription `json:"-" xml:"-"` -} - -type metadataTagDescription struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -22867,6 +21648,8 @@ func (s TagDescription) GoString() string { } type TerminateInstancesInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -22875,12 +21658,6 @@ type TerminateInstancesInput struct { // One or more instance IDs. InstanceIds []*string `locationName:"InstanceId" locationNameList:"InstanceId" type:"list" required:"true"` - - metadataTerminateInstancesInput `json:"-" xml:"-"` -} - -type metadataTerminateInstancesInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -22894,14 +21671,10 @@ func (s TerminateInstancesInput) GoString() string { } type TerminateInstancesOutput struct { + _ struct{} `type:"structure"` + // Information about one or more terminated instances. TerminatingInstances []*InstanceStateChange `locationName:"instancesSet" locationNameList:"item" type:"list"` - - metadataTerminateInstancesOutput `json:"-" xml:"-"` -} - -type metadataTerminateInstancesOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -22915,18 +21688,14 @@ func (s TerminateInstancesOutput) GoString() string { } type UnassignPrivateIpAddressesInput struct { + _ struct{} `type:"structure"` + // The ID of the network interface. NetworkInterfaceId *string `locationName:"networkInterfaceId" type:"string" required:"true"` // The secondary private IP addresses to unassign from the network interface. // You can specify this option multiple times to unassign more than one IP address. PrivateIpAddresses []*string `locationName:"privateIpAddress" locationNameList:"PrivateIpAddress" type:"list" required:"true"` - - metadataUnassignPrivateIpAddressesInput `json:"-" xml:"-"` -} - -type metadataUnassignPrivateIpAddressesInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -22940,11 +21709,7 @@ func (s UnassignPrivateIpAddressesInput) GoString() string { } type UnassignPrivateIpAddressesOutput struct { - metadataUnassignPrivateIpAddressesOutput `json:"-" xml:"-"` -} - -type metadataUnassignPrivateIpAddressesOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -22958,6 +21723,8 @@ func (s UnassignPrivateIpAddressesOutput) GoString() string { } type UnmonitorInstancesInput struct { + _ struct{} `type:"structure"` + // Checks whether you have the required permissions for the action, without // actually making the request, and provides an error response. If you have // the required permissions, the error response is DryRunOperation. Otherwise, @@ -22966,12 +21733,6 @@ type UnmonitorInstancesInput struct { // One or more instance IDs. InstanceIds []*string `locationName:"InstanceId" locationNameList:"InstanceId" type:"list" required:"true"` - - metadataUnmonitorInstancesInput `json:"-" xml:"-"` -} - -type metadataUnmonitorInstancesInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -22985,14 +21746,10 @@ func (s UnmonitorInstancesInput) GoString() string { } type UnmonitorInstancesOutput struct { + _ struct{} `type:"structure"` + // Monitoring information for one or more instances. InstanceMonitorings []*InstanceMonitoring `locationName:"instancesSet" locationNameList:"item" type:"list"` - - metadataUnmonitorInstancesOutput `json:"-" xml:"-"` -} - -type metadataUnmonitorInstancesOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -23007,17 +21764,13 @@ func (s UnmonitorInstancesOutput) GoString() string { // Information about items that were not successfully processed in a batch call. type UnsuccessfulItem struct { + _ struct{} `type:"structure"` + // Information about the error. Error *UnsuccessfulItemError `locationName:"error" type:"structure" required:"true"` // The ID of the resource. ResourceId *string `locationName:"resourceId" type:"string"` - - metadataUnsuccessfulItem `json:"-" xml:"-"` -} - -type metadataUnsuccessfulItem struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -23033,17 +21786,13 @@ func (s UnsuccessfulItem) GoString() string { // Information about the error that occurred. For more information about errors, // see Error Codes (http://docs.aws.amazon.com/AWSEC2/latest/APIReference/errors-overview.html). type UnsuccessfulItemError struct { + _ struct{} `type:"structure"` + // The error code. Code *string `locationName:"code" type:"string" required:"true"` // The error message accompanying the error code. Message *string `locationName:"message" type:"string" required:"true"` - - metadataUnsuccessfulItemError `json:"-" xml:"-"` -} - -type metadataUnsuccessfulItemError struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -23058,17 +21807,13 @@ func (s UnsuccessfulItemError) GoString() string { // Describes the S3 bucket for the disk image. type UserBucket struct { + _ struct{} `type:"structure"` + // The name of the S3 bucket where the disk image is located. S3Bucket *string `type:"string"` // The key for the disk image. S3Key *string `type:"string"` - - metadataUserBucket `json:"-" xml:"-"` -} - -type metadataUserBucket struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -23083,17 +21828,13 @@ func (s UserBucket) GoString() string { // Describes the S3 bucket for the disk image. type UserBucketDetails struct { + _ struct{} `type:"structure"` + // The S3 bucket from which the disk image was created. S3Bucket *string `locationName:"s3Bucket" type:"string"` // The key from which the disk image was created. S3Key *string `locationName:"s3Key" type:"string"` - - metadataUserBucketDetails `json:"-" xml:"-"` -} - -type metadataUserBucketDetails struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -23108,14 +21849,10 @@ func (s UserBucketDetails) GoString() string { // Describes the user data to be made available to an instance. type UserData struct { + _ struct{} `type:"structure"` + // The Base64-encoded MIME user data for the instance. Data *string `locationName:"data" type:"string"` - - metadataUserData `json:"-" xml:"-"` -} - -type metadataUserData struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -23130,6 +21867,8 @@ func (s UserData) GoString() string { // Describes a security group and AWS account ID pair. type UserIdGroupPair struct { + _ struct{} `type:"structure"` + // The ID of the security group. GroupId *string `locationName:"groupId" type:"string"` @@ -23140,12 +21879,6 @@ type UserIdGroupPair struct { // The ID of an AWS account. EC2-Classic only. UserId *string `locationName:"userId" type:"string"` - - metadataUserIdGroupPair `json:"-" xml:"-"` -} - -type metadataUserIdGroupPair struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -23160,6 +21893,8 @@ func (s UserIdGroupPair) GoString() string { // Describes telemetry for a VPN tunnel. type VgwTelemetry struct { + _ struct{} `type:"structure"` + // The number of accepted routes. AcceptedRouteCount *int64 `locationName:"acceptedRouteCount" type:"integer"` @@ -23175,12 +21910,6 @@ type VgwTelemetry struct { // If an error occurs, a description of the error. StatusMessage *string `locationName:"statusMessage" type:"string"` - - metadataVgwTelemetry `json:"-" xml:"-"` -} - -type metadataVgwTelemetry struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -23195,6 +21924,8 @@ func (s VgwTelemetry) GoString() string { // Describes a volume. type Volume struct { + _ struct{} `type:"structure"` + // Information about the volume attachments. Attachments []*VolumeAttachment `locationName:"attachmentSet" locationNameList:"item" type:"list"` @@ -23244,12 +21975,6 @@ type Volume struct { // The volume type. This can be gp2 for General Purpose (SSD) volumes, io1 for // Provisioned IOPS (SSD) volumes, or standard for Magnetic volumes. VolumeType *string `locationName:"volumeType" type:"string" enum:"VolumeType"` - - metadataVolume `json:"-" xml:"-"` -} - -type metadataVolume struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -23264,6 +21989,8 @@ func (s Volume) GoString() string { // Describes volume attachment details. type VolumeAttachment struct { + _ struct{} `type:"structure"` + // The time stamp when the attachment initiated. AttachTime *time.Time `locationName:"attachTime" type:"timestamp" timestampFormat:"iso8601"` @@ -23281,12 +22008,6 @@ type VolumeAttachment struct { // The ID of the volume. VolumeId *string `locationName:"volumeId" type:"string"` - - metadataVolumeAttachment `json:"-" xml:"-"` -} - -type metadataVolumeAttachment struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -23301,14 +22022,10 @@ func (s VolumeAttachment) GoString() string { // Describes an EBS volume. type VolumeDetail struct { + _ struct{} `type:"structure"` + // The size of the volume, in GiB. Size *int64 `locationName:"size" type:"long" required:"true"` - - metadataVolumeDetail `json:"-" xml:"-"` -} - -type metadataVolumeDetail struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -23323,6 +22040,8 @@ func (s VolumeDetail) GoString() string { // Describes a volume status operation code. type VolumeStatusAction struct { + _ struct{} `type:"structure"` + // The code identifying the operation, for example, enable-volume-io. Code *string `locationName:"code" type:"string"` @@ -23334,12 +22053,6 @@ type VolumeStatusAction struct { // The event type associated with this operation. EventType *string `locationName:"eventType" type:"string"` - - metadataVolumeStatusAction `json:"-" xml:"-"` -} - -type metadataVolumeStatusAction struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -23354,17 +22067,13 @@ func (s VolumeStatusAction) GoString() string { // Describes a volume status. type VolumeStatusDetails struct { + _ struct{} `type:"structure"` + // The name of the volume status. Name *string `locationName:"name" type:"string" enum:"VolumeStatusName"` // The intended status of the volume status. Status *string `locationName:"status" type:"string"` - - metadataVolumeStatusDetails `json:"-" xml:"-"` -} - -type metadataVolumeStatusDetails struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -23379,6 +22088,8 @@ func (s VolumeStatusDetails) GoString() string { // Describes a volume status event. type VolumeStatusEvent struct { + _ struct{} `type:"structure"` + // A description of the event. Description *string `locationName:"description" type:"string"` @@ -23393,12 +22104,6 @@ type VolumeStatusEvent struct { // The earliest start time of the event. NotBefore *time.Time `locationName:"notBefore" type:"timestamp" timestampFormat:"iso8601"` - - metadataVolumeStatusEvent `json:"-" xml:"-"` -} - -type metadataVolumeStatusEvent struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -23413,17 +22118,13 @@ func (s VolumeStatusEvent) GoString() string { // Describes the status of a volume. type VolumeStatusInfo struct { + _ struct{} `type:"structure"` + // The details of the volume status. Details []*VolumeStatusDetails `locationName:"details" locationNameList:"item" type:"list"` // The status of the volume. Status *string `locationName:"status" type:"string" enum:"VolumeStatusInfoStatus"` - - metadataVolumeStatusInfo `json:"-" xml:"-"` -} - -type metadataVolumeStatusInfo struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -23438,6 +22139,8 @@ func (s VolumeStatusInfo) GoString() string { // Describes the volume status. type VolumeStatusItem struct { + _ struct{} `type:"structure"` + // The details of the operation. Actions []*VolumeStatusAction `locationName:"actionsSet" locationNameList:"item" type:"list"` @@ -23452,12 +22155,6 @@ type VolumeStatusItem struct { // The volume status. VolumeStatus *VolumeStatusInfo `locationName:"volumeStatus" type:"structure"` - - metadataVolumeStatusItem `json:"-" xml:"-"` -} - -type metadataVolumeStatusItem struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -23472,6 +22169,8 @@ func (s VolumeStatusItem) GoString() string { // Describes a VPC. type Vpc struct { + _ struct{} `type:"structure"` + // The CIDR block for the VPC. CidrBlock *string `locationName:"cidrBlock" type:"string"` @@ -23493,12 +22192,6 @@ type Vpc struct { // The ID of the VPC. VpcId *string `locationName:"vpcId" type:"string"` - - metadataVpc `json:"-" xml:"-"` -} - -type metadataVpc struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -23513,17 +22206,13 @@ func (s Vpc) GoString() string { // Describes an attachment between a virtual private gateway and a VPC. type VpcAttachment struct { + _ struct{} `type:"structure"` + // The current state of the attachment. State *string `locationName:"state" type:"string" enum:"AttachmentStatus"` // The ID of the VPC. VpcId *string `locationName:"vpcId" type:"string"` - - metadataVpcAttachment `json:"-" xml:"-"` -} - -type metadataVpcAttachment struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -23538,6 +22227,8 @@ func (s VpcAttachment) GoString() string { // Describes whether a VPC is enabled for ClassicLink. type VpcClassicLink struct { + _ struct{} `type:"structure"` + // Indicates whether the VPC is enabled for ClassicLink. ClassicLinkEnabled *bool `locationName:"classicLinkEnabled" type:"boolean"` @@ -23546,12 +22237,6 @@ type VpcClassicLink struct { // The ID of the VPC. VpcId *string `locationName:"vpcId" type:"string"` - - metadataVpcClassicLink `json:"-" xml:"-"` -} - -type metadataVpcClassicLink struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -23566,6 +22251,8 @@ func (s VpcClassicLink) GoString() string { // Describes a VPC endpoint. type VpcEndpoint struct { + _ struct{} `type:"structure"` + // The date and time the VPC endpoint was created. CreationTimestamp *time.Time `locationName:"creationTimestamp" type:"timestamp" timestampFormat:"iso8601"` @@ -23586,12 +22273,6 @@ type VpcEndpoint struct { // The ID of the VPC to which the endpoint is associated. VpcId *string `locationName:"vpcId" type:"string"` - - metadataVpcEndpoint `json:"-" xml:"-"` -} - -type metadataVpcEndpoint struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -23606,6 +22287,8 @@ func (s VpcEndpoint) GoString() string { // Describes a VPC peering connection. type VpcPeeringConnection struct { + _ struct{} `type:"structure"` + // The information of the peer VPC. AccepterVpcInfo *VpcPeeringConnectionVpcInfo `locationName:"accepterVpcInfo" type:"structure"` @@ -23623,12 +22306,6 @@ type VpcPeeringConnection struct { // The ID of the VPC peering connection. VpcPeeringConnectionId *string `locationName:"vpcPeeringConnectionId" type:"string"` - - metadataVpcPeeringConnection `json:"-" xml:"-"` -} - -type metadataVpcPeeringConnection struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -23643,17 +22320,13 @@ func (s VpcPeeringConnection) GoString() string { // Describes the status of a VPC peering connection. type VpcPeeringConnectionStateReason struct { + _ struct{} `type:"structure"` + // The status of the VPC peering connection. Code *string `locationName:"code" type:"string" enum:"VpcPeeringConnectionStateReasonCode"` // A message that provides more information about the status, if applicable. Message *string `locationName:"message" type:"string"` - - metadataVpcPeeringConnectionStateReason `json:"-" xml:"-"` -} - -type metadataVpcPeeringConnectionStateReason struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -23668,6 +22341,8 @@ func (s VpcPeeringConnectionStateReason) GoString() string { // Describes a VPC in a VPC peering connection. type VpcPeeringConnectionVpcInfo struct { + _ struct{} `type:"structure"` + // The CIDR block for the VPC. CidrBlock *string `locationName:"cidrBlock" type:"string"` @@ -23676,12 +22351,6 @@ type VpcPeeringConnectionVpcInfo struct { // The ID of the VPC. VpcId *string `locationName:"vpcId" type:"string"` - - metadataVpcPeeringConnectionVpcInfo `json:"-" xml:"-"` -} - -type metadataVpcPeeringConnectionVpcInfo struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -23696,6 +22365,8 @@ func (s VpcPeeringConnectionVpcInfo) GoString() string { // Describes a VPN connection. type VpnConnection struct { + _ struct{} `type:"structure"` + // The configuration information for the VPN connection's customer gateway (in // the native XML format). This element is always present in the CreateVpnConnection // response; however, it's present in the DescribeVpnConnections response only @@ -23728,12 +22399,6 @@ type VpnConnection struct { // The ID of the virtual private gateway at the AWS side of the VPN connection. VpnGatewayId *string `locationName:"vpnGatewayId" type:"string"` - - metadataVpnConnection `json:"-" xml:"-"` -} - -type metadataVpnConnection struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -23748,15 +22413,11 @@ func (s VpnConnection) GoString() string { // Describes VPN connection options. type VpnConnectionOptions struct { + _ struct{} `type:"structure"` + // Indicates whether the VPN connection uses static routes only. Static routes // must be used for devices that don't support BGP. StaticRoutesOnly *bool `locationName:"staticRoutesOnly" type:"boolean"` - - metadataVpnConnectionOptions `json:"-" xml:"-"` -} - -type metadataVpnConnectionOptions struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -23771,15 +22432,11 @@ func (s VpnConnectionOptions) GoString() string { // Describes VPN connection options. type VpnConnectionOptionsSpecification struct { + _ struct{} `type:"structure"` + // Indicates whether the VPN connection uses static routes only. Static routes // must be used for devices that don't support BGP. StaticRoutesOnly *bool `locationName:"staticRoutesOnly" type:"boolean"` - - metadataVpnConnectionOptionsSpecification `json:"-" xml:"-"` -} - -type metadataVpnConnectionOptionsSpecification struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -23794,6 +22451,8 @@ func (s VpnConnectionOptionsSpecification) GoString() string { // Describes a virtual private gateway. type VpnGateway struct { + _ struct{} `type:"structure"` + // The Availability Zone where the virtual private gateway was created. AvailabilityZone *string `locationName:"availabilityZone" type:"string"` @@ -23811,12 +22470,6 @@ type VpnGateway struct { // The ID of the virtual private gateway. VpnGatewayId *string `locationName:"vpnGatewayId" type:"string"` - - metadataVpnGateway `json:"-" xml:"-"` -} - -type metadataVpnGateway struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -23831,6 +22484,8 @@ func (s VpnGateway) GoString() string { // Describes a static route for a VPN connection. type VpnStaticRoute struct { + _ struct{} `type:"structure"` + // The CIDR block associated with the local subnet of the customer data center. DestinationCidrBlock *string `locationName:"destinationCidrBlock" type:"string"` @@ -23839,12 +22494,6 @@ type VpnStaticRoute struct { // The current state of the static route. State *string `locationName:"state" type:"string" enum:"VpnState"` - - metadataVpnStaticRoute `json:"-" xml:"-"` -} - -type metadataVpnStaticRoute struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -23864,6 +22513,26 @@ const ( AccountAttributeNameDefaultVpc = "default-vpc" ) +const ( + // @enum Affinity + AffinityDefault = "default" + // @enum Affinity + AffinityHost = "host" +) + +const ( + // @enum AllocationState + AllocationStateAvailable = "available" + // @enum AllocationState + AllocationStateUnderAssessment = "under-assessment" + // @enum AllocationState + AllocationStatePermanentFailure = "permanent-failure" + // @enum AllocationState + AllocationStateReleased = "released" + // @enum AllocationState + AllocationStateReleasedPermanentFailure = "released-permanent-failure" +) + const ( // @enum AllocationStrategy AllocationStrategyLowestPrice = "lowestPrice" @@ -23889,6 +22558,13 @@ const ( AttachmentStatusDetached = "detached" ) +const ( + // @enum AutoPlacement + AutoPlacementOn = "on" + // @enum AutoPlacement + AutoPlacementOff = "off" +) + const ( // @enum AvailabilityZoneState AvailabilityZoneStateAvailable = "available" @@ -24072,6 +22748,13 @@ const ( GatewayTypeIpsec1 = "ipsec.1" ) +const ( + // @enum HostTenancy + HostTenancyDedicated = "dedicated" + // @enum HostTenancy + HostTenancyHost = "host" +) + const ( // @enum HypervisorType HypervisorTypeOvm = "ovm" @@ -24628,6 +23311,8 @@ const ( TenancyDefault = "default" // @enum Tenancy TenancyDedicated = "dedicated" + // @enum Tenancy + TenancyHost = "host" ) const ( diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/service/ec2/ec2iface/interface.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/service/ec2/ec2iface/interface.go index 5bcf93248..1625ad591 100644 --- a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/service/ec2/ec2iface/interface.go +++ b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/service/ec2/ec2iface/interface.go @@ -18,6 +18,10 @@ type EC2API interface { AllocateAddress(*ec2.AllocateAddressInput) (*ec2.AllocateAddressOutput, error) + AllocateHostsRequest(*ec2.AllocateHostsInput) (*request.Request, *ec2.AllocateHostsOutput) + + AllocateHosts(*ec2.AllocateHostsInput) (*ec2.AllocateHostsOutput, error) + AssignPrivateIpAddressesRequest(*ec2.AssignPrivateIpAddressesInput) (*request.Request, *ec2.AssignPrivateIpAddressesOutput) AssignPrivateIpAddresses(*ec2.AssignPrivateIpAddressesInput) (*ec2.AssignPrivateIpAddressesOutput, error) @@ -346,6 +350,14 @@ type EC2API interface { DescribeFlowLogs(*ec2.DescribeFlowLogsInput) (*ec2.DescribeFlowLogsOutput, error) + DescribeHostsRequest(*ec2.DescribeHostsInput) (*request.Request, *ec2.DescribeHostsOutput) + + DescribeHosts(*ec2.DescribeHostsInput) (*ec2.DescribeHostsOutput, error) + + DescribeIdFormatRequest(*ec2.DescribeIdFormatInput) (*request.Request, *ec2.DescribeIdFormatOutput) + + DescribeIdFormat(*ec2.DescribeIdFormatInput) (*ec2.DescribeIdFormatOutput, error) + DescribeImageAttributeRequest(*ec2.DescribeImageAttributeInput) (*request.Request, *ec2.DescribeImageAttributeOutput) DescribeImageAttribute(*ec2.DescribeImageAttributeInput) (*ec2.DescribeImageAttributeOutput, error) @@ -612,6 +624,14 @@ type EC2API interface { ImportVolume(*ec2.ImportVolumeInput) (*ec2.ImportVolumeOutput, error) + ModifyHostsRequest(*ec2.ModifyHostsInput) (*request.Request, *ec2.ModifyHostsOutput) + + ModifyHosts(*ec2.ModifyHostsInput) (*ec2.ModifyHostsOutput, error) + + ModifyIdFormatRequest(*ec2.ModifyIdFormatInput) (*request.Request, *ec2.ModifyIdFormatOutput) + + ModifyIdFormat(*ec2.ModifyIdFormatInput) (*ec2.ModifyIdFormatOutput, error) + ModifyImageAttributeRequest(*ec2.ModifyImageAttributeInput) (*request.Request, *ec2.ModifyImageAttributeOutput) ModifyImageAttribute(*ec2.ModifyImageAttributeInput) (*ec2.ModifyImageAttributeOutput, error) @@ -620,6 +640,10 @@ type EC2API interface { ModifyInstanceAttribute(*ec2.ModifyInstanceAttributeInput) (*ec2.ModifyInstanceAttributeOutput, error) + ModifyInstancePlacementRequest(*ec2.ModifyInstancePlacementInput) (*request.Request, *ec2.ModifyInstancePlacementOutput) + + ModifyInstancePlacement(*ec2.ModifyInstancePlacementInput) (*ec2.ModifyInstancePlacementOutput, error) + ModifyNetworkInterfaceAttributeRequest(*ec2.ModifyNetworkInterfaceAttributeInput) (*request.Request, *ec2.ModifyNetworkInterfaceAttributeOutput) ModifyNetworkInterfaceAttribute(*ec2.ModifyNetworkInterfaceAttributeInput) (*ec2.ModifyNetworkInterfaceAttributeOutput, error) @@ -680,6 +704,10 @@ type EC2API interface { ReleaseAddress(*ec2.ReleaseAddressInput) (*ec2.ReleaseAddressOutput, error) + ReleaseHostsRequest(*ec2.ReleaseHostsInput) (*request.Request, *ec2.ReleaseHostsOutput) + + ReleaseHosts(*ec2.ReleaseHostsInput) (*ec2.ReleaseHostsOutput, error) + ReplaceNetworkAclAssociationRequest(*ec2.ReplaceNetworkAclAssociationInput) (*request.Request, *ec2.ReplaceNetworkAclAssociationOutput) ReplaceNetworkAclAssociation(*ec2.ReplaceNetworkAclAssociationInput) (*ec2.ReplaceNetworkAclAssociationOutput, error) diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/service/iam/api.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/service/iam/api.go index 118022be5..d51a53cf3 100644 --- a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/service/iam/api.go +++ b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/service/iam/api.go @@ -544,9 +544,6 @@ func (c *IAM) CreateRoleRequest(input *CreateRoleInput) (req *request.Request, o // For information about limitations on role names and the number of roles you // can create, go to Limitations on IAM Entities (http://docs.aws.amazon.com/IAM/latest/UserGuide/LimitationsOnEntities.html) // in the IAM User Guide. -// -// The policy in the following example grants permission to an EC2 instance -// to assume the role. func (c *IAM) CreateRole(input *CreateRoleInput) (*CreateRoleOutput, error) { req, out := c.CreateRoleRequest(input) err := req.Send() @@ -4178,6 +4175,8 @@ func (c *IAM) UploadSigningCertificate(input *UploadSigningCertificateInput) (*U // you cannot recover the secret access key later. If you lose a secret access // key, you must create a new access key. type AccessKey struct { + _ struct{} `type:"structure"` + // The ID for this access key. AccessKeyId *string `min:"16" type:"string" required:"true"` @@ -4193,12 +4192,6 @@ type AccessKey struct { // The name of the IAM user that the access key is associated with. UserName *string `min:"1" type:"string" required:"true"` - - metadataAccessKey `json:"-" xml:"-"` -} - -type metadataAccessKey struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -4216,6 +4209,8 @@ func (s AccessKey) GoString() string { // This data type is used as a response element in the GetAccessKeyLastUsed // action. type AccessKeyLastUsed struct { + _ struct{} `type:"structure"` + // The date and time, in ISO 8601 date-time format (http://www.iso.org/iso/iso8601), // when the access key was most recently used. This field is null when: // @@ -4251,12 +4246,6 @@ type AccessKeyLastUsed struct { // // There is no sign-in data associated with the user ServiceName *string `type:"string" required:"true"` - - metadataAccessKeyLastUsed `json:"-" xml:"-"` -} - -type metadataAccessKeyLastUsed struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -4273,6 +4262,8 @@ func (s AccessKeyLastUsed) GoString() string { // // This data type is used as a response element in the ListAccessKeys action. type AccessKeyMetadata struct { + _ struct{} `type:"structure"` + // The ID for this access key. AccessKeyId *string `min:"16" type:"string"` @@ -4285,12 +4276,6 @@ type AccessKeyMetadata struct { // The name of the IAM user that the key is associated with. UserName *string `min:"1" type:"string"` - - metadataAccessKeyMetadata `json:"-" xml:"-"` -} - -type metadataAccessKeyMetadata struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -4304,6 +4289,8 @@ func (s AccessKeyMetadata) GoString() string { } type AddClientIDToOpenIDConnectProviderInput struct { + _ struct{} `type:"structure"` + // The client ID (also known as audience) to add to the IAM OpenID Connect provider. ClientID *string `min:"1" type:"string" required:"true"` @@ -4311,12 +4298,6 @@ type AddClientIDToOpenIDConnectProviderInput struct { // to add the client ID to. You can get a list of OIDC provider ARNs by using // the ListOpenIDConnectProviders action. OpenIDConnectProviderArn *string `min:"20" type:"string" required:"true"` - - metadataAddClientIDToOpenIDConnectProviderInput `json:"-" xml:"-"` -} - -type metadataAddClientIDToOpenIDConnectProviderInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -4330,11 +4311,7 @@ func (s AddClientIDToOpenIDConnectProviderInput) GoString() string { } type AddClientIDToOpenIDConnectProviderOutput struct { - metadataAddClientIDToOpenIDConnectProviderOutput `json:"-" xml:"-"` -} - -type metadataAddClientIDToOpenIDConnectProviderOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -4348,17 +4325,13 @@ func (s AddClientIDToOpenIDConnectProviderOutput) GoString() string { } type AddRoleToInstanceProfileInput struct { + _ struct{} `type:"structure"` + // The name of the instance profile to update. InstanceProfileName *string `min:"1" type:"string" required:"true"` // The name of the role to add. RoleName *string `min:"1" type:"string" required:"true"` - - metadataAddRoleToInstanceProfileInput `json:"-" xml:"-"` -} - -type metadataAddRoleToInstanceProfileInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -4372,11 +4345,7 @@ func (s AddRoleToInstanceProfileInput) GoString() string { } type AddRoleToInstanceProfileOutput struct { - metadataAddRoleToInstanceProfileOutput `json:"-" xml:"-"` -} - -type metadataAddRoleToInstanceProfileOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -4390,17 +4359,13 @@ func (s AddRoleToInstanceProfileOutput) GoString() string { } type AddUserToGroupInput struct { + _ struct{} `type:"structure"` + // The name of the group to update. GroupName *string `min:"1" type:"string" required:"true"` // The name of the user to add. UserName *string `min:"1" type:"string" required:"true"` - - metadataAddUserToGroupInput `json:"-" xml:"-"` -} - -type metadataAddUserToGroupInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -4414,11 +4379,7 @@ func (s AddUserToGroupInput) GoString() string { } type AddUserToGroupOutput struct { - metadataAddUserToGroupOutput `json:"-" xml:"-"` -} - -type metadataAddUserToGroupOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -4432,6 +4393,8 @@ func (s AddUserToGroupOutput) GoString() string { } type AttachGroupPolicyInput struct { + _ struct{} `type:"structure"` + // The name (friendly name, not ARN) of the group to attach the policy to. GroupName *string `min:"1" type:"string" required:"true"` @@ -4441,12 +4404,6 @@ type AttachGroupPolicyInput struct { // AWS Service Namespaces (http://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html) // in the AWS General Reference. PolicyArn *string `min:"20" type:"string" required:"true"` - - metadataAttachGroupPolicyInput `json:"-" xml:"-"` -} - -type metadataAttachGroupPolicyInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -4460,11 +4417,7 @@ func (s AttachGroupPolicyInput) GoString() string { } type AttachGroupPolicyOutput struct { - metadataAttachGroupPolicyOutput `json:"-" xml:"-"` -} - -type metadataAttachGroupPolicyOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -4478,6 +4431,8 @@ func (s AttachGroupPolicyOutput) GoString() string { } type AttachRolePolicyInput struct { + _ struct{} `type:"structure"` + // The Amazon Resource Name (ARN). ARNs are unique identifiers for AWS resources. // // For more information about ARNs, go to Amazon Resource Names (ARNs) and @@ -4487,12 +4442,6 @@ type AttachRolePolicyInput struct { // The name (friendly name, not ARN) of the role to attach the policy to. RoleName *string `min:"1" type:"string" required:"true"` - - metadataAttachRolePolicyInput `json:"-" xml:"-"` -} - -type metadataAttachRolePolicyInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -4506,11 +4455,7 @@ func (s AttachRolePolicyInput) GoString() string { } type AttachRolePolicyOutput struct { - metadataAttachRolePolicyOutput `json:"-" xml:"-"` -} - -type metadataAttachRolePolicyOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -4524,6 +4469,8 @@ func (s AttachRolePolicyOutput) GoString() string { } type AttachUserPolicyInput struct { + _ struct{} `type:"structure"` + // The Amazon Resource Name (ARN). ARNs are unique identifiers for AWS resources. // // For more information about ARNs, go to Amazon Resource Names (ARNs) and @@ -4533,12 +4480,6 @@ type AttachUserPolicyInput struct { // The name (friendly name, not ARN) of the user to attach the policy to. UserName *string `min:"1" type:"string" required:"true"` - - metadataAttachUserPolicyInput `json:"-" xml:"-"` -} - -type metadataAttachUserPolicyInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -4552,11 +4493,7 @@ func (s AttachUserPolicyInput) GoString() string { } type AttachUserPolicyOutput struct { - metadataAttachUserPolicyOutput `json:"-" xml:"-"` -} - -type metadataAttachUserPolicyOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -4580,6 +4517,8 @@ func (s AttachUserPolicyOutput) GoString() string { // Inline Policies (http://docs.aws.amazon.com/IAM/latest/UserGuide/policies-managed-vs-inline.html) // in the Using IAM guide. type AttachedPolicy struct { + _ struct{} `type:"structure"` + // The Amazon Resource Name (ARN). ARNs are unique identifiers for AWS resources. // // For more information about ARNs, go to Amazon Resource Names (ARNs) and @@ -4589,12 +4528,6 @@ type AttachedPolicy struct { // The friendly name of the attached policy. PolicyName *string `min:"1" type:"string"` - - metadataAttachedPolicy `json:"-" xml:"-"` -} - -type metadataAttachedPolicy struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -4608,18 +4541,14 @@ func (s AttachedPolicy) GoString() string { } type ChangePasswordInput struct { + _ struct{} `type:"structure"` + // The new password. The new password must conform to the AWS account's password // policy, if one exists. NewPassword *string `min:"1" type:"string" required:"true"` // The IAM user's current password. OldPassword *string `min:"1" type:"string" required:"true"` - - metadataChangePasswordInput `json:"-" xml:"-"` -} - -type metadataChangePasswordInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -4633,11 +4562,7 @@ func (s ChangePasswordInput) GoString() string { } type ChangePasswordOutput struct { - metadataChangePasswordOutput `json:"-" xml:"-"` -} - -type metadataChangePasswordOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -4657,6 +4582,8 @@ func (s ChangePasswordOutput) GoString() string { // // This data type is used as an input parameter to SimulatePolicy. type ContextEntry struct { + _ struct{} `type:"structure"` + // The full name of a condition context key, including the service prefix. For // example, aws:SourceIp or s3:VersionId. ContextKeyName *string `min:"5" type:"string"` @@ -4669,12 +4596,6 @@ type ContextEntry struct { // to provide to the simulation for use when the key is referenced by a Condition // element in an input policy. ContextKeyValues []*string `type:"list"` - - metadataContextEntry `json:"-" xml:"-"` -} - -type metadataContextEntry struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -4688,14 +4609,10 @@ func (s ContextEntry) GoString() string { } type CreateAccessKeyInput struct { + _ struct{} `type:"structure"` + // The user name that the new key will belong to. UserName *string `min:"1" type:"string"` - - metadataCreateAccessKeyInput `json:"-" xml:"-"` -} - -type metadataCreateAccessKeyInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -4710,14 +4627,10 @@ func (s CreateAccessKeyInput) GoString() string { // Contains the response to a successful CreateAccessKey request. type CreateAccessKeyOutput struct { + _ struct{} `type:"structure"` + // Information about the access key. AccessKey *AccessKey `type:"structure" required:"true"` - - metadataCreateAccessKeyOutput `json:"-" xml:"-"` -} - -type metadataCreateAccessKeyOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -4731,14 +4644,10 @@ func (s CreateAccessKeyOutput) GoString() string { } type CreateAccountAliasInput struct { + _ struct{} `type:"structure"` + // The account alias to create. AccountAlias *string `min:"3" type:"string" required:"true"` - - metadataCreateAccountAliasInput `json:"-" xml:"-"` -} - -type metadataCreateAccountAliasInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -4752,11 +4661,7 @@ func (s CreateAccountAliasInput) GoString() string { } type CreateAccountAliasOutput struct { - metadataCreateAccountAliasOutput `json:"-" xml:"-"` -} - -type metadataCreateAccountAliasOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -4770,6 +4675,8 @@ func (s CreateAccountAliasOutput) GoString() string { } type CreateGroupInput struct { + _ struct{} `type:"structure"` + // The name of the group to create. Do not include the path in this value. GroupName *string `min:"1" type:"string" required:"true"` @@ -4780,12 +4687,6 @@ type CreateGroupInput struct { // This parameter is optional. If it is not included, it defaults to a slash // (/). Path *string `min:"1" type:"string"` - - metadataCreateGroupInput `json:"-" xml:"-"` -} - -type metadataCreateGroupInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -4800,14 +4701,10 @@ func (s CreateGroupInput) GoString() string { // Contains the response to a successful CreateGroup request. type CreateGroupOutput struct { + _ struct{} `type:"structure"` + // Information about the group. Group *Group `type:"structure" required:"true"` - - metadataCreateGroupOutput `json:"-" xml:"-"` -} - -type metadataCreateGroupOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -4821,6 +4718,8 @@ func (s CreateGroupOutput) GoString() string { } type CreateInstanceProfileInput struct { + _ struct{} `type:"structure"` + // The name of the instance profile to create. InstanceProfileName *string `min:"1" type:"string" required:"true"` @@ -4831,12 +4730,6 @@ type CreateInstanceProfileInput struct { // This parameter is optional. If it is not included, it defaults to a slash // (/). Path *string `min:"1" type:"string"` - - metadataCreateInstanceProfileInput `json:"-" xml:"-"` -} - -type metadataCreateInstanceProfileInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -4851,14 +4744,10 @@ func (s CreateInstanceProfileInput) GoString() string { // Contains the response to a successful CreateInstanceProfile request. type CreateInstanceProfileOutput struct { + _ struct{} `type:"structure"` + // Information about the instance profile. InstanceProfile *InstanceProfile `type:"structure" required:"true"` - - metadataCreateInstanceProfileOutput `json:"-" xml:"-"` -} - -type metadataCreateInstanceProfileOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -4872,6 +4761,8 @@ func (s CreateInstanceProfileOutput) GoString() string { } type CreateLoginProfileInput struct { + _ struct{} `type:"structure"` + // The new password for the user. Password *string `min:"1" type:"string" required:"true"` @@ -4880,12 +4771,6 @@ type CreateLoginProfileInput struct { // The name of the user to create a password for. UserName *string `min:"1" type:"string" required:"true"` - - metadataCreateLoginProfileInput `json:"-" xml:"-"` -} - -type metadataCreateLoginProfileInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -4900,14 +4785,10 @@ func (s CreateLoginProfileInput) GoString() string { // Contains the response to a successful CreateLoginProfile request. type CreateLoginProfileOutput struct { + _ struct{} `type:"structure"` + // The user name and password create date. LoginProfile *LoginProfile `type:"structure" required:"true"` - - metadataCreateLoginProfileOutput `json:"-" xml:"-"` -} - -type metadataCreateLoginProfileOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -4921,6 +4802,8 @@ func (s CreateLoginProfileOutput) GoString() string { } type CreateOpenIDConnectProviderInput struct { + _ struct{} `type:"structure"` + // A list of client IDs (also known as audiences). When a mobile or web app // registers with an OpenID Connect provider, they establish a value that identifies // the application. (This is the value that's sent as the client_id parameter @@ -4965,12 +4848,6 @@ type CreateOpenIDConnectProviderInput struct { // If you try to submit a URL that has already been used for an OpenID Connect // provider in the AWS account, you will get an error. Url *string `min:"1" type:"string" required:"true"` - - metadataCreateOpenIDConnectProviderInput `json:"-" xml:"-"` -} - -type metadataCreateOpenIDConnectProviderInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -4985,15 +4862,11 @@ func (s CreateOpenIDConnectProviderInput) GoString() string { // Contains the response to a successful CreateOpenIDConnectProvider request. type CreateOpenIDConnectProviderOutput struct { + _ struct{} `type:"structure"` + // The Amazon Resource Name (ARN) of the IAM OpenID Connect provider that was // created. For more information, see OpenIDConnectProviderListEntry. OpenIDConnectProviderArn *string `min:"20" type:"string"` - - metadataCreateOpenIDConnectProviderOutput `json:"-" xml:"-"` -} - -type metadataCreateOpenIDConnectProviderOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -5007,6 +4880,8 @@ func (s CreateOpenIDConnectProviderOutput) GoString() string { } type CreatePolicyInput struct { + _ struct{} `type:"structure"` + // A friendly description of the policy. // // Typically used to store information about the permissions defined in the @@ -5030,12 +4905,6 @@ type CreatePolicyInput struct { // The name of the policy document. PolicyName *string `min:"1" type:"string" required:"true"` - - metadataCreatePolicyInput `json:"-" xml:"-"` -} - -type metadataCreatePolicyInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -5050,14 +4919,10 @@ func (s CreatePolicyInput) GoString() string { // Contains the response to a successful CreatePolicy request. type CreatePolicyOutput struct { + _ struct{} `type:"structure"` + // Information about the policy. Policy *Policy `type:"structure"` - - metadataCreatePolicyOutput `json:"-" xml:"-"` -} - -type metadataCreatePolicyOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -5071,6 +4936,8 @@ func (s CreatePolicyOutput) GoString() string { } type CreatePolicyVersionInput struct { + _ struct{} `type:"structure"` + // The Amazon Resource Name (ARN). ARNs are unique identifiers for AWS resources. // // For more information about ARNs, go to Amazon Resource Names (ARNs) and @@ -5091,12 +4958,6 @@ type CreatePolicyVersionInput struct { // Policies (http://docs.aws.amazon.com/IAM/latest/UserGuide/policies-managed-versions.html) // in the IAM User Guide. SetAsDefault *bool `type:"boolean"` - - metadataCreatePolicyVersionInput `json:"-" xml:"-"` -} - -type metadataCreatePolicyVersionInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -5111,14 +4972,10 @@ func (s CreatePolicyVersionInput) GoString() string { // Contains the response to a successful CreatePolicyVersion request. type CreatePolicyVersionOutput struct { + _ struct{} `type:"structure"` + // Information about the policy version. PolicyVersion *PolicyVersion `type:"structure"` - - metadataCreatePolicyVersionOutput `json:"-" xml:"-"` -} - -type metadataCreatePolicyVersionOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -5132,7 +4989,10 @@ func (s CreatePolicyVersionOutput) GoString() string { } type CreateRoleInput struct { - // The policy that grants an entity permission to assume the role. + _ struct{} `type:"structure"` + + // The trust relationship policy document that grants an entity permission to + // assume the role. AssumeRolePolicyDocument *string `min:"1" type:"string" required:"true"` // The path to the role. For more information about paths, see IAM Identifiers @@ -5145,12 +5005,6 @@ type CreateRoleInput struct { // The name of the role to create. RoleName *string `min:"1" type:"string" required:"true"` - - metadataCreateRoleInput `json:"-" xml:"-"` -} - -type metadataCreateRoleInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -5165,14 +5019,10 @@ func (s CreateRoleInput) GoString() string { // Contains the response to a successful CreateRole request. type CreateRoleOutput struct { + _ struct{} `type:"structure"` + // Information about the role. Role *Role `type:"structure" required:"true"` - - metadataCreateRoleOutput `json:"-" xml:"-"` -} - -type metadataCreateRoleOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -5186,6 +5036,8 @@ func (s CreateRoleOutput) GoString() string { } type CreateSAMLProviderInput struct { + _ struct{} `type:"structure"` + // The name of the provider to create. Name *string `min:"1" type:"string" required:"true"` @@ -5198,12 +5050,6 @@ type CreateSAMLProviderInput struct { // For more information, see About SAML 2.0-based Federation (http://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_providers_saml.html) // in the IAM User Guide SAMLMetadataDocument *string `min:"1000" type:"string" required:"true"` - - metadataCreateSAMLProviderInput `json:"-" xml:"-"` -} - -type metadataCreateSAMLProviderInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -5218,14 +5064,10 @@ func (s CreateSAMLProviderInput) GoString() string { // Contains the response to a successful CreateSAMLProvider request. type CreateSAMLProviderOutput struct { + _ struct{} `type:"structure"` + // The Amazon Resource Name (ARN) of the SAML provider. SAMLProviderArn *string `min:"20" type:"string"` - - metadataCreateSAMLProviderOutput `json:"-" xml:"-"` -} - -type metadataCreateSAMLProviderOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -5239,6 +5081,8 @@ func (s CreateSAMLProviderOutput) GoString() string { } type CreateUserInput struct { + _ struct{} `type:"structure"` + // The path for the user name. For more information about paths, see IAM Identifiers // (http://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html) // in the Using IAM guide. @@ -5249,12 +5093,6 @@ type CreateUserInput struct { // The name of the user to create. UserName *string `min:"1" type:"string" required:"true"` - - metadataCreateUserInput `json:"-" xml:"-"` -} - -type metadataCreateUserInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -5269,14 +5107,10 @@ func (s CreateUserInput) GoString() string { // Contains the response to a successful CreateUser request. type CreateUserOutput struct { + _ struct{} `type:"structure"` + // Information about the user. User *User `type:"structure"` - - metadataCreateUserOutput `json:"-" xml:"-"` -} - -type metadataCreateUserOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -5290,6 +5124,8 @@ func (s CreateUserOutput) GoString() string { } type CreateVirtualMFADeviceInput struct { + _ struct{} `type:"structure"` + // The path for the virtual MFA device. For more information about paths, see // IAM Identifiers (http://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html) // in the Using IAM guide. @@ -5301,12 +5137,6 @@ type CreateVirtualMFADeviceInput struct { // The name of the virtual MFA device. Use with path to uniquely identify a // virtual MFA device. VirtualMFADeviceName *string `min:"1" type:"string" required:"true"` - - metadataCreateVirtualMFADeviceInput `json:"-" xml:"-"` -} - -type metadataCreateVirtualMFADeviceInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -5321,14 +5151,10 @@ func (s CreateVirtualMFADeviceInput) GoString() string { // Contains the response to a successful CreateVirtualMFADevice request. type CreateVirtualMFADeviceOutput struct { + _ struct{} `type:"structure"` + // A newly created virtual MFA device. VirtualMFADevice *VirtualMFADevice `type:"structure" required:"true"` - - metadataCreateVirtualMFADeviceOutput `json:"-" xml:"-"` -} - -type metadataCreateVirtualMFADeviceOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -5342,18 +5168,14 @@ func (s CreateVirtualMFADeviceOutput) GoString() string { } type DeactivateMFADeviceInput struct { + _ struct{} `type:"structure"` + // The serial number that uniquely identifies the MFA device. For virtual MFA // devices, the serial number is the device ARN. SerialNumber *string `min:"9" type:"string" required:"true"` // The name of the user whose MFA device you want to deactivate. UserName *string `min:"1" type:"string" required:"true"` - - metadataDeactivateMFADeviceInput `json:"-" xml:"-"` -} - -type metadataDeactivateMFADeviceInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -5367,11 +5189,7 @@ func (s DeactivateMFADeviceInput) GoString() string { } type DeactivateMFADeviceOutput struct { - metadataDeactivateMFADeviceOutput `json:"-" xml:"-"` -} - -type metadataDeactivateMFADeviceOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -5385,18 +5203,14 @@ func (s DeactivateMFADeviceOutput) GoString() string { } type DeleteAccessKeyInput struct { + _ struct{} `type:"structure"` + // The access key ID for the access key ID and secret access key you want to // delete. AccessKeyId *string `min:"16" type:"string" required:"true"` // The name of the user whose key you want to delete. UserName *string `min:"1" type:"string"` - - metadataDeleteAccessKeyInput `json:"-" xml:"-"` -} - -type metadataDeleteAccessKeyInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -5410,11 +5224,7 @@ func (s DeleteAccessKeyInput) GoString() string { } type DeleteAccessKeyOutput struct { - metadataDeleteAccessKeyOutput `json:"-" xml:"-"` -} - -type metadataDeleteAccessKeyOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -5428,14 +5238,10 @@ func (s DeleteAccessKeyOutput) GoString() string { } type DeleteAccountAliasInput struct { + _ struct{} `type:"structure"` + // The name of the account alias to delete. AccountAlias *string `min:"3" type:"string" required:"true"` - - metadataDeleteAccountAliasInput `json:"-" xml:"-"` -} - -type metadataDeleteAccountAliasInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -5449,11 +5255,7 @@ func (s DeleteAccountAliasInput) GoString() string { } type DeleteAccountAliasOutput struct { - metadataDeleteAccountAliasOutput `json:"-" xml:"-"` -} - -type metadataDeleteAccountAliasOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -5467,11 +5269,7 @@ func (s DeleteAccountAliasOutput) GoString() string { } type DeleteAccountPasswordPolicyInput struct { - metadataDeleteAccountPasswordPolicyInput `json:"-" xml:"-"` -} - -type metadataDeleteAccountPasswordPolicyInput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -5485,11 +5283,7 @@ func (s DeleteAccountPasswordPolicyInput) GoString() string { } type DeleteAccountPasswordPolicyOutput struct { - metadataDeleteAccountPasswordPolicyOutput `json:"-" xml:"-"` -} - -type metadataDeleteAccountPasswordPolicyOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -5503,14 +5297,10 @@ func (s DeleteAccountPasswordPolicyOutput) GoString() string { } type DeleteGroupInput struct { + _ struct{} `type:"structure"` + // The name of the group to delete. GroupName *string `min:"1" type:"string" required:"true"` - - metadataDeleteGroupInput `json:"-" xml:"-"` -} - -type metadataDeleteGroupInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -5524,11 +5314,7 @@ func (s DeleteGroupInput) GoString() string { } type DeleteGroupOutput struct { - metadataDeleteGroupOutput `json:"-" xml:"-"` -} - -type metadataDeleteGroupOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -5542,18 +5328,14 @@ func (s DeleteGroupOutput) GoString() string { } type DeleteGroupPolicyInput struct { + _ struct{} `type:"structure"` + // The name (friendly name, not ARN) identifying the group that the policy is // embedded in. GroupName *string `min:"1" type:"string" required:"true"` // The name identifying the policy document to delete. PolicyName *string `min:"1" type:"string" required:"true"` - - metadataDeleteGroupPolicyInput `json:"-" xml:"-"` -} - -type metadataDeleteGroupPolicyInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -5567,11 +5349,7 @@ func (s DeleteGroupPolicyInput) GoString() string { } type DeleteGroupPolicyOutput struct { - metadataDeleteGroupPolicyOutput `json:"-" xml:"-"` -} - -type metadataDeleteGroupPolicyOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -5585,14 +5363,10 @@ func (s DeleteGroupPolicyOutput) GoString() string { } type DeleteInstanceProfileInput struct { + _ struct{} `type:"structure"` + // The name of the instance profile to delete. InstanceProfileName *string `min:"1" type:"string" required:"true"` - - metadataDeleteInstanceProfileInput `json:"-" xml:"-"` -} - -type metadataDeleteInstanceProfileInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -5606,11 +5380,7 @@ func (s DeleteInstanceProfileInput) GoString() string { } type DeleteInstanceProfileOutput struct { - metadataDeleteInstanceProfileOutput `json:"-" xml:"-"` -} - -type metadataDeleteInstanceProfileOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -5624,14 +5394,10 @@ func (s DeleteInstanceProfileOutput) GoString() string { } type DeleteLoginProfileInput struct { + _ struct{} `type:"structure"` + // The name of the user whose password you want to delete. UserName *string `min:"1" type:"string" required:"true"` - - metadataDeleteLoginProfileInput `json:"-" xml:"-"` -} - -type metadataDeleteLoginProfileInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -5645,11 +5411,7 @@ func (s DeleteLoginProfileInput) GoString() string { } type DeleteLoginProfileOutput struct { - metadataDeleteLoginProfileOutput `json:"-" xml:"-"` -} - -type metadataDeleteLoginProfileOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -5663,16 +5425,12 @@ func (s DeleteLoginProfileOutput) GoString() string { } type DeleteOpenIDConnectProviderInput struct { + _ struct{} `type:"structure"` + // The Amazon Resource Name (ARN) of the IAM OpenID Connect provider to delete. // You can get a list of OpenID Connect provider ARNs by using the ListOpenIDConnectProviders // action. OpenIDConnectProviderArn *string `min:"20" type:"string" required:"true"` - - metadataDeleteOpenIDConnectProviderInput `json:"-" xml:"-"` -} - -type metadataDeleteOpenIDConnectProviderInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -5686,11 +5444,7 @@ func (s DeleteOpenIDConnectProviderInput) GoString() string { } type DeleteOpenIDConnectProviderOutput struct { - metadataDeleteOpenIDConnectProviderOutput `json:"-" xml:"-"` -} - -type metadataDeleteOpenIDConnectProviderOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -5704,18 +5458,14 @@ func (s DeleteOpenIDConnectProviderOutput) GoString() string { } type DeletePolicyInput struct { + _ struct{} `type:"structure"` + // The Amazon Resource Name (ARN). ARNs are unique identifiers for AWS resources. // // For more information about ARNs, go to Amazon Resource Names (ARNs) and // AWS Service Namespaces (http://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html) // in the AWS General Reference. PolicyArn *string `min:"20" type:"string" required:"true"` - - metadataDeletePolicyInput `json:"-" xml:"-"` -} - -type metadataDeletePolicyInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -5729,11 +5479,7 @@ func (s DeletePolicyInput) GoString() string { } type DeletePolicyOutput struct { - metadataDeletePolicyOutput `json:"-" xml:"-"` -} - -type metadataDeletePolicyOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -5747,6 +5493,8 @@ func (s DeletePolicyOutput) GoString() string { } type DeletePolicyVersionInput struct { + _ struct{} `type:"structure"` + // The Amazon Resource Name (ARN). ARNs are unique identifiers for AWS resources. // // For more information about ARNs, go to Amazon Resource Names (ARNs) and @@ -5760,12 +5508,6 @@ type DeletePolicyVersionInput struct { // Policies (http://docs.aws.amazon.com/IAM/latest/UserGuide/policies-managed-versions.html) // in the IAM User Guide. VersionId *string `type:"string" required:"true"` - - metadataDeletePolicyVersionInput `json:"-" xml:"-"` -} - -type metadataDeletePolicyVersionInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -5779,11 +5521,7 @@ func (s DeletePolicyVersionInput) GoString() string { } type DeletePolicyVersionOutput struct { - metadataDeletePolicyVersionOutput `json:"-" xml:"-"` -} - -type metadataDeletePolicyVersionOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -5797,14 +5535,10 @@ func (s DeletePolicyVersionOutput) GoString() string { } type DeleteRoleInput struct { + _ struct{} `type:"structure"` + // The name of the role to delete. RoleName *string `min:"1" type:"string" required:"true"` - - metadataDeleteRoleInput `json:"-" xml:"-"` -} - -type metadataDeleteRoleInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -5818,11 +5552,7 @@ func (s DeleteRoleInput) GoString() string { } type DeleteRoleOutput struct { - metadataDeleteRoleOutput `json:"-" xml:"-"` -} - -type metadataDeleteRoleOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -5836,18 +5566,14 @@ func (s DeleteRoleOutput) GoString() string { } type DeleteRolePolicyInput struct { + _ struct{} `type:"structure"` + // The name identifying the policy document to delete. PolicyName *string `min:"1" type:"string" required:"true"` // The name (friendly name, not ARN) identifying the role that the policy is // embedded in. RoleName *string `min:"1" type:"string" required:"true"` - - metadataDeleteRolePolicyInput `json:"-" xml:"-"` -} - -type metadataDeleteRolePolicyInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -5861,11 +5587,7 @@ func (s DeleteRolePolicyInput) GoString() string { } type DeleteRolePolicyOutput struct { - metadataDeleteRolePolicyOutput `json:"-" xml:"-"` -} - -type metadataDeleteRolePolicyOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -5879,14 +5601,10 @@ func (s DeleteRolePolicyOutput) GoString() string { } type DeleteSAMLProviderInput struct { + _ struct{} `type:"structure"` + // The Amazon Resource Name (ARN) of the SAML provider to delete. SAMLProviderArn *string `min:"20" type:"string" required:"true"` - - metadataDeleteSAMLProviderInput `json:"-" xml:"-"` -} - -type metadataDeleteSAMLProviderInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -5900,11 +5618,7 @@ func (s DeleteSAMLProviderInput) GoString() string { } type DeleteSAMLProviderOutput struct { - metadataDeleteSAMLProviderOutput `json:"-" xml:"-"` -} - -type metadataDeleteSAMLProviderOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -5918,17 +5632,13 @@ func (s DeleteSAMLProviderOutput) GoString() string { } type DeleteSSHPublicKeyInput struct { + _ struct{} `type:"structure"` + // The unique identifier for the SSH public key. SSHPublicKeyId *string `min:"20" type:"string" required:"true"` // The name of the IAM user associated with the SSH public key. UserName *string `min:"1" type:"string" required:"true"` - - metadataDeleteSSHPublicKeyInput `json:"-" xml:"-"` -} - -type metadataDeleteSSHPublicKeyInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -5942,11 +5652,7 @@ func (s DeleteSSHPublicKeyInput) GoString() string { } type DeleteSSHPublicKeyOutput struct { - metadataDeleteSSHPublicKeyOutput `json:"-" xml:"-"` -} - -type metadataDeleteSSHPublicKeyOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -5960,14 +5666,10 @@ func (s DeleteSSHPublicKeyOutput) GoString() string { } type DeleteServerCertificateInput struct { + _ struct{} `type:"structure"` + // The name of the server certificate you want to delete. ServerCertificateName *string `min:"1" type:"string" required:"true"` - - metadataDeleteServerCertificateInput `json:"-" xml:"-"` -} - -type metadataDeleteServerCertificateInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -5981,11 +5683,7 @@ func (s DeleteServerCertificateInput) GoString() string { } type DeleteServerCertificateOutput struct { - metadataDeleteServerCertificateOutput `json:"-" xml:"-"` -} - -type metadataDeleteServerCertificateOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -5999,17 +5697,13 @@ func (s DeleteServerCertificateOutput) GoString() string { } type DeleteSigningCertificateInput struct { + _ struct{} `type:"structure"` + // The ID of the signing certificate to delete. CertificateId *string `min:"24" type:"string" required:"true"` // The name of the user the signing certificate belongs to. UserName *string `min:"1" type:"string"` - - metadataDeleteSigningCertificateInput `json:"-" xml:"-"` -} - -type metadataDeleteSigningCertificateInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -6023,11 +5717,7 @@ func (s DeleteSigningCertificateInput) GoString() string { } type DeleteSigningCertificateOutput struct { - metadataDeleteSigningCertificateOutput `json:"-" xml:"-"` -} - -type metadataDeleteSigningCertificateOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -6041,14 +5731,10 @@ func (s DeleteSigningCertificateOutput) GoString() string { } type DeleteUserInput struct { + _ struct{} `type:"structure"` + // The name of the user to delete. UserName *string `min:"1" type:"string" required:"true"` - - metadataDeleteUserInput `json:"-" xml:"-"` -} - -type metadataDeleteUserInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -6062,11 +5748,7 @@ func (s DeleteUserInput) GoString() string { } type DeleteUserOutput struct { - metadataDeleteUserOutput `json:"-" xml:"-"` -} - -type metadataDeleteUserOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -6080,18 +5762,14 @@ func (s DeleteUserOutput) GoString() string { } type DeleteUserPolicyInput struct { + _ struct{} `type:"structure"` + // The name identifying the policy document to delete. PolicyName *string `min:"1" type:"string" required:"true"` // The name (friendly name, not ARN) identifying the user that the policy is // embedded in. UserName *string `min:"1" type:"string" required:"true"` - - metadataDeleteUserPolicyInput `json:"-" xml:"-"` -} - -type metadataDeleteUserPolicyInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -6105,11 +5783,7 @@ func (s DeleteUserPolicyInput) GoString() string { } type DeleteUserPolicyOutput struct { - metadataDeleteUserPolicyOutput `json:"-" xml:"-"` -} - -type metadataDeleteUserPolicyOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -6123,15 +5797,11 @@ func (s DeleteUserPolicyOutput) GoString() string { } type DeleteVirtualMFADeviceInput struct { + _ struct{} `type:"structure"` + // The serial number that uniquely identifies the MFA device. For virtual MFA // devices, the serial number is the same as the ARN. SerialNumber *string `min:"9" type:"string" required:"true"` - - metadataDeleteVirtualMFADeviceInput `json:"-" xml:"-"` -} - -type metadataDeleteVirtualMFADeviceInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -6145,11 +5815,7 @@ func (s DeleteVirtualMFADeviceInput) GoString() string { } type DeleteVirtualMFADeviceOutput struct { - metadataDeleteVirtualMFADeviceOutput `json:"-" xml:"-"` -} - -type metadataDeleteVirtualMFADeviceOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -6163,6 +5829,8 @@ func (s DeleteVirtualMFADeviceOutput) GoString() string { } type DetachGroupPolicyInput struct { + _ struct{} `type:"structure"` + // The name (friendly name, not ARN) of the group to detach the policy from. GroupName *string `min:"1" type:"string" required:"true"` @@ -6172,12 +5840,6 @@ type DetachGroupPolicyInput struct { // AWS Service Namespaces (http://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html) // in the AWS General Reference. PolicyArn *string `min:"20" type:"string" required:"true"` - - metadataDetachGroupPolicyInput `json:"-" xml:"-"` -} - -type metadataDetachGroupPolicyInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -6191,11 +5853,7 @@ func (s DetachGroupPolicyInput) GoString() string { } type DetachGroupPolicyOutput struct { - metadataDetachGroupPolicyOutput `json:"-" xml:"-"` -} - -type metadataDetachGroupPolicyOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -6209,6 +5867,8 @@ func (s DetachGroupPolicyOutput) GoString() string { } type DetachRolePolicyInput struct { + _ struct{} `type:"structure"` + // The Amazon Resource Name (ARN). ARNs are unique identifiers for AWS resources. // // For more information about ARNs, go to Amazon Resource Names (ARNs) and @@ -6218,12 +5878,6 @@ type DetachRolePolicyInput struct { // The name (friendly name, not ARN) of the role to detach the policy from. RoleName *string `min:"1" type:"string" required:"true"` - - metadataDetachRolePolicyInput `json:"-" xml:"-"` -} - -type metadataDetachRolePolicyInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -6237,11 +5891,7 @@ func (s DetachRolePolicyInput) GoString() string { } type DetachRolePolicyOutput struct { - metadataDetachRolePolicyOutput `json:"-" xml:"-"` -} - -type metadataDetachRolePolicyOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -6255,6 +5905,8 @@ func (s DetachRolePolicyOutput) GoString() string { } type DetachUserPolicyInput struct { + _ struct{} `type:"structure"` + // The Amazon Resource Name (ARN). ARNs are unique identifiers for AWS resources. // // For more information about ARNs, go to Amazon Resource Names (ARNs) and @@ -6264,12 +5916,6 @@ type DetachUserPolicyInput struct { // The name (friendly name, not ARN) of the user to detach the policy from. UserName *string `min:"1" type:"string" required:"true"` - - metadataDetachUserPolicyInput `json:"-" xml:"-"` -} - -type metadataDetachUserPolicyInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -6283,11 +5929,7 @@ func (s DetachUserPolicyInput) GoString() string { } type DetachUserPolicyOutput struct { - metadataDetachUserPolicyOutput `json:"-" xml:"-"` -} - -type metadataDetachUserPolicyOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -6301,6 +5943,8 @@ func (s DetachUserPolicyOutput) GoString() string { } type EnableMFADeviceInput struct { + _ struct{} `type:"structure"` + // An authentication code emitted by the device. AuthenticationCode1 *string `min:"6" type:"string" required:"true"` @@ -6313,12 +5957,6 @@ type EnableMFADeviceInput struct { // The name of the user for whom you want to enable the MFA device. UserName *string `min:"1" type:"string" required:"true"` - - metadataEnableMFADeviceInput `json:"-" xml:"-"` -} - -type metadataEnableMFADeviceInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -6332,11 +5970,7 @@ func (s EnableMFADeviceInput) GoString() string { } type EnableMFADeviceOutput struct { - metadataEnableMFADeviceOutput `json:"-" xml:"-"` -} - -type metadataEnableMFADeviceOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -6353,6 +5987,8 @@ func (s EnableMFADeviceOutput) GoString() string { // // This data type is used by the return parameter of SimulatePolicy. type EvaluationResult struct { + _ struct{} `type:"structure"` + // The name of the API action tested on the indicated resource. EvalActionName *string `min:"3" type:"string" required:"true"` @@ -6391,12 +6027,6 @@ type EvaluationResult struct { // The individual results of the simulation of the API action specified in EvalActionName // on each resource. ResourceSpecificResults []*ResourceSpecificResult `type:"list"` - - metadataEvaluationResult `json:"-" xml:"-"` -} - -type metadataEvaluationResult struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -6410,11 +6040,7 @@ func (s EvaluationResult) GoString() string { } type GenerateCredentialReportInput struct { - metadataGenerateCredentialReportInput `json:"-" xml:"-"` -} - -type metadataGenerateCredentialReportInput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -6429,17 +6055,13 @@ func (s GenerateCredentialReportInput) GoString() string { // Contains the response to a successful GenerateCredentialReport request. type GenerateCredentialReportOutput struct { + _ struct{} `type:"structure"` + // Information about the credential report. Description *string `type:"string"` // Information about the state of the credential report. State *string `type:"string" enum:"ReportStateType"` - - metadataGenerateCredentialReportOutput `json:"-" xml:"-"` -} - -type metadataGenerateCredentialReportOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -6453,14 +6075,10 @@ func (s GenerateCredentialReportOutput) GoString() string { } type GetAccessKeyLastUsedInput struct { + _ struct{} `type:"structure"` + // The identifier of an access key. AccessKeyId *string `min:"16" type:"string" required:"true"` - - metadataGetAccessKeyLastUsedInput `json:"-" xml:"-"` -} - -type metadataGetAccessKeyLastUsedInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -6477,17 +6095,13 @@ func (s GetAccessKeyLastUsedInput) GoString() string { // also returned as a member of the AccessKeyMetaData structure returned by // the ListAccessKeys action. type GetAccessKeyLastUsedOutput struct { + _ struct{} `type:"structure"` + // Contains information about the last time the access key was used. AccessKeyLastUsed *AccessKeyLastUsed `type:"structure"` // The name of the AWS IAM user that owns this access key. UserName *string `min:"1" type:"string"` - - metadataGetAccessKeyLastUsedOutput `json:"-" xml:"-"` -} - -type metadataGetAccessKeyLastUsedOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -6501,6 +6115,8 @@ func (s GetAccessKeyLastUsedOutput) GoString() string { } type GetAccountAuthorizationDetailsInput struct { + _ struct{} `type:"structure"` + // A list of entity types (user, group, role, local managed policy, or AWS managed // policy) for filtering the results. Filter []*string `type:"list"` @@ -6521,12 +6137,6 @@ type GetAccountAuthorizationDetailsInput struct { // Marker contains a value to include in the subsequent call that tells the // service where to continue from. MaxItems *int64 `min:"1" type:"integer"` - - metadataGetAccountAuthorizationDetailsInput `json:"-" xml:"-"` -} - -type metadataGetAccountAuthorizationDetailsInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -6541,6 +6151,8 @@ func (s GetAccountAuthorizationDetailsInput) GoString() string { // Contains the response to a successful GetAccountAuthorizationDetails request. type GetAccountAuthorizationDetailsOutput struct { + _ struct{} `type:"structure"` + // A list containing information about IAM groups. GroupDetailList []*GroupDetail `type:"list"` @@ -6564,12 +6176,6 @@ type GetAccountAuthorizationDetailsOutput struct { // A list containing information about IAM users. UserDetailList []*UserDetail `type:"list"` - - metadataGetAccountAuthorizationDetailsOutput `json:"-" xml:"-"` -} - -type metadataGetAccountAuthorizationDetailsOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -6583,11 +6189,7 @@ func (s GetAccountAuthorizationDetailsOutput) GoString() string { } type GetAccountPasswordPolicyInput struct { - metadataGetAccountPasswordPolicyInput `json:"-" xml:"-"` -} - -type metadataGetAccountPasswordPolicyInput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -6602,17 +6204,13 @@ func (s GetAccountPasswordPolicyInput) GoString() string { // Contains the response to a successful GetAccountPasswordPolicy request. type GetAccountPasswordPolicyOutput struct { + _ struct{} `type:"structure"` + // Contains information about the account password policy. // // This data type is used as a response element in the GetAccountPasswordPolicy // action. PasswordPolicy *PasswordPolicy `type:"structure" required:"true"` - - metadataGetAccountPasswordPolicyOutput `json:"-" xml:"-"` -} - -type metadataGetAccountPasswordPolicyOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -6626,11 +6224,7 @@ func (s GetAccountPasswordPolicyOutput) GoString() string { } type GetAccountSummaryInput struct { - metadataGetAccountSummaryInput `json:"-" xml:"-"` -} - -type metadataGetAccountSummaryInput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -6645,6 +6239,8 @@ func (s GetAccountSummaryInput) GoString() string { // Contains the response to a successful GetAccountSummary request. type GetAccountSummaryOutput struct { + _ struct{} `type:"structure"` + // A set of key value pairs containing information about IAM entity usage and // IAM quotas. // @@ -6789,12 +6385,6 @@ type GetAccountSummaryOutput struct { // // The maximum number of policy versions allowed for each managed policy. SummaryMap map[string]*int64 `type:"map"` - - metadataGetAccountSummaryOutput `json:"-" xml:"-"` -} - -type metadataGetAccountSummaryOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -6808,16 +6398,12 @@ func (s GetAccountSummaryOutput) GoString() string { } type GetContextKeysForCustomPolicyInput struct { + _ struct{} `type:"structure"` + // A list of policies for which you want list of context keys used in Condition // elements. Each document is specified as a string containing the complete, // valid JSON text of an IAM policy. PolicyInputList []*string `type:"list" required:"true"` - - metadataGetContextKeysForCustomPolicyInput `json:"-" xml:"-"` -} - -type metadataGetContextKeysForCustomPolicyInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -6833,15 +6419,11 @@ func (s GetContextKeysForCustomPolicyInput) GoString() string { // Contains the response to a successful GetContextKeysForPrincipalPolicy or // GetContextKeysForCustomPolicy request. type GetContextKeysForPolicyResponse struct { + _ struct{} `type:"structure"` + // The list of context keys that are used in the Condition elements of the input // policies. ContextKeyNames []*string `type:"list"` - - metadataGetContextKeysForPolicyResponse `json:"-" xml:"-"` -} - -type metadataGetContextKeysForPolicyResponse struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -6855,6 +6437,8 @@ func (s GetContextKeysForPolicyResponse) GoString() string { } type GetContextKeysForPrincipalPolicyInput struct { + _ struct{} `type:"structure"` + // A optional list of additional policies for which you want list of context // keys used in Condition elements. PolicyInputList []*string `type:"list"` @@ -6867,12 +6451,6 @@ type GetContextKeysForPrincipalPolicyInput struct { // Note that all parameters are shown in unencoded form here for clarity, but // must be URL encoded to be included as a part of a real HTML request. PolicySourceArn *string `min:"20" type:"string" required:"true"` - - metadataGetContextKeysForPrincipalPolicyInput `json:"-" xml:"-"` -} - -type metadataGetContextKeysForPrincipalPolicyInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -6886,11 +6464,7 @@ func (s GetContextKeysForPrincipalPolicyInput) GoString() string { } type GetCredentialReportInput struct { - metadataGetCredentialReportInput `json:"-" xml:"-"` -} - -type metadataGetCredentialReportInput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -6905,6 +6479,8 @@ func (s GetCredentialReportInput) GoString() string { // Contains the response to a successful GetCredentialReport request. type GetCredentialReportOutput struct { + _ struct{} `type:"structure"` + // Contains the credential report. The report is Base64-encoded. Content []byte `type:"blob"` @@ -6914,12 +6490,6 @@ type GetCredentialReportOutput struct { // The format (MIME type) of the credential report. ReportFormat *string `type:"string" enum:"ReportFormatType"` - - metadataGetCredentialReportOutput `json:"-" xml:"-"` -} - -type metadataGetCredentialReportOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -6933,6 +6503,8 @@ func (s GetCredentialReportOutput) GoString() string { } type GetGroupInput struct { + _ struct{} `type:"structure"` + // The name of the group. GroupName *string `min:"1" type:"string" required:"true"` @@ -6952,12 +6524,6 @@ type GetGroupInput struct { // Marker contains a value to include in the subsequent call that tells the // service where to continue from. MaxItems *int64 `min:"1" type:"integer"` - - metadataGetGroupInput `json:"-" xml:"-"` -} - -type metadataGetGroupInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -6972,6 +6538,8 @@ func (s GetGroupInput) GoString() string { // Contains the response to a successful GetGroup request. type GetGroupOutput struct { + _ struct{} `type:"structure"` + // Information about the group. Group *Group `type:"structure" required:"true"` @@ -6989,12 +6557,6 @@ type GetGroupOutput struct { // A list of users in the group. Users []*User `type:"list" required:"true"` - - metadataGetGroupOutput `json:"-" xml:"-"` -} - -type metadataGetGroupOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -7008,17 +6570,13 @@ func (s GetGroupOutput) GoString() string { } type GetGroupPolicyInput struct { + _ struct{} `type:"structure"` + // The name of the group the policy is associated with. GroupName *string `min:"1" type:"string" required:"true"` // The name of the policy document to get. PolicyName *string `min:"1" type:"string" required:"true"` - - metadataGetGroupPolicyInput `json:"-" xml:"-"` -} - -type metadataGetGroupPolicyInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -7033,6 +6591,8 @@ func (s GetGroupPolicyInput) GoString() string { // Contains the response to a successful GetGroupPolicy request. type GetGroupPolicyOutput struct { + _ struct{} `type:"structure"` + // The group the policy is associated with. GroupName *string `min:"1" type:"string" required:"true"` @@ -7041,12 +6601,6 @@ type GetGroupPolicyOutput struct { // The name of the policy. PolicyName *string `min:"1" type:"string" required:"true"` - - metadataGetGroupPolicyOutput `json:"-" xml:"-"` -} - -type metadataGetGroupPolicyOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -7060,14 +6614,10 @@ func (s GetGroupPolicyOutput) GoString() string { } type GetInstanceProfileInput struct { + _ struct{} `type:"structure"` + // The name of the instance profile to get information about. InstanceProfileName *string `min:"1" type:"string" required:"true"` - - metadataGetInstanceProfileInput `json:"-" xml:"-"` -} - -type metadataGetInstanceProfileInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -7082,14 +6632,10 @@ func (s GetInstanceProfileInput) GoString() string { // Contains the response to a successful GetInstanceProfile request. type GetInstanceProfileOutput struct { + _ struct{} `type:"structure"` + // Information about the instance profile. InstanceProfile *InstanceProfile `type:"structure" required:"true"` - - metadataGetInstanceProfileOutput `json:"-" xml:"-"` -} - -type metadataGetInstanceProfileOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -7103,14 +6649,10 @@ func (s GetInstanceProfileOutput) GoString() string { } type GetLoginProfileInput struct { + _ struct{} `type:"structure"` + // The name of the user whose login profile you want to retrieve. UserName *string `min:"1" type:"string" required:"true"` - - metadataGetLoginProfileInput `json:"-" xml:"-"` -} - -type metadataGetLoginProfileInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -7125,14 +6667,10 @@ func (s GetLoginProfileInput) GoString() string { // Contains the response to a successful GetLoginProfile request. type GetLoginProfileOutput struct { + _ struct{} `type:"structure"` + // The user name and password create date for the user. LoginProfile *LoginProfile `type:"structure" required:"true"` - - metadataGetLoginProfileOutput `json:"-" xml:"-"` -} - -type metadataGetLoginProfileOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -7146,16 +6684,12 @@ func (s GetLoginProfileOutput) GoString() string { } type GetOpenIDConnectProviderInput struct { + _ struct{} `type:"structure"` + // The Amazon Resource Name (ARN) of the IAM OpenID Connect (OIDC) provider // to get information for. You can get a list of OIDC provider ARNs by using // the ListOpenIDConnectProviders action. OpenIDConnectProviderArn *string `min:"20" type:"string" required:"true"` - - metadataGetOpenIDConnectProviderInput `json:"-" xml:"-"` -} - -type metadataGetOpenIDConnectProviderInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -7170,6 +6704,8 @@ func (s GetOpenIDConnectProviderInput) GoString() string { // Contains the response to a successful GetOpenIDConnectProvider request. type GetOpenIDConnectProviderOutput struct { + _ struct{} `type:"structure"` + // A list of client IDs (also known as audiences) that are associated with the // specified IAM OpenID Connect provider. For more information, see CreateOpenIDConnectProvider. ClientIDList []*string `type:"list"` @@ -7185,12 +6721,6 @@ type GetOpenIDConnectProviderOutput struct { // The URL that the IAM OpenID Connect provider is associated with. For more // information, see CreateOpenIDConnectProvider. Url *string `min:"1" type:"string"` - - metadataGetOpenIDConnectProviderOutput `json:"-" xml:"-"` -} - -type metadataGetOpenIDConnectProviderOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -7204,18 +6734,14 @@ func (s GetOpenIDConnectProviderOutput) GoString() string { } type GetPolicyInput struct { + _ struct{} `type:"structure"` + // The Amazon Resource Name (ARN). ARNs are unique identifiers for AWS resources. // // For more information about ARNs, go to Amazon Resource Names (ARNs) and // AWS Service Namespaces (http://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html) // in the AWS General Reference. PolicyArn *string `min:"20" type:"string" required:"true"` - - metadataGetPolicyInput `json:"-" xml:"-"` -} - -type metadataGetPolicyInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -7230,14 +6756,10 @@ func (s GetPolicyInput) GoString() string { // Contains the response to a successful GetPolicy request. type GetPolicyOutput struct { + _ struct{} `type:"structure"` + // Information about the policy. Policy *Policy `type:"structure"` - - metadataGetPolicyOutput `json:"-" xml:"-"` -} - -type metadataGetPolicyOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -7251,6 +6773,8 @@ func (s GetPolicyOutput) GoString() string { } type GetPolicyVersionInput struct { + _ struct{} `type:"structure"` + // The Amazon Resource Name (ARN). ARNs are unique identifiers for AWS resources. // // For more information about ARNs, go to Amazon Resource Names (ARNs) and @@ -7260,12 +6784,6 @@ type GetPolicyVersionInput struct { // Identifies the policy version to retrieve. VersionId *string `type:"string" required:"true"` - - metadataGetPolicyVersionInput `json:"-" xml:"-"` -} - -type metadataGetPolicyVersionInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -7280,18 +6798,14 @@ func (s GetPolicyVersionInput) GoString() string { // Contains the response to a successful GetPolicyVersion request. type GetPolicyVersionOutput struct { + _ struct{} `type:"structure"` + // Information about the policy version. // // For more information about managed policy versions, see Versioning for Managed // Policies (http://docs.aws.amazon.com/IAM/latest/UserGuide/policies-managed-versions.html) // in the IAM User Guide. PolicyVersion *PolicyVersion `type:"structure"` - - metadataGetPolicyVersionOutput `json:"-" xml:"-"` -} - -type metadataGetPolicyVersionOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -7305,14 +6819,10 @@ func (s GetPolicyVersionOutput) GoString() string { } type GetRoleInput struct { + _ struct{} `type:"structure"` + // The name of the role to get information about. RoleName *string `min:"1" type:"string" required:"true"` - - metadataGetRoleInput `json:"-" xml:"-"` -} - -type metadataGetRoleInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -7327,14 +6837,10 @@ func (s GetRoleInput) GoString() string { // Contains the response to a successful GetRole request. type GetRoleOutput struct { + _ struct{} `type:"structure"` + // Information about the role. Role *Role `type:"structure" required:"true"` - - metadataGetRoleOutput `json:"-" xml:"-"` -} - -type metadataGetRoleOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -7348,17 +6854,13 @@ func (s GetRoleOutput) GoString() string { } type GetRolePolicyInput struct { + _ struct{} `type:"structure"` + // The name of the policy document to get. PolicyName *string `min:"1" type:"string" required:"true"` // The name of the role associated with the policy. RoleName *string `min:"1" type:"string" required:"true"` - - metadataGetRolePolicyInput `json:"-" xml:"-"` -} - -type metadataGetRolePolicyInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -7373,6 +6875,8 @@ func (s GetRolePolicyInput) GoString() string { // Contains the response to a successful GetRolePolicy request. type GetRolePolicyOutput struct { + _ struct{} `type:"structure"` + // The policy document. PolicyDocument *string `min:"1" type:"string" required:"true"` @@ -7381,12 +6885,6 @@ type GetRolePolicyOutput struct { // The role the policy is associated with. RoleName *string `min:"1" type:"string" required:"true"` - - metadataGetRolePolicyOutput `json:"-" xml:"-"` -} - -type metadataGetRolePolicyOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -7400,14 +6898,10 @@ func (s GetRolePolicyOutput) GoString() string { } type GetSAMLProviderInput struct { + _ struct{} `type:"structure"` + // The Amazon Resource Name (ARN) of the SAML provider to get information about. SAMLProviderArn *string `min:"20" type:"string" required:"true"` - - metadataGetSAMLProviderInput `json:"-" xml:"-"` -} - -type metadataGetSAMLProviderInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -7422,6 +6916,8 @@ func (s GetSAMLProviderInput) GoString() string { // Contains the response to a successful GetSAMLProvider request. type GetSAMLProviderOutput struct { + _ struct{} `type:"structure"` + // The date and time when the SAML provider was created. CreateDate *time.Time `type:"timestamp" timestampFormat:"iso8601"` @@ -7430,12 +6926,6 @@ type GetSAMLProviderOutput struct { // The expiration date and time for the SAML provider. ValidUntil *time.Time `type:"timestamp" timestampFormat:"iso8601"` - - metadataGetSAMLProviderOutput `json:"-" xml:"-"` -} - -type metadataGetSAMLProviderOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -7449,6 +6939,8 @@ func (s GetSAMLProviderOutput) GoString() string { } type GetSSHPublicKeyInput struct { + _ struct{} `type:"structure"` + // Specifies the public key encoding format to use in the response. To retrieve // the public key in ssh-rsa format, use SSH. To retrieve the public key in // PEM format, use PEM. @@ -7459,12 +6951,6 @@ type GetSSHPublicKeyInput struct { // The name of the IAM user associated with the SSH public key. UserName *string `min:"1" type:"string" required:"true"` - - metadataGetSSHPublicKeyInput `json:"-" xml:"-"` -} - -type metadataGetSSHPublicKeyInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -7479,14 +6965,10 @@ func (s GetSSHPublicKeyInput) GoString() string { // Contains the response to a successful GetSSHPublicKey request. type GetSSHPublicKeyOutput struct { + _ struct{} `type:"structure"` + // Information about the SSH public key. SSHPublicKey *SSHPublicKey `type:"structure"` - - metadataGetSSHPublicKeyOutput `json:"-" xml:"-"` -} - -type metadataGetSSHPublicKeyOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -7500,14 +6982,10 @@ func (s GetSSHPublicKeyOutput) GoString() string { } type GetServerCertificateInput struct { + _ struct{} `type:"structure"` + // The name of the server certificate you want to retrieve information about. ServerCertificateName *string `min:"1" type:"string" required:"true"` - - metadataGetServerCertificateInput `json:"-" xml:"-"` -} - -type metadataGetServerCertificateInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -7522,14 +7000,10 @@ func (s GetServerCertificateInput) GoString() string { // Contains the response to a successful GetServerCertificate request. type GetServerCertificateOutput struct { + _ struct{} `type:"structure"` + // Information about the server certificate. ServerCertificate *ServerCertificate `type:"structure" required:"true"` - - metadataGetServerCertificateOutput `json:"-" xml:"-"` -} - -type metadataGetServerCertificateOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -7543,17 +7017,13 @@ func (s GetServerCertificateOutput) GoString() string { } type GetUserInput struct { + _ struct{} `type:"structure"` + // The name of the user to get information about. // // This parameter is optional. If it is not included, it defaults to the user // making the request. UserName *string `min:"1" type:"string"` - - metadataGetUserInput `json:"-" xml:"-"` -} - -type metadataGetUserInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -7568,14 +7038,10 @@ func (s GetUserInput) GoString() string { // Contains the response to a successful GetUser request. type GetUserOutput struct { + _ struct{} `type:"structure"` + // Information about the user. User *User `type:"structure" required:"true"` - - metadataGetUserOutput `json:"-" xml:"-"` -} - -type metadataGetUserOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -7589,17 +7055,13 @@ func (s GetUserOutput) GoString() string { } type GetUserPolicyInput struct { + _ struct{} `type:"structure"` + // The name of the policy document to get. PolicyName *string `min:"1" type:"string" required:"true"` // The name of the user who the policy is associated with. UserName *string `min:"1" type:"string" required:"true"` - - metadataGetUserPolicyInput `json:"-" xml:"-"` -} - -type metadataGetUserPolicyInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -7614,6 +7076,8 @@ func (s GetUserPolicyInput) GoString() string { // Contains the response to a successful GetUserPolicy request. type GetUserPolicyOutput struct { + _ struct{} `type:"structure"` + // The policy document. PolicyDocument *string `min:"1" type:"string" required:"true"` @@ -7622,12 +7086,6 @@ type GetUserPolicyOutput struct { // The user the policy is associated with. UserName *string `min:"1" type:"string" required:"true"` - - metadataGetUserPolicyOutput `json:"-" xml:"-"` -} - -type metadataGetUserPolicyOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -7646,6 +7104,8 @@ func (s GetUserPolicyOutput) GoString() string { // // CreateGroup GetGroup ListGroups type Group struct { + _ struct{} `type:"structure"` + // The Amazon Resource Name (ARN) specifying the group. For more information // about ARNs and how to use them in policies, see IAM Identifiers (http://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html) // in the Using IAM guide. @@ -7667,12 +7127,6 @@ type Group struct { // (http://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html) // in the Using IAM guide. Path *string `min:"1" type:"string" required:"true"` - - metadataGroup `json:"-" xml:"-"` -} - -type metadataGroup struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -7690,6 +7144,8 @@ func (s Group) GoString() string { // This data type is used as a response element in the GetAccountAuthorizationDetails // action. type GroupDetail struct { + _ struct{} `type:"structure"` + // The Amazon Resource Name (ARN). ARNs are unique identifiers for AWS resources. // // For more information about ARNs, go to Amazon Resource Names (ARNs) and @@ -7719,12 +7175,6 @@ type GroupDetail struct { // (http://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html) // in the Using IAM guide. Path *string `min:"1" type:"string"` - - metadataGroupDetail `json:"-" xml:"-"` -} - -type metadataGroupDetail struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -7749,6 +7199,8 @@ func (s GroupDetail) GoString() string { // // ListInstanceProfilesForRole type InstanceProfile struct { + _ struct{} `type:"structure"` + // The Amazon Resource Name (ARN) specifying the instance profile. For more // information about ARNs and how to use them in policies, see IAM Identifiers // (http://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html) @@ -7773,12 +7225,6 @@ type InstanceProfile struct { // The role associated with the instance profile. Roles []*Role `type:"list" required:"true"` - - metadataInstanceProfile `json:"-" xml:"-"` -} - -type metadataInstanceProfile struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -7792,6 +7238,8 @@ func (s InstanceProfile) GoString() string { } type ListAccessKeysInput struct { + _ struct{} `type:"structure"` + // Use this parameter only when paginating results and only after you receive // a response indicating that the results are truncated. Set it to the value // of the Marker element in the response that you received to indicate where @@ -7811,12 +7259,6 @@ type ListAccessKeysInput struct { // The name of the user. UserName *string `min:"1" type:"string"` - - metadataListAccessKeysInput `json:"-" xml:"-"` -} - -type metadataListAccessKeysInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -7831,6 +7273,8 @@ func (s ListAccessKeysInput) GoString() string { // Contains the response to a successful ListAccessKeys request. type ListAccessKeysOutput struct { + _ struct{} `type:"structure"` + // A list of access key metadata. AccessKeyMetadata []*AccessKeyMetadata `type:"list" required:"true"` @@ -7845,12 +7289,6 @@ type ListAccessKeysOutput struct { // When IsTruncated is true, this element is present and contains the value // to use for the Marker parameter in a subsequent pagination request. Marker *string `min:"1" type:"string"` - - metadataListAccessKeysOutput `json:"-" xml:"-"` -} - -type metadataListAccessKeysOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -7864,6 +7302,8 @@ func (s ListAccessKeysOutput) GoString() string { } type ListAccountAliasesInput struct { + _ struct{} `type:"structure"` + // Use this parameter only when paginating results and only after you receive // a response indicating that the results are truncated. Set it to the value // of the Marker element in the response that you received to indicate where @@ -7880,12 +7320,6 @@ type ListAccountAliasesInput struct { // Marker contains a value to include in the subsequent call that tells the // service where to continue from. MaxItems *int64 `min:"1" type:"integer"` - - metadataListAccountAliasesInput `json:"-" xml:"-"` -} - -type metadataListAccountAliasesInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -7900,6 +7334,8 @@ func (s ListAccountAliasesInput) GoString() string { // Contains the response to a successful ListAccountAliases request. type ListAccountAliasesOutput struct { + _ struct{} `type:"structure"` + // A list of aliases associated with the account. AWS supports only one alias // per account. AccountAliases []*string `type:"list" required:"true"` @@ -7915,12 +7351,6 @@ type ListAccountAliasesOutput struct { // When IsTruncated is true, this element is present and contains the value // to use for the Marker parameter in a subsequent pagination request. Marker *string `min:"1" type:"string"` - - metadataListAccountAliasesOutput `json:"-" xml:"-"` -} - -type metadataListAccountAliasesOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -7934,6 +7364,8 @@ func (s ListAccountAliasesOutput) GoString() string { } type ListAttachedGroupPoliciesInput struct { + _ struct{} `type:"structure"` + // The name (friendly name, not ARN) of the group to list attached policies // for. GroupName *string `min:"1" type:"string" required:"true"` @@ -7958,12 +7390,6 @@ type ListAttachedGroupPoliciesInput struct { // The path prefix for filtering the results. This parameter is optional. If // it is not included, it defaults to a slash (/), listing all policies. PathPrefix *string `type:"string"` - - metadataListAttachedGroupPoliciesInput `json:"-" xml:"-"` -} - -type metadataListAttachedGroupPoliciesInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -7978,6 +7404,8 @@ func (s ListAttachedGroupPoliciesInput) GoString() string { // Contains the response to a successful ListAttachedGroupPolicies request. type ListAttachedGroupPoliciesOutput struct { + _ struct{} `type:"structure"` + // A list of the attached policies. AttachedPolicies []*AttachedPolicy `type:"list"` @@ -7992,12 +7420,6 @@ type ListAttachedGroupPoliciesOutput struct { // When IsTruncated is true, this element is present and contains the value // to use for the Marker parameter in a subsequent pagination request. Marker *string `min:"1" type:"string"` - - metadataListAttachedGroupPoliciesOutput `json:"-" xml:"-"` -} - -type metadataListAttachedGroupPoliciesOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -8011,6 +7433,8 @@ func (s ListAttachedGroupPoliciesOutput) GoString() string { } type ListAttachedRolePoliciesInput struct { + _ struct{} `type:"structure"` + // Use this parameter only when paginating results and only after you receive // a response indicating that the results are truncated. Set it to the value // of the Marker element in the response that you received to indicate where @@ -8034,12 +7458,6 @@ type ListAttachedRolePoliciesInput struct { // The name (friendly name, not ARN) of the role to list attached policies for. RoleName *string `min:"1" type:"string" required:"true"` - - metadataListAttachedRolePoliciesInput `json:"-" xml:"-"` -} - -type metadataListAttachedRolePoliciesInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -8054,6 +7472,8 @@ func (s ListAttachedRolePoliciesInput) GoString() string { // Contains the response to a successful ListAttachedRolePolicies request. type ListAttachedRolePoliciesOutput struct { + _ struct{} `type:"structure"` + // A list of the attached policies. AttachedPolicies []*AttachedPolicy `type:"list"` @@ -8068,12 +7488,6 @@ type ListAttachedRolePoliciesOutput struct { // When IsTruncated is true, this element is present and contains the value // to use for the Marker parameter in a subsequent pagination request. Marker *string `min:"1" type:"string"` - - metadataListAttachedRolePoliciesOutput `json:"-" xml:"-"` -} - -type metadataListAttachedRolePoliciesOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -8087,6 +7501,8 @@ func (s ListAttachedRolePoliciesOutput) GoString() string { } type ListAttachedUserPoliciesInput struct { + _ struct{} `type:"structure"` + // Use this parameter only when paginating results and only after you receive // a response indicating that the results are truncated. Set it to the value // of the Marker element in the response that you received to indicate where @@ -8110,12 +7526,6 @@ type ListAttachedUserPoliciesInput struct { // The name (friendly name, not ARN) of the user to list attached policies for. UserName *string `min:"1" type:"string" required:"true"` - - metadataListAttachedUserPoliciesInput `json:"-" xml:"-"` -} - -type metadataListAttachedUserPoliciesInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -8130,6 +7540,8 @@ func (s ListAttachedUserPoliciesInput) GoString() string { // Contains the response to a successful ListAttachedUserPolicies request. type ListAttachedUserPoliciesOutput struct { + _ struct{} `type:"structure"` + // A list of the attached policies. AttachedPolicies []*AttachedPolicy `type:"list"` @@ -8144,12 +7556,6 @@ type ListAttachedUserPoliciesOutput struct { // When IsTruncated is true, this element is present and contains the value // to use for the Marker parameter in a subsequent pagination request. Marker *string `min:"1" type:"string"` - - metadataListAttachedUserPoliciesOutput `json:"-" xml:"-"` -} - -type metadataListAttachedUserPoliciesOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -8163,6 +7569,8 @@ func (s ListAttachedUserPoliciesOutput) GoString() string { } type ListEntitiesForPolicyInput struct { + _ struct{} `type:"structure"` + // The entity type to use for filtering the results. // // For example, when EntityFilter is Role, only the roles that are attached @@ -8197,12 +7605,6 @@ type ListEntitiesForPolicyInput struct { // AWS Service Namespaces (http://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html) // in the AWS General Reference. PolicyArn *string `min:"20" type:"string" required:"true"` - - metadataListEntitiesForPolicyInput `json:"-" xml:"-"` -} - -type metadataListEntitiesForPolicyInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -8217,6 +7619,8 @@ func (s ListEntitiesForPolicyInput) GoString() string { // Contains the response to a successful ListEntitiesForPolicy request. type ListEntitiesForPolicyOutput struct { + _ struct{} `type:"structure"` + // A flag that indicates whether there are more items to return. If your results // were truncated, you can make a subsequent pagination request using the Marker // request parameter to retrieve more items. Note that IAM might return fewer @@ -8237,12 +7641,6 @@ type ListEntitiesForPolicyOutput struct { // A list of users that the policy is attached to. PolicyUsers []*PolicyUser `type:"list"` - - metadataListEntitiesForPolicyOutput `json:"-" xml:"-"` -} - -type metadataListEntitiesForPolicyOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -8256,6 +7654,8 @@ func (s ListEntitiesForPolicyOutput) GoString() string { } type ListGroupPoliciesInput struct { + _ struct{} `type:"structure"` + // The name of the group to list policies for. GroupName *string `min:"1" type:"string" required:"true"` @@ -8275,12 +7675,6 @@ type ListGroupPoliciesInput struct { // Marker contains a value to include in the subsequent call that tells the // service where to continue from. MaxItems *int64 `min:"1" type:"integer"` - - metadataListGroupPoliciesInput `json:"-" xml:"-"` -} - -type metadataListGroupPoliciesInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -8295,6 +7689,8 @@ func (s ListGroupPoliciesInput) GoString() string { // Contains the response to a successful ListGroupPolicies request. type ListGroupPoliciesOutput struct { + _ struct{} `type:"structure"` + // A flag that indicates whether there are more items to return. If your results // were truncated, you can make a subsequent pagination request using the Marker // request parameter to retrieve more items. Note that IAM might return fewer @@ -8309,12 +7705,6 @@ type ListGroupPoliciesOutput struct { // A list of policy names. PolicyNames []*string `type:"list" required:"true"` - - metadataListGroupPoliciesOutput `json:"-" xml:"-"` -} - -type metadataListGroupPoliciesOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -8328,6 +7718,8 @@ func (s ListGroupPoliciesOutput) GoString() string { } type ListGroupsForUserInput struct { + _ struct{} `type:"structure"` + // Use this parameter only when paginating results and only after you receive // a response indicating that the results are truncated. Set it to the value // of the Marker element in the response that you received to indicate where @@ -8347,12 +7739,6 @@ type ListGroupsForUserInput struct { // The name of the user to list groups for. UserName *string `min:"1" type:"string" required:"true"` - - metadataListGroupsForUserInput `json:"-" xml:"-"` -} - -type metadataListGroupsForUserInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -8367,6 +7753,8 @@ func (s ListGroupsForUserInput) GoString() string { // Contains the response to a successful ListGroupsForUser request. type ListGroupsForUserOutput struct { + _ struct{} `type:"structure"` + // A list of groups. Groups []*Group `type:"list" required:"true"` @@ -8381,12 +7769,6 @@ type ListGroupsForUserOutput struct { // When IsTruncated is true, this element is present and contains the value // to use for the Marker parameter in a subsequent pagination request. Marker *string `min:"1" type:"string"` - - metadataListGroupsForUserOutput `json:"-" xml:"-"` -} - -type metadataListGroupsForUserOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -8400,6 +7782,8 @@ func (s ListGroupsForUserOutput) GoString() string { } type ListGroupsInput struct { + _ struct{} `type:"structure"` + // Use this parameter only when paginating results and only after you receive // a response indicating that the results are truncated. Set it to the value // of the Marker element in the response that you received to indicate where @@ -8423,12 +7807,6 @@ type ListGroupsInput struct { // This parameter is optional. If it is not included, it defaults to a slash // (/), listing all groups. PathPrefix *string `min:"1" type:"string"` - - metadataListGroupsInput `json:"-" xml:"-"` -} - -type metadataListGroupsInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -8443,6 +7821,8 @@ func (s ListGroupsInput) GoString() string { // Contains the response to a successful ListGroups request. type ListGroupsOutput struct { + _ struct{} `type:"structure"` + // A list of groups. Groups []*Group `type:"list" required:"true"` @@ -8457,12 +7837,6 @@ type ListGroupsOutput struct { // When IsTruncated is true, this element is present and contains the value // to use for the Marker parameter in a subsequent pagination request. Marker *string `min:"1" type:"string"` - - metadataListGroupsOutput `json:"-" xml:"-"` -} - -type metadataListGroupsOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -8476,6 +7850,8 @@ func (s ListGroupsOutput) GoString() string { } type ListInstanceProfilesForRoleInput struct { + _ struct{} `type:"structure"` + // Use this parameter only when paginating results and only after you receive // a response indicating that the results are truncated. Set it to the value // of the Marker element in the response that you received to indicate where @@ -8495,12 +7871,6 @@ type ListInstanceProfilesForRoleInput struct { // The name of the role to list instance profiles for. RoleName *string `min:"1" type:"string" required:"true"` - - metadataListInstanceProfilesForRoleInput `json:"-" xml:"-"` -} - -type metadataListInstanceProfilesForRoleInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -8515,6 +7885,8 @@ func (s ListInstanceProfilesForRoleInput) GoString() string { // Contains the response to a successful ListInstanceProfilesForRole request. type ListInstanceProfilesForRoleOutput struct { + _ struct{} `type:"structure"` + // A list of instance profiles. InstanceProfiles []*InstanceProfile `type:"list" required:"true"` @@ -8529,12 +7901,6 @@ type ListInstanceProfilesForRoleOutput struct { // When IsTruncated is true, this element is present and contains the value // to use for the Marker parameter in a subsequent pagination request. Marker *string `min:"1" type:"string"` - - metadataListInstanceProfilesForRoleOutput `json:"-" xml:"-"` -} - -type metadataListInstanceProfilesForRoleOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -8548,6 +7914,8 @@ func (s ListInstanceProfilesForRoleOutput) GoString() string { } type ListInstanceProfilesInput struct { + _ struct{} `type:"structure"` + // Use this parameter only when paginating results and only after you receive // a response indicating that the results are truncated. Set it to the value // of the Marker element in the response that you received to indicate where @@ -8571,12 +7939,6 @@ type ListInstanceProfilesInput struct { // This parameter is optional. If it is not included, it defaults to a slash // (/), listing all instance profiles. PathPrefix *string `min:"1" type:"string"` - - metadataListInstanceProfilesInput `json:"-" xml:"-"` -} - -type metadataListInstanceProfilesInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -8591,6 +7953,8 @@ func (s ListInstanceProfilesInput) GoString() string { // Contains the response to a successful ListInstanceProfiles request. type ListInstanceProfilesOutput struct { + _ struct{} `type:"structure"` + // A list of instance profiles. InstanceProfiles []*InstanceProfile `type:"list" required:"true"` @@ -8605,12 +7969,6 @@ type ListInstanceProfilesOutput struct { // When IsTruncated is true, this element is present and contains the value // to use for the Marker parameter in a subsequent pagination request. Marker *string `min:"1" type:"string"` - - metadataListInstanceProfilesOutput `json:"-" xml:"-"` -} - -type metadataListInstanceProfilesOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -8624,6 +7982,8 @@ func (s ListInstanceProfilesOutput) GoString() string { } type ListMFADevicesInput struct { + _ struct{} `type:"structure"` + // Use this parameter only when paginating results and only after you receive // a response indicating that the results are truncated. Set it to the value // of the Marker element in the response that you received to indicate where @@ -8643,12 +8003,6 @@ type ListMFADevicesInput struct { // The name of the user whose MFA devices you want to list. UserName *string `min:"1" type:"string"` - - metadataListMFADevicesInput `json:"-" xml:"-"` -} - -type metadataListMFADevicesInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -8663,6 +8017,8 @@ func (s ListMFADevicesInput) GoString() string { // Contains the response to a successful ListMFADevices request. type ListMFADevicesOutput struct { + _ struct{} `type:"structure"` + // A flag that indicates whether there are more items to return. If your results // were truncated, you can make a subsequent pagination request using the Marker // request parameter to retrieve more items. Note that IAM might return fewer @@ -8677,12 +8033,6 @@ type ListMFADevicesOutput struct { // When IsTruncated is true, this element is present and contains the value // to use for the Marker parameter in a subsequent pagination request. Marker *string `min:"1" type:"string"` - - metadataListMFADevicesOutput `json:"-" xml:"-"` -} - -type metadataListMFADevicesOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -8696,11 +8046,7 @@ func (s ListMFADevicesOutput) GoString() string { } type ListOpenIDConnectProvidersInput struct { - metadataListOpenIDConnectProvidersInput `json:"-" xml:"-"` -} - -type metadataListOpenIDConnectProvidersInput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -8715,14 +8061,10 @@ func (s ListOpenIDConnectProvidersInput) GoString() string { // Contains the response to a successful ListOpenIDConnectProviders request. type ListOpenIDConnectProvidersOutput struct { + _ struct{} `type:"structure"` + // The list of IAM OpenID Connect providers in the AWS account. OpenIDConnectProviderList []*OpenIDConnectProviderListEntry `type:"list"` - - metadataListOpenIDConnectProvidersOutput `json:"-" xml:"-"` -} - -type metadataListOpenIDConnectProvidersOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -8736,6 +8078,8 @@ func (s ListOpenIDConnectProvidersOutput) GoString() string { } type ListPoliciesInput struct { + _ struct{} `type:"structure"` + // Use this parameter only when paginating results and only after you receive // a response indicating that the results are truncated. Set it to the value // of the Marker element in the response that you received to indicate where @@ -8772,12 +8116,6 @@ type ListPoliciesInput struct { // This parameter is optional. If it is not included, or if it is set to All, // all policies are returned. Scope *string `type:"string" enum:"policyScopeType"` - - metadataListPoliciesInput `json:"-" xml:"-"` -} - -type metadataListPoliciesInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -8792,6 +8130,8 @@ func (s ListPoliciesInput) GoString() string { // Contains the response to a successful ListPolicies request. type ListPoliciesOutput struct { + _ struct{} `type:"structure"` + // A flag that indicates whether there are more items to return. If your results // were truncated, you can make a subsequent pagination request using the Marker // request parameter to retrieve more items. Note that IAM might return fewer @@ -8806,12 +8146,6 @@ type ListPoliciesOutput struct { // A list of policies. Policies []*Policy `type:"list"` - - metadataListPoliciesOutput `json:"-" xml:"-"` -} - -type metadataListPoliciesOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -8825,6 +8159,8 @@ func (s ListPoliciesOutput) GoString() string { } type ListPolicyVersionsInput struct { + _ struct{} `type:"structure"` + // Use this parameter only when paginating results and only after you receive // a response indicating that the results are truncated. Set it to the value // of the Marker element in the response that you received to indicate where @@ -8848,12 +8184,6 @@ type ListPolicyVersionsInput struct { // AWS Service Namespaces (http://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html) // in the AWS General Reference. PolicyArn *string `min:"20" type:"string" required:"true"` - - metadataListPolicyVersionsInput `json:"-" xml:"-"` -} - -type metadataListPolicyVersionsInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -8868,6 +8198,8 @@ func (s ListPolicyVersionsInput) GoString() string { // Contains the response to a successful ListPolicyVersions request. type ListPolicyVersionsOutput struct { + _ struct{} `type:"structure"` + // A flag that indicates whether there are more items to return. If your results // were truncated, you can make a subsequent pagination request using the Marker // request parameter to retrieve more items. Note that IAM might return fewer @@ -8886,12 +8218,6 @@ type ListPolicyVersionsOutput struct { // Policies (http://docs.aws.amazon.com/IAM/latest/UserGuide/policies-managed-versions.html) // in the IAM User Guide. Versions []*PolicyVersion `type:"list"` - - metadataListPolicyVersionsOutput `json:"-" xml:"-"` -} - -type metadataListPolicyVersionsOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -8905,6 +8231,8 @@ func (s ListPolicyVersionsOutput) GoString() string { } type ListRolePoliciesInput struct { + _ struct{} `type:"structure"` + // Use this parameter only when paginating results and only after you receive // a response indicating that the results are truncated. Set it to the value // of the Marker element in the response that you received to indicate where @@ -8924,12 +8252,6 @@ type ListRolePoliciesInput struct { // The name of the role to list policies for. RoleName *string `min:"1" type:"string" required:"true"` - - metadataListRolePoliciesInput `json:"-" xml:"-"` -} - -type metadataListRolePoliciesInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -8944,6 +8266,8 @@ func (s ListRolePoliciesInput) GoString() string { // Contains the response to a successful ListRolePolicies request. type ListRolePoliciesOutput struct { + _ struct{} `type:"structure"` + // A flag that indicates whether there are more items to return. If your results // were truncated, you can make a subsequent pagination request using the Marker // request parameter to retrieve more items. Note that IAM might return fewer @@ -8958,12 +8282,6 @@ type ListRolePoliciesOutput struct { // A list of policy names. PolicyNames []*string `type:"list" required:"true"` - - metadataListRolePoliciesOutput `json:"-" xml:"-"` -} - -type metadataListRolePoliciesOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -8977,6 +8295,8 @@ func (s ListRolePoliciesOutput) GoString() string { } type ListRolesInput struct { + _ struct{} `type:"structure"` + // Use this parameter only when paginating results and only after you receive // a response indicating that the results are truncated. Set it to the value // of the Marker element in the response that you received to indicate where @@ -9000,12 +8320,6 @@ type ListRolesInput struct { // This parameter is optional. If it is not included, it defaults to a slash // (/), listing all roles. PathPrefix *string `min:"1" type:"string"` - - metadataListRolesInput `json:"-" xml:"-"` -} - -type metadataListRolesInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -9020,6 +8334,8 @@ func (s ListRolesInput) GoString() string { // Contains the response to a successful ListRoles request. type ListRolesOutput struct { + _ struct{} `type:"structure"` + // A flag that indicates whether there are more items to return. If your results // were truncated, you can make a subsequent pagination request using the Marker // request parameter to retrieve more items. Note that IAM might return fewer @@ -9034,12 +8350,6 @@ type ListRolesOutput struct { // A list of roles. Roles []*Role `type:"list" required:"true"` - - metadataListRolesOutput `json:"-" xml:"-"` -} - -type metadataListRolesOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -9053,11 +8363,7 @@ func (s ListRolesOutput) GoString() string { } type ListSAMLProvidersInput struct { - metadataListSAMLProvidersInput `json:"-" xml:"-"` -} - -type metadataListSAMLProvidersInput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -9072,14 +8378,10 @@ func (s ListSAMLProvidersInput) GoString() string { // Contains the response to a successful ListSAMLProviders request. type ListSAMLProvidersOutput struct { + _ struct{} `type:"structure"` + // The list of SAML providers for this account. SAMLProviderList []*SAMLProviderListEntry `type:"list"` - - metadataListSAMLProvidersOutput `json:"-" xml:"-"` -} - -type metadataListSAMLProvidersOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -9093,6 +8395,8 @@ func (s ListSAMLProvidersOutput) GoString() string { } type ListSSHPublicKeysInput struct { + _ struct{} `type:"structure"` + // Use this parameter only when paginating results and only after you receive // a response indicating that the results are truncated. Set it to the value // of the Marker element in the response that you received to indicate where @@ -9114,12 +8418,6 @@ type ListSSHPublicKeysInput struct { // the UserName field is determined implicitly based on the AWS access key used // to sign the request. UserName *string `min:"1" type:"string"` - - metadataListSSHPublicKeysInput `json:"-" xml:"-"` -} - -type metadataListSSHPublicKeysInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -9134,6 +8432,8 @@ func (s ListSSHPublicKeysInput) GoString() string { // Contains the response to a successful ListSSHPublicKeys request. type ListSSHPublicKeysOutput struct { + _ struct{} `type:"structure"` + // A flag that indicates whether there are more items to return. If your results // were truncated, you can make a subsequent pagination request using the Marker // request parameter to retrieve more items. Note that IAM might return fewer @@ -9148,12 +8448,6 @@ type ListSSHPublicKeysOutput struct { // A list of SSH public keys. SSHPublicKeys []*SSHPublicKeyMetadata `type:"list"` - - metadataListSSHPublicKeysOutput `json:"-" xml:"-"` -} - -type metadataListSSHPublicKeysOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -9167,6 +8461,8 @@ func (s ListSSHPublicKeysOutput) GoString() string { } type ListServerCertificatesInput struct { + _ struct{} `type:"structure"` + // Use this parameter only when paginating results and only after you receive // a response indicating that the results are truncated. Set it to the value // of the Marker element in the response that you received to indicate where @@ -9190,12 +8486,6 @@ type ListServerCertificatesInput struct { // This parameter is optional. If it is not included, it defaults to a slash // (/), listing all server certificates. PathPrefix *string `min:"1" type:"string"` - - metadataListServerCertificatesInput `json:"-" xml:"-"` -} - -type metadataListServerCertificatesInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -9210,6 +8500,8 @@ func (s ListServerCertificatesInput) GoString() string { // Contains the response to a successful ListServerCertificates request. type ListServerCertificatesOutput struct { + _ struct{} `type:"structure"` + // A flag that indicates whether there are more items to return. If your results // were truncated, you can make a subsequent pagination request using the Marker // request parameter to retrieve more items. Note that IAM might return fewer @@ -9224,12 +8516,6 @@ type ListServerCertificatesOutput struct { // A list of server certificates. ServerCertificateMetadataList []*ServerCertificateMetadata `type:"list" required:"true"` - - metadataListServerCertificatesOutput `json:"-" xml:"-"` -} - -type metadataListServerCertificatesOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -9243,6 +8529,8 @@ func (s ListServerCertificatesOutput) GoString() string { } type ListSigningCertificatesInput struct { + _ struct{} `type:"structure"` + // Use this parameter only when paginating results and only after you receive // a response indicating that the results are truncated. Set it to the value // of the Marker element in the response that you received to indicate where @@ -9262,12 +8550,6 @@ type ListSigningCertificatesInput struct { // The name of the user. UserName *string `min:"1" type:"string"` - - metadataListSigningCertificatesInput `json:"-" xml:"-"` -} - -type metadataListSigningCertificatesInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -9282,6 +8564,8 @@ func (s ListSigningCertificatesInput) GoString() string { // Contains the response to a successful ListSigningCertificates request. type ListSigningCertificatesOutput struct { + _ struct{} `type:"structure"` + // A list of the user's signing certificate information. Certificates []*SigningCertificate `type:"list" required:"true"` @@ -9296,12 +8580,6 @@ type ListSigningCertificatesOutput struct { // When IsTruncated is true, this element is present and contains the value // to use for the Marker parameter in a subsequent pagination request. Marker *string `min:"1" type:"string"` - - metadataListSigningCertificatesOutput `json:"-" xml:"-"` -} - -type metadataListSigningCertificatesOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -9315,6 +8593,8 @@ func (s ListSigningCertificatesOutput) GoString() string { } type ListUserPoliciesInput struct { + _ struct{} `type:"structure"` + // Use this parameter only when paginating results and only after you receive // a response indicating that the results are truncated. Set it to the value // of the Marker element in the response that you received to indicate where @@ -9334,12 +8614,6 @@ type ListUserPoliciesInput struct { // The name of the user to list policies for. UserName *string `min:"1" type:"string" required:"true"` - - metadataListUserPoliciesInput `json:"-" xml:"-"` -} - -type metadataListUserPoliciesInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -9354,6 +8628,8 @@ func (s ListUserPoliciesInput) GoString() string { // Contains the response to a successful ListUserPolicies request. type ListUserPoliciesOutput struct { + _ struct{} `type:"structure"` + // A flag that indicates whether there are more items to return. If your results // were truncated, you can make a subsequent pagination request using the Marker // request parameter to retrieve more items. Note that IAM might return fewer @@ -9368,12 +8644,6 @@ type ListUserPoliciesOutput struct { // A list of policy names. PolicyNames []*string `type:"list" required:"true"` - - metadataListUserPoliciesOutput `json:"-" xml:"-"` -} - -type metadataListUserPoliciesOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -9387,6 +8657,8 @@ func (s ListUserPoliciesOutput) GoString() string { } type ListUsersInput struct { + _ struct{} `type:"structure"` + // Use this parameter only when paginating results and only after you receive // a response indicating that the results are truncated. Set it to the value // of the Marker element in the response that you received to indicate where @@ -9410,12 +8682,6 @@ type ListUsersInput struct { // This parameter is optional. If it is not included, it defaults to a slash // (/), listing all user names. PathPrefix *string `min:"1" type:"string"` - - metadataListUsersInput `json:"-" xml:"-"` -} - -type metadataListUsersInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -9430,6 +8696,8 @@ func (s ListUsersInput) GoString() string { // Contains the response to a successful ListUsers request. type ListUsersOutput struct { + _ struct{} `type:"structure"` + // A flag that indicates whether there are more items to return. If your results // were truncated, you can make a subsequent pagination request using the Marker // request parameter to retrieve more items. Note that IAM might return fewer @@ -9444,12 +8712,6 @@ type ListUsersOutput struct { // A list of users. Users []*User `type:"list" required:"true"` - - metadataListUsersOutput `json:"-" xml:"-"` -} - -type metadataListUsersOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -9463,6 +8725,8 @@ func (s ListUsersOutput) GoString() string { } type ListVirtualMFADevicesInput struct { + _ struct{} `type:"structure"` + // The status (unassigned or assigned) of the devices to list. If you do not // specify an AssignmentStatus, the action defaults to Any which lists both // assigned and unassigned virtual MFA devices. @@ -9484,12 +8748,6 @@ type ListVirtualMFADevicesInput struct { // Marker contains a value to include in the subsequent call that tells the // service where to continue from. MaxItems *int64 `min:"1" type:"integer"` - - metadataListVirtualMFADevicesInput `json:"-" xml:"-"` -} - -type metadataListVirtualMFADevicesInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -9504,6 +8762,8 @@ func (s ListVirtualMFADevicesInput) GoString() string { // Contains the response to a successful ListVirtualMFADevices request. type ListVirtualMFADevicesOutput struct { + _ struct{} `type:"structure"` + // A flag that indicates whether there are more items to return. If your results // were truncated, you can make a subsequent pagination request using the Marker // request parameter to retrieve more items. Note that IAM might return fewer @@ -9519,12 +8779,6 @@ type ListVirtualMFADevicesOutput struct { // The list of virtual MFA devices in the current account that match the AssignmentStatus // value that was passed in the request. VirtualMFADevices []*VirtualMFADevice `type:"list" required:"true"` - - metadataListVirtualMFADevicesOutput `json:"-" xml:"-"` -} - -type metadataListVirtualMFADevicesOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -9542,6 +8796,8 @@ func (s ListVirtualMFADevicesOutput) GoString() string { // This data type is used as a response element in the CreateLoginProfile // and GetLoginProfile actions. type LoginProfile struct { + _ struct{} `type:"structure"` + // The date when the password for the user was created. CreateDate *time.Time `type:"timestamp" timestampFormat:"iso8601" required:"true"` @@ -9551,12 +8807,6 @@ type LoginProfile struct { // The name of the user, which can be used for signing in to the AWS Management // Console. UserName *string `min:"1" type:"string" required:"true"` - - metadataLoginProfile `json:"-" xml:"-"` -} - -type metadataLoginProfile struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -9573,6 +8823,8 @@ func (s LoginProfile) GoString() string { // // This data type is used as a response element in the ListMFADevices action. type MFADevice struct { + _ struct{} `type:"structure"` + // The date when the MFA device was enabled for the user. EnableDate *time.Time `type:"timestamp" timestampFormat:"iso8601" required:"true"` @@ -9582,12 +8834,6 @@ type MFADevice struct { // The user with whom the MFA device is associated. UserName *string `min:"1" type:"string" required:"true"` - - metadataMFADevice `json:"-" xml:"-"` -} - -type metadataMFADevice struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -9611,6 +8857,8 @@ func (s MFADevice) GoString() string { // Policies (http://docs.aws.amazon.com/IAM/latest/UserGuide/policies-managed-vs-inline.html) // in the Using IAM guide. type ManagedPolicyDetail struct { + _ struct{} `type:"structure"` + // The Amazon Resource Name (ARN). ARNs are unique identifiers for AWS resources. // // For more information about ARNs, go to Amazon Resource Names (ARNs) and @@ -9666,12 +8914,6 @@ type ManagedPolicyDetail struct { // field contains the date and time when the most recent policy version was // created. UpdateDate *time.Time `type:"timestamp" timestampFormat:"iso8601"` - - metadataManagedPolicyDetail `json:"-" xml:"-"` -} - -type metadataManagedPolicyDetail struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -9686,18 +8928,14 @@ func (s ManagedPolicyDetail) GoString() string { // Contains the Amazon Resource Name (ARN) for an IAM OpenID Connect provider. type OpenIDConnectProviderListEntry struct { + _ struct{} `type:"structure"` + // The Amazon Resource Name (ARN). ARNs are unique identifiers for AWS resources. // // For more information about ARNs, go to Amazon Resource Names (ARNs) and // AWS Service Namespaces (http://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html) // in the AWS General Reference. Arn *string `min:"20" type:"string"` - - metadataOpenIDConnectProviderListEntry `json:"-" xml:"-"` -} - -type metadataOpenIDConnectProviderListEntry struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -9715,6 +8953,8 @@ func (s OpenIDConnectProviderListEntry) GoString() string { // This data type is used as a response element in the GetAccountPasswordPolicy // action. type PasswordPolicy struct { + _ struct{} `type:"structure"` + // Specifies whether IAM users are allowed to change their own password. AllowUsersToChangePassword *bool `type:"boolean"` @@ -9748,12 +8988,6 @@ type PasswordPolicy struct { // Specifies whether to require uppercase characters for IAM user passwords. RequireUppercaseCharacters *bool `type:"boolean"` - - metadataPasswordPolicy `json:"-" xml:"-"` -} - -type metadataPasswordPolicy struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -9775,6 +9009,8 @@ func (s PasswordPolicy) GoString() string { // Inline Policies (http://docs.aws.amazon.com/IAM/latest/UserGuide/policies-managed-vs-inline.html) // in the Using IAM guide. type Policy struct { + _ struct{} `type:"structure"` + // The Amazon Resource Name (ARN). ARNs are unique identifiers for AWS resources. // // For more information about ARNs, go to Amazon Resource Names (ARNs) and @@ -9825,12 +9061,6 @@ type Policy struct { // field contains the date and time when the most recent policy version was // created. UpdateDate *time.Time `type:"timestamp" timestampFormat:"iso8601"` - - metadataPolicy `json:"-" xml:"-"` -} - -type metadataPolicy struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -9848,17 +9078,13 @@ func (s Policy) GoString() string { // This data type is used as a response element in the GetAccountAuthorizationDetails // action. type PolicyDetail struct { + _ struct{} `type:"structure"` + // The policy document. PolicyDocument *string `min:"1" type:"string"` // The name of the policy. PolicyName *string `min:"1" type:"string"` - - metadataPolicyDetail `json:"-" xml:"-"` -} - -type metadataPolicyDetail struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -9880,14 +9106,10 @@ func (s PolicyDetail) GoString() string { // Inline Policies (http://docs.aws.amazon.com/IAM/latest/UserGuide/policies-managed-vs-inline.html) // in the Using IAM guide. type PolicyGroup struct { + _ struct{} `type:"structure"` + // The name (friendly name, not ARN) identifying the group. GroupName *string `min:"1" type:"string"` - - metadataPolicyGroup `json:"-" xml:"-"` -} - -type metadataPolicyGroup struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -9909,14 +9131,10 @@ func (s PolicyGroup) GoString() string { // Inline Policies (http://docs.aws.amazon.com/IAM/latest/UserGuide/policies-managed-vs-inline.html) // in the Using IAM guide. type PolicyRole struct { + _ struct{} `type:"structure"` + // The name (friendly name, not ARN) identifying the role. RoleName *string `min:"1" type:"string"` - - metadataPolicyRole `json:"-" xml:"-"` -} - -type metadataPolicyRole struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -9938,14 +9156,10 @@ func (s PolicyRole) GoString() string { // Inline Policies (http://docs.aws.amazon.com/IAM/latest/UserGuide/policies-managed-vs-inline.html) // in the Using IAM guide. type PolicyUser struct { + _ struct{} `type:"structure"` + // The name (friendly name, not ARN) identifying the user. UserName *string `min:"1" type:"string"` - - metadataPolicyUser `json:"-" xml:"-"` -} - -type metadataPolicyUser struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -9968,6 +9182,8 @@ func (s PolicyUser) GoString() string { // Inline Policies (http://docs.aws.amazon.com/IAM/latest/UserGuide/policies-managed-vs-inline.html) // in the Using IAM guide. type PolicyVersion struct { + _ struct{} `type:"structure"` + // The date and time, in ISO 8601 date-time format (http://www.iso.org/iso/iso8601), // when the policy version was created. CreateDate *time.Time `type:"timestamp" timestampFormat:"iso8601"` @@ -9987,12 +9203,6 @@ type PolicyVersion struct { // Policy version identifiers always begin with v (always lowercase). When // a policy is created, the first policy version is v1. VersionId *string `type:"string"` - - metadataPolicyVersion `json:"-" xml:"-"` -} - -type metadataPolicyVersion struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -10010,17 +9220,13 @@ func (s PolicyVersion) GoString() string { // // This data type is used as a member of the Statement type. type Position struct { + _ struct{} `type:"structure"` + // The column in the line containing the specified position in the document. Column *int64 `type:"integer"` // The line containing the specified position in the document. Line *int64 `type:"integer"` - - metadataPosition `json:"-" xml:"-"` -} - -type metadataPosition struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -10034,6 +9240,8 @@ func (s Position) GoString() string { } type PutGroupPolicyInput struct { + _ struct{} `type:"structure"` + // The name of the group to associate the policy with. GroupName *string `min:"1" type:"string" required:"true"` @@ -10042,12 +9250,6 @@ type PutGroupPolicyInput struct { // The name of the policy document. PolicyName *string `min:"1" type:"string" required:"true"` - - metadataPutGroupPolicyInput `json:"-" xml:"-"` -} - -type metadataPutGroupPolicyInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -10061,11 +9263,7 @@ func (s PutGroupPolicyInput) GoString() string { } type PutGroupPolicyOutput struct { - metadataPutGroupPolicyOutput `json:"-" xml:"-"` -} - -type metadataPutGroupPolicyOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -10079,6 +9277,8 @@ func (s PutGroupPolicyOutput) GoString() string { } type PutRolePolicyInput struct { + _ struct{} `type:"structure"` + // The policy document. PolicyDocument *string `min:"1" type:"string" required:"true"` @@ -10087,12 +9287,6 @@ type PutRolePolicyInput struct { // The name of the role to associate the policy with. RoleName *string `min:"1" type:"string" required:"true"` - - metadataPutRolePolicyInput `json:"-" xml:"-"` -} - -type metadataPutRolePolicyInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -10106,11 +9300,7 @@ func (s PutRolePolicyInput) GoString() string { } type PutRolePolicyOutput struct { - metadataPutRolePolicyOutput `json:"-" xml:"-"` -} - -type metadataPutRolePolicyOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -10124,6 +9314,8 @@ func (s PutRolePolicyOutput) GoString() string { } type PutUserPolicyInput struct { + _ struct{} `type:"structure"` + // The policy document. PolicyDocument *string `min:"1" type:"string" required:"true"` @@ -10132,12 +9324,6 @@ type PutUserPolicyInput struct { // The name of the user to associate the policy with. UserName *string `min:"1" type:"string" required:"true"` - - metadataPutUserPolicyInput `json:"-" xml:"-"` -} - -type metadataPutUserPolicyInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -10151,11 +9337,7 @@ func (s PutUserPolicyInput) GoString() string { } type PutUserPolicyOutput struct { - metadataPutUserPolicyOutput `json:"-" xml:"-"` -} - -type metadataPutUserPolicyOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -10169,6 +9351,8 @@ func (s PutUserPolicyOutput) GoString() string { } type RemoveClientIDFromOpenIDConnectProviderInput struct { + _ struct{} `type:"structure"` + // The client ID (also known as audience) to remove from the IAM OpenID Connect // provider. For more information about client IDs, see CreateOpenIDConnectProvider. ClientID *string `min:"1" type:"string" required:"true"` @@ -10177,12 +9361,6 @@ type RemoveClientIDFromOpenIDConnectProviderInput struct { // to remove the client ID from. You can get a list of OIDC provider ARNs by // using the ListOpenIDConnectProviders action. OpenIDConnectProviderArn *string `min:"20" type:"string" required:"true"` - - metadataRemoveClientIDFromOpenIDConnectProviderInput `json:"-" xml:"-"` -} - -type metadataRemoveClientIDFromOpenIDConnectProviderInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -10196,11 +9374,7 @@ func (s RemoveClientIDFromOpenIDConnectProviderInput) GoString() string { } type RemoveClientIDFromOpenIDConnectProviderOutput struct { - metadataRemoveClientIDFromOpenIDConnectProviderOutput `json:"-" xml:"-"` -} - -type metadataRemoveClientIDFromOpenIDConnectProviderOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -10214,17 +9388,13 @@ func (s RemoveClientIDFromOpenIDConnectProviderOutput) GoString() string { } type RemoveRoleFromInstanceProfileInput struct { + _ struct{} `type:"structure"` + // The name of the instance profile to update. InstanceProfileName *string `min:"1" type:"string" required:"true"` // The name of the role to remove. RoleName *string `min:"1" type:"string" required:"true"` - - metadataRemoveRoleFromInstanceProfileInput `json:"-" xml:"-"` -} - -type metadataRemoveRoleFromInstanceProfileInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -10238,11 +9408,7 @@ func (s RemoveRoleFromInstanceProfileInput) GoString() string { } type RemoveRoleFromInstanceProfileOutput struct { - metadataRemoveRoleFromInstanceProfileOutput `json:"-" xml:"-"` -} - -type metadataRemoveRoleFromInstanceProfileOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -10256,17 +9422,13 @@ func (s RemoveRoleFromInstanceProfileOutput) GoString() string { } type RemoveUserFromGroupInput struct { + _ struct{} `type:"structure"` + // The name of the group to update. GroupName *string `min:"1" type:"string" required:"true"` // The name of the user to remove. UserName *string `min:"1" type:"string" required:"true"` - - metadataRemoveUserFromGroupInput `json:"-" xml:"-"` -} - -type metadataRemoveUserFromGroupInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -10280,11 +9442,7 @@ func (s RemoveUserFromGroupInput) GoString() string { } type RemoveUserFromGroupOutput struct { - metadataRemoveUserFromGroupOutput `json:"-" xml:"-"` -} - -type metadataRemoveUserFromGroupOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -10302,6 +9460,8 @@ func (s RemoveUserFromGroupOutput) GoString() string { // // This data type is used by a member of the EvaluationResult data type. type ResourceSpecificResult struct { + _ struct{} `type:"structure"` + // Additional details about the results of the evaluation decision. When there // are both IAM policies and resource policies, this parameter explains how // each set of policies contributes to the final evaluation decision. When simulating @@ -10328,12 +9488,6 @@ type ResourceSpecificResult struct { // keys used by a set of policies, you can call GetContextKeysForCustomPolicy // or GetContextKeysForPrincipalPolicy. MissingContextValues []*string `type:"list"` - - metadataResourceSpecificResult `json:"-" xml:"-"` -} - -type metadataResourceSpecificResult struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -10347,6 +9501,8 @@ func (s ResourceSpecificResult) GoString() string { } type ResyncMFADeviceInput struct { + _ struct{} `type:"structure"` + // An authentication code emitted by the device. AuthenticationCode1 *string `min:"6" type:"string" required:"true"` @@ -10358,12 +9514,6 @@ type ResyncMFADeviceInput struct { // The name of the user whose MFA device you want to resynchronize. UserName *string `min:"1" type:"string" required:"true"` - - metadataResyncMFADeviceInput `json:"-" xml:"-"` -} - -type metadataResyncMFADeviceInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -10377,11 +9527,7 @@ func (s ResyncMFADeviceInput) GoString() string { } type ResyncMFADeviceOutput struct { - metadataResyncMFADeviceOutput `json:"-" xml:"-"` -} - -type metadataResyncMFADeviceOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -10404,6 +9550,8 @@ func (s ResyncMFADeviceOutput) GoString() string { // // ListRoles type Role struct { + _ struct{} `type:"structure"` + // The Amazon Resource Name (ARN) specifying the role. For more information // about ARNs and how to use them in policies, see IAM Identifiers (http://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html) // in the Using IAM guide. @@ -10428,12 +9576,6 @@ type Role struct { // The friendly name that identifies the role. RoleName *string `min:"1" type:"string" required:"true"` - - metadataRole `json:"-" xml:"-"` -} - -type metadataRole struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -10451,6 +9593,8 @@ func (s Role) GoString() string { // This data type is used as a response element in the GetAccountAuthorizationDetails // action. type RoleDetail struct { + _ struct{} `type:"structure"` + // The Amazon Resource Name (ARN). ARNs are unique identifiers for AWS resources. // // For more information about ARNs, go to Amazon Resource Names (ARNs) and @@ -10488,12 +9632,6 @@ type RoleDetail struct { // A list of inline policies embedded in the role. These policies are the role's // access (permissions) policies. RolePolicyList []*PolicyDetail `type:"list"` - - metadataRoleDetail `json:"-" xml:"-"` -} - -type metadataRoleDetail struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -10508,6 +9646,8 @@ func (s RoleDetail) GoString() string { // Contains the list of SAML providers for this account. type SAMLProviderListEntry struct { + _ struct{} `type:"structure"` + // The Amazon Resource Name (ARN) of the SAML provider. Arn *string `min:"20" type:"string"` @@ -10516,12 +9656,6 @@ type SAMLProviderListEntry struct { // The expiration date and time for the SAML provider. ValidUntil *time.Time `type:"timestamp" timestampFormat:"iso8601"` - - metadataSAMLProviderListEntry `json:"-" xml:"-"` -} - -type metadataSAMLProviderListEntry struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -10539,6 +9673,8 @@ func (s SAMLProviderListEntry) GoString() string { // This data type is used as a response element in the GetSSHPublicKey and // UploadSSHPublicKey actions. type SSHPublicKey struct { + _ struct{} `type:"structure"` + // The MD5 message digest of the SSH public key. Fingerprint *string `min:"48" type:"string" required:"true"` @@ -10558,12 +9694,6 @@ type SSHPublicKey struct { // The name of the IAM user associated with the SSH public key. UserName *string `min:"1" type:"string" required:"true"` - - metadataSSHPublicKey `json:"-" xml:"-"` -} - -type metadataSSHPublicKey struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -10580,6 +9710,8 @@ func (s SSHPublicKey) GoString() string { // // This data type is used as a response element in the ListSSHPublicKeys action. type SSHPublicKeyMetadata struct { + _ struct{} `type:"structure"` + // The unique identifier for the SSH public key. SSHPublicKeyId *string `min:"20" type:"string" required:"true"` @@ -10593,12 +9725,6 @@ type SSHPublicKeyMetadata struct { // The name of the IAM user associated with the SSH public key. UserName *string `min:"1" type:"string" required:"true"` - - metadataSSHPublicKeyMetadata `json:"-" xml:"-"` -} - -type metadataSSHPublicKeyMetadata struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -10616,6 +9742,8 @@ func (s SSHPublicKeyMetadata) GoString() string { // This data type is used as a response element in the GetServerCertificate // action. type ServerCertificate struct { + _ struct{} `type:"structure"` + // The contents of the public key certificate. CertificateBody *string `min:"1" type:"string" required:"true"` @@ -10625,12 +9753,6 @@ type ServerCertificate struct { // The meta information of the server certificate, such as its name, path, ID, // and ARN. ServerCertificateMetadata *ServerCertificateMetadata `type:"structure" required:"true"` - - metadataServerCertificate `json:"-" xml:"-"` -} - -type metadataServerCertificate struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -10649,6 +9771,8 @@ func (s ServerCertificate) GoString() string { // This data type is used as a response element in the UploadServerCertificate // and ListServerCertificates actions. type ServerCertificateMetadata struct { + _ struct{} `type:"structure"` + // The Amazon Resource Name (ARN) specifying the server certificate. For more // information about ARNs and how to use them in policies, see IAM Identifiers // (http://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html) @@ -10673,12 +9797,6 @@ type ServerCertificateMetadata struct { // The date when the server certificate was uploaded. UploadDate *time.Time `type:"timestamp" timestampFormat:"iso8601"` - - metadataServerCertificateMetadata `json:"-" xml:"-"` -} - -type metadataServerCertificateMetadata struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -10692,6 +9810,8 @@ func (s ServerCertificateMetadata) GoString() string { } type SetDefaultPolicyVersionInput struct { + _ struct{} `type:"structure"` + // The Amazon Resource Name (ARN). ARNs are unique identifiers for AWS resources. // // For more information about ARNs, go to Amazon Resource Names (ARNs) and @@ -10705,12 +9825,6 @@ type SetDefaultPolicyVersionInput struct { // Policies (http://docs.aws.amazon.com/IAM/latest/UserGuide/policies-managed-versions.html) // in the IAM User Guide. VersionId *string `type:"string" required:"true"` - - metadataSetDefaultPolicyVersionInput `json:"-" xml:"-"` -} - -type metadataSetDefaultPolicyVersionInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -10724,11 +9838,7 @@ func (s SetDefaultPolicyVersionInput) GoString() string { } type SetDefaultPolicyVersionOutput struct { - metadataSetDefaultPolicyVersionOutput `json:"-" xml:"-"` -} - -type metadataSetDefaultPolicyVersionOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -10746,6 +9856,8 @@ func (s SetDefaultPolicyVersionOutput) GoString() string { // This data type is used as a response element in the UploadSigningCertificate // and ListSigningCertificates actions. type SigningCertificate struct { + _ struct{} `type:"structure"` + // The contents of the signing certificate. CertificateBody *string `min:"1" type:"string" required:"true"` @@ -10761,12 +9873,6 @@ type SigningCertificate struct { // The name of the user the signing certificate is associated with. UserName *string `min:"1" type:"string" required:"true"` - - metadataSigningCertificate `json:"-" xml:"-"` -} - -type metadataSigningCertificate struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -10780,6 +9886,8 @@ func (s SigningCertificate) GoString() string { } type SimulateCustomPolicyInput struct { + _ struct{} `type:"structure"` + // A list of names of API actions to evaluate in the simulation. Each action // is evaluated against each resource. Each action must include the service // identifier, such as iam:CreateUser. @@ -10895,12 +10003,6 @@ type SimulateCustomPolicyInput struct { // Each resource in the simulation is treated as if it had this policy attached. // You can include only one resource-based policy in a simulation. ResourcePolicy *string `min:"1" type:"string"` - - metadataSimulateCustomPolicyInput `json:"-" xml:"-"` -} - -type metadataSimulateCustomPolicyInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -10916,6 +10018,8 @@ func (s SimulateCustomPolicyInput) GoString() string { // Contains the response to a successful SimulatePrincipalPolicy or SimulateCustomPolicy // request. type SimulatePolicyResponse struct { + _ struct{} `type:"structure"` + // The results of the simulation. EvaluationResults []*EvaluationResult `type:"list"` @@ -10930,12 +10034,6 @@ type SimulatePolicyResponse struct { // When IsTruncated is true, this element is present and contains the value // to use for the Marker parameter in a subsequent pagination request. Marker *string `min:"1" type:"string"` - - metadataSimulatePolicyResponse `json:"-" xml:"-"` -} - -type metadataSimulatePolicyResponse struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -10949,6 +10047,8 @@ func (s SimulatePolicyResponse) GoString() string { } type SimulatePrincipalPolicyInput struct { + _ struct{} `type:"structure"` + // A list of names of API actions to evaluate in the simulation. Each action // is evaluated for each resource. Each action must include the service identifier, // such as iam:CreateUser. @@ -11070,12 +10170,6 @@ type SimulatePrincipalPolicyInput struct { // Each resource in the simulation is treated as if it had this policy attached. // You can include only one resource-based policy in a simulation. ResourcePolicy *string `min:"1" type:"string"` - - metadataSimulatePrincipalPolicyInput `json:"-" xml:"-"` -} - -type metadataSimulatePrincipalPolicyInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -11094,6 +10188,8 @@ func (s SimulatePrincipalPolicyInput) GoString() string { // This data type is used by the MatchedStatements member of the EvaluationResult // type. type Statement struct { + _ struct{} `type:"structure"` + // The row and column of the end of a Statement in an IAM policy. EndPosition *Position `type:"structure"` @@ -11105,12 +10201,6 @@ type Statement struct { // The row and column of the beginning of the Statement in an IAM policy. StartPosition *Position `type:"structure"` - - metadataStatement `json:"-" xml:"-"` -} - -type metadataStatement struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -11124,6 +10214,8 @@ func (s Statement) GoString() string { } type UpdateAccessKeyInput struct { + _ struct{} `type:"structure"` + // The access key ID of the secret access key you want to update. AccessKeyId *string `min:"16" type:"string" required:"true"` @@ -11134,12 +10226,6 @@ type UpdateAccessKeyInput struct { // The name of the user whose key you want to update. UserName *string `min:"1" type:"string"` - - metadataUpdateAccessKeyInput `json:"-" xml:"-"` -} - -type metadataUpdateAccessKeyInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -11153,11 +10239,7 @@ func (s UpdateAccessKeyInput) GoString() string { } type UpdateAccessKeyOutput struct { - metadataUpdateAccessKeyOutput `json:"-" xml:"-"` -} - -type metadataUpdateAccessKeyOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -11171,6 +10253,8 @@ func (s UpdateAccessKeyOutput) GoString() string { } type UpdateAccountPasswordPolicyInput struct { + _ struct{} `type:"structure"` + // Allows all IAM users in your account to use the AWS Management Console to // change their own passwords. For more information, see Letting IAM Users Change // Their Own Passwords (http://docs.aws.amazon.com/IAM/latest/UserGuide/HowToPwdIAMUser.html) @@ -11227,12 +10311,6 @@ type UpdateAccountPasswordPolicyInput struct { // // Default value: false RequireUppercaseCharacters *bool `type:"boolean"` - - metadataUpdateAccountPasswordPolicyInput `json:"-" xml:"-"` -} - -type metadataUpdateAccountPasswordPolicyInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -11246,11 +10324,7 @@ func (s UpdateAccountPasswordPolicyInput) GoString() string { } type UpdateAccountPasswordPolicyOutput struct { - metadataUpdateAccountPasswordPolicyOutput `json:"-" xml:"-"` -} - -type metadataUpdateAccountPasswordPolicyOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -11264,17 +10338,13 @@ func (s UpdateAccountPasswordPolicyOutput) GoString() string { } type UpdateAssumeRolePolicyInput struct { + _ struct{} `type:"structure"` + // The policy that grants an entity permission to assume the role. PolicyDocument *string `min:"1" type:"string" required:"true"` // The name of the role to update. RoleName *string `min:"1" type:"string" required:"true"` - - metadataUpdateAssumeRolePolicyInput `json:"-" xml:"-"` -} - -type metadataUpdateAssumeRolePolicyInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -11288,11 +10358,7 @@ func (s UpdateAssumeRolePolicyInput) GoString() string { } type UpdateAssumeRolePolicyOutput struct { - metadataUpdateAssumeRolePolicyOutput `json:"-" xml:"-"` -} - -type metadataUpdateAssumeRolePolicyOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -11306,6 +10372,8 @@ func (s UpdateAssumeRolePolicyOutput) GoString() string { } type UpdateGroupInput struct { + _ struct{} `type:"structure"` + // Name of the group to update. If you're changing the name of the group, this // is the original name. GroupName *string `min:"1" type:"string" required:"true"` @@ -11315,12 +10383,6 @@ type UpdateGroupInput struct { // New path for the group. Only include this if changing the group's path. NewPath *string `min:"1" type:"string"` - - metadataUpdateGroupInput `json:"-" xml:"-"` -} - -type metadataUpdateGroupInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -11334,11 +10396,7 @@ func (s UpdateGroupInput) GoString() string { } type UpdateGroupOutput struct { - metadataUpdateGroupOutput `json:"-" xml:"-"` -} - -type metadataUpdateGroupOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -11352,6 +10410,8 @@ func (s UpdateGroupOutput) GoString() string { } type UpdateLoginProfileInput struct { + _ struct{} `type:"structure"` + // The new password for the specified user. Password *string `min:"1" type:"string"` @@ -11360,12 +10420,6 @@ type UpdateLoginProfileInput struct { // The name of the user whose password you want to update. UserName *string `min:"1" type:"string" required:"true"` - - metadataUpdateLoginProfileInput `json:"-" xml:"-"` -} - -type metadataUpdateLoginProfileInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -11379,11 +10433,7 @@ func (s UpdateLoginProfileInput) GoString() string { } type UpdateLoginProfileOutput struct { - metadataUpdateLoginProfileOutput `json:"-" xml:"-"` -} - -type metadataUpdateLoginProfileOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -11397,6 +10447,8 @@ func (s UpdateLoginProfileOutput) GoString() string { } type UpdateOpenIDConnectProviderThumbprintInput struct { + _ struct{} `type:"structure"` + // The Amazon Resource Name (ARN) of the IAM OpenID Connect (OIDC) provider // to update the thumbprint for. You can get a list of OIDC provider ARNs by // using the ListOpenIDConnectProviders action. @@ -11405,12 +10457,6 @@ type UpdateOpenIDConnectProviderThumbprintInput struct { // A list of certificate thumbprints that are associated with the specified // IAM OpenID Connect provider. For more information, see CreateOpenIDConnectProvider. ThumbprintList []*string `type:"list" required:"true"` - - metadataUpdateOpenIDConnectProviderThumbprintInput `json:"-" xml:"-"` -} - -type metadataUpdateOpenIDConnectProviderThumbprintInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -11424,11 +10470,7 @@ func (s UpdateOpenIDConnectProviderThumbprintInput) GoString() string { } type UpdateOpenIDConnectProviderThumbprintOutput struct { - metadataUpdateOpenIDConnectProviderThumbprintOutput `json:"-" xml:"-"` -} - -type metadataUpdateOpenIDConnectProviderThumbprintOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -11442,6 +10484,8 @@ func (s UpdateOpenIDConnectProviderThumbprintOutput) GoString() string { } type UpdateSAMLProviderInput struct { + _ struct{} `type:"structure"` + // An XML document generated by an identity provider (IdP) that supports SAML // 2.0. The document includes the issuer's name, expiration information, and // keys that can be used to validate the SAML authentication response (assertions) @@ -11451,12 +10495,6 @@ type UpdateSAMLProviderInput struct { // The Amazon Resource Name (ARN) of the SAML provider to update. SAMLProviderArn *string `min:"20" type:"string" required:"true"` - - metadataUpdateSAMLProviderInput `json:"-" xml:"-"` -} - -type metadataUpdateSAMLProviderInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -11471,14 +10509,10 @@ func (s UpdateSAMLProviderInput) GoString() string { // Contains the response to a successful UpdateSAMLProvider request. type UpdateSAMLProviderOutput struct { + _ struct{} `type:"structure"` + // The Amazon Resource Name (ARN) of the SAML provider that was updated. SAMLProviderArn *string `min:"20" type:"string"` - - metadataUpdateSAMLProviderOutput `json:"-" xml:"-"` -} - -type metadataUpdateSAMLProviderOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -11492,6 +10526,8 @@ func (s UpdateSAMLProviderOutput) GoString() string { } type UpdateSSHPublicKeyInput struct { + _ struct{} `type:"structure"` + // The unique identifier for the SSH public key. SSHPublicKeyId *string `min:"20" type:"string" required:"true"` @@ -11502,12 +10538,6 @@ type UpdateSSHPublicKeyInput struct { // The name of the IAM user associated with the SSH public key. UserName *string `min:"1" type:"string" required:"true"` - - metadataUpdateSSHPublicKeyInput `json:"-" xml:"-"` -} - -type metadataUpdateSSHPublicKeyInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -11521,11 +10551,7 @@ func (s UpdateSSHPublicKeyInput) GoString() string { } type UpdateSSHPublicKeyOutput struct { - metadataUpdateSSHPublicKeyOutput `json:"-" xml:"-"` -} - -type metadataUpdateSSHPublicKeyOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -11539,6 +10565,8 @@ func (s UpdateSSHPublicKeyOutput) GoString() string { } type UpdateServerCertificateInput struct { + _ struct{} `type:"structure"` + // The new path for the server certificate. Include this only if you are updating // the server certificate's path. NewPath *string `min:"1" type:"string"` @@ -11550,12 +10578,6 @@ type UpdateServerCertificateInput struct { // The name of the server certificate that you want to update. ServerCertificateName *string `min:"1" type:"string" required:"true"` - - metadataUpdateServerCertificateInput `json:"-" xml:"-"` -} - -type metadataUpdateServerCertificateInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -11569,11 +10591,7 @@ func (s UpdateServerCertificateInput) GoString() string { } type UpdateServerCertificateOutput struct { - metadataUpdateServerCertificateOutput `json:"-" xml:"-"` -} - -type metadataUpdateServerCertificateOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -11587,6 +10605,8 @@ func (s UpdateServerCertificateOutput) GoString() string { } type UpdateSigningCertificateInput struct { + _ struct{} `type:"structure"` + // The ID of the signing certificate you want to update. CertificateId *string `min:"24" type:"string" required:"true"` @@ -11597,12 +10617,6 @@ type UpdateSigningCertificateInput struct { // The name of the user the signing certificate belongs to. UserName *string `min:"1" type:"string"` - - metadataUpdateSigningCertificateInput `json:"-" xml:"-"` -} - -type metadataUpdateSigningCertificateInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -11616,11 +10630,7 @@ func (s UpdateSigningCertificateInput) GoString() string { } type UpdateSigningCertificateOutput struct { - metadataUpdateSigningCertificateOutput `json:"-" xml:"-"` -} - -type metadataUpdateSigningCertificateOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -11634,6 +10644,8 @@ func (s UpdateSigningCertificateOutput) GoString() string { } type UpdateUserInput struct { + _ struct{} `type:"structure"` + // New path for the user. Include this parameter only if you're changing the // user's path. NewPath *string `min:"1" type:"string"` @@ -11645,12 +10657,6 @@ type UpdateUserInput struct { // Name of the user to update. If you're changing the name of the user, this // is the original user name. UserName *string `min:"1" type:"string" required:"true"` - - metadataUpdateUserInput `json:"-" xml:"-"` -} - -type metadataUpdateUserInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -11664,11 +10670,7 @@ func (s UpdateUserInput) GoString() string { } type UpdateUserOutput struct { - metadataUpdateUserOutput `json:"-" xml:"-"` -} - -type metadataUpdateUserOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -11682,18 +10684,14 @@ func (s UpdateUserOutput) GoString() string { } type UploadSSHPublicKeyInput struct { + _ struct{} `type:"structure"` + // The SSH public key. The public key must be encoded in ssh-rsa format or PEM // format. SSHPublicKeyBody *string `min:"1" type:"string" required:"true"` // The name of the IAM user to associate the SSH public key with. UserName *string `min:"1" type:"string" required:"true"` - - metadataUploadSSHPublicKeyInput `json:"-" xml:"-"` -} - -type metadataUploadSSHPublicKeyInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -11708,14 +10706,10 @@ func (s UploadSSHPublicKeyInput) GoString() string { // Contains the response to a successful UploadSSHPublicKey request. type UploadSSHPublicKeyOutput struct { + _ struct{} `type:"structure"` + // Contains information about the SSH public key. SSHPublicKey *SSHPublicKey `type:"structure"` - - metadataUploadSSHPublicKeyOutput `json:"-" xml:"-"` -} - -type metadataUploadSSHPublicKeyOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -11729,6 +10723,8 @@ func (s UploadSSHPublicKeyOutput) GoString() string { } type UploadServerCertificateInput struct { + _ struct{} `type:"structure"` + // The contents of the public key certificate in PEM-encoded format. CertificateBody *string `min:"1" type:"string" required:"true"` @@ -11755,12 +10751,6 @@ type UploadServerCertificateInput struct { // The name for the server certificate. Do not include the path in this value. // The name of the certificate cannot contain any spaces. ServerCertificateName *string `min:"1" type:"string" required:"true"` - - metadataUploadServerCertificateInput `json:"-" xml:"-"` -} - -type metadataUploadServerCertificateInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -11775,15 +10765,11 @@ func (s UploadServerCertificateInput) GoString() string { // Contains the response to a successful UploadServerCertificate request. type UploadServerCertificateOutput struct { + _ struct{} `type:"structure"` + // The meta information of the uploaded server certificate without its certificate // body, certificate chain, and private key. ServerCertificateMetadata *ServerCertificateMetadata `type:"structure"` - - metadataUploadServerCertificateOutput `json:"-" xml:"-"` -} - -type metadataUploadServerCertificateOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -11797,17 +10783,13 @@ func (s UploadServerCertificateOutput) GoString() string { } type UploadSigningCertificateInput struct { + _ struct{} `type:"structure"` + // The contents of the signing certificate. CertificateBody *string `min:"1" type:"string" required:"true"` // The name of the user the signing certificate is for. UserName *string `min:"1" type:"string"` - - metadataUploadSigningCertificateInput `json:"-" xml:"-"` -} - -type metadataUploadSigningCertificateInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -11822,14 +10804,10 @@ func (s UploadSigningCertificateInput) GoString() string { // Contains the response to a successful UploadSigningCertificate request. type UploadSigningCertificateOutput struct { + _ struct{} `type:"structure"` + // Information about the certificate. Certificate *SigningCertificate `type:"structure" required:"true"` - - metadataUploadSigningCertificateOutput `json:"-" xml:"-"` -} - -type metadataUploadSigningCertificateOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -11852,6 +10830,8 @@ func (s UploadSigningCertificateOutput) GoString() string { // // ListUsers type User struct { + _ struct{} `type:"structure"` + // The Amazon Resource Name (ARN) that identifies the user. For more information // about ARNs and how to use ARNs in policies, see IAM Identifiers (http://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html) // in the Using IAM guide. @@ -11891,12 +10871,6 @@ type User struct { // The friendly name identifying the user. UserName *string `min:"1" type:"string" required:"true"` - - metadataUser `json:"-" xml:"-"` -} - -type metadataUser struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -11915,6 +10889,8 @@ func (s User) GoString() string { // This data type is used as a response element in the GetAccountAuthorizationDetails // action. type UserDetail struct { + _ struct{} `type:"structure"` + // The Amazon Resource Name (ARN). ARNs are unique identifiers for AWS resources. // // For more information about ARNs, go to Amazon Resource Names (ARNs) and @@ -11947,12 +10923,6 @@ type UserDetail struct { // A list of the inline policies embedded in the user. UserPolicyList []*PolicyDetail `type:"list"` - - metadataUserDetail `json:"-" xml:"-"` -} - -type metadataUserDetail struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -11967,6 +10937,8 @@ func (s UserDetail) GoString() string { // Contains information about a virtual MFA device. type VirtualMFADevice struct { + _ struct{} `type:"structure"` + // The Base32 seed defined as specified in RFC3548 (http://www.ietf.org/rfc/rfc3548.txt). // The Base32StringSeed is Base64-encoded. Base32StringSeed []byte `type:"blob"` @@ -11993,12 +10965,6 @@ type VirtualMFADevice struct { // // ListUsers User *User `type:"structure"` - - metadataVirtualMFADevice `json:"-" xml:"-"` -} - -type metadataVirtualMFADevice struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/service/s3/api.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/service/s3/api.go index 7e13c5399..1d6312207 100644 --- a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/service/s3/api.go +++ b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/service/s3/api.go @@ -145,11 +145,11 @@ func (c *S3) CreateMultipartUploadRequest(input *CreateMultipartUploadInput) (re // Initiates a multipart upload and returns an upload ID. // -// Note: After you initiate multipart upload and upload one or more parts, -// you must either complete or abort multipart upload in order to stop getting -// charged for storage of the uploaded parts. Only after you either complete -// or abort multipart upload, Amazon S3 frees up the parts storage and stops -// charging you for the parts storage. +// Note: After you initiate multipart upload and upload one or more parts, you +// must either complete or abort multipart upload in order to stop getting charged +// for storage of the uploaded parts. Only after you either complete or abort +// multipart upload, Amazon S3 frees up the parts storage and stops charging +// you for the parts storage. func (c *S3) CreateMultipartUpload(input *CreateMultipartUploadInput) (*CreateMultipartUploadOutput, error) { req, out := c.CreateMultipartUploadRequest(input) err := req.Send() @@ -1576,11 +1576,11 @@ func (c *S3) UploadPartRequest(input *UploadPartInput) (req *request.Request, ou // Uploads a part in a multipart upload. // -// Note: After you initiate multipart upload and upload one or more parts, -// you must either complete or abort multipart upload in order to stop getting -// charged for storage of the uploaded parts. Only after you either complete -// or abort multipart upload, Amazon S3 frees up the parts storage and stops -// charging you for the parts storage. +// Note: After you initiate multipart upload and upload one or more parts, you +// must either complete or abort multipart upload in order to stop getting charged +// for storage of the uploaded parts. Only after you either complete or abort +// multipart upload, Amazon S3 frees up the parts storage and stops charging +// you for the parts storage. func (c *S3) UploadPart(input *UploadPartInput) (*UploadPartOutput, error) { req, out := c.UploadPartRequest(input) err := req.Send() @@ -1615,6 +1615,8 @@ func (c *S3) UploadPartCopy(input *UploadPartCopyInput) (*UploadPartCopyOutput, } type AbortMultipartUploadInput struct { + _ struct{} `type:"structure"` + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` Key *string `location:"uri" locationName:"Key" min:"1" type:"string" required:"true"` @@ -1626,12 +1628,6 @@ type AbortMultipartUploadInput struct { RequestPayer *string `location:"header" locationName:"x-amz-request-payer" type:"string" enum:"RequestPayer"` UploadId *string `location:"querystring" locationName:"uploadId" type:"string" required:"true"` - - metadataAbortMultipartUploadInput `json:"-" xml:"-"` -} - -type metadataAbortMultipartUploadInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -1645,15 +1641,11 @@ func (s AbortMultipartUploadInput) GoString() string { } type AbortMultipartUploadOutput struct { + _ struct{} `type:"structure"` + // If present, indicates that the requester was successfully charged for the // request. RequestCharged *string `location:"header" locationName:"x-amz-request-charged" type:"string" enum:"RequestCharged"` - - metadataAbortMultipartUploadOutput `json:"-" xml:"-"` -} - -type metadataAbortMultipartUploadOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -1667,16 +1659,12 @@ func (s AbortMultipartUploadOutput) GoString() string { } type AccessControlPolicy struct { + _ struct{} `type:"structure"` + // A list of grants. Grants []*Grant `locationName:"AccessControlList" locationNameList:"Grant" type:"list"` Owner *Owner `type:"structure"` - - metadataAccessControlPolicy `json:"-" xml:"-"` -} - -type metadataAccessControlPolicy struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -1690,17 +1678,13 @@ func (s AccessControlPolicy) GoString() string { } type Bucket struct { + _ struct{} `type:"structure"` + // Date the bucket was created. CreationDate *time.Time `type:"timestamp" timestampFormat:"iso8601"` // The name of the bucket. Name *string `type:"string"` - - metadataBucket `json:"-" xml:"-"` -} - -type metadataBucket struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -1714,13 +1698,9 @@ func (s Bucket) GoString() string { } type BucketLifecycleConfiguration struct { + _ struct{} `type:"structure"` + Rules []*LifecycleRule `locationName:"Rule" type:"list" flattened:"true" required:"true"` - - metadataBucketLifecycleConfiguration `json:"-" xml:"-"` -} - -type metadataBucketLifecycleConfiguration struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -1734,13 +1714,9 @@ func (s BucketLifecycleConfiguration) GoString() string { } type BucketLoggingStatus struct { + _ struct{} `type:"structure"` + LoggingEnabled *LoggingEnabled `type:"structure"` - - metadataBucketLoggingStatus `json:"-" xml:"-"` -} - -type metadataBucketLoggingStatus struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -1754,13 +1730,9 @@ func (s BucketLoggingStatus) GoString() string { } type CORSConfiguration struct { + _ struct{} `type:"structure"` + CORSRules []*CORSRule `locationName:"CORSRule" type:"list" flattened:"true" required:"true"` - - metadataCORSConfiguration `json:"-" xml:"-"` -} - -type metadataCORSConfiguration struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -1774,6 +1746,8 @@ func (s CORSConfiguration) GoString() string { } type CORSRule struct { + _ struct{} `type:"structure"` + // Specifies which headers are allowed in a pre-flight OPTIONS request. AllowedHeaders []*string `locationName:"AllowedHeader" type:"list" flattened:"true"` @@ -1792,12 +1766,6 @@ type CORSRule struct { // The time in seconds that your browser is to cache the preflight response // for the specified resource. MaxAgeSeconds *int64 `type:"integer"` - - metadataCORSRule `json:"-" xml:"-"` -} - -type metadataCORSRule struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -1811,6 +1779,8 @@ func (s CORSRule) GoString() string { } type CloudFunctionConfiguration struct { + _ struct{} `type:"structure"` + CloudFunction *string `type:"string"` // Bucket event for which to send notifications. @@ -1823,12 +1793,6 @@ type CloudFunctionConfiguration struct { Id *string `type:"string"` InvocationRole *string `type:"string"` - - metadataCloudFunctionConfiguration `json:"-" xml:"-"` -} - -type metadataCloudFunctionConfiguration struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -1842,13 +1806,9 @@ func (s CloudFunctionConfiguration) GoString() string { } type CommonPrefix struct { + _ struct{} `type:"structure"` + Prefix *string `type:"string"` - - metadataCommonPrefix `json:"-" xml:"-"` -} - -type metadataCommonPrefix struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -1862,6 +1822,8 @@ func (s CommonPrefix) GoString() string { } type CompleteMultipartUploadInput struct { + _ struct{} `type:"structure" payload:"MultipartUpload"` + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` Key *string `location:"uri" locationName:"Key" min:"1" type:"string" required:"true"` @@ -1875,12 +1837,6 @@ type CompleteMultipartUploadInput struct { RequestPayer *string `location:"header" locationName:"x-amz-request-payer" type:"string" enum:"RequestPayer"` UploadId *string `location:"querystring" locationName:"uploadId" type:"string" required:"true"` - - metadataCompleteMultipartUploadInput `json:"-" xml:"-"` -} - -type metadataCompleteMultipartUploadInput struct { - SDKShapeTraits bool `type:"structure" payload:"MultipartUpload"` } // String returns the string representation @@ -1894,6 +1850,8 @@ func (s CompleteMultipartUploadInput) GoString() string { } type CompleteMultipartUploadOutput struct { + _ struct{} `type:"structure"` + Bucket *string `type:"string"` // Entity tag of the object. @@ -1921,12 +1879,6 @@ type CompleteMultipartUploadOutput struct { // Version of the object. VersionId *string `location:"header" locationName:"x-amz-version-id" type:"string"` - - metadataCompleteMultipartUploadOutput `json:"-" xml:"-"` -} - -type metadataCompleteMultipartUploadOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -1940,13 +1892,9 @@ func (s CompleteMultipartUploadOutput) GoString() string { } type CompletedMultipartUpload struct { + _ struct{} `type:"structure"` + Parts []*CompletedPart `locationName:"Part" type:"list" flattened:"true"` - - metadataCompletedMultipartUpload `json:"-" xml:"-"` -} - -type metadataCompletedMultipartUpload struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -1960,18 +1908,14 @@ func (s CompletedMultipartUpload) GoString() string { } type CompletedPart struct { + _ struct{} `type:"structure"` + // Entity tag returned when the part was uploaded. ETag *string `type:"string"` // Part number that identifies the part. This is a positive integer between // 1 and 10,000. PartNumber *int64 `type:"integer"` - - metadataCompletedPart `json:"-" xml:"-"` -} - -type metadataCompletedPart struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -1985,6 +1929,8 @@ func (s CompletedPart) GoString() string { } type Condition struct { + _ struct{} `type:"structure"` + // The HTTP error code when the redirect is applied. In the event of an error, // if the error code equals this value, then the specified redirect is applied. // Required when parent element Condition is specified and sibling KeyPrefixEquals @@ -2000,12 +1946,6 @@ type Condition struct { // is not specified. If both conditions are specified, both must be true for // the redirect to be applied. KeyPrefixEquals *string `type:"string"` - - metadataCondition `json:"-" xml:"-"` -} - -type metadataCondition struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -2019,6 +1959,8 @@ func (s Condition) GoString() string { } type CopyObjectInput struct { + _ struct{} `type:"structure"` + // The canned ACL to apply to the object. ACL *string `location:"header" locationName:"x-amz-acl" type:"string" enum:"ObjectCannedACL"` @@ -2133,12 +2075,6 @@ type CopyObjectInput struct { // to another object in the same bucket or to an external URL. Amazon S3 stores // the value of this header in the object metadata. WebsiteRedirectLocation *string `location:"header" locationName:"x-amz-website-redirect-location" type:"string"` - - metadataCopyObjectInput `json:"-" xml:"-"` -} - -type metadataCopyObjectInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -2152,6 +2088,8 @@ func (s CopyObjectInput) GoString() string { } type CopyObjectOutput struct { + _ struct{} `type:"structure" payload:"CopyObjectResult"` + CopyObjectResult *CopyObjectResult `type:"structure"` CopySourceVersionId *string `location:"header" locationName:"x-amz-copy-source-version-id" type:"string"` @@ -2183,12 +2121,6 @@ type CopyObjectOutput struct { // Version ID of the newly created copy. VersionId *string `location:"header" locationName:"x-amz-version-id" type:"string"` - - metadataCopyObjectOutput `json:"-" xml:"-"` -} - -type metadataCopyObjectOutput struct { - SDKShapeTraits bool `type:"structure" payload:"CopyObjectResult"` } // String returns the string representation @@ -2202,15 +2134,11 @@ func (s CopyObjectOutput) GoString() string { } type CopyObjectResult struct { + _ struct{} `type:"structure"` + ETag *string `type:"string"` LastModified *time.Time `type:"timestamp" timestampFormat:"iso8601"` - - metadataCopyObjectResult `json:"-" xml:"-"` -} - -type metadataCopyObjectResult struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -2224,17 +2152,13 @@ func (s CopyObjectResult) GoString() string { } type CopyPartResult struct { + _ struct{} `type:"structure"` + // Entity tag of the object. ETag *string `type:"string"` // Date and time at which the object was uploaded. LastModified *time.Time `type:"timestamp" timestampFormat:"iso8601"` - - metadataCopyPartResult `json:"-" xml:"-"` -} - -type metadataCopyPartResult struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -2248,15 +2172,11 @@ func (s CopyPartResult) GoString() string { } type CreateBucketConfiguration struct { + _ struct{} `type:"structure"` + // Specifies the region where the bucket will be created. If you don't specify // a region, the bucket will be created in US Standard. LocationConstraint *string `type:"string" enum:"BucketLocationConstraint"` - - metadataCreateBucketConfiguration `json:"-" xml:"-"` -} - -type metadataCreateBucketConfiguration struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -2270,6 +2190,8 @@ func (s CreateBucketConfiguration) GoString() string { } type CreateBucketInput struct { + _ struct{} `type:"structure" payload:"CreateBucketConfiguration"` + // The canned ACL to apply to the bucket. ACL *string `location:"header" locationName:"x-amz-acl" type:"string" enum:"BucketCannedACL"` @@ -2292,12 +2214,6 @@ type CreateBucketInput struct { // Allows grantee to write the ACL for the applicable bucket. GrantWriteACP *string `location:"header" locationName:"x-amz-grant-write-acp" type:"string"` - - metadataCreateBucketInput `json:"-" xml:"-"` -} - -type metadataCreateBucketInput struct { - SDKShapeTraits bool `type:"structure" payload:"CreateBucketConfiguration"` } // String returns the string representation @@ -2311,13 +2227,9 @@ func (s CreateBucketInput) GoString() string { } type CreateBucketOutput struct { + _ struct{} `type:"structure"` + Location *string `location:"header" locationName:"Location" type:"string"` - - metadataCreateBucketOutput `json:"-" xml:"-"` -} - -type metadataCreateBucketOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -2331,6 +2243,8 @@ func (s CreateBucketOutput) GoString() string { } type CreateMultipartUploadInput struct { + _ struct{} `type:"structure"` + // The canned ACL to apply to the object. ACL *string `location:"header" locationName:"x-amz-acl" type:"string" enum:"ObjectCannedACL"` @@ -2411,12 +2325,6 @@ type CreateMultipartUploadInput struct { // to another object in the same bucket or to an external URL. Amazon S3 stores // the value of this header in the object metadata. WebsiteRedirectLocation *string `location:"header" locationName:"x-amz-website-redirect-location" type:"string"` - - metadataCreateMultipartUploadInput `json:"-" xml:"-"` -} - -type metadataCreateMultipartUploadInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -2430,6 +2338,8 @@ func (s CreateMultipartUploadInput) GoString() string { } type CreateMultipartUploadOutput struct { + _ struct{} `type:"structure"` + // Name of the bucket to which the multipart upload was initiated. Bucket *string `locationName:"Bucket" type:"string"` @@ -2460,12 +2370,6 @@ type CreateMultipartUploadOutput struct { // ID for the initiated multipart upload. UploadId *string `type:"string"` - - metadataCreateMultipartUploadOutput `json:"-" xml:"-"` -} - -type metadataCreateMultipartUploadOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -2479,17 +2383,13 @@ func (s CreateMultipartUploadOutput) GoString() string { } type Delete struct { + _ struct{} `type:"structure"` + Objects []*ObjectIdentifier `locationName:"Object" type:"list" flattened:"true" required:"true"` // Element to enable quiet mode for the request. When you add this element, // you must set its value to true. Quiet *bool `type:"boolean"` - - metadataDelete `json:"-" xml:"-"` -} - -type metadataDelete struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -2503,13 +2403,9 @@ func (s Delete) GoString() string { } type DeleteBucketCorsInput struct { + _ struct{} `type:"structure"` + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` - - metadataDeleteBucketCorsInput `json:"-" xml:"-"` -} - -type metadataDeleteBucketCorsInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -2523,11 +2419,7 @@ func (s DeleteBucketCorsInput) GoString() string { } type DeleteBucketCorsOutput struct { - metadataDeleteBucketCorsOutput `json:"-" xml:"-"` -} - -type metadataDeleteBucketCorsOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -2541,13 +2433,9 @@ func (s DeleteBucketCorsOutput) GoString() string { } type DeleteBucketInput struct { + _ struct{} `type:"structure"` + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` - - metadataDeleteBucketInput `json:"-" xml:"-"` -} - -type metadataDeleteBucketInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -2561,13 +2449,9 @@ func (s DeleteBucketInput) GoString() string { } type DeleteBucketLifecycleInput struct { + _ struct{} `type:"structure"` + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` - - metadataDeleteBucketLifecycleInput `json:"-" xml:"-"` -} - -type metadataDeleteBucketLifecycleInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -2581,11 +2465,7 @@ func (s DeleteBucketLifecycleInput) GoString() string { } type DeleteBucketLifecycleOutput struct { - metadataDeleteBucketLifecycleOutput `json:"-" xml:"-"` -} - -type metadataDeleteBucketLifecycleOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -2599,11 +2479,7 @@ func (s DeleteBucketLifecycleOutput) GoString() string { } type DeleteBucketOutput struct { - metadataDeleteBucketOutput `json:"-" xml:"-"` -} - -type metadataDeleteBucketOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -2617,13 +2493,9 @@ func (s DeleteBucketOutput) GoString() string { } type DeleteBucketPolicyInput struct { + _ struct{} `type:"structure"` + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` - - metadataDeleteBucketPolicyInput `json:"-" xml:"-"` -} - -type metadataDeleteBucketPolicyInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -2637,11 +2509,7 @@ func (s DeleteBucketPolicyInput) GoString() string { } type DeleteBucketPolicyOutput struct { - metadataDeleteBucketPolicyOutput `json:"-" xml:"-"` -} - -type metadataDeleteBucketPolicyOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -2655,13 +2523,9 @@ func (s DeleteBucketPolicyOutput) GoString() string { } type DeleteBucketReplicationInput struct { + _ struct{} `type:"structure"` + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` - - metadataDeleteBucketReplicationInput `json:"-" xml:"-"` -} - -type metadataDeleteBucketReplicationInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -2675,11 +2539,7 @@ func (s DeleteBucketReplicationInput) GoString() string { } type DeleteBucketReplicationOutput struct { - metadataDeleteBucketReplicationOutput `json:"-" xml:"-"` -} - -type metadataDeleteBucketReplicationOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -2693,13 +2553,9 @@ func (s DeleteBucketReplicationOutput) GoString() string { } type DeleteBucketTaggingInput struct { + _ struct{} `type:"structure"` + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` - - metadataDeleteBucketTaggingInput `json:"-" xml:"-"` -} - -type metadataDeleteBucketTaggingInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -2713,11 +2569,7 @@ func (s DeleteBucketTaggingInput) GoString() string { } type DeleteBucketTaggingOutput struct { - metadataDeleteBucketTaggingOutput `json:"-" xml:"-"` -} - -type metadataDeleteBucketTaggingOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -2731,13 +2583,9 @@ func (s DeleteBucketTaggingOutput) GoString() string { } type DeleteBucketWebsiteInput struct { + _ struct{} `type:"structure"` + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` - - metadataDeleteBucketWebsiteInput `json:"-" xml:"-"` -} - -type metadataDeleteBucketWebsiteInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -2751,11 +2599,7 @@ func (s DeleteBucketWebsiteInput) GoString() string { } type DeleteBucketWebsiteOutput struct { - metadataDeleteBucketWebsiteOutput `json:"-" xml:"-"` -} - -type metadataDeleteBucketWebsiteOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -2769,6 +2613,8 @@ func (s DeleteBucketWebsiteOutput) GoString() string { } type DeleteMarkerEntry struct { + _ struct{} `type:"structure"` + // Specifies whether the object is (true) or is not (false) the latest version // of an object. IsLatest *bool `type:"boolean"` @@ -2783,12 +2629,6 @@ type DeleteMarkerEntry struct { // Version ID of an object. VersionId *string `type:"string"` - - metadataDeleteMarkerEntry `json:"-" xml:"-"` -} - -type metadataDeleteMarkerEntry struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -2802,6 +2642,8 @@ func (s DeleteMarkerEntry) GoString() string { } type DeleteObjectInput struct { + _ struct{} `type:"structure"` + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` Key *string `location:"uri" locationName:"Key" min:"1" type:"string" required:"true"` @@ -2818,12 +2660,6 @@ type DeleteObjectInput struct { // VersionId used to reference a specific version of the object. VersionId *string `location:"querystring" locationName:"versionId" type:"string"` - - metadataDeleteObjectInput `json:"-" xml:"-"` -} - -type metadataDeleteObjectInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -2837,6 +2673,8 @@ func (s DeleteObjectInput) GoString() string { } type DeleteObjectOutput struct { + _ struct{} `type:"structure"` + // Specifies whether the versioned object that was permanently deleted was (true) // or was not (false) a delete marker. DeleteMarker *bool `location:"header" locationName:"x-amz-delete-marker" type:"boolean"` @@ -2848,12 +2686,6 @@ type DeleteObjectOutput struct { // Returns the version ID of the delete marker created as a result of the DELETE // operation. VersionId *string `location:"header" locationName:"x-amz-version-id" type:"string"` - - metadataDeleteObjectOutput `json:"-" xml:"-"` -} - -type metadataDeleteObjectOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -2867,6 +2699,8 @@ func (s DeleteObjectOutput) GoString() string { } type DeleteObjectsInput struct { + _ struct{} `type:"structure" payload:"Delete"` + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` Delete *Delete `locationName:"Delete" type:"structure" required:"true"` @@ -2880,12 +2714,6 @@ type DeleteObjectsInput struct { // Documentation on downloading objects from requester pays buckets can be found // at http://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html RequestPayer *string `location:"header" locationName:"x-amz-request-payer" type:"string" enum:"RequestPayer"` - - metadataDeleteObjectsInput `json:"-" xml:"-"` -} - -type metadataDeleteObjectsInput struct { - SDKShapeTraits bool `type:"structure" payload:"Delete"` } // String returns the string representation @@ -2899,6 +2727,8 @@ func (s DeleteObjectsInput) GoString() string { } type DeleteObjectsOutput struct { + _ struct{} `type:"structure"` + Deleted []*DeletedObject `type:"list" flattened:"true"` Errors []*Error `locationName:"Error" type:"list" flattened:"true"` @@ -2906,12 +2736,6 @@ type DeleteObjectsOutput struct { // If present, indicates that the requester was successfully charged for the // request. RequestCharged *string `location:"header" locationName:"x-amz-request-charged" type:"string" enum:"RequestCharged"` - - metadataDeleteObjectsOutput `json:"-" xml:"-"` -} - -type metadataDeleteObjectsOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -2925,6 +2749,8 @@ func (s DeleteObjectsOutput) GoString() string { } type DeletedObject struct { + _ struct{} `type:"structure"` + DeleteMarker *bool `type:"boolean"` DeleteMarkerVersionId *string `type:"string"` @@ -2932,12 +2758,6 @@ type DeletedObject struct { Key *string `min:"1" type:"string"` VersionId *string `type:"string"` - - metadataDeletedObject `json:"-" xml:"-"` -} - -type metadataDeletedObject struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -2951,18 +2771,14 @@ func (s DeletedObject) GoString() string { } type Destination struct { + _ struct{} `type:"structure"` + // Amazon resource name (ARN) of the bucket where you want Amazon S3 to store // replicas of the object identified by the rule. Bucket *string `type:"string" required:"true"` // The class of storage used to store the object. StorageClass *string `type:"string" enum:"StorageClass"` - - metadataDestination `json:"-" xml:"-"` -} - -type metadataDestination struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -2976,6 +2792,8 @@ func (s Destination) GoString() string { } type Error struct { + _ struct{} `type:"structure"` + Code *string `type:"string"` Key *string `min:"1" type:"string"` @@ -2983,12 +2801,6 @@ type Error struct { Message *string `type:"string"` VersionId *string `type:"string"` - - metadataError `json:"-" xml:"-"` -} - -type metadataError struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -3002,14 +2814,10 @@ func (s Error) GoString() string { } type ErrorDocument struct { + _ struct{} `type:"structure"` + // The object key name to use when a 4XX class error occurs. Key *string `min:"1" type:"string" required:"true"` - - metadataErrorDocument `json:"-" xml:"-"` -} - -type metadataErrorDocument struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -3024,6 +2832,8 @@ func (s ErrorDocument) GoString() string { // Container for key value pair that defines the criteria for the filter rule. type FilterRule struct { + _ struct{} `type:"structure"` + // Object key name prefix or suffix identifying one or more objects to which // the filtering rule applies. Maximum prefix length can be up to 1,024 characters. // Overlapping prefixes and suffixes are not supported. For more information, @@ -3032,12 +2842,6 @@ type FilterRule struct { Name *string `type:"string" enum:"FilterRuleName"` Value *string `type:"string"` - - metadataFilterRule `json:"-" xml:"-"` -} - -type metadataFilterRule struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -3051,13 +2855,9 @@ func (s FilterRule) GoString() string { } type GetBucketAclInput struct { + _ struct{} `type:"structure"` + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` - - metadataGetBucketAclInput `json:"-" xml:"-"` -} - -type metadataGetBucketAclInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -3071,16 +2871,12 @@ func (s GetBucketAclInput) GoString() string { } type GetBucketAclOutput struct { + _ struct{} `type:"structure"` + // A list of grants. Grants []*Grant `locationName:"AccessControlList" locationNameList:"Grant" type:"list"` Owner *Owner `type:"structure"` - - metadataGetBucketAclOutput `json:"-" xml:"-"` -} - -type metadataGetBucketAclOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -3094,13 +2890,9 @@ func (s GetBucketAclOutput) GoString() string { } type GetBucketCorsInput struct { + _ struct{} `type:"structure"` + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` - - metadataGetBucketCorsInput `json:"-" xml:"-"` -} - -type metadataGetBucketCorsInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -3114,13 +2906,9 @@ func (s GetBucketCorsInput) GoString() string { } type GetBucketCorsOutput struct { + _ struct{} `type:"structure"` + CORSRules []*CORSRule `locationName:"CORSRule" type:"list" flattened:"true"` - - metadataGetBucketCorsOutput `json:"-" xml:"-"` -} - -type metadataGetBucketCorsOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -3134,13 +2922,9 @@ func (s GetBucketCorsOutput) GoString() string { } type GetBucketLifecycleConfigurationInput struct { + _ struct{} `type:"structure"` + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` - - metadataGetBucketLifecycleConfigurationInput `json:"-" xml:"-"` -} - -type metadataGetBucketLifecycleConfigurationInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -3154,13 +2938,9 @@ func (s GetBucketLifecycleConfigurationInput) GoString() string { } type GetBucketLifecycleConfigurationOutput struct { + _ struct{} `type:"structure"` + Rules []*LifecycleRule `locationName:"Rule" type:"list" flattened:"true"` - - metadataGetBucketLifecycleConfigurationOutput `json:"-" xml:"-"` -} - -type metadataGetBucketLifecycleConfigurationOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -3174,13 +2954,9 @@ func (s GetBucketLifecycleConfigurationOutput) GoString() string { } type GetBucketLifecycleInput struct { + _ struct{} `type:"structure"` + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` - - metadataGetBucketLifecycleInput `json:"-" xml:"-"` -} - -type metadataGetBucketLifecycleInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -3194,13 +2970,9 @@ func (s GetBucketLifecycleInput) GoString() string { } type GetBucketLifecycleOutput struct { + _ struct{} `type:"structure"` + Rules []*Rule `locationName:"Rule" type:"list" flattened:"true"` - - metadataGetBucketLifecycleOutput `json:"-" xml:"-"` -} - -type metadataGetBucketLifecycleOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -3214,13 +2986,9 @@ func (s GetBucketLifecycleOutput) GoString() string { } type GetBucketLocationInput struct { + _ struct{} `type:"structure"` + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` - - metadataGetBucketLocationInput `json:"-" xml:"-"` -} - -type metadataGetBucketLocationInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -3234,13 +3002,9 @@ func (s GetBucketLocationInput) GoString() string { } type GetBucketLocationOutput struct { + _ struct{} `type:"structure"` + LocationConstraint *string `type:"string" enum:"BucketLocationConstraint"` - - metadataGetBucketLocationOutput `json:"-" xml:"-"` -} - -type metadataGetBucketLocationOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -3254,13 +3018,9 @@ func (s GetBucketLocationOutput) GoString() string { } type GetBucketLoggingInput struct { + _ struct{} `type:"structure"` + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` - - metadataGetBucketLoggingInput `json:"-" xml:"-"` -} - -type metadataGetBucketLoggingInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -3274,13 +3034,9 @@ func (s GetBucketLoggingInput) GoString() string { } type GetBucketLoggingOutput struct { + _ struct{} `type:"structure"` + LoggingEnabled *LoggingEnabled `type:"structure"` - - metadataGetBucketLoggingOutput `json:"-" xml:"-"` -} - -type metadataGetBucketLoggingOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -3294,14 +3050,10 @@ func (s GetBucketLoggingOutput) GoString() string { } type GetBucketNotificationConfigurationRequest struct { + _ struct{} `type:"structure"` + // Name of the buket to get the notification configuration for. Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` - - metadataGetBucketNotificationConfigurationRequest `json:"-" xml:"-"` -} - -type metadataGetBucketNotificationConfigurationRequest struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -3315,13 +3067,9 @@ func (s GetBucketNotificationConfigurationRequest) GoString() string { } type GetBucketPolicyInput struct { + _ struct{} `type:"structure"` + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` - - metadataGetBucketPolicyInput `json:"-" xml:"-"` -} - -type metadataGetBucketPolicyInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -3335,14 +3083,10 @@ func (s GetBucketPolicyInput) GoString() string { } type GetBucketPolicyOutput struct { + _ struct{} `type:"structure" payload:"Policy"` + // The bucket policy as a JSON document. Policy *string `type:"string"` - - metadataGetBucketPolicyOutput `json:"-" xml:"-"` -} - -type metadataGetBucketPolicyOutput struct { - SDKShapeTraits bool `type:"structure" payload:"Policy"` } // String returns the string representation @@ -3356,13 +3100,9 @@ func (s GetBucketPolicyOutput) GoString() string { } type GetBucketReplicationInput struct { + _ struct{} `type:"structure"` + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` - - metadataGetBucketReplicationInput `json:"-" xml:"-"` -} - -type metadataGetBucketReplicationInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -3376,15 +3116,11 @@ func (s GetBucketReplicationInput) GoString() string { } type GetBucketReplicationOutput struct { + _ struct{} `type:"structure" payload:"ReplicationConfiguration"` + // Container for replication rules. You can add as many as 1,000 rules. Total // replication configuration size can be up to 2 MB. ReplicationConfiguration *ReplicationConfiguration `type:"structure"` - - metadataGetBucketReplicationOutput `json:"-" xml:"-"` -} - -type metadataGetBucketReplicationOutput struct { - SDKShapeTraits bool `type:"structure" payload:"ReplicationConfiguration"` } // String returns the string representation @@ -3398,13 +3134,9 @@ func (s GetBucketReplicationOutput) GoString() string { } type GetBucketRequestPaymentInput struct { + _ struct{} `type:"structure"` + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` - - metadataGetBucketRequestPaymentInput `json:"-" xml:"-"` -} - -type metadataGetBucketRequestPaymentInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -3418,14 +3150,10 @@ func (s GetBucketRequestPaymentInput) GoString() string { } type GetBucketRequestPaymentOutput struct { + _ struct{} `type:"structure"` + // Specifies who pays for the download and request fees. Payer *string `type:"string" enum:"Payer"` - - metadataGetBucketRequestPaymentOutput `json:"-" xml:"-"` -} - -type metadataGetBucketRequestPaymentOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -3439,13 +3167,9 @@ func (s GetBucketRequestPaymentOutput) GoString() string { } type GetBucketTaggingInput struct { + _ struct{} `type:"structure"` + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` - - metadataGetBucketTaggingInput `json:"-" xml:"-"` -} - -type metadataGetBucketTaggingInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -3459,13 +3183,9 @@ func (s GetBucketTaggingInput) GoString() string { } type GetBucketTaggingOutput struct { + _ struct{} `type:"structure"` + TagSet []*Tag `locationNameList:"Tag" type:"list" required:"true"` - - metadataGetBucketTaggingOutput `json:"-" xml:"-"` -} - -type metadataGetBucketTaggingOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -3479,13 +3199,9 @@ func (s GetBucketTaggingOutput) GoString() string { } type GetBucketVersioningInput struct { + _ struct{} `type:"structure"` + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` - - metadataGetBucketVersioningInput `json:"-" xml:"-"` -} - -type metadataGetBucketVersioningInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -3499,6 +3215,8 @@ func (s GetBucketVersioningInput) GoString() string { } type GetBucketVersioningOutput struct { + _ struct{} `type:"structure"` + // Specifies whether MFA delete is enabled in the bucket versioning configuration. // This element is only returned if the bucket has been configured with MFA // delete. If the bucket has never been so configured, this element is not returned. @@ -3506,12 +3224,6 @@ type GetBucketVersioningOutput struct { // The versioning state of the bucket. Status *string `type:"string" enum:"BucketVersioningStatus"` - - metadataGetBucketVersioningOutput `json:"-" xml:"-"` -} - -type metadataGetBucketVersioningOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -3525,13 +3237,9 @@ func (s GetBucketVersioningOutput) GoString() string { } type GetBucketWebsiteInput struct { + _ struct{} `type:"structure"` + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` - - metadataGetBucketWebsiteInput `json:"-" xml:"-"` -} - -type metadataGetBucketWebsiteInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -3545,6 +3253,8 @@ func (s GetBucketWebsiteInput) GoString() string { } type GetBucketWebsiteOutput struct { + _ struct{} `type:"structure"` + ErrorDocument *ErrorDocument `type:"structure"` IndexDocument *IndexDocument `type:"structure"` @@ -3552,12 +3262,6 @@ type GetBucketWebsiteOutput struct { RedirectAllRequestsTo *RedirectAllRequestsTo `type:"structure"` RoutingRules []*RoutingRule `locationNameList:"RoutingRule" type:"list"` - - metadataGetBucketWebsiteOutput `json:"-" xml:"-"` -} - -type metadataGetBucketWebsiteOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -3571,6 +3275,8 @@ func (s GetBucketWebsiteOutput) GoString() string { } type GetObjectAclInput struct { + _ struct{} `type:"structure"` + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` Key *string `location:"uri" locationName:"Key" min:"1" type:"string" required:"true"` @@ -3583,12 +3289,6 @@ type GetObjectAclInput struct { // VersionId used to reference a specific version of the object. VersionId *string `location:"querystring" locationName:"versionId" type:"string"` - - metadataGetObjectAclInput `json:"-" xml:"-"` -} - -type metadataGetObjectAclInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -3602,6 +3302,8 @@ func (s GetObjectAclInput) GoString() string { } type GetObjectAclOutput struct { + _ struct{} `type:"structure"` + // A list of grants. Grants []*Grant `locationName:"AccessControlList" locationNameList:"Grant" type:"list"` @@ -3610,12 +3312,6 @@ type GetObjectAclOutput struct { // If present, indicates that the requester was successfully charged for the // request. RequestCharged *string `location:"header" locationName:"x-amz-request-charged" type:"string" enum:"RequestCharged"` - - metadataGetObjectAclOutput `json:"-" xml:"-"` -} - -type metadataGetObjectAclOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -3629,6 +3325,8 @@ func (s GetObjectAclOutput) GoString() string { } type GetObjectInput struct { + _ struct{} `type:"structure"` + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` // Return the object only if its entity tag (ETag) is the same as the one specified, @@ -3694,12 +3392,6 @@ type GetObjectInput struct { // VersionId used to reference a specific version of the object. VersionId *string `location:"querystring" locationName:"versionId" type:"string"` - - metadataGetObjectInput `json:"-" xml:"-"` -} - -type metadataGetObjectInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -3713,6 +3405,8 @@ func (s GetObjectInput) GoString() string { } type GetObjectOutput struct { + _ struct{} `type:"structure" payload:"Body"` + AcceptRanges *string `location:"header" locationName:"accept-ranges" type:"string"` // Object data. @@ -3807,12 +3501,6 @@ type GetObjectOutput struct { // to another object in the same bucket or to an external URL. Amazon S3 stores // the value of this header in the object metadata. WebsiteRedirectLocation *string `location:"header" locationName:"x-amz-website-redirect-location" type:"string"` - - metadataGetObjectOutput `json:"-" xml:"-"` -} - -type metadataGetObjectOutput struct { - SDKShapeTraits bool `type:"structure" payload:"Body"` } // String returns the string representation @@ -3826,6 +3514,8 @@ func (s GetObjectOutput) GoString() string { } type GetObjectTorrentInput struct { + _ struct{} `type:"structure"` + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` Key *string `location:"uri" locationName:"Key" min:"1" type:"string" required:"true"` @@ -3835,12 +3525,6 @@ type GetObjectTorrentInput struct { // Documentation on downloading objects from requester pays buckets can be found // at http://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html RequestPayer *string `location:"header" locationName:"x-amz-request-payer" type:"string" enum:"RequestPayer"` - - metadataGetObjectTorrentInput `json:"-" xml:"-"` -} - -type metadataGetObjectTorrentInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -3854,17 +3538,13 @@ func (s GetObjectTorrentInput) GoString() string { } type GetObjectTorrentOutput struct { + _ struct{} `type:"structure" payload:"Body"` + Body io.ReadCloser `type:"blob"` // If present, indicates that the requester was successfully charged for the // request. RequestCharged *string `location:"header" locationName:"x-amz-request-charged" type:"string" enum:"RequestCharged"` - - metadataGetObjectTorrentOutput `json:"-" xml:"-"` -} - -type metadataGetObjectTorrentOutput struct { - SDKShapeTraits bool `type:"structure" payload:"Body"` } // String returns the string representation @@ -3878,16 +3558,12 @@ func (s GetObjectTorrentOutput) GoString() string { } type Grant struct { + _ struct{} `type:"structure"` + Grantee *Grantee `type:"structure"` // Specifies the permission given to the grantee. Permission *string `type:"string" enum:"Permission"` - - metadataGrant `json:"-" xml:"-"` -} - -type metadataGrant struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -3901,6 +3577,8 @@ func (s Grant) GoString() string { } type Grantee struct { + _ struct{} `type:"structure" xmlPrefix:"xsi" xmlURI:"http://www.w3.org/2001/XMLSchema-instance"` + // Screen name of the grantee. DisplayName *string `type:"string"` @@ -3915,12 +3593,6 @@ type Grantee struct { // URI of the grantee group. URI *string `type:"string"` - - metadataGrantee `json:"-" xml:"-"` -} - -type metadataGrantee struct { - SDKShapeTraits bool `type:"structure" xmlPrefix:"xsi" xmlURI:"http://www.w3.org/2001/XMLSchema-instance"` } // String returns the string representation @@ -3934,13 +3606,9 @@ func (s Grantee) GoString() string { } type HeadBucketInput struct { + _ struct{} `type:"structure"` + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` - - metadataHeadBucketInput `json:"-" xml:"-"` -} - -type metadataHeadBucketInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -3954,11 +3622,7 @@ func (s HeadBucketInput) GoString() string { } type HeadBucketOutput struct { - metadataHeadBucketOutput `json:"-" xml:"-"` -} - -type metadataHeadBucketOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -3972,6 +3636,8 @@ func (s HeadBucketOutput) GoString() string { } type HeadObjectInput struct { + _ struct{} `type:"structure"` + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` // Return the object only if its entity tag (ETag) is the same as the one specified, @@ -4019,12 +3685,6 @@ type HeadObjectInput struct { // VersionId used to reference a specific version of the object. VersionId *string `location:"querystring" locationName:"versionId" type:"string"` - - metadataHeadObjectInput `json:"-" xml:"-"` -} - -type metadataHeadObjectInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -4038,6 +3698,8 @@ func (s HeadObjectInput) GoString() string { } type HeadObjectOutput struct { + _ struct{} `type:"structure"` + AcceptRanges *string `location:"header" locationName:"accept-ranges" type:"string"` // Specifies caching behavior along the request/reply chain. @@ -4126,12 +3788,6 @@ type HeadObjectOutput struct { // to another object in the same bucket or to an external URL. Amazon S3 stores // the value of this header in the object metadata. WebsiteRedirectLocation *string `location:"header" locationName:"x-amz-website-redirect-location" type:"string"` - - metadataHeadObjectOutput `json:"-" xml:"-"` -} - -type metadataHeadObjectOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -4145,17 +3801,13 @@ func (s HeadObjectOutput) GoString() string { } type IndexDocument struct { + _ struct{} `type:"structure"` + // A suffix that is appended to a request that is for a directory on the website // endpoint (e.g. if the suffix is index.html and you make a request to samplebucket/images/ // the data that is returned will be for the object with the key name images/index.html) // The suffix must not be empty and must not include a slash character. Suffix *string `type:"string" required:"true"` - - metadataIndexDocument `json:"-" xml:"-"` -} - -type metadataIndexDocument struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -4169,18 +3821,14 @@ func (s IndexDocument) GoString() string { } type Initiator struct { + _ struct{} `type:"structure"` + // Name of the Principal. DisplayName *string `type:"string"` // If the principal is an AWS account, it provides the Canonical User ID. If // the principal is an IAM User, it provides a user ARN value. ID *string `type:"string"` - - metadataInitiator `json:"-" xml:"-"` -} - -type metadataInitiator struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -4195,15 +3843,11 @@ func (s Initiator) GoString() string { // Container for object key name prefix and suffix filtering rules. type KeyFilter struct { + _ struct{} `type:"structure"` + // A list of containers for key value pair that defines the criteria for the // filter rule. FilterRules []*FilterRule `locationName:"FilterRule" type:"list" flattened:"true"` - - metadataKeyFilter `json:"-" xml:"-"` -} - -type metadataKeyFilter struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -4218,6 +3862,8 @@ func (s KeyFilter) GoString() string { // Container for specifying the AWS Lambda notification configuration. type LambdaFunctionConfiguration struct { + _ struct{} `type:"structure"` + Events []*string `locationName:"Event" type:"list" flattened:"true" required:"true"` // Container for object key name filtering rules. For information about key @@ -4232,12 +3878,6 @@ type LambdaFunctionConfiguration struct { // Lambda cloud function ARN that Amazon S3 can invoke when it detects events // of the specified type. LambdaFunctionArn *string `locationName:"CloudFunction" type:"string" required:"true"` - - metadataLambdaFunctionConfiguration `json:"-" xml:"-"` -} - -type metadataLambdaFunctionConfiguration struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -4251,13 +3891,9 @@ func (s LambdaFunctionConfiguration) GoString() string { } type LifecycleConfiguration struct { + _ struct{} `type:"structure"` + Rules []*Rule `locationName:"Rule" type:"list" flattened:"true" required:"true"` - - metadataLifecycleConfiguration `json:"-" xml:"-"` -} - -type metadataLifecycleConfiguration struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -4271,6 +3907,8 @@ func (s LifecycleConfiguration) GoString() string { } type LifecycleExpiration struct { + _ struct{} `type:"structure"` + // Indicates at what date the object is to be moved or deleted. Should be in // GMT ISO 8601 Format. Date *time.Time `type:"timestamp" timestampFormat:"iso8601"` @@ -4278,12 +3916,6 @@ type LifecycleExpiration struct { // Indicates the lifetime, in days, of the objects that are subject to the rule. // The value must be a non-zero positive integer. Days *int64 `type:"integer"` - - metadataLifecycleExpiration `json:"-" xml:"-"` -} - -type metadataLifecycleExpiration struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -4297,6 +3929,8 @@ func (s LifecycleExpiration) GoString() string { } type LifecycleRule struct { + _ struct{} `type:"structure"` + Expiration *LifecycleExpiration `type:"structure"` // Unique identifier for the rule. The value cannot be longer than 255 characters. @@ -4319,12 +3953,6 @@ type LifecycleRule struct { Status *string `type:"string" required:"true" enum:"ExpirationStatus"` Transitions []*Transition `locationName:"Transition" type:"list" flattened:"true"` - - metadataLifecycleRule `json:"-" xml:"-"` -} - -type metadataLifecycleRule struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -4338,11 +3966,7 @@ func (s LifecycleRule) GoString() string { } type ListBucketsInput struct { - metadataListBucketsInput `json:"-" xml:"-"` -} - -type metadataListBucketsInput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -4356,15 +3980,11 @@ func (s ListBucketsInput) GoString() string { } type ListBucketsOutput struct { + _ struct{} `type:"structure"` + Buckets []*Bucket `locationNameList:"Bucket" type:"list"` Owner *Owner `type:"structure"` - - metadataListBucketsOutput `json:"-" xml:"-"` -} - -type metadataListBucketsOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -4378,6 +3998,8 @@ func (s ListBucketsOutput) GoString() string { } type ListMultipartUploadsInput struct { + _ struct{} `type:"structure"` + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` // Character you use to group keys. @@ -4408,12 +4030,6 @@ type ListMultipartUploadsInput struct { // should begin. If key-marker is not specified, the upload-id-marker parameter // is ignored. UploadIdMarker *string `location:"querystring" locationName:"upload-id-marker" type:"string"` - - metadataListMultipartUploadsInput `json:"-" xml:"-"` -} - -type metadataListMultipartUploadsInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -4427,6 +4043,8 @@ func (s ListMultipartUploadsInput) GoString() string { } type ListMultipartUploadsOutput struct { + _ struct{} `type:"structure"` + // Name of the bucket to which the multipart upload was initiated. Bucket *string `type:"string"` @@ -4466,12 +4084,6 @@ type ListMultipartUploadsOutput struct { UploadIdMarker *string `type:"string"` Uploads []*MultipartUpload `locationName:"Upload" type:"list" flattened:"true"` - - metadataListMultipartUploadsOutput `json:"-" xml:"-"` -} - -type metadataListMultipartUploadsOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -4485,6 +4097,8 @@ func (s ListMultipartUploadsOutput) GoString() string { } type ListObjectVersionsInput struct { + _ struct{} `type:"structure"` + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` // A delimiter is a character you use to group keys. @@ -4510,12 +4124,6 @@ type ListObjectVersionsInput struct { // Specifies the object version you want to start listing from. VersionIdMarker *string `location:"querystring" locationName:"version-id-marker" type:"string"` - - metadataListObjectVersionsInput `json:"-" xml:"-"` -} - -type metadataListObjectVersionsInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -4529,6 +4137,8 @@ func (s ListObjectVersionsInput) GoString() string { } type ListObjectVersionsOutput struct { + _ struct{} `type:"structure"` + CommonPrefixes []*CommonPrefix `type:"list" flattened:"true"` DeleteMarkers []*DeleteMarkerEntry `locationName:"DeleteMarker" type:"list" flattened:"true"` @@ -4563,12 +4173,6 @@ type ListObjectVersionsOutput struct { VersionIdMarker *string `type:"string"` Versions []*ObjectVersion `locationName:"Version" type:"list" flattened:"true"` - - metadataListObjectVersionsOutput `json:"-" xml:"-"` -} - -type metadataListObjectVersionsOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -4582,6 +4186,8 @@ func (s ListObjectVersionsOutput) GoString() string { } type ListObjectsInput struct { + _ struct{} `type:"structure"` + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` // A delimiter is a character you use to group keys. @@ -4604,12 +4210,6 @@ type ListObjectsInput struct { // Limits the response to keys that begin with the specified prefix. Prefix *string `location:"querystring" locationName:"prefix" type:"string"` - - metadataListObjectsInput `json:"-" xml:"-"` -} - -type metadataListObjectsInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -4623,6 +4223,8 @@ func (s ListObjectsInput) GoString() string { } type ListObjectsOutput struct { + _ struct{} `type:"structure"` + CommonPrefixes []*CommonPrefix `type:"list" flattened:"true"` Contents []*Object `type:"list" flattened:"true"` @@ -4652,12 +4254,6 @@ type ListObjectsOutput struct { NextMarker *string `type:"string"` Prefix *string `type:"string"` - - metadataListObjectsOutput `json:"-" xml:"-"` -} - -type metadataListObjectsOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -4671,6 +4267,8 @@ func (s ListObjectsOutput) GoString() string { } type ListPartsInput struct { + _ struct{} `type:"structure"` + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` Key *string `location:"uri" locationName:"Key" min:"1" type:"string" required:"true"` @@ -4690,12 +4288,6 @@ type ListPartsInput struct { // Upload ID identifying the multipart upload whose parts are being listed. UploadId *string `location:"querystring" locationName:"uploadId" type:"string" required:"true"` - - metadataListPartsInput `json:"-" xml:"-"` -} - -type metadataListPartsInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -4709,6 +4301,8 @@ func (s ListPartsInput) GoString() string { } type ListPartsOutput struct { + _ struct{} `type:"structure"` + // Name of the bucket to which the multipart upload was initiated. Bucket *string `type:"string"` @@ -4745,12 +4339,6 @@ type ListPartsOutput struct { // Upload ID identifying the multipart upload whose parts are being listed. UploadId *string `type:"string"` - - metadataListPartsOutput `json:"-" xml:"-"` -} - -type metadataListPartsOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -4764,6 +4352,8 @@ func (s ListPartsOutput) GoString() string { } type LoggingEnabled struct { + _ struct{} `type:"structure"` + // Specifies the bucket where you want Amazon S3 to store server access logs. // You can have your logs delivered to any bucket that you own, including the // same bucket that is being logged. You can also configure multiple buckets @@ -4777,12 +4367,6 @@ type LoggingEnabled struct { // This element lets you specify a prefix for the keys that the log files will // be stored under. TargetPrefix *string `type:"string"` - - metadataLoggingEnabled `json:"-" xml:"-"` -} - -type metadataLoggingEnabled struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -4796,6 +4380,8 @@ func (s LoggingEnabled) GoString() string { } type MultipartUpload struct { + _ struct{} `type:"structure"` + // Date and time at which the multipart upload was initiated. Initiated *time.Time `type:"timestamp" timestampFormat:"iso8601"` @@ -4812,12 +4398,6 @@ type MultipartUpload struct { // Upload ID that identifies the multipart upload. UploadId *string `type:"string"` - - metadataMultipartUpload `json:"-" xml:"-"` -} - -type metadataMultipartUpload struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -4836,18 +4416,14 @@ func (s MultipartUpload) GoString() string { // to request that Amazon S3 delete noncurrent object versions at a specific // period in the object's lifetime. type NoncurrentVersionExpiration struct { + _ struct{} `type:"structure"` + // Specifies the number of days an object is noncurrent before Amazon S3 can // perform the associated action. For information about the noncurrent days // calculations, see How Amazon S3 Calculates When an Object Became Noncurrent // (/AmazonS3/latest/dev/s3-access-control.html) in the Amazon Simple Storage // Service Developer Guide. NoncurrentDays *int64 `type:"integer"` - - metadataNoncurrentVersionExpiration `json:"-" xml:"-"` -} - -type metadataNoncurrentVersionExpiration struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -4866,6 +4442,8 @@ func (s NoncurrentVersionExpiration) GoString() string { // to request that Amazon S3 transition noncurrent object versions to the STANDARD_IA // or GLACIER storage class at a specific period in the object's lifetime. type NoncurrentVersionTransition struct { + _ struct{} `type:"structure"` + // Specifies the number of days an object is noncurrent before Amazon S3 can // perform the associated action. For information about the noncurrent days // calculations, see How Amazon S3 Calculates When an Object Became Noncurrent @@ -4875,12 +4453,6 @@ type NoncurrentVersionTransition struct { // The class of storage used to store the object. StorageClass *string `type:"string" enum:"TransitionStorageClass"` - - metadataNoncurrentVersionTransition `json:"-" xml:"-"` -} - -type metadataNoncurrentVersionTransition struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -4896,17 +4468,13 @@ func (s NoncurrentVersionTransition) GoString() string { // Container for specifying the notification configuration of the bucket. If // this element is empty, notifications are turned off on the bucket. type NotificationConfiguration struct { + _ struct{} `type:"structure"` + LambdaFunctionConfigurations []*LambdaFunctionConfiguration `locationName:"CloudFunctionConfiguration" type:"list" flattened:"true"` QueueConfigurations []*QueueConfiguration `locationName:"QueueConfiguration" type:"list" flattened:"true"` TopicConfigurations []*TopicConfiguration `locationName:"TopicConfiguration" type:"list" flattened:"true"` - - metadataNotificationConfiguration `json:"-" xml:"-"` -} - -type metadataNotificationConfiguration struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -4920,17 +4488,13 @@ func (s NotificationConfiguration) GoString() string { } type NotificationConfigurationDeprecated struct { + _ struct{} `type:"structure"` + CloudFunctionConfiguration *CloudFunctionConfiguration `type:"structure"` QueueConfiguration *QueueConfigurationDeprecated `type:"structure"` TopicConfiguration *TopicConfigurationDeprecated `type:"structure"` - - metadataNotificationConfigurationDeprecated `json:"-" xml:"-"` -} - -type metadataNotificationConfigurationDeprecated struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -4947,14 +4511,10 @@ func (s NotificationConfigurationDeprecated) GoString() string { // name filtering, go to Configuring Event Notifications (http://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html) // in the Amazon Simple Storage Service Developer Guide. type NotificationConfigurationFilter struct { + _ struct{} `type:"structure"` + // Container for object key name prefix and suffix filtering rules. Key *KeyFilter `locationName:"S3Key" type:"structure"` - - metadataNotificationConfigurationFilter `json:"-" xml:"-"` -} - -type metadataNotificationConfigurationFilter struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -4968,6 +4528,8 @@ func (s NotificationConfigurationFilter) GoString() string { } type Object struct { + _ struct{} `type:"structure"` + ETag *string `type:"string"` Key *string `min:"1" type:"string"` @@ -4980,12 +4542,6 @@ type Object struct { // The class of storage used to store the object. StorageClass *string `type:"string" enum:"ObjectStorageClass"` - - metadataObject `json:"-" xml:"-"` -} - -type metadataObject struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -4999,17 +4555,13 @@ func (s Object) GoString() string { } type ObjectIdentifier struct { + _ struct{} `type:"structure"` + // Key name of the object to delete. Key *string `min:"1" type:"string" required:"true"` // VersionId for the specific version of the object to delete. VersionId *string `type:"string"` - - metadataObjectIdentifier `json:"-" xml:"-"` -} - -type metadataObjectIdentifier struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -5023,6 +4575,8 @@ func (s ObjectIdentifier) GoString() string { } type ObjectVersion struct { + _ struct{} `type:"structure"` + ETag *string `type:"string"` // Specifies whether the object is (true) or is not (false) the latest version @@ -5045,12 +4599,6 @@ type ObjectVersion struct { // Version ID of an object. VersionId *string `type:"string"` - - metadataObjectVersion `json:"-" xml:"-"` -} - -type metadataObjectVersion struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -5064,15 +4612,11 @@ func (s ObjectVersion) GoString() string { } type Owner struct { + _ struct{} `type:"structure"` + DisplayName *string `type:"string"` ID *string `type:"string"` - - metadataOwner `json:"-" xml:"-"` -} - -type metadataOwner struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -5086,6 +4630,8 @@ func (s Owner) GoString() string { } type Part struct { + _ struct{} `type:"structure"` + // Entity tag returned when the part was uploaded. ETag *string `type:"string"` @@ -5098,12 +4644,6 @@ type Part struct { // Size of the uploaded part data. Size *int64 `type:"integer"` - - metadataPart `json:"-" xml:"-"` -} - -type metadataPart struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -5117,6 +4657,8 @@ func (s Part) GoString() string { } type PutBucketAclInput struct { + _ struct{} `type:"structure" payload:"AccessControlPolicy"` + // The canned ACL to apply to the bucket. ACL *string `location:"header" locationName:"x-amz-acl" type:"string" enum:"BucketCannedACL"` @@ -5139,12 +4681,6 @@ type PutBucketAclInput struct { // Allows grantee to write the ACL for the applicable bucket. GrantWriteACP *string `location:"header" locationName:"x-amz-grant-write-acp" type:"string"` - - metadataPutBucketAclInput `json:"-" xml:"-"` -} - -type metadataPutBucketAclInput struct { - SDKShapeTraits bool `type:"structure" payload:"AccessControlPolicy"` } // String returns the string representation @@ -5158,11 +4694,7 @@ func (s PutBucketAclInput) GoString() string { } type PutBucketAclOutput struct { - metadataPutBucketAclOutput `json:"-" xml:"-"` -} - -type metadataPutBucketAclOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -5176,15 +4708,11 @@ func (s PutBucketAclOutput) GoString() string { } type PutBucketCorsInput struct { + _ struct{} `type:"structure" payload:"CORSConfiguration"` + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` CORSConfiguration *CORSConfiguration `locationName:"CORSConfiguration" type:"structure" required:"true"` - - metadataPutBucketCorsInput `json:"-" xml:"-"` -} - -type metadataPutBucketCorsInput struct { - SDKShapeTraits bool `type:"structure" payload:"CORSConfiguration"` } // String returns the string representation @@ -5198,11 +4726,7 @@ func (s PutBucketCorsInput) GoString() string { } type PutBucketCorsOutput struct { - metadataPutBucketCorsOutput `json:"-" xml:"-"` -} - -type metadataPutBucketCorsOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -5216,15 +4740,11 @@ func (s PutBucketCorsOutput) GoString() string { } type PutBucketLifecycleConfigurationInput struct { + _ struct{} `type:"structure" payload:"LifecycleConfiguration"` + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` LifecycleConfiguration *BucketLifecycleConfiguration `locationName:"LifecycleConfiguration" type:"structure"` - - metadataPutBucketLifecycleConfigurationInput `json:"-" xml:"-"` -} - -type metadataPutBucketLifecycleConfigurationInput struct { - SDKShapeTraits bool `type:"structure" payload:"LifecycleConfiguration"` } // String returns the string representation @@ -5238,11 +4758,7 @@ func (s PutBucketLifecycleConfigurationInput) GoString() string { } type PutBucketLifecycleConfigurationOutput struct { - metadataPutBucketLifecycleConfigurationOutput `json:"-" xml:"-"` -} - -type metadataPutBucketLifecycleConfigurationOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -5256,15 +4772,11 @@ func (s PutBucketLifecycleConfigurationOutput) GoString() string { } type PutBucketLifecycleInput struct { + _ struct{} `type:"structure" payload:"LifecycleConfiguration"` + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` LifecycleConfiguration *LifecycleConfiguration `locationName:"LifecycleConfiguration" type:"structure"` - - metadataPutBucketLifecycleInput `json:"-" xml:"-"` -} - -type metadataPutBucketLifecycleInput struct { - SDKShapeTraits bool `type:"structure" payload:"LifecycleConfiguration"` } // String returns the string representation @@ -5278,11 +4790,7 @@ func (s PutBucketLifecycleInput) GoString() string { } type PutBucketLifecycleOutput struct { - metadataPutBucketLifecycleOutput `json:"-" xml:"-"` -} - -type metadataPutBucketLifecycleOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -5296,15 +4804,11 @@ func (s PutBucketLifecycleOutput) GoString() string { } type PutBucketLoggingInput struct { + _ struct{} `type:"structure" payload:"BucketLoggingStatus"` + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` BucketLoggingStatus *BucketLoggingStatus `locationName:"BucketLoggingStatus" type:"structure" required:"true"` - - metadataPutBucketLoggingInput `json:"-" xml:"-"` -} - -type metadataPutBucketLoggingInput struct { - SDKShapeTraits bool `type:"structure" payload:"BucketLoggingStatus"` } // String returns the string representation @@ -5318,11 +4822,7 @@ func (s PutBucketLoggingInput) GoString() string { } type PutBucketLoggingOutput struct { - metadataPutBucketLoggingOutput `json:"-" xml:"-"` -} - -type metadataPutBucketLoggingOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -5336,17 +4836,13 @@ func (s PutBucketLoggingOutput) GoString() string { } type PutBucketNotificationConfigurationInput struct { + _ struct{} `type:"structure" payload:"NotificationConfiguration"` + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` // Container for specifying the notification configuration of the bucket. If // this element is empty, notifications are turned off on the bucket. NotificationConfiguration *NotificationConfiguration `locationName:"NotificationConfiguration" type:"structure" required:"true"` - - metadataPutBucketNotificationConfigurationInput `json:"-" xml:"-"` -} - -type metadataPutBucketNotificationConfigurationInput struct { - SDKShapeTraits bool `type:"structure" payload:"NotificationConfiguration"` } // String returns the string representation @@ -5360,11 +4856,7 @@ func (s PutBucketNotificationConfigurationInput) GoString() string { } type PutBucketNotificationConfigurationOutput struct { - metadataPutBucketNotificationConfigurationOutput `json:"-" xml:"-"` -} - -type metadataPutBucketNotificationConfigurationOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -5378,15 +4870,11 @@ func (s PutBucketNotificationConfigurationOutput) GoString() string { } type PutBucketNotificationInput struct { + _ struct{} `type:"structure" payload:"NotificationConfiguration"` + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` NotificationConfiguration *NotificationConfigurationDeprecated `locationName:"NotificationConfiguration" type:"structure" required:"true"` - - metadataPutBucketNotificationInput `json:"-" xml:"-"` -} - -type metadataPutBucketNotificationInput struct { - SDKShapeTraits bool `type:"structure" payload:"NotificationConfiguration"` } // String returns the string representation @@ -5400,11 +4888,7 @@ func (s PutBucketNotificationInput) GoString() string { } type PutBucketNotificationOutput struct { - metadataPutBucketNotificationOutput `json:"-" xml:"-"` -} - -type metadataPutBucketNotificationOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -5418,16 +4902,12 @@ func (s PutBucketNotificationOutput) GoString() string { } type PutBucketPolicyInput struct { + _ struct{} `type:"structure" payload:"Policy"` + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` // The bucket policy as a JSON document. Policy *string `type:"string" required:"true"` - - metadataPutBucketPolicyInput `json:"-" xml:"-"` -} - -type metadataPutBucketPolicyInput struct { - SDKShapeTraits bool `type:"structure" payload:"Policy"` } // String returns the string representation @@ -5441,11 +4921,7 @@ func (s PutBucketPolicyInput) GoString() string { } type PutBucketPolicyOutput struct { - metadataPutBucketPolicyOutput `json:"-" xml:"-"` -} - -type metadataPutBucketPolicyOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -5459,17 +4935,13 @@ func (s PutBucketPolicyOutput) GoString() string { } type PutBucketReplicationInput struct { + _ struct{} `type:"structure" payload:"ReplicationConfiguration"` + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` // Container for replication rules. You can add as many as 1,000 rules. Total // replication configuration size can be up to 2 MB. ReplicationConfiguration *ReplicationConfiguration `locationName:"ReplicationConfiguration" type:"structure" required:"true"` - - metadataPutBucketReplicationInput `json:"-" xml:"-"` -} - -type metadataPutBucketReplicationInput struct { - SDKShapeTraits bool `type:"structure" payload:"ReplicationConfiguration"` } // String returns the string representation @@ -5483,11 +4955,7 @@ func (s PutBucketReplicationInput) GoString() string { } type PutBucketReplicationOutput struct { - metadataPutBucketReplicationOutput `json:"-" xml:"-"` -} - -type metadataPutBucketReplicationOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -5501,15 +4969,11 @@ func (s PutBucketReplicationOutput) GoString() string { } type PutBucketRequestPaymentInput struct { + _ struct{} `type:"structure" payload:"RequestPaymentConfiguration"` + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` RequestPaymentConfiguration *RequestPaymentConfiguration `locationName:"RequestPaymentConfiguration" type:"structure" required:"true"` - - metadataPutBucketRequestPaymentInput `json:"-" xml:"-"` -} - -type metadataPutBucketRequestPaymentInput struct { - SDKShapeTraits bool `type:"structure" payload:"RequestPaymentConfiguration"` } // String returns the string representation @@ -5523,11 +4987,7 @@ func (s PutBucketRequestPaymentInput) GoString() string { } type PutBucketRequestPaymentOutput struct { - metadataPutBucketRequestPaymentOutput `json:"-" xml:"-"` -} - -type metadataPutBucketRequestPaymentOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -5541,15 +5001,11 @@ func (s PutBucketRequestPaymentOutput) GoString() string { } type PutBucketTaggingInput struct { + _ struct{} `type:"structure" payload:"Tagging"` + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` Tagging *Tagging `locationName:"Tagging" type:"structure" required:"true"` - - metadataPutBucketTaggingInput `json:"-" xml:"-"` -} - -type metadataPutBucketTaggingInput struct { - SDKShapeTraits bool `type:"structure" payload:"Tagging"` } // String returns the string representation @@ -5563,11 +5019,7 @@ func (s PutBucketTaggingInput) GoString() string { } type PutBucketTaggingOutput struct { - metadataPutBucketTaggingOutput `json:"-" xml:"-"` -} - -type metadataPutBucketTaggingOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -5581,6 +5033,8 @@ func (s PutBucketTaggingOutput) GoString() string { } type PutBucketVersioningInput struct { + _ struct{} `type:"structure" payload:"VersioningConfiguration"` + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` // The concatenation of the authentication device's serial number, a space, @@ -5588,12 +5042,6 @@ type PutBucketVersioningInput struct { MFA *string `location:"header" locationName:"x-amz-mfa" type:"string"` VersioningConfiguration *VersioningConfiguration `locationName:"VersioningConfiguration" type:"structure" required:"true"` - - metadataPutBucketVersioningInput `json:"-" xml:"-"` -} - -type metadataPutBucketVersioningInput struct { - SDKShapeTraits bool `type:"structure" payload:"VersioningConfiguration"` } // String returns the string representation @@ -5607,11 +5055,7 @@ func (s PutBucketVersioningInput) GoString() string { } type PutBucketVersioningOutput struct { - metadataPutBucketVersioningOutput `json:"-" xml:"-"` -} - -type metadataPutBucketVersioningOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -5625,15 +5069,11 @@ func (s PutBucketVersioningOutput) GoString() string { } type PutBucketWebsiteInput struct { + _ struct{} `type:"structure" payload:"WebsiteConfiguration"` + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` WebsiteConfiguration *WebsiteConfiguration `locationName:"WebsiteConfiguration" type:"structure" required:"true"` - - metadataPutBucketWebsiteInput `json:"-" xml:"-"` -} - -type metadataPutBucketWebsiteInput struct { - SDKShapeTraits bool `type:"structure" payload:"WebsiteConfiguration"` } // String returns the string representation @@ -5647,11 +5087,7 @@ func (s PutBucketWebsiteInput) GoString() string { } type PutBucketWebsiteOutput struct { - metadataPutBucketWebsiteOutput `json:"-" xml:"-"` -} - -type metadataPutBucketWebsiteOutput struct { - SDKShapeTraits bool `type:"structure"` + _ struct{} `type:"structure"` } // String returns the string representation @@ -5665,6 +5101,8 @@ func (s PutBucketWebsiteOutput) GoString() string { } type PutObjectAclInput struct { + _ struct{} `type:"structure" payload:"AccessControlPolicy"` + // The canned ACL to apply to the object. ACL *string `location:"header" locationName:"x-amz-acl" type:"string" enum:"ObjectCannedACL"` @@ -5695,12 +5133,6 @@ type PutObjectAclInput struct { // Documentation on downloading objects from requester pays buckets can be found // at http://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html RequestPayer *string `location:"header" locationName:"x-amz-request-payer" type:"string" enum:"RequestPayer"` - - metadataPutObjectAclInput `json:"-" xml:"-"` -} - -type metadataPutObjectAclInput struct { - SDKShapeTraits bool `type:"structure" payload:"AccessControlPolicy"` } // String returns the string representation @@ -5714,15 +5146,11 @@ func (s PutObjectAclInput) GoString() string { } type PutObjectAclOutput struct { + _ struct{} `type:"structure"` + // If present, indicates that the requester was successfully charged for the // request. RequestCharged *string `location:"header" locationName:"x-amz-request-charged" type:"string" enum:"RequestCharged"` - - metadataPutObjectAclOutput `json:"-" xml:"-"` -} - -type metadataPutObjectAclOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -5736,6 +5164,8 @@ func (s PutObjectAclOutput) GoString() string { } type PutObjectInput struct { + _ struct{} `type:"structure" payload:"Body"` + // The canned ACL to apply to the object. ACL *string `location:"header" locationName:"x-amz-acl" type:"string" enum:"ObjectCannedACL"` @@ -5823,12 +5253,6 @@ type PutObjectInput struct { // to another object in the same bucket or to an external URL. Amazon S3 stores // the value of this header in the object metadata. WebsiteRedirectLocation *string `location:"header" locationName:"x-amz-website-redirect-location" type:"string"` - - metadataPutObjectInput `json:"-" xml:"-"` -} - -type metadataPutObjectInput struct { - SDKShapeTraits bool `type:"structure" payload:"Body"` } // String returns the string representation @@ -5842,6 +5266,8 @@ func (s PutObjectInput) GoString() string { } type PutObjectOutput struct { + _ struct{} `type:"structure"` + // Entity tag for the uploaded object. ETag *string `location:"header" locationName:"ETag" type:"string"` @@ -5873,12 +5299,6 @@ type PutObjectOutput struct { // Version of the object. VersionId *string `location:"header" locationName:"x-amz-version-id" type:"string"` - - metadataPutObjectOutput `json:"-" xml:"-"` -} - -type metadataPutObjectOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -5894,6 +5314,8 @@ func (s PutObjectOutput) GoString() string { // Container for specifying an configuration when you want Amazon S3 to publish // events to an Amazon Simple Queue Service (Amazon SQS) queue. type QueueConfiguration struct { + _ struct{} `type:"structure"` + Events []*string `locationName:"Event" type:"list" flattened:"true" required:"true"` // Container for object key name filtering rules. For information about key @@ -5908,12 +5330,6 @@ type QueueConfiguration struct { // Amazon SQS queue ARN to which Amazon S3 will publish a message when it detects // events of specified type. QueueArn *string `locationName:"Queue" type:"string" required:"true"` - - metadataQueueConfiguration `json:"-" xml:"-"` -} - -type metadataQueueConfiguration struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -5927,6 +5343,8 @@ func (s QueueConfiguration) GoString() string { } type QueueConfigurationDeprecated struct { + _ struct{} `type:"structure"` + // Bucket event for which to send notifications. Event *string `type:"string" enum:"Event"` @@ -5937,12 +5355,6 @@ type QueueConfigurationDeprecated struct { Id *string `type:"string"` Queue *string `type:"string"` - - metadataQueueConfigurationDeprecated `json:"-" xml:"-"` -} - -type metadataQueueConfigurationDeprecated struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -5956,6 +5368,8 @@ func (s QueueConfigurationDeprecated) GoString() string { } type Redirect struct { + _ struct{} `type:"structure"` + // The host name to use in the redirect request. HostName *string `type:"string"` @@ -5979,12 +5393,6 @@ type Redirect struct { // request to error.html. Not required if one of the sibling is present. Can // be present only if ReplaceKeyPrefixWith is not provided. ReplaceKeyWith *string `type:"string"` - - metadataRedirect `json:"-" xml:"-"` -} - -type metadataRedirect struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -5998,18 +5406,14 @@ func (s Redirect) GoString() string { } type RedirectAllRequestsTo struct { + _ struct{} `type:"structure"` + // Name of the host where requests will be redirected. HostName *string `type:"string" required:"true"` // Protocol to use (http, https) when redirecting requests. The default is the // protocol that is used in the original request. Protocol *string `type:"string" enum:"Protocol"` - - metadataRedirectAllRequestsTo `json:"-" xml:"-"` -} - -type metadataRedirectAllRequestsTo struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -6025,6 +5429,8 @@ func (s RedirectAllRequestsTo) GoString() string { // Container for replication rules. You can add as many as 1,000 rules. Total // replication configuration size can be up to 2 MB. type ReplicationConfiguration struct { + _ struct{} `type:"structure"` + // Amazon Resource Name (ARN) of an IAM role for Amazon S3 to assume when replicating // the objects. Role *string `type:"string" required:"true"` @@ -6032,12 +5438,6 @@ type ReplicationConfiguration struct { // Container for information about a particular replication rule. Replication // configuration must have at least one rule and can contain up to 1,000 rules. Rules []*ReplicationRule `locationName:"Rule" type:"list" flattened:"true" required:"true"` - - metadataReplicationConfiguration `json:"-" xml:"-"` -} - -type metadataReplicationConfiguration struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -6051,6 +5451,8 @@ func (s ReplicationConfiguration) GoString() string { } type ReplicationRule struct { + _ struct{} `type:"structure"` + Destination *Destination `type:"structure" required:"true"` // Unique identifier for the rule. The value cannot be longer than 255 characters. @@ -6063,12 +5465,6 @@ type ReplicationRule struct { // The rule is ignored if status is not Enabled. Status *string `type:"string" required:"true" enum:"ReplicationRuleStatus"` - - metadataReplicationRule `json:"-" xml:"-"` -} - -type metadataReplicationRule struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -6082,14 +5478,10 @@ func (s ReplicationRule) GoString() string { } type RequestPaymentConfiguration struct { + _ struct{} `type:"structure"` + // Specifies who pays for the download and request fees. Payer *string `type:"string" required:"true" enum:"Payer"` - - metadataRequestPaymentConfiguration `json:"-" xml:"-"` -} - -type metadataRequestPaymentConfiguration struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -6103,6 +5495,8 @@ func (s RequestPaymentConfiguration) GoString() string { } type RestoreObjectInput struct { + _ struct{} `type:"structure" payload:"RestoreRequest"` + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` Key *string `location:"uri" locationName:"Key" min:"1" type:"string" required:"true"` @@ -6116,12 +5510,6 @@ type RestoreObjectInput struct { RestoreRequest *RestoreRequest `locationName:"RestoreRequest" type:"structure"` VersionId *string `location:"querystring" locationName:"versionId" type:"string"` - - metadataRestoreObjectInput `json:"-" xml:"-"` -} - -type metadataRestoreObjectInput struct { - SDKShapeTraits bool `type:"structure" payload:"RestoreRequest"` } // String returns the string representation @@ -6135,15 +5523,11 @@ func (s RestoreObjectInput) GoString() string { } type RestoreObjectOutput struct { + _ struct{} `type:"structure"` + // If present, indicates that the requester was successfully charged for the // request. RequestCharged *string `location:"header" locationName:"x-amz-request-charged" type:"string" enum:"RequestCharged"` - - metadataRestoreObjectOutput `json:"-" xml:"-"` -} - -type metadataRestoreObjectOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -6157,14 +5541,10 @@ func (s RestoreObjectOutput) GoString() string { } type RestoreRequest struct { + _ struct{} `type:"structure"` + // Lifetime of the active copy in days Days *int64 `type:"integer" required:"true"` - - metadataRestoreRequest `json:"-" xml:"-"` -} - -type metadataRestoreRequest struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -6178,6 +5558,8 @@ func (s RestoreRequest) GoString() string { } type RoutingRule struct { + _ struct{} `type:"structure"` + // A container for describing a condition that must be met for the specified // redirect to apply. For example, 1. If request is for pages in the /docs folder, // redirect to the /documents folder. 2. If request results in HTTP error 4xx, @@ -6188,12 +5570,6 @@ type RoutingRule struct { // host, to another page, or with another protocol. In the event of an error, // you can can specify a different error code to return. Redirect *Redirect `type:"structure" required:"true"` - - metadataRoutingRule `json:"-" xml:"-"` -} - -type metadataRoutingRule struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -6207,6 +5583,8 @@ func (s RoutingRule) GoString() string { } type Rule struct { + _ struct{} `type:"structure"` + Expiration *LifecycleExpiration `type:"structure"` // Unique identifier for the rule. The value cannot be longer than 255 characters. @@ -6234,12 +5612,6 @@ type Rule struct { Status *string `type:"string" required:"true" enum:"ExpirationStatus"` Transition *Transition `type:"structure"` - - metadataRule `json:"-" xml:"-"` -} - -type metadataRule struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -6253,17 +5625,13 @@ func (s Rule) GoString() string { } type Tag struct { + _ struct{} `type:"structure"` + // Name of the tag. Key *string `min:"1" type:"string" required:"true"` // Value of the tag. Value *string `type:"string" required:"true"` - - metadataTag `json:"-" xml:"-"` -} - -type metadataTag struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -6277,13 +5645,9 @@ func (s Tag) GoString() string { } type Tagging struct { + _ struct{} `type:"structure"` + TagSet []*Tag `locationNameList:"Tag" type:"list" required:"true"` - - metadataTagging `json:"-" xml:"-"` -} - -type metadataTagging struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -6297,16 +5661,12 @@ func (s Tagging) GoString() string { } type TargetGrant struct { + _ struct{} `type:"structure"` + Grantee *Grantee `type:"structure"` // Logging permissions assigned to the Grantee for the bucket. Permission *string `type:"string" enum:"BucketLogsPermission"` - - metadataTargetGrant `json:"-" xml:"-"` -} - -type metadataTargetGrant struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -6322,6 +5682,8 @@ func (s TargetGrant) GoString() string { // Container for specifying the configuration when you want Amazon S3 to publish // events to an Amazon Simple Notification Service (Amazon SNS) topic. type TopicConfiguration struct { + _ struct{} `type:"structure"` + Events []*string `locationName:"Event" type:"list" flattened:"true" required:"true"` // Container for object key name filtering rules. For information about key @@ -6336,12 +5698,6 @@ type TopicConfiguration struct { // Amazon SNS topic ARN to which Amazon S3 will publish a message when it detects // events of specified type. TopicArn *string `locationName:"Topic" type:"string" required:"true"` - - metadataTopicConfiguration `json:"-" xml:"-"` -} - -type metadataTopicConfiguration struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -6355,6 +5711,8 @@ func (s TopicConfiguration) GoString() string { } type TopicConfigurationDeprecated struct { + _ struct{} `type:"structure"` + // Bucket event for which to send notifications. Event *string `type:"string" enum:"Event"` @@ -6367,12 +5725,6 @@ type TopicConfigurationDeprecated struct { // Amazon SNS topic to which Amazon S3 will publish a message to report the // specified events for the bucket. Topic *string `type:"string"` - - metadataTopicConfigurationDeprecated `json:"-" xml:"-"` -} - -type metadataTopicConfigurationDeprecated struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -6386,6 +5738,8 @@ func (s TopicConfigurationDeprecated) GoString() string { } type Transition struct { + _ struct{} `type:"structure"` + // Indicates at what date the object is to be moved or deleted. Should be in // GMT ISO 8601 Format. Date *time.Time `type:"timestamp" timestampFormat:"iso8601"` @@ -6396,12 +5750,6 @@ type Transition struct { // The class of storage used to store the object. StorageClass *string `type:"string" enum:"TransitionStorageClass"` - - metadataTransition `json:"-" xml:"-"` -} - -type metadataTransition struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -6415,6 +5763,8 @@ func (s Transition) GoString() string { } type UploadPartCopyInput struct { + _ struct{} `type:"structure"` + Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` // The name of the source bucket and key name of the source object, separated @@ -6484,12 +5834,6 @@ type UploadPartCopyInput struct { // Upload ID identifying the multipart upload whose part is being copied. UploadId *string `location:"querystring" locationName:"uploadId" type:"string" required:"true"` - - metadataUploadPartCopyInput `json:"-" xml:"-"` -} - -type metadataUploadPartCopyInput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -6503,6 +5847,8 @@ func (s UploadPartCopyInput) GoString() string { } type UploadPartCopyOutput struct { + _ struct{} `type:"structure" payload:"CopyPartResult"` + CopyPartResult *CopyPartResult `type:"structure"` // The version of the source object that was copied, if you have enabled versioning @@ -6530,12 +5876,6 @@ type UploadPartCopyOutput struct { // The Server-side encryption algorithm used when storing this object in S3 // (e.g., AES256, aws:kms). ServerSideEncryption *string `location:"header" locationName:"x-amz-server-side-encryption" type:"string" enum:"ServerSideEncryption"` - - metadataUploadPartCopyOutput `json:"-" xml:"-"` -} - -type metadataUploadPartCopyOutput struct { - SDKShapeTraits bool `type:"structure" payload:"CopyPartResult"` } // String returns the string representation @@ -6549,6 +5889,8 @@ func (s UploadPartCopyOutput) GoString() string { } type UploadPartInput struct { + _ struct{} `type:"structure" payload:"Body"` + Body io.ReadSeeker `type:"blob"` Bucket *string `location:"uri" locationName:"Bucket" type:"string" required:"true"` @@ -6587,12 +5929,6 @@ type UploadPartInput struct { // Upload ID identifying the multipart upload whose part is being uploaded. UploadId *string `location:"querystring" locationName:"uploadId" type:"string" required:"true"` - - metadataUploadPartInput `json:"-" xml:"-"` -} - -type metadataUploadPartInput struct { - SDKShapeTraits bool `type:"structure" payload:"Body"` } // String returns the string representation @@ -6606,6 +5942,8 @@ func (s UploadPartInput) GoString() string { } type UploadPartOutput struct { + _ struct{} `type:"structure"` + // Entity tag for the uploaded object. ETag *string `location:"header" locationName:"ETag" type:"string"` @@ -6630,12 +5968,6 @@ type UploadPartOutput struct { // The Server-side encryption algorithm used when storing this object in S3 // (e.g., AES256, aws:kms). ServerSideEncryption *string `location:"header" locationName:"x-amz-server-side-encryption" type:"string" enum:"ServerSideEncryption"` - - metadataUploadPartOutput `json:"-" xml:"-"` -} - -type metadataUploadPartOutput struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -6649,6 +5981,8 @@ func (s UploadPartOutput) GoString() string { } type VersioningConfiguration struct { + _ struct{} `type:"structure"` + // Specifies whether MFA delete is enabled in the bucket versioning configuration. // This element is only returned if the bucket has been configured with MFA // delete. If the bucket has never been so configured, this element is not returned. @@ -6656,12 +5990,6 @@ type VersioningConfiguration struct { // The versioning state of the bucket. Status *string `type:"string" enum:"BucketVersioningStatus"` - - metadataVersioningConfiguration `json:"-" xml:"-"` -} - -type metadataVersioningConfiguration struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -6675,6 +6003,8 @@ func (s VersioningConfiguration) GoString() string { } type WebsiteConfiguration struct { + _ struct{} `type:"structure"` + ErrorDocument *ErrorDocument `type:"structure"` IndexDocument *IndexDocument `type:"structure"` @@ -6682,12 +6012,6 @@ type WebsiteConfiguration struct { RedirectAllRequestsTo *RedirectAllRequestsTo `type:"structure"` RoutingRules []*RoutingRule `locationNameList:"RoutingRule" type:"list"` - - metadataWebsiteConfiguration `json:"-" xml:"-"` -} - -type metadataWebsiteConfiguration struct { - SDKShapeTraits bool `type:"structure"` } // String returns the string representation @@ -6828,6 +6152,8 @@ const ( // @enum ObjectCannedACL ObjectCannedACLAuthenticatedRead = "authenticated-read" // @enum ObjectCannedACL + ObjectCannedACLAwsExecRead = "aws-exec-read" + // @enum ObjectCannedACL ObjectCannedACLBucketOwnerRead = "bucket-owner-read" // @enum ObjectCannedACL ObjectCannedACLBucketOwnerFullControl = "bucket-owner-full-control" diff --git a/Godeps/_workspace/src/github.com/coreos/etcd/client/client.go b/Godeps/_workspace/src/github.com/coreos/etcd/client/client.go index 34adb82b0..e484032c1 100644 --- a/Godeps/_workspace/src/github.com/coreos/etcd/client/client.go +++ b/Godeps/_workspace/src/github.com/coreos/etcd/client/client.go @@ -378,9 +378,12 @@ func (c *simpleHTTPClient) Do(ctx context.Context, act httpAction) (*http.Respon return nil, nil, err } - hctx, hcancel := context.WithCancel(ctx) + var hctx context.Context + var hcancel context.CancelFunc if c.headerTimeout > 0 { hctx, hcancel = context.WithTimeout(ctx, c.headerTimeout) + } else { + hctx, hcancel = context.WithCancel(ctx) } defer hcancel() diff --git a/Godeps/_workspace/src/github.com/coreos/etcd/pkg/pathutil/path.go b/Godeps/_workspace/src/github.com/coreos/etcd/pkg/pathutil/path.go index 82fd1db39..f26254ba9 100644 --- a/Godeps/_workspace/src/github.com/coreos/etcd/pkg/pathutil/path.go +++ b/Godeps/_workspace/src/github.com/coreos/etcd/pkg/pathutil/path.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// Package pathutil implements utility functions for handling slash-separated +// paths. package pathutil import "path" diff --git a/Godeps/_workspace/src/github.com/fatih/structs/.travis.yml b/Godeps/_workspace/src/github.com/fatih/structs/.travis.yml index c3bd50e2e..2bbcdef5f 100644 --- a/Godeps/_workspace/src/github.com/fatih/structs/.travis.yml +++ b/Godeps/_workspace/src/github.com/fatih/structs/.travis.yml @@ -1,5 +1,6 @@ language: go go: 1.5 +sudo: false before_install: - go get github.com/axw/gocov/gocov - go get github.com/mattn/goveralls diff --git a/Godeps/_workspace/src/github.com/fatih/structs/field.go b/Godeps/_workspace/src/github.com/fatih/structs/field.go index 4b5e15b06..1178b0ca6 100644 --- a/Godeps/_workspace/src/github.com/fatih/structs/field.go +++ b/Godeps/_workspace/src/github.com/fatih/structs/field.go @@ -84,6 +84,13 @@ func (f *Field) Set(val interface{}) error { return nil } +// Zero sets the field to its zero value. It returns an error if the field is not +// settable (not addressable or not exported). +func (f *Field) Zero() error { + zero := reflect.Zero(f.value.Type()).Interface() + return f.Set(zero) +} + // Fields returns a slice of Fields. This is particular handy to get the fields // of a nested struct . A struct tag with the content of "-" ignores the // checking of that particular field. Example: diff --git a/Godeps/_workspace/src/github.com/fatih/structs/structs.go b/Godeps/_workspace/src/github.com/fatih/structs/structs.go index a0b77e67d..f3dcf9a66 100644 --- a/Godeps/_workspace/src/github.com/fatih/structs/structs.go +++ b/Godeps/_workspace/src/github.com/fatih/structs/structs.go @@ -94,7 +94,12 @@ func (s *Struct) Map() map[string]interface{} { // map[string]interface{} too n := New(val.Interface()) n.TagName = s.TagName - finalVal = n.Map() + m := n.Map() + if len(m) == 0 { + finalVal = val.Interface() + } else { + finalVal = m + } } else { finalVal = val.Interface() } diff --git a/Godeps/_workspace/src/github.com/ghodss/yaml/.gitignore b/Godeps/_workspace/src/github.com/ghodss/yaml/.gitignore new file mode 100644 index 000000000..e256a31e0 --- /dev/null +++ b/Godeps/_workspace/src/github.com/ghodss/yaml/.gitignore @@ -0,0 +1,20 @@ +# OSX leaves these everywhere on SMB shares +._* + +# Eclipse files +.classpath +.project +.settings/** + +# Emacs save files +*~ + +# Vim-related files +[._]*.s[a-w][a-z] +[._]s[a-w][a-z] +*.un~ +Session.vim +.netrwhist + +# Go test binaries +*.test diff --git a/Godeps/_workspace/src/github.com/ghodss/yaml/.travis.yml b/Godeps/_workspace/src/github.com/ghodss/yaml/.travis.yml new file mode 100644 index 000000000..0e9d6edc0 --- /dev/null +++ b/Godeps/_workspace/src/github.com/ghodss/yaml/.travis.yml @@ -0,0 +1,7 @@ +language: go +go: + - 1.3 + - 1.4 +script: + - go test + - go build diff --git a/Godeps/_workspace/src/github.com/ghodss/yaml/LICENSE b/Godeps/_workspace/src/github.com/ghodss/yaml/LICENSE new file mode 100644 index 000000000..7805d36de --- /dev/null +++ b/Godeps/_workspace/src/github.com/ghodss/yaml/LICENSE @@ -0,0 +1,50 @@ +The MIT License (MIT) + +Copyright (c) 2014 Sam Ghods + +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. + + +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/Godeps/_workspace/src/github.com/ghodss/yaml/README.md b/Godeps/_workspace/src/github.com/ghodss/yaml/README.md new file mode 100644 index 000000000..f8f7e3695 --- /dev/null +++ b/Godeps/_workspace/src/github.com/ghodss/yaml/README.md @@ -0,0 +1,116 @@ +# YAML marshaling and unmarshaling support for Go + +[![Build Status](https://travis-ci.org/ghodss/yaml.svg)](https://travis-ci.org/ghodss/yaml) + +## Introduction + +A wrapper around [go-yaml](https://github.com/go-yaml/yaml) designed to enable a better way of handling YAML when marshaling to and from structs. + +In short, this library first converts YAML to JSON using go-yaml and then uses `json.Marshal` and `json.Unmarshal` to convert to or from the struct. This means that it effectively reuses the JSON struct tags as well as the custom JSON methods `MarshalJSON` and `UnmarshalJSON` unlike go-yaml. For a detailed overview of the rationale behind this method, [see this blog post](http://ghodss.com/2014/the-right-way-to-handle-yaml-in-golang/). + +## Compatibility + +This package uses [go-yaml v2](https://github.com/go-yaml/yaml) and therefore supports [everything go-yaml supports](https://github.com/go-yaml/yaml#compatibility). + +## Caveats + +**Caveat #1:** When using `yaml.Marshal` and `yaml.Unmarshal`, binary data should NOT be preceded with the `!!binary` YAML tag. If you do, go-yaml will convert the binary data from base64 to native binary data, which is not compatible with JSON. You can still use binary in your YAML files though - just store them without the `!!binary` tag and decode the base64 in your code (e.g. in the custom JSON methods `MarshalJSON` and `UnmarshalJSON`). This also has the benefit that your YAML and your JSON binary data will be decoded exactly the same way. As an example: + +``` +BAD: + exampleKey: !!binary gIGC + +GOOD: + exampleKey: gIGC +... and decode the base64 data in your code. +``` + +**Caveat #2:** When using `YAMLToJSON` directly, maps with keys that are maps will result in an error since this is not supported by JSON. This error will occur in `Unmarshal` as well since you can't unmarshal map keys anyways since struct fields can't be keys. + +## Installation and usage + +To install, run: + +``` +$ go get github.com/ghodss/yaml +``` + +And import using: + +``` +import "github.com/ghodss/yaml" +``` + +Usage is very similar to the JSON library: + +```go +import ( + "fmt" + + "github.com/ghodss/yaml" +) + +type Person struct { + Name string `json:"name"` // Affects YAML field names too. + Age int `json:"name"` +} + +func main() { + // Marshal a Person struct to YAML. + p := Person{"John", 30} + y, err := yaml.Marshal(p) + if err != nil { + fmt.Printf("err: %v\n", err) + return + } + fmt.Println(string(y)) + /* Output: + name: John + age: 30 + */ + + // Unmarshal the YAML back into a Person struct. + var p2 Person + err := yaml.Unmarshal(y, &p2) + if err != nil { + fmt.Printf("err: %v\n", err) + return + } + fmt.Println(p2) + /* Output: + {John 30} + */ +} +``` + +`yaml.YAMLToJSON` and `yaml.JSONToYAML` methods are also available: + +```go +import ( + "fmt" + + "github.com/ghodss/yaml" +) +func main() { + j := []byte(`{"name": "John", "age": 30}`) + y, err := yaml.JSONToYAML(j) + if err != nil { + fmt.Printf("err: %v\n", err) + return + } + fmt.Println(string(y)) + /* Output: + name: John + age: 30 + */ + j2, err := yaml.YAMLToJSON(y) + if err != nil { + fmt.Printf("err: %v\n", err) + return + } + fmt.Println(string(j2)) + /* Output: + {"age":30,"name":"John"} + */ +} +``` diff --git a/Godeps/_workspace/src/github.com/ghodss/yaml/fields.go b/Godeps/_workspace/src/github.com/ghodss/yaml/fields.go new file mode 100644 index 000000000..0bd3c2b46 --- /dev/null +++ b/Godeps/_workspace/src/github.com/ghodss/yaml/fields.go @@ -0,0 +1,497 @@ +// Copyright 2013 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 yaml + +import ( + "bytes" + "encoding" + "encoding/json" + "reflect" + "sort" + "strings" + "sync" + "unicode" + "unicode/utf8" +) + +// 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 indirect(v reflect.Value, decodingNull bool) (json.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().(json.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 +} + +// A field represents a single field found in a struct. +type field struct { + name string + nameBytes []byte // []byte(name) + equalFold func(s, t []byte) bool // bytes.EqualFold or equivalent + + tag bool + index []int + typ reflect.Type + omitEmpty bool + quoted bool +} + +func fillField(f field) field { + f.nameBytes = []byte(f.name) + f.equalFold = foldFunc(f.nameBytes) + return f +} + +// byName sorts field by name, breaking ties with depth, +// then breaking ties with "name came from json tag", then +// breaking ties with index sequence. +type byName []field + +func (x byName) Len() int { return len(x) } + +func (x byName) Swap(i, j int) { x[i], x[j] = x[j], x[i] } + +func (x byName) Less(i, j int) bool { + if x[i].name != x[j].name { + return x[i].name < x[j].name + } + if len(x[i].index) != len(x[j].index) { + return len(x[i].index) < len(x[j].index) + } + if x[i].tag != x[j].tag { + return x[i].tag + } + return byIndex(x).Less(i, j) +} + +// byIndex sorts field by index sequence. +type byIndex []field + +func (x byIndex) Len() int { return len(x) } + +func (x byIndex) Swap(i, j int) { x[i], x[j] = x[j], x[i] } + +func (x byIndex) Less(i, j int) bool { + for k, xik := range x[i].index { + if k >= len(x[j].index) { + return false + } + if xik != x[j].index[k] { + return xik < x[j].index[k] + } + } + return len(x[i].index) < len(x[j].index) +} + +// typeFields returns a list of fields that JSON should recognize for the given type. +// The algorithm is breadth-first search over the set of structs to include - the top struct +// and then any reachable anonymous structs. +func typeFields(t reflect.Type) []field { + // Anonymous fields to explore at the current level and the next. + current := []field{} + next := []field{{typ: t}} + + // Count of queued names for current level and the next. + count := map[reflect.Type]int{} + nextCount := map[reflect.Type]int{} + + // Types already visited at an earlier level. + visited := map[reflect.Type]bool{} + + // Fields found. + var fields []field + + for len(next) > 0 { + current, next = next, current[:0] + count, nextCount = nextCount, map[reflect.Type]int{} + + for _, f := range current { + if visited[f.typ] { + continue + } + visited[f.typ] = true + + // Scan f.typ for fields to include. + for i := 0; i < f.typ.NumField(); i++ { + sf := f.typ.Field(i) + if sf.PkgPath != "" { // unexported + continue + } + tag := sf.Tag.Get("json") + if tag == "-" { + continue + } + name, opts := parseTag(tag) + if !isValidTag(name) { + name = "" + } + index := make([]int, len(f.index)+1) + copy(index, f.index) + index[len(f.index)] = i + + ft := sf.Type + if ft.Name() == "" && ft.Kind() == reflect.Ptr { + // Follow pointer. + ft = ft.Elem() + } + + // Record found field and index sequence. + if name != "" || !sf.Anonymous || ft.Kind() != reflect.Struct { + tagged := name != "" + if name == "" { + name = sf.Name + } + fields = append(fields, fillField(field{ + name: name, + tag: tagged, + index: index, + typ: ft, + omitEmpty: opts.Contains("omitempty"), + quoted: opts.Contains("string"), + })) + if count[f.typ] > 1 { + // If there were multiple instances, add a second, + // so that the annihilation code will see a duplicate. + // It only cares about the distinction between 1 or 2, + // so don't bother generating any more copies. + fields = append(fields, fields[len(fields)-1]) + } + continue + } + + // Record new anonymous struct to explore in next round. + nextCount[ft]++ + if nextCount[ft] == 1 { + next = append(next, fillField(field{name: ft.Name(), index: index, typ: ft})) + } + } + } + } + + sort.Sort(byName(fields)) + + // Delete all fields that are hidden by the Go rules for embedded fields, + // except that fields with JSON tags are promoted. + + // The fields are sorted in primary order of name, secondary order + // of field index length. Loop over names; for each name, delete + // hidden fields by choosing the one dominant field that survives. + out := fields[:0] + for advance, i := 0, 0; i < len(fields); i += advance { + // One iteration per name. + // Find the sequence of fields with the name of this first field. + fi := fields[i] + name := fi.name + for advance = 1; i+advance < len(fields); advance++ { + fj := fields[i+advance] + if fj.name != name { + break + } + } + if advance == 1 { // Only one field with this name + out = append(out, fi) + continue + } + dominant, ok := dominantField(fields[i : i+advance]) + if ok { + out = append(out, dominant) + } + } + + fields = out + sort.Sort(byIndex(fields)) + + return fields +} + +// dominantField looks through the fields, all of which are known to +// have the same name, to find the single field that dominates the +// others using Go's embedding rules, modified by the presence of +// JSON tags. If there are multiple top-level fields, the boolean +// will be false: This condition is an error in Go and we skip all +// the fields. +func dominantField(fields []field) (field, bool) { + // The fields are sorted in increasing index-length order. The winner + // must therefore be one with the shortest index length. Drop all + // longer entries, which is easy: just truncate the slice. + length := len(fields[0].index) + tagged := -1 // Index of first tagged field. + for i, f := range fields { + if len(f.index) > length { + fields = fields[:i] + break + } + if f.tag { + if tagged >= 0 { + // Multiple tagged fields at the same level: conflict. + // Return no field. + return field{}, false + } + tagged = i + } + } + if tagged >= 0 { + return fields[tagged], true + } + // All remaining fields have the same length. If there's more than one, + // we have a conflict (two fields named "X" at the same level) and we + // return no field. + if len(fields) > 1 { + return field{}, false + } + return fields[0], true +} + +var fieldCache struct { + sync.RWMutex + m map[reflect.Type][]field +} + +// cachedTypeFields is like typeFields but uses a cache to avoid repeated work. +func cachedTypeFields(t reflect.Type) []field { + fieldCache.RLock() + f := fieldCache.m[t] + fieldCache.RUnlock() + if f != nil { + return f + } + + // Compute fields without lock. + // Might duplicate effort but won't hold other computations back. + f = typeFields(t) + if f == nil { + f = []field{} + } + + fieldCache.Lock() + if fieldCache.m == nil { + fieldCache.m = map[reflect.Type][]field{} + } + fieldCache.m[t] = f + fieldCache.Unlock() + return f +} + +func isValidTag(s string) bool { + if s == "" { + return false + } + for _, c := range s { + switch { + case strings.ContainsRune("!#$%&()*+-./:<=>?@[]^_{|}~ ", c): + // Backslash and quote chars are reserved, but + // otherwise any punctuation chars are allowed + // in a tag name. + default: + if !unicode.IsLetter(c) && !unicode.IsDigit(c) { + return false + } + } + } + return true +} + +const ( + caseMask = ^byte(0x20) // Mask to ignore case in ASCII. + kelvin = '\u212a' + smallLongEss = '\u017f' +) + +// foldFunc returns one of four different case folding equivalence +// functions, from most general (and slow) to fastest: +// +// 1) bytes.EqualFold, if the key s contains any non-ASCII UTF-8 +// 2) equalFoldRight, if s contains special folding ASCII ('k', 'K', 's', 'S') +// 3) asciiEqualFold, no special, but includes non-letters (including _) +// 4) simpleLetterEqualFold, no specials, no non-letters. +// +// The letters S and K are special because they map to 3 runes, not just 2: +// * S maps to s and to U+017F 'ſ' Latin small letter long s +// * k maps to K and to U+212A 'K' Kelvin sign +// See http://play.golang.org/p/tTxjOc0OGo +// +// The returned function is specialized for matching against s and +// should only be given s. It's not curried for performance reasons. +func foldFunc(s []byte) func(s, t []byte) bool { + nonLetter := false + special := false // special letter + for _, b := range s { + if b >= utf8.RuneSelf { + return bytes.EqualFold + } + upper := b & caseMask + if upper < 'A' || upper > 'Z' { + nonLetter = true + } else if upper == 'K' || upper == 'S' { + // See above for why these letters are special. + special = true + } + } + if special { + return equalFoldRight + } + if nonLetter { + return asciiEqualFold + } + return simpleLetterEqualFold +} + +// equalFoldRight is a specialization of bytes.EqualFold when s is +// known to be all ASCII (including punctuation), but contains an 's', +// 'S', 'k', or 'K', requiring a Unicode fold on the bytes in t. +// See comments on foldFunc. +func equalFoldRight(s, t []byte) bool { + for _, sb := range s { + if len(t) == 0 { + return false + } + tb := t[0] + if tb < utf8.RuneSelf { + if sb != tb { + sbUpper := sb & caseMask + if 'A' <= sbUpper && sbUpper <= 'Z' { + if sbUpper != tb&caseMask { + return false + } + } else { + return false + } + } + t = t[1:] + continue + } + // sb is ASCII and t is not. t must be either kelvin + // sign or long s; sb must be s, S, k, or K. + tr, size := utf8.DecodeRune(t) + switch sb { + case 's', 'S': + if tr != smallLongEss { + return false + } + case 'k', 'K': + if tr != kelvin { + return false + } + default: + return false + } + t = t[size:] + + } + if len(t) > 0 { + return false + } + return true +} + +// asciiEqualFold is a specialization of bytes.EqualFold for use when +// s is all ASCII (but may contain non-letters) and contains no +// special-folding letters. +// See comments on foldFunc. +func asciiEqualFold(s, t []byte) bool { + if len(s) != len(t) { + return false + } + for i, sb := range s { + tb := t[i] + if sb == tb { + continue + } + if ('a' <= sb && sb <= 'z') || ('A' <= sb && sb <= 'Z') { + if sb&caseMask != tb&caseMask { + return false + } + } else { + return false + } + } + return true +} + +// simpleLetterEqualFold is a specialization of bytes.EqualFold for +// use when s is all ASCII letters (no underscores, etc) and also +// doesn't contain 'k', 'K', 's', or 'S'. +// See comments on foldFunc. +func simpleLetterEqualFold(s, t []byte) bool { + if len(s) != len(t) { + return false + } + for i, b := range s { + if b&caseMask != t[i]&caseMask { + return false + } + } + return true +} + +// tagOptions is the string following a comma in a struct field's "json" +// tag, or the empty string. It does not include the leading comma. +type tagOptions string + +// parseTag splits a struct field's json tag into its name and +// comma-separated options. +func parseTag(tag string) (string, tagOptions) { + if idx := strings.Index(tag, ","); idx != -1 { + return tag[:idx], tagOptions(tag[idx+1:]) + } + return tag, tagOptions("") +} + +// Contains reports whether a comma-separated list of options +// contains a particular substr flag. substr must be surrounded by a +// string boundary or commas. +func (o tagOptions) Contains(optionName string) bool { + if len(o) == 0 { + return false + } + s := string(o) + for s != "" { + var next string + i := strings.Index(s, ",") + if i >= 0 { + s, next = s[:i], s[i+1:] + } + if s == optionName { + return true + } + s = next + } + return false +} diff --git a/Godeps/_workspace/src/github.com/ghodss/yaml/yaml.go b/Godeps/_workspace/src/github.com/ghodss/yaml/yaml.go new file mode 100644 index 000000000..c02beacb9 --- /dev/null +++ b/Godeps/_workspace/src/github.com/ghodss/yaml/yaml.go @@ -0,0 +1,277 @@ +package yaml + +import ( + "bytes" + "encoding/json" + "fmt" + "reflect" + "strconv" + + "gopkg.in/yaml.v2" +) + +// Marshals the object into JSON then converts JSON to YAML and returns the +// YAML. +func Marshal(o interface{}) ([]byte, error) { + j, err := json.Marshal(o) + if err != nil { + return nil, fmt.Errorf("error marshaling into JSON: ", err) + } + + y, err := JSONToYAML(j) + if err != nil { + return nil, fmt.Errorf("error converting JSON to YAML: ", err) + } + + return y, nil +} + +// Converts YAML to JSON then uses JSON to unmarshal into an object. +func Unmarshal(y []byte, o interface{}) error { + vo := reflect.ValueOf(o) + j, err := yamlToJSON(y, &vo) + if err != nil { + return fmt.Errorf("error converting YAML to JSON: %v", err) + } + + err = json.Unmarshal(j, o) + if err != nil { + return fmt.Errorf("error unmarshaling JSON: %v", err) + } + + return nil +} + +// Convert JSON to YAML. +func JSONToYAML(j []byte) ([]byte, error) { + // Convert the JSON to an object. + var jsonObj interface{} + // We are using yaml.Unmarshal here (instead of json.Unmarshal) because the + // Go JSON library doesn't try to pick the right number type (int, float, + // etc.) when unmarshling to interface{}, it just picks float64 + // universally. go-yaml does go through the effort of picking the right + // number type, so we can preserve number type throughout this process. + err := yaml.Unmarshal(j, &jsonObj) + if err != nil { + return nil, err + } + + // Marshal this object into YAML. + return yaml.Marshal(jsonObj) +} + +// Convert YAML to JSON. Since JSON is a subset of YAML, passing JSON through +// this method should be a no-op. +// +// Things YAML can do that are not supported by JSON: +// * In YAML you can have binary and null keys in your maps. These are invalid +// in JSON. (int and float keys are converted to strings.) +// * Binary data in YAML with the !!binary tag is not supported. If you want to +// use binary data with this library, encode the data as base64 as usual but do +// not use the !!binary tag in your YAML. This will ensure the original base64 +// encoded data makes it all the way through to the JSON. +func YAMLToJSON(y []byte) ([]byte, error) { + return yamlToJSON(y, nil) +} + +func yamlToJSON(y []byte, jsonTarget *reflect.Value) ([]byte, error) { + // Convert the YAML to an object. + var yamlObj interface{} + err := yaml.Unmarshal(y, &yamlObj) + if err != nil { + return nil, err + } + + // YAML objects are not completely compatible with JSON objects (e.g. you + // can have non-string keys in YAML). So, convert the YAML-compatible object + // to a JSON-compatible object, failing with an error if irrecoverable + // incompatibilties happen along the way. + jsonObj, err := convertToJSONableObject(yamlObj, jsonTarget) + if err != nil { + return nil, err + } + + // Convert this object to JSON and return the data. + return json.Marshal(jsonObj) +} + +func convertToJSONableObject(yamlObj interface{}, jsonTarget *reflect.Value) (interface{}, error) { + var err error + + // Resolve jsonTarget to a concrete value (i.e. not a pointer or an + // interface). We pass decodingNull as false because we're not actually + // decoding into the value, we're just checking if the ultimate target is a + // string. + if jsonTarget != nil { + ju, tu, pv := indirect(*jsonTarget, false) + // We have a JSON or Text Umarshaler at this level, so we can't be trying + // to decode into a string. + if ju != nil || tu != nil { + jsonTarget = nil + } else { + jsonTarget = &pv + } + } + + // If yamlObj is a number or a boolean, check if jsonTarget is a string - + // if so, coerce. Else return normal. + // If yamlObj is a map or array, find the field that each key is + // unmarshaling to, and when you recurse pass the reflect.Value for that + // field back into this function. + switch typedYAMLObj := yamlObj.(type) { + case map[interface{}]interface{}: + // JSON does not support arbitrary keys in a map, so we must convert + // these keys to strings. + // + // From my reading of go-yaml v2 (specifically the resolve function), + // keys can only have the types string, int, int64, float64, binary + // (unsupported), or null (unsupported). + strMap := make(map[string]interface{}) + for k, v := range typedYAMLObj { + // Resolve the key to a string first. + var keyString string + switch typedKey := k.(type) { + case string: + keyString = typedKey + case int: + keyString = strconv.Itoa(typedKey) + case int64: + // go-yaml will only return an int64 as a key if the system + // architecture is 32-bit and the key's value is between 32-bit + // and 64-bit. Otherwise the key type will simply be int. + keyString = strconv.FormatInt(typedKey, 10) + case float64: + // Stolen from go-yaml to use the same conversion to string as + // the go-yaml library uses to convert float to string when + // Marshaling. + s := strconv.FormatFloat(typedKey, 'g', -1, 32) + switch s { + case "+Inf": + s = ".inf" + case "-Inf": + s = "-.inf" + case "NaN": + s = ".nan" + } + keyString = s + case bool: + if typedKey { + keyString = "true" + } else { + keyString = "false" + } + default: + return nil, fmt.Errorf("Unsupported map key of type: %s, key: %+#v, value: %+#v", + reflect.TypeOf(k), k, v) + } + + // jsonTarget should be a struct or a map. If it's a struct, find + // the field it's going to map to and pass its reflect.Value. If + // it's a map, find the element type of the map and pass the + // reflect.Value created from that type. If it's neither, just pass + // nil - JSON conversion will error for us if it's a real issue. + if jsonTarget != nil { + t := *jsonTarget + if t.Kind() == reflect.Struct { + keyBytes := []byte(keyString) + // Find the field that the JSON library would use. + var f *field + fields := cachedTypeFields(t.Type()) + for i := range fields { + ff := &fields[i] + if bytes.Equal(ff.nameBytes, keyBytes) { + f = ff + break + } + // Do case-insensitive comparison. + if f == nil && ff.equalFold(ff.nameBytes, keyBytes) { + f = ff + } + } + if f != nil { + // Find the reflect.Value of the most preferential + // struct field. + jtf := t.Field(f.index[0]) + strMap[keyString], err = convertToJSONableObject(v, &jtf) + if err != nil { + return nil, err + } + continue + } + } else if t.Kind() == reflect.Map { + // Create a zero value of the map's element type to use as + // the JSON target. + jtv := reflect.Zero(t.Type().Elem()) + strMap[keyString], err = convertToJSONableObject(v, &jtv) + if err != nil { + return nil, err + } + continue + } + } + strMap[keyString], err = convertToJSONableObject(v, nil) + if err != nil { + return nil, err + } + } + return strMap, nil + case []interface{}: + // We need to recurse into arrays in case there are any + // map[interface{}]interface{}'s inside and to convert any + // numbers to strings. + + // If jsonTarget is a slice (which it really should be), find the + // thing it's going to map to. If it's not a slice, just pass nil + // - JSON conversion will error for us if it's a real issue. + var jsonSliceElemValue *reflect.Value + if jsonTarget != nil { + t := *jsonTarget + if t.Kind() == reflect.Slice { + // By default slices point to nil, but we need a reflect.Value + // pointing to a value of the slice type, so we create one here. + ev := reflect.Indirect(reflect.New(t.Type().Elem())) + jsonSliceElemValue = &ev + } + } + + // Make and use a new array. + arr := make([]interface{}, len(typedYAMLObj)) + for i, v := range typedYAMLObj { + arr[i], err = convertToJSONableObject(v, jsonSliceElemValue) + if err != nil { + return nil, err + } + } + return arr, nil + default: + // If the target type is a string and the YAML type is a number, + // convert the YAML type to a string. + if jsonTarget != nil && (*jsonTarget).Kind() == reflect.String { + // Based on my reading of go-yaml, it may return int, int64, + // float64, or uint64. + var s string + switch typedVal := typedYAMLObj.(type) { + case int: + s = strconv.FormatInt(int64(typedVal), 10) + case int64: + s = strconv.FormatInt(typedVal, 10) + case float64: + s = strconv.FormatFloat(typedVal, 'g', -1, 32) + case uint64: + s = strconv.FormatUint(typedVal, 10) + case bool: + if typedVal { + s = "true" + } else { + s = "false" + } + } + if len(s) > 0 { + yamlObj = interface{}(s) + } + } + return yamlObj, nil + } + + return nil, nil +} diff --git a/Godeps/_workspace/src/github.com/go-ini/ini/README.md b/Godeps/_workspace/src/github.com/go-ini/ini/README.md index 1272038a9..5d7f1c710 100644 --- a/Godeps/_workspace/src/github.com/go-ini/ini/README.md +++ b/Godeps/_workspace/src/github.com/go-ini/ini/README.md @@ -95,6 +95,12 @@ Same rule applies to key operations: key := cfg.Section("").Key("key name") ``` +To check if a key exists: + +```go +yes := cfg.Section("").HasKey("key name") +``` + To create a new key: ```go @@ -133,6 +139,18 @@ val := cfg.Section("").Key("key name").Validate(func(in string) string { }) ``` +If you do not want any auto-transformation (such as recursive read) for the values, you can get raw value directly (this way you get much better performance): + +```go +val := cfg.Section("").Key("key name").Value() +``` + +To check if raw value exists: + +```go +yes := cfg.Section("").HasValue("test value") +``` + To get value with types: ```go @@ -464,7 +482,7 @@ type Info struct { } func main() { - err = ini.MapToWithMapper(&Info{}, ini.TitleUnderscore, []byte("packag_name=ini")) + err = ini.MapToWithMapper(&Info{}, ini.TitleUnderscore, []byte("package_name=ini")) // ... cfg, err := ini.Load([]byte("PACKAGE_NAME=ini")) diff --git a/Godeps/_workspace/src/github.com/go-ini/ini/README_ZH.md b/Godeps/_workspace/src/github.com/go-ini/ini/README_ZH.md index 45e19eddd..acda259be 100644 --- a/Godeps/_workspace/src/github.com/go-ini/ini/README_ZH.md +++ b/Godeps/_workspace/src/github.com/go-ini/ini/README_ZH.md @@ -88,6 +88,12 @@ key, err := cfg.Section("").GetKey("key name") key := cfg.Section("").Key("key name") ``` +判断某个键是否存在: + +```go +yes := cfg.Section("").HasKey("key name") +``` + 创建一个新的键: ```go @@ -126,6 +132,18 @@ val := cfg.Section("").Key("key name").Validate(func(in string) string { }) ``` +如果您不需要任何对值的自动转变功能(例如递归读取),可以直接获取原值(这种方式性能最佳): + +```go +val := cfg.Section("").Key("key name").Value() +``` + +判断某个原值是否存在: + +```go +yes := cfg.Section("").HasValue("test value") +``` + 获取其它类型的值: ```go @@ -455,7 +473,7 @@ type Info struct{ } func main() { - err = ini.MapToWithMapper(&Info{}, ini.TitleUnderscore, []byte("packag_name=ini")) + err = ini.MapToWithMapper(&Info{}, ini.TitleUnderscore, []byte("package_name=ini")) // ... cfg, err := ini.Load([]byte("PACKAGE_NAME=ini")) diff --git a/Godeps/_workspace/src/github.com/go-ini/ini/ini.go b/Godeps/_workspace/src/github.com/go-ini/ini/ini.go index 1fee789a1..a8d21739f 100644 --- a/Godeps/_workspace/src/github.com/go-ini/ini/ini.go +++ b/Godeps/_workspace/src/github.com/go-ini/ini/ini.go @@ -35,7 +35,7 @@ const ( // Maximum allowed depth when recursively substituing variable names. _DEPTH_VALUES = 99 - _VERSION = "1.6.0" + _VERSION = "1.7.0" ) func Version() string { @@ -618,6 +618,27 @@ func (s *Section) GetKey(name string) (*Key, error) { return key, nil } +// HasKey returns true if section contains a key with given name. +func (s *Section) Haskey(name string) bool { + key, _ := s.GetKey(name) + return key != nil +} + +// HasKey returns true if section contains given raw value. +func (s *Section) HasValue(value string) bool { + if s.f.BlockMode { + s.f.lock.RLock() + defer s.f.lock.RUnlock() + } + + for _, k := range s.keys { + if value == k.value { + return true + } + } + return false +} + // Key assumes named Key exists in section and returns a zero-value when not. func (s *Section) Key(name string) *Key { key, err := s.GetKey(name) @@ -737,7 +758,10 @@ func Load(source interface{}, others ...interface{}) (_ *File, err error) { } } f := newFile(sources) - return f, f.Reload() + if err = f.Reload(); err != nil { + return nil, err + } + return f, nil } // Empty returns an empty file object. diff --git a/Godeps/_workspace/src/github.com/go-ldap/ldap/filter.go b/Godeps/_workspace/src/github.com/go-ldap/ldap/filter.go index 2c1bc38e8..63bcec1e3 100644 --- a/Godeps/_workspace/src/github.com/go-ldap/ldap/filter.go +++ b/Godeps/_workspace/src/github.com/go-ldap/ldap/filter.go @@ -53,6 +53,20 @@ var FilterSubstringsMap = map[uint64]string{ FilterSubstringsFinal: "Substrings Final", } +const ( + MatchingRuleAssertionMatchingRule = 1 + MatchingRuleAssertionType = 2 + MatchingRuleAssertionMatchValue = 3 + MatchingRuleAssertionDNAttributes = 4 +) + +var MatchingRuleAssertionMap = map[uint64]string{ + MatchingRuleAssertionMatchingRule: "Matching Rule Assertion Matching Rule", + MatchingRuleAssertionType: "Matching Rule Assertion Type", + MatchingRuleAssertionMatchValue: "Matching Rule Assertion Match Value", + MatchingRuleAssertionDNAttributes: "Matching Rule Assertion DN Attributes", +} + func CompileFilter(filter string) (*ber.Packet, error) { if len(filter) == 0 || filter[0] != '(' { return nil, NewError(ErrorFilterCompile, errors.New("ldap: filter does not start with an '('")) @@ -111,7 +125,7 @@ func DecompileFilter(packet *ber.Packet) (ret string, err error) { if i == 0 && child.Tag != FilterSubstringsInitial { ret += "*" } - ret += ber.DecodeString(child.Data.Bytes()) + ret += EscapeFilter(ber.DecodeString(child.Data.Bytes())) if child.Tag != FilterSubstringsFinal { ret += "*" } @@ -135,6 +149,37 @@ func DecompileFilter(packet *ber.Packet) (ret string, err error) { ret += ber.DecodeString(packet.Children[0].Data.Bytes()) ret += "~=" ret += EscapeFilter(ber.DecodeString(packet.Children[1].Data.Bytes())) + case FilterExtensibleMatch: + attr := "" + dnAttributes := false + matchingRule := "" + value := "" + + for _, child := range packet.Children { + switch child.Tag { + case MatchingRuleAssertionMatchingRule: + matchingRule = ber.DecodeString(child.Data.Bytes()) + case MatchingRuleAssertionType: + attr = ber.DecodeString(child.Data.Bytes()) + case MatchingRuleAssertionMatchValue: + value = ber.DecodeString(child.Data.Bytes()) + case MatchingRuleAssertionDNAttributes: + dnAttributes = child.Value.(bool) + } + } + + if len(attr) > 0 { + ret += attr + } + if dnAttributes { + ret += ":dn" + } + if len(matchingRule) > 0 { + ret += ":" + ret += matchingRule + } + ret += ":=" + ret += EscapeFilter(value) } ret += ")" @@ -194,10 +239,20 @@ func compileFilter(filter string, pos int) (*ber.Packet, int, error) { packet.AppendChild(child) return packet, newPos, err default: + READING_ATTR := 0 + READING_EXTENSIBLE_MATCHING_RULE := 1 + READING_CONDITION := 2 + + state := READING_ATTR + attribute := "" + extensibleDNAttributes := false + extensibleMatchingRule := "" condition := "" + for newPos < len(filter) { - currentRune, currentWidth = utf8.DecodeRuneInString(filter[newPos:]) + remainingFilter := filter[newPos:] + currentRune, currentWidth = utf8.DecodeRuneInString(remainingFilter) if currentRune == ')' { break } @@ -205,27 +260,86 @@ func compileFilter(filter string, pos int) (*ber.Packet, int, error) { return packet, newPos, NewError(ErrorFilterCompile, fmt.Errorf("ldap: error reading rune at position %d", newPos)) } - nextRune, nextWidth := utf8.DecodeRuneInString(filter[newPos+currentWidth:]) + switch state { + case READING_ATTR: + switch { + // Extensible rule, with only DN-matching + case currentRune == ':' && strings.HasPrefix(remainingFilter, ":dn:="): + packet = ber.Encode(ber.ClassContext, ber.TypeConstructed, FilterExtensibleMatch, nil, FilterMap[FilterExtensibleMatch]) + extensibleDNAttributes = true + state = READING_CONDITION + newPos += 5 - switch { - case packet != nil: + // Extensible rule, with DN-matching and a matching OID + case currentRune == ':' && strings.HasPrefix(remainingFilter, ":dn:"): + packet = ber.Encode(ber.ClassContext, ber.TypeConstructed, FilterExtensibleMatch, nil, FilterMap[FilterExtensibleMatch]) + extensibleDNAttributes = true + state = READING_EXTENSIBLE_MATCHING_RULE + newPos += 4 + + // Extensible rule, with attr only + case currentRune == ':' && strings.HasPrefix(remainingFilter, ":="): + packet = ber.Encode(ber.ClassContext, ber.TypeConstructed, FilterExtensibleMatch, nil, FilterMap[FilterExtensibleMatch]) + state = READING_CONDITION + newPos += 2 + + // Extensible rule, with no DN attribute matching + case currentRune == ':': + packet = ber.Encode(ber.ClassContext, ber.TypeConstructed, FilterExtensibleMatch, nil, FilterMap[FilterExtensibleMatch]) + state = READING_EXTENSIBLE_MATCHING_RULE + newPos += 1 + + // Equality condition + case currentRune == '=': + packet = ber.Encode(ber.ClassContext, ber.TypeConstructed, FilterEqualityMatch, nil, FilterMap[FilterEqualityMatch]) + state = READING_CONDITION + newPos += 1 + + // Greater-than or equal + case currentRune == '>' && strings.HasPrefix(remainingFilter, ">="): + packet = ber.Encode(ber.ClassContext, ber.TypeConstructed, FilterGreaterOrEqual, nil, FilterMap[FilterGreaterOrEqual]) + state = READING_CONDITION + newPos += 2 + + // Less-than or equal + case currentRune == '<' && strings.HasPrefix(remainingFilter, "<="): + packet = ber.Encode(ber.ClassContext, ber.TypeConstructed, FilterLessOrEqual, nil, FilterMap[FilterLessOrEqual]) + state = READING_CONDITION + newPos += 2 + + // Approx + case currentRune == '~' && strings.HasPrefix(remainingFilter, "~="): + packet = ber.Encode(ber.ClassContext, ber.TypeConstructed, FilterApproxMatch, nil, FilterMap[FilterApproxMatch]) + state = READING_CONDITION + newPos += 2 + + // Still reading the attribute name + default: + attribute += fmt.Sprintf("%c", currentRune) + newPos += currentWidth + } + + case READING_EXTENSIBLE_MATCHING_RULE: + switch { + + // Matching rule OID is done + case currentRune == ':' && strings.HasPrefix(remainingFilter, ":="): + state = READING_CONDITION + newPos += 2 + + // Still reading the matching rule oid + default: + extensibleMatchingRule += fmt.Sprintf("%c", currentRune) + newPos += currentWidth + } + + case READING_CONDITION: + // append to the condition condition += fmt.Sprintf("%c", currentRune) - case currentRune == '=': - packet = ber.Encode(ber.ClassContext, ber.TypeConstructed, FilterEqualityMatch, nil, FilterMap[FilterEqualityMatch]) - case currentRune == '>' && nextRune == '=': - packet = ber.Encode(ber.ClassContext, ber.TypeConstructed, FilterGreaterOrEqual, nil, FilterMap[FilterGreaterOrEqual]) - newPos += nextWidth // we're skipping the next character as well - case currentRune == '<' && nextRune == '=': - packet = ber.Encode(ber.ClassContext, ber.TypeConstructed, FilterLessOrEqual, nil, FilterMap[FilterLessOrEqual]) - newPos += nextWidth // we're skipping the next character as well - case currentRune == '~' && nextRune == '=': - packet = ber.Encode(ber.ClassContext, ber.TypeConstructed, FilterApproxMatch, nil, FilterMap[FilterLessOrEqual]) - newPos += nextWidth // we're skipping the next character as well - case packet == nil: - attribute += fmt.Sprintf("%c", currentRune) + newPos += currentWidth } - newPos += currentWidth } + if newPos == len(filter) { err = NewError(ErrorFilterCompile, errors.New("ldap: unexpected end of filter")) return packet, newPos, err @@ -236,6 +350,36 @@ func compileFilter(filter string, pos int) (*ber.Packet, int, error) { } switch { + case packet.Tag == FilterExtensibleMatch: + // MatchingRuleAssertion ::= SEQUENCE { + // matchingRule [1] MatchingRuleID OPTIONAL, + // type [2] AttributeDescription OPTIONAL, + // matchValue [3] AssertionValue, + // dnAttributes [4] BOOLEAN DEFAULT FALSE + // } + + // Include the matching rule oid, if specified + if len(extensibleMatchingRule) > 0 { + packet.AppendChild(ber.NewString(ber.ClassContext, ber.TypePrimitive, MatchingRuleAssertionMatchingRule, extensibleMatchingRule, MatchingRuleAssertionMap[MatchingRuleAssertionMatchingRule])) + } + + // Include the attribute, if specified + if len(attribute) > 0 { + packet.AppendChild(ber.NewString(ber.ClassContext, ber.TypePrimitive, MatchingRuleAssertionType, attribute, MatchingRuleAssertionMap[MatchingRuleAssertionType])) + } + + // Add the value (only required child) + encodedString, err := escapedStringToEncodedBytes(condition) + if err != nil { + return packet, newPos, err + } + packet.AppendChild(ber.NewString(ber.ClassContext, ber.TypePrimitive, MatchingRuleAssertionMatchValue, encodedString, MatchingRuleAssertionMap[MatchingRuleAssertionMatchValue])) + + // Defaults to false, so only include in the sequence if true + if extensibleDNAttributes { + packet.AppendChild(ber.NewBoolean(ber.ClassContext, ber.TypePrimitive, MatchingRuleAssertionDNAttributes, extensibleDNAttributes, MatchingRuleAssertionMap[MatchingRuleAssertionDNAttributes])) + } + case packet.Tag == FilterEqualityMatch && condition == "*": packet = ber.NewString(ber.ClassContext, ber.TypePrimitive, FilterPresent, attribute, FilterMap[FilterPresent]) case packet.Tag == FilterEqualityMatch && strings.Contains(condition, "*"): @@ -257,38 +401,56 @@ func compileFilter(filter string, pos int) (*ber.Packet, int, error) { default: tag = FilterSubstringsAny } - seq.AppendChild(ber.NewString(ber.ClassContext, ber.TypePrimitive, tag, part, FilterSubstringsMap[uint64(tag)])) + encodedString, err := escapedStringToEncodedBytes(part) + if err != nil { + return packet, newPos, err + } + seq.AppendChild(ber.NewString(ber.ClassContext, ber.TypePrimitive, tag, encodedString, FilterSubstringsMap[uint64(tag)])) } packet.AppendChild(seq) default: - var buffer bytes.Buffer - for i := 0; i < len(condition); i++ { - // Check for escaped hex characters and convert them to their literal value for transport. - if condition[i] == '\\' { - // http://tools.ietf.org/search/rfc4515 - // \ (%x5C) is not a valid character unless it is followed by two HEX characters due to not - // being a member of UTF1SUBSET. - if i+2 > len(condition) { - err = NewError(ErrorFilterCompile, errors.New("ldap: missing characters for escape in filter")) - return packet, newPos, err - } - if escByte, decodeErr := hexpac.DecodeString(condition[i+1 : i+3]); decodeErr != nil { - err = NewError(ErrorFilterCompile, errors.New("ldap: invalid characters for escape in filter")) - return packet, newPos, err - } else { - buffer.WriteByte(escByte[0]) - i += 2 // +1 from end of loop, so 3 total for \xx. - } - } else { - buffer.WriteString(string(condition[i])) - } + encodedString, err := escapedStringToEncodedBytes(condition) + if err != nil { + return packet, newPos, err } - packet.AppendChild(ber.NewString(ber.ClassUniversal, ber.TypePrimitive, ber.TagOctetString, attribute, "Attribute")) - packet.AppendChild(ber.NewString(ber.ClassUniversal, ber.TypePrimitive, ber.TagOctetString, buffer.String(), "Condition")) + packet.AppendChild(ber.NewString(ber.ClassUniversal, ber.TypePrimitive, ber.TagOctetString, encodedString, "Condition")) } newPos += currentWidth return packet, newPos, err } } + +// Convert from "ABC\xx\xx\xx" form to literal bytes for transport +func escapedStringToEncodedBytes(escapedString string) (string, error) { + var buffer bytes.Buffer + i := 0 + for i < len(escapedString) { + currentRune, currentWidth := utf8.DecodeRuneInString(escapedString[i:]) + if currentRune == utf8.RuneError { + return "", NewError(ErrorFilterCompile, fmt.Errorf("ldap: error reading rune at position %d", i)) + } + + // Check for escaped hex characters and convert them to their literal value for transport. + if currentRune == '\\' { + // http://tools.ietf.org/search/rfc4515 + // \ (%x5C) is not a valid character unless it is followed by two HEX characters due to not + // being a member of UTF1SUBSET. + if i+2 > len(escapedString) { + return "", NewError(ErrorFilterCompile, errors.New("ldap: missing characters for escape in filter")) + } + if escByte, decodeErr := hexpac.DecodeString(escapedString[i+1 : i+3]); decodeErr != nil { + return "", NewError(ErrorFilterCompile, errors.New("ldap: invalid characters for escape in filter")) + } else { + buffer.WriteByte(escByte[0]) + i += 2 // +1 from end of loop, so 3 total for \xx. + } + } else { + buffer.WriteRune(currentRune) + } + + i += currentWidth + } + return buffer.String(), nil +} diff --git a/Godeps/_workspace/src/github.com/gocql/gocql/AUTHORS b/Godeps/_workspace/src/github.com/gocql/gocql/AUTHORS index 9f821548c..18cc932a9 100644 --- a/Godeps/_workspace/src/github.com/gocql/gocql/AUTHORS +++ b/Godeps/_workspace/src/github.com/gocql/gocql/AUTHORS @@ -57,4 +57,7 @@ Adrien Bustany Andrey Smirnov Adam Weiner Daniel Cannon -Johnny Bergström \ No newline at end of file +Johnny Bergström +Adriano Orioli +Claudiu Raveica +Artem Chernyshev diff --git a/Godeps/_workspace/src/github.com/gocql/gocql/cluster.go b/Godeps/_workspace/src/github.com/gocql/gocql/cluster.go index 1dfedb636..4fe85d434 100644 --- a/Godeps/_workspace/src/github.com/gocql/gocql/cluster.go +++ b/Godeps/_workspace/src/github.com/gocql/gocql/cluster.go @@ -9,7 +9,7 @@ import ( "sync" "time" - "github.com/gocql/gocql/lru" + "github.com/gocql/gocql/internal/lru" ) const defaultMaxPreparedStmts = 1000 @@ -89,7 +89,6 @@ type ClusterConfig struct { Port int // port (default: 9042) Keyspace string // initial keyspace (optional) NumConns int // number of connections per host (default: 2) - NumStreams int // number of streams per connection (default: max per protocol, either 128 or 32768) Consistency Consistency // default consistency level (default: Quorum) Compressor Compressor // compression algorithm (default: nil) Authenticator Authenticator // authenticator (default: nil) diff --git a/Godeps/_workspace/src/github.com/gocql/gocql/conn.go b/Godeps/_workspace/src/github.com/gocql/gocql/conn.go index 046451bef..9e1e3cae4 100644 --- a/Godeps/_workspace/src/github.com/gocql/gocql/conn.go +++ b/Godeps/_workspace/src/github.com/gocql/gocql/conn.go @@ -18,8 +18,26 @@ import ( "sync" "sync/atomic" "time" + + "github.com/gocql/gocql/internal/streams" ) +var ( + approvedAuthenticators = [...]string{ + "org.apache.cassandra.auth.PasswordAuthenticator", + "com.instaclustr.cassandra.auth.SharedSecretAuthenticator", + } +) + +func approve(authenticator string) bool { + for _, s := range approvedAuthenticators { + if authenticator == s { + return true + } + } + return false +} + //JoinHostPort is a utility to return a address string that can be used //gocql.Conn to form a connection with a host. func JoinHostPort(addr string, port int) string { @@ -41,7 +59,7 @@ type PasswordAuthenticator struct { } func (p PasswordAuthenticator) Challenge(req []byte) ([]byte, Authenticator, error) { - if string(req) != "org.apache.cassandra.auth.PasswordAuthenticator" { + if !approve(string(req)) { return nil, nil, fmt.Errorf("unexpected authenticator %q", req) } resp := make([]byte, 2+len(p.Username)+len(p.Password)) @@ -75,7 +93,6 @@ type ConnConfig struct { ProtoVersion int CQLVersion string Timeout time.Duration - NumStreams int Compressor Compressor Authenticator Authenticator Keepalive time.Duration @@ -103,8 +120,9 @@ type Conn struct { headerBuf []byte - uniq chan int - calls []callReq + streams *streams.IDGenerator + mu sync.RWMutex + calls map[int]*callReq errorHandler ConnErrorHandler compressor Compressor @@ -153,26 +171,15 @@ func Connect(addr string, cfg *ConnConfig, errorHandler ConnErrorHandler, sessio } headerSize := 8 - - maxStreams := 128 if cfg.ProtoVersion > protoVersion2 { - maxStreams = 32768 headerSize = 9 } - streams := cfg.NumStreams - if streams <= 0 || streams >= maxStreams { - streams = maxStreams - } else { - streams++ - } - c := &Conn{ conn: conn, r: bufio.NewReader(conn), cfg: cfg, - uniq: make(chan int, streams), - calls: make([]callReq, streams), + calls: make(map[int]*callReq), timeout: cfg.Timeout, version: uint8(cfg.ProtoVersion), addr: conn.RemoteAddr().String(), @@ -182,19 +189,13 @@ func Connect(addr string, cfg *ConnConfig, errorHandler ConnErrorHandler, sessio headerBuf: make([]byte, headerSize), quit: make(chan struct{}), session: session, + streams: streams.New(cfg.ProtoVersion), } if cfg.Keepalive > 0 { c.setKeepalive(cfg.Keepalive) } - // reserve stream 0 incase cassandra returns an error on it without us sending - // a request. - for i := 1; i < streams; i++ { - c.calls[i].resp = make(chan error) - c.uniq <- i - } - go c.serve() if err := c.startup(); err != nil { @@ -324,8 +325,8 @@ func (c *Conn) closeWithError(err error) { if err != nil { // we should attempt to deliver the error back to the caller if it // exists - for id := 0; id < len(c.calls); id++ { - req := &c.calls[id] + c.mu.RLock() + for _, req := range c.calls { // we need to send the error to all waiting queries, put the state // of this conn into not active so that it can not execute any queries. if err != nil { @@ -335,6 +336,7 @@ func (c *Conn) closeWithError(err error) { } } } + c.mu.RUnlock() } // if error was nil then unblock the quit channel @@ -391,7 +393,7 @@ func (c *Conn) recv() error { return err } - if head.stream > len(c.calls) { + if head.stream > c.streams.NumStreams { return fmt.Errorf("gocql: frame header stream is beyond call exepected bounds: %d", head.stream) } else if head.stream == -1 { // TODO: handle cassandra event frames, we shouldnt get any currently @@ -418,8 +420,10 @@ func (c *Conn) recv() error { } } - call := &c.calls[head.stream] - if call == nil || call.framer == nil { + c.mu.RLock() + call, ok := c.calls[head.stream] + c.mu.RUnlock() + if call == nil || call.framer == nil || !ok { log.Printf("gocql: received response for stream which has no handler: header=%v\n", head) return c.discardFrame(head) } @@ -447,19 +451,25 @@ func (c *Conn) recv() error { type callReq struct { // could use a waitgroup but this allows us to do timeouts on the read/send - resp chan error - framer *framer - timeout chan struct{} // indicates to recv() that a call has timedout + resp chan error + framer *framer + timeout chan struct{} // indicates to recv() that a call has timedout + streamID int // current stream in use } func (c *Conn) releaseStream(stream int) { - call := &c.calls[stream] - call.framer = nil - - select { - case c.uniq <- stream: - case <-c.quit: + c.mu.Lock() + call := c.calls[stream] + if call != nil && stream != call.streamID { + panic(fmt.Sprintf("attempt to release streamID with ivalid stream: %d -> %+v\n", stream, call)) + } else if call == nil { + panic(fmt.Sprintf("releasing a stream not in use: %d", stream)) } + delete(c.calls, stream) + c.mu.Unlock() + + streamPool.Put(call) + c.streams.Clear(stream) } func (c *Conn) handleTimeout() { @@ -468,20 +478,41 @@ func (c *Conn) handleTimeout() { } } +var ( + streamPool = sync.Pool{ + New: func() interface{} { + return &callReq{ + resp: make(chan error), + } + }, + } +) + func (c *Conn) exec(req frameWriter, tracer Tracer) (*framer, error) { // TODO: move tracer onto conn - var stream int - select { - case stream = <-c.uniq: - case <-c.quit: - return nil, ErrConnectionClosed + stream, ok := c.streams.GetStream() + if !ok { + fmt.Println(c.streams) + return nil, ErrNoStreams } // resp is basically a waiting semaphore protecting the framer framer := newFramer(c, c, c.compressor, c.version) - call := &c.calls[stream] + + c.mu.Lock() + call := c.calls[stream] + if call != nil { + c.mu.Unlock() + return nil, fmt.Errorf("attempting to use stream already in use: %d -> %d", stream, call.streamID) + } else { + call = streamPool.Get().(*callReq) + } + c.calls[stream] = call + c.mu.Unlock() + call.framer = framer call.timeout = make(chan struct{}) + call.streamID = stream if tracer != nil { framer.trace() @@ -749,7 +780,7 @@ func (c *Conn) Address() string { } func (c *Conn) AvailableStreams() int { - return len(c.uniq) + return c.streams.Available() } func (c *Conn) UseKeyspace(keyspace string) error { @@ -961,4 +992,5 @@ var ( ErrTimeoutNoResponse = errors.New("gocql: no response received from cassandra within timeout period") ErrTooManyTimeouts = errors.New("gocql: too many query timeouts on the connection") ErrConnectionClosed = errors.New("gocql: connection closed waiting for response") + ErrNoStreams = errors.New("gocql: no streams available on connection") ) diff --git a/Godeps/_workspace/src/github.com/gocql/gocql/connectionpool.go b/Godeps/_workspace/src/github.com/gocql/gocql/connectionpool.go index fa532c229..cacd4d570 100644 --- a/Godeps/_workspace/src/github.com/gocql/gocql/connectionpool.go +++ b/Godeps/_workspace/src/github.com/gocql/gocql/connectionpool.go @@ -97,7 +97,6 @@ func newPolicyConnPool(session *Session, hostPolicy HostSelectionPolicy, ProtoVersion: cfg.ProtoVersion, CQLVersion: cfg.CQLVersion, Timeout: cfg.Timeout, - NumStreams: cfg.NumStreams, Compressor: cfg.Compressor, Authenticator: cfg.Authenticator, Keepalive: cfg.SocketKeepalive, diff --git a/Godeps/_workspace/src/github.com/gocql/gocql/control.go b/Godeps/_workspace/src/github.com/gocql/gocql/control.go index fbb09bfab..bd12b936e 100644 --- a/Godeps/_workspace/src/github.com/gocql/gocql/control.go +++ b/Godeps/_workspace/src/github.com/gocql/gocql/control.go @@ -7,11 +7,14 @@ import ( "time" ) +// Ensure that the atomic variable is aligned to a 64bit boundary +// so that atomic operations can be applied on 32bit architectures. type controlConn struct { + connecting uint64 + session *Session conn atomic.Value - connecting uint64 retry RetryPolicy diff --git a/Godeps/_workspace/src/github.com/gocql/gocql/lru/lru.go b/Godeps/_workspace/src/github.com/gocql/gocql/internal/lru/lru.go similarity index 100% rename from Godeps/_workspace/src/github.com/gocql/gocql/lru/lru.go rename to Godeps/_workspace/src/github.com/gocql/gocql/internal/lru/lru.go diff --git a/Godeps/_workspace/src/github.com/gocql/gocql/murmur.go b/Godeps/_workspace/src/github.com/gocql/gocql/internal/murmur/murmur.go similarity index 97% rename from Godeps/_workspace/src/github.com/gocql/gocql/murmur.go rename to Godeps/_workspace/src/github.com/gocql/gocql/internal/murmur/murmur.go index eb287f5b4..8d28f145f 100644 --- a/Godeps/_workspace/src/github.com/gocql/gocql/murmur.go +++ b/Godeps/_workspace/src/github.com/gocql/gocql/internal/murmur/murmur.go @@ -1,12 +1,12 @@ // +build !appengine -package gocql +package murmur import ( "unsafe" ) -func murmur3H1(data []byte) uint64 { +func Murmur3H1(data []byte) uint64 { length := len(data) var h1, h2, k1, k2 uint64 diff --git a/Godeps/_workspace/src/github.com/gocql/gocql/murmur_appengine.go b/Godeps/_workspace/src/github.com/gocql/gocql/internal/murmur/murmur_appengine.go similarity index 97% rename from Godeps/_workspace/src/github.com/gocql/gocql/murmur_appengine.go rename to Godeps/_workspace/src/github.com/gocql/gocql/internal/murmur/murmur_appengine.go index 9899b425f..7396186e3 100644 --- a/Godeps/_workspace/src/github.com/gocql/gocql/murmur_appengine.go +++ b/Godeps/_workspace/src/github.com/gocql/gocql/internal/murmur/murmur_appengine.go @@ -1,10 +1,10 @@ // +build appengine -package gocql +package murmur import "encoding/binary" -func murmur3H1(data []byte) uint64 { +func Murmur3H1(data []byte) uint64 { length := len(data) var h1, h2, k1, k2 uint64 diff --git a/Godeps/_workspace/src/github.com/gocql/gocql/internal/streams/streams.go b/Godeps/_workspace/src/github.com/gocql/gocql/internal/streams/streams.go new file mode 100644 index 000000000..0d738a5c8 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gocql/gocql/internal/streams/streams.go @@ -0,0 +1,140 @@ +package streams + +import ( + "math" + "strconv" + "sync/atomic" +) + +const bucketBits = 64 + +// IDGenerator tracks and allocates streams which are in use. +type IDGenerator struct { + NumStreams int + inuseStreams int32 + numBuckets uint32 + + // streams is a bitset where each bit represents a stream, a 1 implies in use + streams []uint64 + offset uint32 +} + +func New(protocol int) *IDGenerator { + maxStreams := 128 + if protocol > 2 { + maxStreams = 32768 + } + + buckets := maxStreams / 64 + // reserve stream 0 + streams := make([]uint64, buckets) + streams[0] = 1 << 63 + + return &IDGenerator{ + NumStreams: maxStreams, + streams: streams, + numBuckets: uint32(buckets), + offset: uint32(buckets) - 1, + } +} + +func streamFromBucket(bucket, streamInBucket int) int { + return (bucket * bucketBits) + streamInBucket +} + +func (s *IDGenerator) GetStream() (int, bool) { + // based closely on the java-driver stream ID generator + // avoid false sharing subsequent requests. + offset := atomic.LoadUint32(&s.offset) + for !atomic.CompareAndSwapUint32(&s.offset, offset, (offset+1)%s.numBuckets) { + offset = atomic.LoadUint32(&s.offset) + } + offset = (offset + 1) % s.numBuckets + + for i := uint32(0); i < s.numBuckets; i++ { + pos := int((i + offset) % s.numBuckets) + + bucket := atomic.LoadUint64(&s.streams[pos]) + if bucket == math.MaxUint64 { + // all streams in use + continue + } + + for j := 0; j < bucketBits; j++ { + mask := uint64(1 << streamOffset(j)) + if bucket&mask == 0 { + if atomic.CompareAndSwapUint64(&s.streams[pos], bucket, bucket|mask) { + atomic.AddInt32(&s.inuseStreams, 1) + return streamFromBucket(int(pos), j), true + } + bucket = atomic.LoadUint64(&s.streams[offset]) + } + } + } + + return 0, false +} + +func bitfmt(b uint64) string { + return strconv.FormatUint(b, 16) +} + +// returns the bucket offset of a given stream +func bucketOffset(i int) int { + return i / bucketBits +} + +func streamOffset(stream int) uint64 { + return bucketBits - uint64(stream%bucketBits) - 1 +} + +func isSet(bits uint64, stream int) bool { + return bits>>streamOffset(stream)&1 == 1 +} + +func (s *IDGenerator) isSet(stream int) bool { + bits := atomic.LoadUint64(&s.streams[bucketOffset(stream)]) + return isSet(bits, stream) +} + +func (s *IDGenerator) String() string { + size := s.numBuckets * (bucketBits + 1) + buf := make([]byte, 0, size) + for i := 0; i < int(s.numBuckets); i++ { + bits := atomic.LoadUint64(&s.streams[i]) + buf = append(buf, bitfmt(bits)...) + buf = append(buf, ' ') + } + return string(buf[:size-1 : size-1]) +} + +func (s *IDGenerator) Clear(stream int) (inuse bool) { + offset := bucketOffset(stream) + bucket := atomic.LoadUint64(&s.streams[offset]) + + mask := uint64(1) << streamOffset(stream) + if bucket&mask != mask { + // already cleared + return false + } + + for !atomic.CompareAndSwapUint64(&s.streams[offset], bucket, bucket & ^mask) { + bucket = atomic.LoadUint64(&s.streams[offset]) + if bucket&mask != mask { + // already cleared + return false + } + } + + // TODO: make this account for 0 stream being reserved + if atomic.AddInt32(&s.inuseStreams, -1) < 0 { + // TODO(zariel): remove this + panic("negative streams inuse") + } + + return true +} + +func (s *IDGenerator) Available() int { + return s.NumStreams - int(atomic.LoadInt32(&s.inuseStreams)) - 1 +} diff --git a/Godeps/_workspace/src/github.com/gocql/gocql/policies.go b/Godeps/_workspace/src/github.com/gocql/gocql/policies.go index 8dde3368f..b21f18a5e 100644 --- a/Godeps/_workspace/src/github.com/gocql/gocql/policies.go +++ b/Godeps/_workspace/src/github.com/gocql/gocql/policies.go @@ -354,12 +354,20 @@ func (r *roundRobinConnPolicy) SetConns(conns []*Conn) { } func (r *roundRobinConnPolicy) Pick(qry *Query) *Conn { - pos := atomic.AddUint32(&r.pos, 1) - var conn *Conn + pos := int(atomic.AddUint32(&r.pos, 1) - 1) r.mu.RLock() - if len(r.conns) > 0 { - conn = r.conns[pos%uint32(len(r.conns))] + defer r.mu.RUnlock() + + if len(r.conns) == 0 { + return nil } - r.mu.RUnlock() - return conn + + for i := 0; i < len(r.conns); i++ { + conn := r.conns[(pos+i)%len(r.conns)] + if conn.AvailableStreams() > 0 { + return conn + } + } + + return nil } diff --git a/Godeps/_workspace/src/github.com/gocql/gocql/session.go b/Godeps/_workspace/src/github.com/gocql/gocql/session.go index f3117ea59..23e6a90bd 100644 --- a/Godeps/_workspace/src/github.com/gocql/gocql/session.go +++ b/Godeps/_workspace/src/github.com/gocql/gocql/session.go @@ -16,7 +16,7 @@ import ( "time" "unicode" - "github.com/gocql/gocql/lru" + "github.com/gocql/gocql/internal/lru" ) // Session is the interface used by users to interact with the database. @@ -54,15 +54,6 @@ func NewSession(cfg ClusterConfig) (*Session, error) { return nil, ErrNoHosts } - maxStreams := 128 - if cfg.ProtoVersion > protoVersion2 { - maxStreams = 32768 - } - - if cfg.NumStreams <= 0 || cfg.NumStreams > maxStreams { - cfg.NumStreams = maxStreams - } - //Adjust the size of the prepared statements cache to match the latest configuration stmtsLRU.Lock() initStmtsLRU(cfg.MaxPreparedStmts) @@ -893,6 +884,12 @@ func (iter *Iter) Close() error { return iter.err } +// WillSwitchPage detects if iterator reached end of current page +// and the next page is available. +func (iter *Iter) WillSwitchPage() bool { + return iter.pos >= len(iter.rows) && iter.next != nil +} + // checkErrAndNotFound handle error and NotFound in one method. func (iter *Iter) checkErrAndNotFound() error { if iter.err != nil { diff --git a/Godeps/_workspace/src/github.com/gocql/gocql/token.go b/Godeps/_workspace/src/github.com/gocql/gocql/token.go index d796683d3..97b96537c 100644 --- a/Godeps/_workspace/src/github.com/gocql/gocql/token.go +++ b/Godeps/_workspace/src/github.com/gocql/gocql/token.go @@ -12,6 +12,8 @@ import ( "sort" "strconv" "strings" + + "github.com/gocql/gocql/internal/murmur" ) // a token partitioner @@ -36,7 +38,7 @@ func (p murmur3Partitioner) Name() string { } func (p murmur3Partitioner) Hash(partitionKey []byte) token { - h1 := murmur3H1(partitionKey) + h1 := murmur.Murmur3H1(partitionKey) return murmur3Token(int64(h1)) } diff --git a/Godeps/_workspace/src/github.com/google/go-github/github/issues_events.go b/Godeps/_workspace/src/github.com/google/go-github/github/issues_events.go index b6292d821..9062d4da1 100644 --- a/Godeps/_workspace/src/github.com/google/go-github/github/issues_events.go +++ b/Godeps/_workspace/src/github.com/google/go-github/github/issues_events.go @@ -22,52 +22,52 @@ type IssueEvent struct { // values are: // // closed - // The issue was closed by the actor. When the commit_id is - // present, it identifies the commit that closed the issue using - // “closes / fixes #NN” syntax. - // - // reopened - // The issue was reopened by the actor. - // - // subscribed - // The actor subscribed to receive notifications for an issue. + // The Actor closed the issue. + // If the issue was closed by commit message, CommitID holds the SHA1 hash of the commit. // // merged - // The issue was merged by the actor. The commit_id attribute is the SHA1 of the HEAD commit that was merged. + // The Actor merged into master a branch containing a commit mentioning the issue. + // CommitID holds the SHA1 of the merge commit. // // referenced - // The issue was referenced from a commit message. The commit_id attribute is the commit SHA1 of where that happened. + // The Actor committed to master a commit mentioning the issue in its commit message. + // CommitID holds the SHA1 of the commit. // - // mentioned - // The actor was @mentioned in an issue body. - // - // assigned - // The issue was assigned to the actor. - // - // head_ref_deleted - // The pull request’s branch was deleted. - // - // head_ref_restored - // The pull request’s branch was restored. - // - // labeled - // A label was added. + // reopened, locked, unlocked + // The Actor did that to the issue. // // renamed - // The issue title was changed. + // The Actor changed the issue title from Rename.From to Rename.To. + // + // mentioned + // Someone unspecified @mentioned the Actor [sic] in an issue comment body. + // + // assigned, unassigned + // The Actor assigned the issue to or removed the assignment from the Assignee. + // + // labeled, unlabeled + // The Actor added or removed the Label from the issue. + // + // milestoned, demilestoned + // The Actor added or removed the issue from the Milestone. + // + // subscribed, unsubscribed + // The Actor subscribed to or unsubscribed from notifications for an issue. + // + // head_ref_deleted, head_ref_restored + // The pull request’s branch was deleted or restored. + // Event *string `json:"event,omitempty"` - // The SHA of the commit that referenced this commit, if applicable. - CommitID *string `json:"commit_id,omitempty"` - CreatedAt *time.Time `json:"created_at,omitempty"` Issue *Issue `json:"issue,omitempty"` - // Only present on 'labeled' events. - Label *Label `json:"label,omitempty"` - - // Only present on 'renamed' events. - Rename *Rename `json:"rename,omitempty"` + // Only present on certain events; see above. + Assignee *User `json:"assignee,omitempty"` + CommitID *string `json:"commit_id,omitempty"` + Milestone *Milestone `json:"milestone,omitempty"` + Label *Label `json:"label,omitempty"` + Rename *Rename `json:"rename,omitempty"` } // ListIssueEvents lists events for the specified issue. diff --git a/Godeps/_workspace/src/github.com/hashicorp/consul/api/README.md b/Godeps/_workspace/src/github.com/hashicorp/consul/api/README.md index 3b7c89ddb..6fcdd2033 100644 --- a/Godeps/_workspace/src/github.com/hashicorp/consul/api/README.md +++ b/Godeps/_workspace/src/github.com/hashicorp/consul/api/README.md @@ -4,7 +4,7 @@ Consul API client This package provides the `api` package which attempts to provide programmatic access to the full Consul API. -Currently, all of the Consul APIs included in version 0.3 are supported. +Currently, all of the Consul APIs included in version 0.6.0 are supported. Documentation ============= diff --git a/Godeps/_workspace/src/github.com/hashicorp/consul/api/agent.go b/Godeps/_workspace/src/github.com/hashicorp/consul/api/agent.go index 2b950d0a3..e4466a651 100644 --- a/Godeps/_workspace/src/github.com/hashicorp/consul/api/agent.go +++ b/Godeps/_workspace/src/github.com/hashicorp/consul/api/agent.go @@ -63,13 +63,15 @@ type AgentCheckRegistration struct { // AgentServiceCheck is used to create an associated // check for a service type AgentServiceCheck struct { - Script string `json:",omitempty"` - Interval string `json:",omitempty"` - Timeout string `json:",omitempty"` - TTL string `json:",omitempty"` - HTTP string `json:",omitempty"` - TCP string `json:",omitempty"` - Status string `json:",omitempty"` + Script string `json:",omitempty"` + DockerContainerID string `json:",omitempty"` + Shell string `json:",omitempty"` // Only supported for Docker. + Interval string `json:",omitempty"` + Timeout string `json:",omitempty"` + TTL string `json:",omitempty"` + HTTP string `json:",omitempty"` + TCP string `json:",omitempty"` + Status string `json:",omitempty"` } type AgentServiceChecks []*AgentServiceCheck diff --git a/Godeps/_workspace/src/github.com/hashicorp/consul/api/lock.go b/Godeps/_workspace/src/github.com/hashicorp/consul/api/lock.go index a76685f04..c1f6edf82 100644 --- a/Godeps/_workspace/src/github.com/hashicorp/consul/api/lock.go +++ b/Godeps/_workspace/src/github.com/hashicorp/consul/api/lock.go @@ -2,6 +2,7 @@ package api import ( "fmt" + "strings" "sync" "time" ) @@ -22,9 +23,15 @@ const ( // DefaultLockRetryTime is how long we wait after a failed lock acquisition // before attempting to do the lock again. This is so that once a lock-delay - // is in affect, we do not hot loop retrying the acquisition. + // is in effect, we do not hot loop retrying the acquisition. DefaultLockRetryTime = 5 * time.Second + // DefaultMonitorRetryTime is how long we wait after a failed monitor check + // of a lock (500 response code). This allows the monitor to ride out brief + // periods of unavailability, subject to the MonitorRetries setting in the + // lock options which is by default set to 0, disabling this feature. + DefaultMonitorRetryTime = 2 * time.Second + // LockFlagValue is a magic flag we set to indicate a key // is being used for a lock. It is used to detect a potential // conflict with a semaphore. @@ -62,11 +69,13 @@ type Lock struct { // LockOptions is used to parameterize the Lock behavior. type LockOptions struct { - Key string // Must be set and have write permissions - Value []byte // Optional, value to associate with the lock - Session string // Optional, created if not specified - SessionName string // Optional, defaults to DefaultLockSessionName - SessionTTL string // Optional, defaults to DefaultLockSessionTTL + Key string // Must be set and have write permissions + Value []byte // Optional, value to associate with the lock + Session string // Optional, created if not specified + SessionName string // Optional, defaults to DefaultLockSessionName + SessionTTL string // Optional, defaults to DefaultLockSessionTTL + MonitorRetries int // Optional, defaults to 0 which means no retries + MonitorRetryTime time.Duration // Optional, defaults to DefaultMonitorRetryTime } // LockKey returns a handle to a lock struct which can be used @@ -96,6 +105,9 @@ func (c *Client) LockOpts(opts *LockOptions) (*Lock, error) { return nil, fmt.Errorf("invalid SessionTTL: %v", err) } } + if opts.MonitorRetryTime == 0 { + opts.MonitorRetryTime = DefaultMonitorRetryTime + } l := &Lock{ c: c, opts: opts, @@ -327,8 +339,24 @@ func (l *Lock) monitorLock(session string, stopCh chan struct{}) { kv := l.c.KV() opts := &QueryOptions{RequireConsistent: true} WAIT: + retries := l.opts.MonitorRetries +RETRY: pair, meta, err := kv.Get(l.opts.Key, opts) if err != nil { + // TODO (slackpad) - Make a real error type here instead of using + // a string check. + const serverError = "Unexpected response code: 500" + + // If configured we can try to ride out a brief Consul unavailability + // by doing retries. Note that we have to attempt the retry in a non- + // blocking fashion so that we have a clean place to reset the retry + // counter if service is restored. + if retries > 0 && strings.Contains(err.Error(), serverError) { + time.Sleep(l.opts.MonitorRetryTime) + retries-- + opts.WaitIndex = 0 + goto RETRY + } return } if pair != nil && pair.Session == session { diff --git a/Godeps/_workspace/src/github.com/hashicorp/go-cleanhttp/cleanhttp.go b/Godeps/_workspace/src/github.com/hashicorp/go-cleanhttp/cleanhttp.go index 1676d79cb..c692e23f4 100644 --- a/Godeps/_workspace/src/github.com/hashicorp/go-cleanhttp/cleanhttp.go +++ b/Godeps/_workspace/src/github.com/hashicorp/go-cleanhttp/cleanhttp.go @@ -3,13 +3,14 @@ package cleanhttp import ( "net" "net/http" + "runtime" "time" ) // DefaultTransport returns a new http.Transport with the same default values // as http.DefaultTransport func DefaultTransport() *http.Transport { - return &http.Transport{ + transport := &http.Transport{ Proxy: http.ProxyFromEnvironment, Dial: (&net.Dialer{ Timeout: 30 * time.Second, @@ -17,6 +18,8 @@ func DefaultTransport() *http.Transport { }).Dial, TLSHandshakeTimeout: 10 * time.Second, } + SetTransportFinalizer(transport) + return transport } // DefaultClient returns a new http.Client with the same default values as @@ -26,3 +29,12 @@ func DefaultClient() *http.Client { Transport: DefaultTransport(), } } + +// SetTransportFinalizer sets a finalizer on the transport to ensure that +// idle connections are closed prior to garbage collection; otherwise +// these may leak +func SetTransportFinalizer(transport *http.Transport) { + runtime.SetFinalizer(&transport, func(t **http.Transport) { + (*t).CloseIdleConnections() + }) +} diff --git a/Godeps/_workspace/src/github.com/hashicorp/uuid/LICENSE b/Godeps/_workspace/src/github.com/hashicorp/go-uuid/LICENSE similarity index 100% rename from Godeps/_workspace/src/github.com/hashicorp/uuid/LICENSE rename to Godeps/_workspace/src/github.com/hashicorp/go-uuid/LICENSE diff --git a/Godeps/_workspace/src/github.com/hashicorp/uuid/README.md b/Godeps/_workspace/src/github.com/hashicorp/go-uuid/README.md similarity index 84% rename from Godeps/_workspace/src/github.com/hashicorp/uuid/README.md rename to Godeps/_workspace/src/github.com/hashicorp/go-uuid/README.md index 000d868f5..21fdda4ad 100644 --- a/Godeps/_workspace/src/github.com/hashicorp/uuid/README.md +++ b/Godeps/_workspace/src/github.com/hashicorp/go-uuid/README.md @@ -5,4 +5,4 @@ Generates UUID-format strings using purely high quality random bytes. Documentation ============= -The full documentation is available on [Godoc](http://godoc.org/github.com/hashicorp/uuid). +The full documentation is available on [Godoc](http://godoc.org/github.com/hashicorp/go-uuid). diff --git a/Godeps/_workspace/src/github.com/hashicorp/uuid/uuid.go b/Godeps/_workspace/src/github.com/hashicorp/go-uuid/uuid.go similarity index 100% rename from Godeps/_workspace/src/github.com/hashicorp/uuid/uuid.go rename to Godeps/_workspace/src/github.com/hashicorp/go-uuid/uuid.go diff --git a/Godeps/_workspace/src/github.com/hashicorp/golang-lru/2q.go b/Godeps/_workspace/src/github.com/hashicorp/golang-lru/2q.go new file mode 100644 index 000000000..fa5fc0556 --- /dev/null +++ b/Godeps/_workspace/src/github.com/hashicorp/golang-lru/2q.go @@ -0,0 +1,212 @@ +package lru + +import ( + "fmt" + "sync" + + "github.com/hashicorp/golang-lru/internal" +) + +const ( + // Default2QRecentRatio is the ratio of the 2Q cache dedicated + // to recently added entries that have only been accessed once. + Default2QRecentRatio = 0.25 + + // Default2QGhostEntries is the default ratio of ghost + // entries kept to track entries recently evicted + Default2QGhostEntries = 0.50 +) + +// TwoQueueCache is a thread-safe fixed size 2Q cache. +// 2Q is an enhancement over the standard LRU cache +// in that it tracks both frequently and recently used +// entries seperately. This avoids a burst in access to new +// entries from evicting frequently used entries. It adds some +// additional tracking overhead to the standard LRU cache, and is +// computationally about 2x the cost, and adds some metadata over +// head. The ARCCache is similar, but does not require setting any +// parameters. +type TwoQueueCache struct { + size int + recentSize int + + recent *internal.LRU + frequent *internal.LRU + recentEvict *internal.LRU + lock sync.RWMutex +} + +// New2Q creates a new TwoQueueCache using the default +// values for the parameters. +func New2Q(size int) (*TwoQueueCache, error) { + return New2QParams(size, Default2QRecentRatio, Default2QGhostEntries) +} + +// New2QParams creates a new TwoQueueCache using the provided +// parameter values. +func New2QParams(size int, recentRatio float64, ghostRatio float64) (*TwoQueueCache, error) { + if size <= 0 { + return nil, fmt.Errorf("invalid size") + } + if recentRatio < 0.0 || recentRatio > 1.0 { + return nil, fmt.Errorf("invalid recent ratio") + } + if ghostRatio < 0.0 || ghostRatio > 1.0 { + return nil, fmt.Errorf("invalid ghost ratio") + } + + // Determine the sub-sizes + recentSize := int(float64(size) * recentRatio) + evictSize := int(float64(size) * ghostRatio) + + // Allocate the LRUs + recent, err := internal.NewLRU(size, nil) + if err != nil { + return nil, err + } + frequent, err := internal.NewLRU(size, nil) + if err != nil { + return nil, err + } + recentEvict, err := internal.NewLRU(evictSize, nil) + if err != nil { + return nil, err + } + + // Initialize the cache + c := &TwoQueueCache{ + size: size, + recentSize: recentSize, + recent: recent, + frequent: frequent, + recentEvict: recentEvict, + } + return c, nil +} + +func (c *TwoQueueCache) Get(key interface{}) (interface{}, bool) { + c.lock.Lock() + defer c.lock.Unlock() + + // Check if this is a frequent value + if val, ok := c.frequent.Get(key); ok { + return val, ok + } + + // If the value is contained in recent, then we + // promote it to frequent + if val, ok := c.recent.Peek(key); ok { + c.recent.Remove(key) + c.frequent.Add(key, val) + return val, ok + } + + // No hit + return nil, false +} + +func (c *TwoQueueCache) Add(key, value interface{}) { + c.lock.Lock() + defer c.lock.Unlock() + + // Check if the value is frequently used already, + // and just update the value + if c.frequent.Contains(key) { + c.frequent.Add(key, value) + return + } + + // Check if the value is recently used, and promote + // the value into the frequent list + if c.recent.Contains(key) { + c.recent.Remove(key) + c.frequent.Add(key, value) + return + } + + // If the value was recently evicted, add it to the + // frequently used list + if c.recentEvict.Contains(key) { + c.ensureSpace(true) + c.recentEvict.Remove(key) + c.frequent.Add(key, value) + return + } + + // Add to the recently seen list + c.ensureSpace(false) + c.recent.Add(key, value) + return +} + +// ensureSpace is used to ensure we have space in the cache +func (c *TwoQueueCache) ensureSpace(recentEvict bool) { + // If we have space, nothing to do + recentLen := c.recent.Len() + freqLen := c.frequent.Len() + if recentLen+freqLen < c.size { + return + } + + // If the recent buffer is larger than + // the target, evict from there + if recentLen > 0 && (recentLen > c.recentSize || (recentLen == c.recentSize && !recentEvict)) { + k, _, _ := c.recent.RemoveOldest() + c.recentEvict.Add(k, nil) + return + } + + // Remove from the frequent list otherwise + c.frequent.RemoveOldest() +} + +func (c *TwoQueueCache) Len() int { + c.lock.RLock() + defer c.lock.RUnlock() + return c.recent.Len() + c.frequent.Len() +} + +func (c *TwoQueueCache) Keys() []interface{} { + c.lock.RLock() + defer c.lock.RUnlock() + k1 := c.frequent.Keys() + k2 := c.recent.Keys() + return append(k1, k2...) +} + +func (c *TwoQueueCache) Remove(key interface{}) { + c.lock.Lock() + defer c.lock.Unlock() + if c.frequent.Remove(key) { + return + } + if c.recent.Remove(key) { + return + } + if c.recentEvict.Remove(key) { + return + } +} + +func (c *TwoQueueCache) Purge() { + c.lock.Lock() + defer c.lock.Unlock() + c.recent.Purge() + c.frequent.Purge() + c.recentEvict.Purge() +} + +func (c *TwoQueueCache) Contains(key interface{}) bool { + c.lock.RLock() + defer c.lock.RUnlock() + return c.frequent.Contains(key) || c.recent.Contains(key) +} + +func (c *TwoQueueCache) Peek(key interface{}) (interface{}, bool) { + c.lock.RLock() + defer c.lock.RUnlock() + if val, ok := c.frequent.Peek(key); ok { + return val, ok + } + return c.recent.Peek(key) +} diff --git a/Godeps/_workspace/src/github.com/hashicorp/golang-lru/arc.go b/Godeps/_workspace/src/github.com/hashicorp/golang-lru/arc.go new file mode 100644 index 000000000..5fa8f25bb --- /dev/null +++ b/Godeps/_workspace/src/github.com/hashicorp/golang-lru/arc.go @@ -0,0 +1,257 @@ +package lru + +import ( + "sync" + + "github.com/hashicorp/golang-lru/internal" +) + +// ARCCache is a thread-safe fixed size Adaptive Replacement Cache (ARC). +// ARC is an enhancement over the standard LRU cache in that tracks both +// frequency and recency of use. This avoids a burst in access to new +// entries from evicting the frequently used older entries. It adds some +// additional tracking overhead to a standard LRU cache, computationally +// it is roughly 2x the cost, and the extra memory overhead is linear +// with the size of the cache. ARC has been patented by IBM, but is +// similar to the TwoQueueCache (2Q) which requires setting parameters. +type ARCCache struct { + size int // Size is the total capacity of the cache + p int // P is the dynamic preference towards T1 or T2 + + t1 *internal.LRU // T1 is the LRU for recently accessed items + b1 *internal.LRU // B1 is the LRU for evictions from t1 + + t2 *internal.LRU // T2 is the LRU for frequently accessed items + b2 *internal.LRU // B2 is the LRU for evictions from t2 + + lock sync.RWMutex +} + +// NewARC creates an ARC of the given size +func NewARC(size int) (*ARCCache, error) { + // Create the sub LRUs + b1, err := internal.NewLRU(size, nil) + if err != nil { + return nil, err + } + b2, err := internal.NewLRU(size, nil) + if err != nil { + return nil, err + } + t1, err := internal.NewLRU(size, nil) + if err != nil { + return nil, err + } + t2, err := internal.NewLRU(size, nil) + if err != nil { + return nil, err + } + + // Initialize the ARC + c := &ARCCache{ + size: size, + p: 0, + t1: t1, + b1: b1, + t2: t2, + b2: b2, + } + return c, nil +} + +// Get looks up a key's value from the cache. +func (c *ARCCache) Get(key interface{}) (interface{}, bool) { + c.lock.Lock() + defer c.lock.Unlock() + + // Ff the value is contained in T1 (recent), then + // promote it to T2 (frequent) + if val, ok := c.t1.Peek(key); ok { + c.t1.Remove(key) + c.t2.Add(key, val) + return val, ok + } + + // Check if the value is contained in T2 (frequent) + if val, ok := c.t2.Get(key); ok { + return val, ok + } + + // No hit + return nil, false +} + +// Add adds a value to the cache. +func (c *ARCCache) Add(key, value interface{}) { + c.lock.Lock() + defer c.lock.Unlock() + + // Check if the value is contained in T1 (recent), and potentially + // promote it to frequent T2 + if c.t1.Contains(key) { + c.t1.Remove(key) + c.t2.Add(key, value) + return + } + + // Check if the value is already in T2 (frequent) and update it + if c.t2.Contains(key) { + c.t2.Add(key, value) + return + } + + // Check if this value was recently evicted as part of the + // recently used list + if c.b1.Contains(key) { + // T1 set is too small, increase P appropriately + delta := 1 + b1Len := c.b1.Len() + b2Len := c.b2.Len() + if b2Len > b1Len { + delta = b2Len / b1Len + } + if c.p+delta >= c.size { + c.p = c.size + } else { + c.p += delta + } + + // Potentially need to make room in the cache + if c.t1.Len()+c.t2.Len() >= c.size { + c.replace(false) + } + + // Remove from B1 + c.b1.Remove(key) + + // Add the key to the frequently used list + c.t2.Add(key, value) + return + } + + // Check if this value was recently evicted as part of the + // frequently used list + if c.b2.Contains(key) { + // T2 set is too small, decrease P appropriately + delta := 1 + b1Len := c.b1.Len() + b2Len := c.b2.Len() + if b1Len > b2Len { + delta = b1Len / b2Len + } + if delta >= c.p { + c.p = 0 + } else { + c.p -= delta + } + + // Potentially need to make room in the cache + if c.t1.Len()+c.t2.Len() >= c.size { + c.replace(true) + } + + // Remove from B2 + c.b2.Remove(key) + + // Add the key to the frequntly used list + c.t2.Add(key, value) + return + } + + // Potentially need to make room in the cache + if c.t1.Len()+c.t2.Len() >= c.size { + c.replace(false) + } + + // Keep the size of the ghost buffers trim + if c.b1.Len() > c.size-c.p { + c.b1.RemoveOldest() + } + if c.b2.Len() > c.p { + c.b2.RemoveOldest() + } + + // Add to the recently seen list + c.t1.Add(key, value) + return +} + +// replace is used to adaptively evict from either T1 or T2 +// based on the current learned value of P +func (c *ARCCache) replace(b2ContainsKey bool) { + t1Len := c.t1.Len() + if t1Len > 0 && (t1Len > c.p || (t1Len == c.p && b2ContainsKey)) { + k, _, ok := c.t1.RemoveOldest() + if ok { + c.b1.Add(k, nil) + } + } else { + k, _, ok := c.t2.RemoveOldest() + if ok { + c.b2.Add(k, nil) + } + } +} + +// Len returns the number of cached entries +func (c *ARCCache) Len() int { + c.lock.RLock() + defer c.lock.RUnlock() + return c.t1.Len() + c.t2.Len() +} + +// Keys returns all the cached keys +func (c *ARCCache) Keys() []interface{} { + c.lock.RLock() + defer c.lock.RUnlock() + k1 := c.t1.Keys() + k2 := c.t2.Keys() + return append(k1, k2...) +} + +// Remove is used to purge a key from the cache +func (c *ARCCache) Remove(key interface{}) { + c.lock.Lock() + defer c.lock.Unlock() + if c.t1.Remove(key) { + return + } + if c.t2.Remove(key) { + return + } + if c.b1.Remove(key) { + return + } + if c.b2.Remove(key) { + return + } +} + +// Purge is used to clear the cache +func (c *ARCCache) Purge() { + c.lock.Lock() + defer c.lock.Unlock() + c.t1.Purge() + c.t2.Purge() + c.b1.Purge() + c.b2.Purge() +} + +// Contains is used to check if the cache contains a key +// without updating recency or frequency. +func (c *ARCCache) Contains(key interface{}) bool { + c.lock.RLock() + defer c.lock.RUnlock() + return c.t1.Contains(key) || c.t2.Contains(key) +} + +// Peek is used to inspect the cache value of a key +// without updating recency or frequency. +func (c *ARCCache) Peek(key interface{}) (interface{}, bool) { + c.lock.RLock() + defer c.lock.RUnlock() + if val, ok := c.t1.Peek(key); ok { + return val, ok + } + return c.t2.Peek(key) +} diff --git a/Godeps/_workspace/src/github.com/hashicorp/golang-lru/internal/lru.go b/Godeps/_workspace/src/github.com/hashicorp/golang-lru/internal/lru.go new file mode 100644 index 000000000..602ba2a9d --- /dev/null +++ b/Godeps/_workspace/src/github.com/hashicorp/golang-lru/internal/lru.go @@ -0,0 +1,160 @@ +package internal + +import ( + "container/list" + "errors" +) + +// EvictCallback is used to get a callback when a cache entry is evicted +type EvictCallback func(key interface{}, value interface{}) + +// LRU implements a non-thread safe fixed size LRU cache +type LRU struct { + size int + evictList *list.List + items map[interface{}]*list.Element + onEvict EvictCallback +} + +// entry is used to hold a value in the evictList +type entry struct { + key interface{} + value interface{} +} + +// NewLRU constructs an LRU of the given size +func NewLRU(size int, onEvict EvictCallback) (*LRU, error) { + if size <= 0 { + return nil, errors.New("Must provide a positive size") + } + c := &LRU{ + size: size, + evictList: list.New(), + items: make(map[interface{}]*list.Element), + onEvict: onEvict, + } + return c, nil +} + +// Purge is used to completely clear the cache +func (c *LRU) Purge() { + for k, v := range c.items { + if c.onEvict != nil { + c.onEvict(k, v.Value.(*entry).value) + } + delete(c.items, k) + } + c.evictList.Init() +} + +// Add adds a value to the cache. Returns true if an eviction occured. +func (c *LRU) Add(key, value interface{}) bool { + // Check for existing item + if ent, ok := c.items[key]; ok { + c.evictList.MoveToFront(ent) + ent.Value.(*entry).value = value + return false + } + + // Add new item + ent := &entry{key, value} + entry := c.evictList.PushFront(ent) + c.items[key] = entry + + evict := c.evictList.Len() > c.size + // Verify size not exceeded + if evict { + c.removeOldest() + } + return evict +} + +// Get looks up a key's value from the cache. +func (c *LRU) Get(key interface{}) (value interface{}, ok bool) { + if ent, ok := c.items[key]; ok { + c.evictList.MoveToFront(ent) + return ent.Value.(*entry).value, true + } + return +} + +// Check if a key is in the cache, without updating the recent-ness +// or deleting it for being stale. +func (c *LRU) Contains(key interface{}) (ok bool) { + _, ok = c.items[key] + return ok +} + +// Returns the key value (or undefined if not found) without updating +// the "recently used"-ness of the key. +func (c *LRU) Peek(key interface{}) (value interface{}, ok bool) { + if ent, ok := c.items[key]; ok { + return ent.Value.(*entry).value, true + } + return nil, ok +} + +// Remove removes the provided key from the cache, returning if the +// key was contained. +func (c *LRU) Remove(key interface{}) bool { + if ent, ok := c.items[key]; ok { + c.removeElement(ent) + return true + } + return false +} + +// RemoveOldest removes the oldest item from the cache. +func (c *LRU) RemoveOldest() (interface{}, interface{}, bool) { + ent := c.evictList.Back() + if ent != nil { + c.removeElement(ent) + kv := ent.Value.(*entry) + return kv.key, kv.value, true + } + return nil, nil, false +} + +// GetOldest returns the oldest entry +func (c *LRU) GetOldest() (interface{}, interface{}, bool) { + ent := c.evictList.Back() + if ent != nil { + kv := ent.Value.(*entry) + return kv.key, kv.value, true + } + return nil, nil, false +} + +// Keys returns a slice of the keys in the cache, from oldest to newest. +func (c *LRU) Keys() []interface{} { + keys := make([]interface{}, len(c.items)) + i := 0 + for ent := c.evictList.Back(); ent != nil; ent = ent.Prev() { + keys[i] = ent.Value.(*entry).key + i++ + } + return keys +} + +// Len returns the number of items in the cache. +func (c *LRU) Len() int { + return c.evictList.Len() +} + +// removeOldest removes the oldest item from the cache. +func (c *LRU) removeOldest() { + ent := c.evictList.Back() + if ent != nil { + c.removeElement(ent) + } +} + +// removeElement is used to remove a given list element from the cache +func (c *LRU) removeElement(e *list.Element) { + c.evictList.Remove(e) + kv := e.Value.(*entry) + delete(c.items, kv.key) + if c.onEvict != nil { + c.onEvict(kv.key, kv.value) + } +} diff --git a/Godeps/_workspace/src/github.com/hashicorp/golang-lru/lru.go b/Godeps/_workspace/src/github.com/hashicorp/golang-lru/lru.go index 694ea36fc..6af85a898 100644 --- a/Godeps/_workspace/src/github.com/hashicorp/golang-lru/lru.go +++ b/Godeps/_workspace/src/github.com/hashicorp/golang-lru/lru.go @@ -4,24 +4,15 @@ package lru import ( - "container/list" - "errors" "sync" + + "github.com/hashicorp/golang-lru/internal" ) // Cache is a thread-safe fixed size LRU cache. type Cache struct { - size int - evictList *list.List - items map[interface{}]*list.Element - lock sync.RWMutex - onEvicted func(key interface{}, value interface{}) -} - -// entry is used to hold a value in the evictList -type entry struct { - key interface{} - value interface{} + lru *internal.LRU + lock sync.RWMutex } // New creates an LRU of the given size @@ -29,15 +20,15 @@ func New(size int) (*Cache, error) { return NewWithEvict(size, nil) } +// NewWithEvict constructs a fixed size cache with the given eviction +// callback. func NewWithEvict(size int, onEvicted func(key interface{}, value interface{})) (*Cache, error) { - if size <= 0 { - return nil, errors.New("Must provide a positive size") + lru, err := internal.NewLRU(size, internal.EvictCallback(onEvicted)) + if err != nil { + return nil, err } c := &Cache{ - size: size, - evictList: list.New(), - items: make(map[interface{}]*list.Element), - onEvicted: onEvicted, + lru: lru, } return c, nil } @@ -45,155 +36,79 @@ func NewWithEvict(size int, onEvicted func(key interface{}, value interface{})) // Purge is used to completely clear the cache func (c *Cache) Purge() { c.lock.Lock() - defer c.lock.Unlock() - - for k, v := range c.items { - if c.onEvicted != nil { - c.onEvicted(k, v.Value.(*entry).value) - } - - delete(c.items, k) - } - - c.evictList.Init() + c.lru.Purge() + c.lock.Unlock() } // Add adds a value to the cache. Returns true if an eviction occured. func (c *Cache) Add(key, value interface{}) bool { c.lock.Lock() defer c.lock.Unlock() - - // Check for existing item - if ent, ok := c.items[key]; ok { - c.evictList.MoveToFront(ent) - ent.Value.(*entry).value = value - return false - } - - // Add new item - ent := &entry{key, value} - entry := c.evictList.PushFront(ent) - c.items[key] = entry - - evict := c.evictList.Len() > c.size - // Verify size not exceeded - if evict { - c.removeOldest() - } - return evict + return c.lru.Add(key, value) } // Get looks up a key's value from the cache. -func (c *Cache) Get(key interface{}) (value interface{}, ok bool) { +func (c *Cache) Get(key interface{}) (interface{}, bool) { c.lock.Lock() defer c.lock.Unlock() - - if ent, ok := c.items[key]; ok { - c.evictList.MoveToFront(ent) - return ent.Value.(*entry).value, true - } - return + return c.lru.Get(key) } -// Check if a key is in the cache, without updating the recent-ness or deleting it for being stale. -func (c *Cache) Contains(key interface{}) (ok bool) { +// Check if a key is in the cache, without updating the recent-ness +// or deleting it for being stale. +func (c *Cache) Contains(key interface{}) bool { c.lock.RLock() defer c.lock.RUnlock() - - _, ok = c.items[key] - return ok + return c.lru.Contains(key) } -// Returns the key value (or undefined if not found) without updating the "recently used"-ness of the key. -// (If you find yourself using this a lot, you might be using the wrong sort of data structure, but there are some use cases where it's handy.) -func (c *Cache) Peek(key interface{}) (value interface{}, ok bool) { +// Returns the key value (or undefined if not found) without updating +// the "recently used"-ness of the key. +func (c *Cache) Peek(key interface{}) (interface{}, bool) { c.lock.RLock() defer c.lock.RUnlock() - - if ent, ok := c.items[key]; ok { - return ent.Value.(*entry).value, true - } - return nil, ok + return c.lru.Peek(key) } -// ContainsOrAdd checks if a key is in the cache (without updating the recent-ness or deleting it for being stale), -// if not, adds the value. Returns whether found and whether an eviction occurred. +// ContainsOrAdd checks if a key is in the cache without updating the +// recent-ness or deleting it for being stale, and if not, adds the value. +// Returns whether found and whether an eviction occurred. func (c *Cache) ContainsOrAdd(key, value interface{}) (ok, evict bool) { c.lock.Lock() defer c.lock.Unlock() - _, ok = c.items[key] - if ok { + if c.lru.Contains(key) { return true, false + } else { + evict := c.lru.Add(key, value) + return false, evict } - - ent := &entry{key, value} - entry := c.evictList.PushFront(ent) - c.items[key] = entry - - evict = c.evictList.Len() > c.size - // Verify size not exceeded - if evict { - c.removeOldest() - } - return false, evict } // Remove removes the provided key from the cache. func (c *Cache) Remove(key interface{}) { c.lock.Lock() - defer c.lock.Unlock() - - if ent, ok := c.items[key]; ok { - c.removeElement(ent) - } + c.lru.Remove(key) + c.lock.Unlock() } // RemoveOldest removes the oldest item from the cache. func (c *Cache) RemoveOldest() { c.lock.Lock() - defer c.lock.Unlock() - c.removeOldest() + c.lru.RemoveOldest() + c.lock.Unlock() } // Keys returns a slice of the keys in the cache, from oldest to newest. func (c *Cache) Keys() []interface{} { c.lock.RLock() defer c.lock.RUnlock() - - keys := make([]interface{}, len(c.items)) - ent := c.evictList.Back() - i := 0 - for ent != nil { - keys[i] = ent.Value.(*entry).key - ent = ent.Prev() - i++ - } - - return keys + return c.lru.Keys() } // Len returns the number of items in the cache. func (c *Cache) Len() int { c.lock.RLock() defer c.lock.RUnlock() - return c.evictList.Len() -} - -// removeOldest removes the oldest item from the cache. -func (c *Cache) removeOldest() { - ent := c.evictList.Back() - if ent != nil { - c.removeElement(ent) - } -} - -// removeElement is used to remove a given list element from the cache -func (c *Cache) removeElement(e *list.Element) { - c.evictList.Remove(e) - kv := e.Value.(*entry) - delete(c.items, kv.key) - if c.onEvicted != nil { - c.onEvicted(kv.key, kv.value) - } + return c.lru.Len() } diff --git a/Godeps/_workspace/src/github.com/kardianos/osext/osext.go b/Godeps/_workspace/src/github.com/kardianos/osext/osext.go index 7bef46f03..c0de8b7f5 100644 --- a/Godeps/_workspace/src/github.com/kardianos/osext/osext.go +++ b/Godeps/_workspace/src/github.com/kardianos/osext/osext.go @@ -7,12 +7,18 @@ package osext import "path/filepath" +var cx, ce = executableClean() + +func executableClean() (string, error) { + p, err := executable() + return filepath.Clean(p), err +} + // Executable returns an absolute path that can be used to // re-invoke the current program. // It may not be valid after the current program exits. func Executable() (string, error) { - p, err := executable() - return filepath.Clean(p), err + return cx, ce } // Returns same path as Executable, returns just the folder diff --git a/Godeps/_workspace/src/github.com/kardianos/osext/osext_sysctl.go b/Godeps/_workspace/src/github.com/kardianos/osext/osext_sysctl.go index e19dd038e..66da0bcf9 100644 --- a/Godeps/_workspace/src/github.com/kardianos/osext/osext_sysctl.go +++ b/Godeps/_workspace/src/github.com/kardianos/osext/osext_sysctl.go @@ -53,30 +53,30 @@ func executable() (string, error) { // NULL terminated arguments. var args []string argv := uintptr(unsafe.Pointer(&buf[0])) - Loop: - for { - argp := *(**[1<<20]byte)(unsafe.Pointer(argv)) - if argp == nil { - break - } - for i := 0; uintptr(i) < n; i++ { - // we don't want the full arguments list - if string(argp[i]) == " " { - break Loop - } - if argp[i] != 0 { - continue - } - args = append(args, string(argp[:i])) - n -= uintptr(i) - break - } - if n < unsafe.Sizeof(argv) { - break - } - argv += unsafe.Sizeof(argv) - n -= unsafe.Sizeof(argv) + Loop: + for { + argp := *(**[1 << 20]byte)(unsafe.Pointer(argv)) + if argp == nil { + break } + for i := 0; uintptr(i) < n; i++ { + // we don't want the full arguments list + if string(argp[i]) == " " { + break Loop + } + if argp[i] != 0 { + continue + } + args = append(args, string(argp[:i])) + n -= uintptr(i) + break + } + if n < unsafe.Sizeof(argv) { + break + } + argv += unsafe.Sizeof(argv) + n -= unsafe.Sizeof(argv) + } execPath = args[0] // There is no canonical way to get an executable path on // OpenBSD, so check PATH in case we are called directly diff --git a/Godeps/_workspace/src/github.com/lib/pq/conn.go b/Godeps/_workspace/src/github.com/lib/pq/conn.go index ce661d66e..4af880fb5 100644 --- a/Godeps/_workspace/src/github.com/lib/pq/conn.go +++ b/Godeps/_workspace/src/github.com/lib/pq/conn.go @@ -557,13 +557,15 @@ func (cn *conn) simpleQuery(q string) (res *rows, err error) { cn.bad = true errorf("unexpected message %q in simple query execution", t) } - res = &rows{ - cn: cn, - colNames: st.colNames, - colTyps: st.colTyps, - colFmts: st.colFmts, - done: true, + if res == nil { + res = &rows{ + cn: cn, + colNames: st.colNames, + colTyps: st.colTyps, + colFmts: st.colFmts, + } } + res.done = true case 'Z': cn.processReadyForQuery(r) // done diff --git a/Godeps/_workspace/src/golang.org/x/crypto/ssh/kex.go b/Godeps/_workspace/src/golang.org/x/crypto/ssh/kex.go index ea19d537f..3ec603c0a 100644 --- a/Godeps/_workspace/src/golang.org/x/crypto/ssh/kex.go +++ b/Godeps/_workspace/src/golang.org/x/crypto/ssh/kex.go @@ -8,8 +8,8 @@ import ( "crypto" "crypto/ecdsa" "crypto/elliptic" - "crypto/subtle" "crypto/rand" + "crypto/subtle" "errors" "io" "math/big" diff --git a/Godeps/_workspace/src/gopkg.in/yaml.v2/LICENSE b/Godeps/_workspace/src/gopkg.in/yaml.v2/LICENSE new file mode 100644 index 000000000..a68e67f01 --- /dev/null +++ b/Godeps/_workspace/src/gopkg.in/yaml.v2/LICENSE @@ -0,0 +1,188 @@ + +Copyright (c) 2011-2014 - Canonical Inc. + +This software is licensed under the LGPLv3, included below. + +As a special exception to the GNU Lesser General Public License version 3 +("LGPL3"), the copyright holders of this Library give you permission to +convey to a third party a Combined Work that links statically or dynamically +to this Library without providing any Minimal Corresponding Source or +Minimal Application Code as set out in 4d or providing the installation +information set out in section 4e, provided that you comply with the other +provisions of LGPL3 and provided that you meet, for the Application the +terms and conditions of the license(s) which apply to the Application. + +Except as stated in this special exception, the provisions of LGPL3 will +continue to comply in full to this Library. If you modify this Library, you +may apply this exception to your version of this Library, but you are not +obliged to do so. If you do not wish to do so, delete this exception +statement from your version. This exception does not (and cannot) modify any +license terms which apply to the Application, with which you must still +comply. + + + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/Godeps/_workspace/src/gopkg.in/yaml.v2/LICENSE.libyaml b/Godeps/_workspace/src/gopkg.in/yaml.v2/LICENSE.libyaml new file mode 100644 index 000000000..8da58fbf6 --- /dev/null +++ b/Godeps/_workspace/src/gopkg.in/yaml.v2/LICENSE.libyaml @@ -0,0 +1,31 @@ +The following files were ported to Go from C files of libyaml, and thus +are still covered by their original copyright and license: + + apic.go + emitterc.go + parserc.go + readerc.go + scannerc.go + writerc.go + yamlh.go + yamlprivateh.go + +Copyright (c) 2006 Kirill Simonov + +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/Godeps/_workspace/src/gopkg.in/yaml.v2/README.md b/Godeps/_workspace/src/gopkg.in/yaml.v2/README.md new file mode 100644 index 000000000..7b8bd8670 --- /dev/null +++ b/Godeps/_workspace/src/gopkg.in/yaml.v2/README.md @@ -0,0 +1,131 @@ +# YAML support for the Go language + +Introduction +------------ + +The yaml package enables Go programs to comfortably encode and decode YAML +values. It was developed within [Canonical](https://www.canonical.com) as +part of the [juju](https://juju.ubuntu.com) project, and is based on a +pure Go port of the well-known [libyaml](http://pyyaml.org/wiki/LibYAML) +C library to parse and generate YAML data quickly and reliably. + +Compatibility +------------- + +The yaml package supports most of YAML 1.1 and 1.2, including support for +anchors, tags, map merging, etc. Multi-document unmarshalling is not yet +implemented, and base-60 floats from YAML 1.1 are purposefully not +supported since they're a poor design and are gone in YAML 1.2. + +Installation and usage +---------------------- + +The import path for the package is *gopkg.in/yaml.v2*. + +To install it, run: + + go get gopkg.in/yaml.v2 + +API documentation +----------------- + +If opened in a browser, the import path itself leads to the API documentation: + + * [https://gopkg.in/yaml.v2](https://gopkg.in/yaml.v2) + +API stability +------------- + +The package API for yaml v2 will remain stable as described in [gopkg.in](https://gopkg.in). + + +License +------- + +The yaml package is licensed under the LGPL with an exception that allows it to be linked statically. Please see the LICENSE file for details. + + +Example +------- + +```Go +package main + +import ( + "fmt" + "log" + + "gopkg.in/yaml.v2" +) + +var data = ` +a: Easy! +b: + c: 2 + d: [3, 4] +` + +type T struct { + A string + B struct { + RenamedC int `yaml:"c"` + D []int `yaml:",flow"` + } +} + +func main() { + t := T{} + + err := yaml.Unmarshal([]byte(data), &t) + if err != nil { + log.Fatalf("error: %v", err) + } + fmt.Printf("--- t:\n%v\n\n", t) + + d, err := yaml.Marshal(&t) + if err != nil { + log.Fatalf("error: %v", err) + } + fmt.Printf("--- t dump:\n%s\n\n", string(d)) + + m := make(map[interface{}]interface{}) + + err = yaml.Unmarshal([]byte(data), &m) + if err != nil { + log.Fatalf("error: %v", err) + } + fmt.Printf("--- m:\n%v\n\n", m) + + d, err = yaml.Marshal(&m) + if err != nil { + log.Fatalf("error: %v", err) + } + fmt.Printf("--- m dump:\n%s\n\n", string(d)) +} +``` + +This example will generate the following output: + +``` +--- t: +{Easy! {2 [3 4]}} + +--- t dump: +a: Easy! +b: + c: 2 + d: [3, 4] + + +--- m: +map[a:Easy! b:map[c:2 d:[3 4]]] + +--- m dump: +a: Easy! +b: + c: 2 + d: + - 3 + - 4 +``` + diff --git a/Godeps/_workspace/src/gopkg.in/yaml.v2/apic.go b/Godeps/_workspace/src/gopkg.in/yaml.v2/apic.go new file mode 100644 index 000000000..95ec014e8 --- /dev/null +++ b/Godeps/_workspace/src/gopkg.in/yaml.v2/apic.go @@ -0,0 +1,742 @@ +package yaml + +import ( + "io" + "os" +) + +func yaml_insert_token(parser *yaml_parser_t, pos int, token *yaml_token_t) { + //fmt.Println("yaml_insert_token", "pos:", pos, "typ:", token.typ, "head:", parser.tokens_head, "len:", len(parser.tokens)) + + // Check if we can move the queue at the beginning of the buffer. + if parser.tokens_head > 0 && len(parser.tokens) == cap(parser.tokens) { + if parser.tokens_head != len(parser.tokens) { + copy(parser.tokens, parser.tokens[parser.tokens_head:]) + } + parser.tokens = parser.tokens[:len(parser.tokens)-parser.tokens_head] + parser.tokens_head = 0 + } + parser.tokens = append(parser.tokens, *token) + if pos < 0 { + return + } + copy(parser.tokens[parser.tokens_head+pos+1:], parser.tokens[parser.tokens_head+pos:]) + parser.tokens[parser.tokens_head+pos] = *token +} + +// Create a new parser object. +func yaml_parser_initialize(parser *yaml_parser_t) bool { + *parser = yaml_parser_t{ + raw_buffer: make([]byte, 0, input_raw_buffer_size), + buffer: make([]byte, 0, input_buffer_size), + } + return true +} + +// Destroy a parser object. +func yaml_parser_delete(parser *yaml_parser_t) { + *parser = yaml_parser_t{} +} + +// String read handler. +func yaml_string_read_handler(parser *yaml_parser_t, buffer []byte) (n int, err error) { + if parser.input_pos == len(parser.input) { + return 0, io.EOF + } + n = copy(buffer, parser.input[parser.input_pos:]) + parser.input_pos += n + return n, nil +} + +// File read handler. +func yaml_file_read_handler(parser *yaml_parser_t, buffer []byte) (n int, err error) { + return parser.input_file.Read(buffer) +} + +// Set a string input. +func yaml_parser_set_input_string(parser *yaml_parser_t, input []byte) { + if parser.read_handler != nil { + panic("must set the input source only once") + } + parser.read_handler = yaml_string_read_handler + parser.input = input + parser.input_pos = 0 +} + +// Set a file input. +func yaml_parser_set_input_file(parser *yaml_parser_t, file *os.File) { + if parser.read_handler != nil { + panic("must set the input source only once") + } + parser.read_handler = yaml_file_read_handler + parser.input_file = file +} + +// Set the source encoding. +func yaml_parser_set_encoding(parser *yaml_parser_t, encoding yaml_encoding_t) { + if parser.encoding != yaml_ANY_ENCODING { + panic("must set the encoding only once") + } + parser.encoding = encoding +} + +// Create a new emitter object. +func yaml_emitter_initialize(emitter *yaml_emitter_t) bool { + *emitter = yaml_emitter_t{ + buffer: make([]byte, output_buffer_size), + raw_buffer: make([]byte, 0, output_raw_buffer_size), + states: make([]yaml_emitter_state_t, 0, initial_stack_size), + events: make([]yaml_event_t, 0, initial_queue_size), + } + return true +} + +// Destroy an emitter object. +func yaml_emitter_delete(emitter *yaml_emitter_t) { + *emitter = yaml_emitter_t{} +} + +// String write handler. +func yaml_string_write_handler(emitter *yaml_emitter_t, buffer []byte) error { + *emitter.output_buffer = append(*emitter.output_buffer, buffer...) + return nil +} + +// File write handler. +func yaml_file_write_handler(emitter *yaml_emitter_t, buffer []byte) error { + _, err := emitter.output_file.Write(buffer) + return err +} + +// Set a string output. +func yaml_emitter_set_output_string(emitter *yaml_emitter_t, output_buffer *[]byte) { + if emitter.write_handler != nil { + panic("must set the output target only once") + } + emitter.write_handler = yaml_string_write_handler + emitter.output_buffer = output_buffer +} + +// Set a file output. +func yaml_emitter_set_output_file(emitter *yaml_emitter_t, file io.Writer) { + if emitter.write_handler != nil { + panic("must set the output target only once") + } + emitter.write_handler = yaml_file_write_handler + emitter.output_file = file +} + +// Set the output encoding. +func yaml_emitter_set_encoding(emitter *yaml_emitter_t, encoding yaml_encoding_t) { + if emitter.encoding != yaml_ANY_ENCODING { + panic("must set the output encoding only once") + } + emitter.encoding = encoding +} + +// Set the canonical output style. +func yaml_emitter_set_canonical(emitter *yaml_emitter_t, canonical bool) { + emitter.canonical = canonical +} + +//// Set the indentation increment. +func yaml_emitter_set_indent(emitter *yaml_emitter_t, indent int) { + if indent < 2 || indent > 9 { + indent = 2 + } + emitter.best_indent = indent +} + +// Set the preferred line width. +func yaml_emitter_set_width(emitter *yaml_emitter_t, width int) { + if width < 0 { + width = -1 + } + emitter.best_width = width +} + +// Set if unescaped non-ASCII characters are allowed. +func yaml_emitter_set_unicode(emitter *yaml_emitter_t, unicode bool) { + emitter.unicode = unicode +} + +// Set the preferred line break character. +func yaml_emitter_set_break(emitter *yaml_emitter_t, line_break yaml_break_t) { + emitter.line_break = line_break +} + +///* +// * Destroy a token object. +// */ +// +//YAML_DECLARE(void) +//yaml_token_delete(yaml_token_t *token) +//{ +// assert(token); // Non-NULL token object expected. +// +// switch (token.type) +// { +// case YAML_TAG_DIRECTIVE_TOKEN: +// yaml_free(token.data.tag_directive.handle); +// yaml_free(token.data.tag_directive.prefix); +// break; +// +// case YAML_ALIAS_TOKEN: +// yaml_free(token.data.alias.value); +// break; +// +// case YAML_ANCHOR_TOKEN: +// yaml_free(token.data.anchor.value); +// break; +// +// case YAML_TAG_TOKEN: +// yaml_free(token.data.tag.handle); +// yaml_free(token.data.tag.suffix); +// break; +// +// case YAML_SCALAR_TOKEN: +// yaml_free(token.data.scalar.value); +// break; +// +// default: +// break; +// } +// +// memset(token, 0, sizeof(yaml_token_t)); +//} +// +///* +// * Check if a string is a valid UTF-8 sequence. +// * +// * Check 'reader.c' for more details on UTF-8 encoding. +// */ +// +//static int +//yaml_check_utf8(yaml_char_t *start, size_t length) +//{ +// yaml_char_t *end = start+length; +// yaml_char_t *pointer = start; +// +// while (pointer < end) { +// unsigned char octet; +// unsigned int width; +// unsigned int value; +// size_t k; +// +// octet = pointer[0]; +// width = (octet & 0x80) == 0x00 ? 1 : +// (octet & 0xE0) == 0xC0 ? 2 : +// (octet & 0xF0) == 0xE0 ? 3 : +// (octet & 0xF8) == 0xF0 ? 4 : 0; +// value = (octet & 0x80) == 0x00 ? octet & 0x7F : +// (octet & 0xE0) == 0xC0 ? octet & 0x1F : +// (octet & 0xF0) == 0xE0 ? octet & 0x0F : +// (octet & 0xF8) == 0xF0 ? octet & 0x07 : 0; +// if (!width) return 0; +// if (pointer+width > end) return 0; +// for (k = 1; k < width; k ++) { +// octet = pointer[k]; +// if ((octet & 0xC0) != 0x80) return 0; +// value = (value << 6) + (octet & 0x3F); +// } +// if (!((width == 1) || +// (width == 2 && value >= 0x80) || +// (width == 3 && value >= 0x800) || +// (width == 4 && value >= 0x10000))) return 0; +// +// pointer += width; +// } +// +// return 1; +//} +// + +// Create STREAM-START. +func yaml_stream_start_event_initialize(event *yaml_event_t, encoding yaml_encoding_t) bool { + *event = yaml_event_t{ + typ: yaml_STREAM_START_EVENT, + encoding: encoding, + } + return true +} + +// Create STREAM-END. +func yaml_stream_end_event_initialize(event *yaml_event_t) bool { + *event = yaml_event_t{ + typ: yaml_STREAM_END_EVENT, + } + return true +} + +// Create DOCUMENT-START. +func yaml_document_start_event_initialize(event *yaml_event_t, version_directive *yaml_version_directive_t, + tag_directives []yaml_tag_directive_t, implicit bool) bool { + *event = yaml_event_t{ + typ: yaml_DOCUMENT_START_EVENT, + version_directive: version_directive, + tag_directives: tag_directives, + implicit: implicit, + } + return true +} + +// Create DOCUMENT-END. +func yaml_document_end_event_initialize(event *yaml_event_t, implicit bool) bool { + *event = yaml_event_t{ + typ: yaml_DOCUMENT_END_EVENT, + implicit: implicit, + } + return true +} + +///* +// * Create ALIAS. +// */ +// +//YAML_DECLARE(int) +//yaml_alias_event_initialize(event *yaml_event_t, anchor *yaml_char_t) +//{ +// mark yaml_mark_t = { 0, 0, 0 } +// anchor_copy *yaml_char_t = NULL +// +// assert(event) // Non-NULL event object is expected. +// assert(anchor) // Non-NULL anchor is expected. +// +// if (!yaml_check_utf8(anchor, strlen((char *)anchor))) return 0 +// +// anchor_copy = yaml_strdup(anchor) +// if (!anchor_copy) +// return 0 +// +// ALIAS_EVENT_INIT(*event, anchor_copy, mark, mark) +// +// return 1 +//} + +// Create SCALAR. +func yaml_scalar_event_initialize(event *yaml_event_t, anchor, tag, value []byte, plain_implicit, quoted_implicit bool, style yaml_scalar_style_t) bool { + *event = yaml_event_t{ + typ: yaml_SCALAR_EVENT, + anchor: anchor, + tag: tag, + value: value, + implicit: plain_implicit, + quoted_implicit: quoted_implicit, + style: yaml_style_t(style), + } + return true +} + +// Create SEQUENCE-START. +func yaml_sequence_start_event_initialize(event *yaml_event_t, anchor, tag []byte, implicit bool, style yaml_sequence_style_t) bool { + *event = yaml_event_t{ + typ: yaml_SEQUENCE_START_EVENT, + anchor: anchor, + tag: tag, + implicit: implicit, + style: yaml_style_t(style), + } + return true +} + +// Create SEQUENCE-END. +func yaml_sequence_end_event_initialize(event *yaml_event_t) bool { + *event = yaml_event_t{ + typ: yaml_SEQUENCE_END_EVENT, + } + return true +} + +// Create MAPPING-START. +func yaml_mapping_start_event_initialize(event *yaml_event_t, anchor, tag []byte, implicit bool, style yaml_mapping_style_t) bool { + *event = yaml_event_t{ + typ: yaml_MAPPING_START_EVENT, + anchor: anchor, + tag: tag, + implicit: implicit, + style: yaml_style_t(style), + } + return true +} + +// Create MAPPING-END. +func yaml_mapping_end_event_initialize(event *yaml_event_t) bool { + *event = yaml_event_t{ + typ: yaml_MAPPING_END_EVENT, + } + return true +} + +// Destroy an event object. +func yaml_event_delete(event *yaml_event_t) { + *event = yaml_event_t{} +} + +///* +// * Create a document object. +// */ +// +//YAML_DECLARE(int) +//yaml_document_initialize(document *yaml_document_t, +// version_directive *yaml_version_directive_t, +// tag_directives_start *yaml_tag_directive_t, +// tag_directives_end *yaml_tag_directive_t, +// start_implicit int, end_implicit int) +//{ +// struct { +// error yaml_error_type_t +// } context +// struct { +// start *yaml_node_t +// end *yaml_node_t +// top *yaml_node_t +// } nodes = { NULL, NULL, NULL } +// version_directive_copy *yaml_version_directive_t = NULL +// struct { +// start *yaml_tag_directive_t +// end *yaml_tag_directive_t +// top *yaml_tag_directive_t +// } tag_directives_copy = { NULL, NULL, NULL } +// value yaml_tag_directive_t = { NULL, NULL } +// mark yaml_mark_t = { 0, 0, 0 } +// +// assert(document) // Non-NULL document object is expected. +// assert((tag_directives_start && tag_directives_end) || +// (tag_directives_start == tag_directives_end)) +// // Valid tag directives are expected. +// +// if (!STACK_INIT(&context, nodes, INITIAL_STACK_SIZE)) goto error +// +// if (version_directive) { +// version_directive_copy = yaml_malloc(sizeof(yaml_version_directive_t)) +// if (!version_directive_copy) goto error +// version_directive_copy.major = version_directive.major +// version_directive_copy.minor = version_directive.minor +// } +// +// if (tag_directives_start != tag_directives_end) { +// tag_directive *yaml_tag_directive_t +// if (!STACK_INIT(&context, tag_directives_copy, INITIAL_STACK_SIZE)) +// goto error +// for (tag_directive = tag_directives_start +// tag_directive != tag_directives_end; tag_directive ++) { +// assert(tag_directive.handle) +// assert(tag_directive.prefix) +// if (!yaml_check_utf8(tag_directive.handle, +// strlen((char *)tag_directive.handle))) +// goto error +// if (!yaml_check_utf8(tag_directive.prefix, +// strlen((char *)tag_directive.prefix))) +// goto error +// value.handle = yaml_strdup(tag_directive.handle) +// value.prefix = yaml_strdup(tag_directive.prefix) +// if (!value.handle || !value.prefix) goto error +// if (!PUSH(&context, tag_directives_copy, value)) +// goto error +// value.handle = NULL +// value.prefix = NULL +// } +// } +// +// DOCUMENT_INIT(*document, nodes.start, nodes.end, version_directive_copy, +// tag_directives_copy.start, tag_directives_copy.top, +// start_implicit, end_implicit, mark, mark) +// +// return 1 +// +//error: +// STACK_DEL(&context, nodes) +// yaml_free(version_directive_copy) +// while (!STACK_EMPTY(&context, tag_directives_copy)) { +// value yaml_tag_directive_t = POP(&context, tag_directives_copy) +// yaml_free(value.handle) +// yaml_free(value.prefix) +// } +// STACK_DEL(&context, tag_directives_copy) +// yaml_free(value.handle) +// yaml_free(value.prefix) +// +// return 0 +//} +// +///* +// * Destroy a document object. +// */ +// +//YAML_DECLARE(void) +//yaml_document_delete(document *yaml_document_t) +//{ +// struct { +// error yaml_error_type_t +// } context +// tag_directive *yaml_tag_directive_t +// +// context.error = YAML_NO_ERROR // Eliminate a compliler warning. +// +// assert(document) // Non-NULL document object is expected. +// +// while (!STACK_EMPTY(&context, document.nodes)) { +// node yaml_node_t = POP(&context, document.nodes) +// yaml_free(node.tag) +// switch (node.type) { +// case YAML_SCALAR_NODE: +// yaml_free(node.data.scalar.value) +// break +// case YAML_SEQUENCE_NODE: +// STACK_DEL(&context, node.data.sequence.items) +// break +// case YAML_MAPPING_NODE: +// STACK_DEL(&context, node.data.mapping.pairs) +// break +// default: +// assert(0) // Should not happen. +// } +// } +// STACK_DEL(&context, document.nodes) +// +// yaml_free(document.version_directive) +// for (tag_directive = document.tag_directives.start +// tag_directive != document.tag_directives.end +// tag_directive++) { +// yaml_free(tag_directive.handle) +// yaml_free(tag_directive.prefix) +// } +// yaml_free(document.tag_directives.start) +// +// memset(document, 0, sizeof(yaml_document_t)) +//} +// +///** +// * Get a document node. +// */ +// +//YAML_DECLARE(yaml_node_t *) +//yaml_document_get_node(document *yaml_document_t, index int) +//{ +// assert(document) // Non-NULL document object is expected. +// +// if (index > 0 && document.nodes.start + index <= document.nodes.top) { +// return document.nodes.start + index - 1 +// } +// return NULL +//} +// +///** +// * Get the root object. +// */ +// +//YAML_DECLARE(yaml_node_t *) +//yaml_document_get_root_node(document *yaml_document_t) +//{ +// assert(document) // Non-NULL document object is expected. +// +// if (document.nodes.top != document.nodes.start) { +// return document.nodes.start +// } +// return NULL +//} +// +///* +// * Add a scalar node to a document. +// */ +// +//YAML_DECLARE(int) +//yaml_document_add_scalar(document *yaml_document_t, +// tag *yaml_char_t, value *yaml_char_t, length int, +// style yaml_scalar_style_t) +//{ +// struct { +// error yaml_error_type_t +// } context +// mark yaml_mark_t = { 0, 0, 0 } +// tag_copy *yaml_char_t = NULL +// value_copy *yaml_char_t = NULL +// node yaml_node_t +// +// assert(document) // Non-NULL document object is expected. +// assert(value) // Non-NULL value is expected. +// +// if (!tag) { +// tag = (yaml_char_t *)YAML_DEFAULT_SCALAR_TAG +// } +// +// if (!yaml_check_utf8(tag, strlen((char *)tag))) goto error +// tag_copy = yaml_strdup(tag) +// if (!tag_copy) goto error +// +// if (length < 0) { +// length = strlen((char *)value) +// } +// +// if (!yaml_check_utf8(value, length)) goto error +// value_copy = yaml_malloc(length+1) +// if (!value_copy) goto error +// memcpy(value_copy, value, length) +// value_copy[length] = '\0' +// +// SCALAR_NODE_INIT(node, tag_copy, value_copy, length, style, mark, mark) +// if (!PUSH(&context, document.nodes, node)) goto error +// +// return document.nodes.top - document.nodes.start +// +//error: +// yaml_free(tag_copy) +// yaml_free(value_copy) +// +// return 0 +//} +// +///* +// * Add a sequence node to a document. +// */ +// +//YAML_DECLARE(int) +//yaml_document_add_sequence(document *yaml_document_t, +// tag *yaml_char_t, style yaml_sequence_style_t) +//{ +// struct { +// error yaml_error_type_t +// } context +// mark yaml_mark_t = { 0, 0, 0 } +// tag_copy *yaml_char_t = NULL +// struct { +// start *yaml_node_item_t +// end *yaml_node_item_t +// top *yaml_node_item_t +// } items = { NULL, NULL, NULL } +// node yaml_node_t +// +// assert(document) // Non-NULL document object is expected. +// +// if (!tag) { +// tag = (yaml_char_t *)YAML_DEFAULT_SEQUENCE_TAG +// } +// +// if (!yaml_check_utf8(tag, strlen((char *)tag))) goto error +// tag_copy = yaml_strdup(tag) +// if (!tag_copy) goto error +// +// if (!STACK_INIT(&context, items, INITIAL_STACK_SIZE)) goto error +// +// SEQUENCE_NODE_INIT(node, tag_copy, items.start, items.end, +// style, mark, mark) +// if (!PUSH(&context, document.nodes, node)) goto error +// +// return document.nodes.top - document.nodes.start +// +//error: +// STACK_DEL(&context, items) +// yaml_free(tag_copy) +// +// return 0 +//} +// +///* +// * Add a mapping node to a document. +// */ +// +//YAML_DECLARE(int) +//yaml_document_add_mapping(document *yaml_document_t, +// tag *yaml_char_t, style yaml_mapping_style_t) +//{ +// struct { +// error yaml_error_type_t +// } context +// mark yaml_mark_t = { 0, 0, 0 } +// tag_copy *yaml_char_t = NULL +// struct { +// start *yaml_node_pair_t +// end *yaml_node_pair_t +// top *yaml_node_pair_t +// } pairs = { NULL, NULL, NULL } +// node yaml_node_t +// +// assert(document) // Non-NULL document object is expected. +// +// if (!tag) { +// tag = (yaml_char_t *)YAML_DEFAULT_MAPPING_TAG +// } +// +// if (!yaml_check_utf8(tag, strlen((char *)tag))) goto error +// tag_copy = yaml_strdup(tag) +// if (!tag_copy) goto error +// +// if (!STACK_INIT(&context, pairs, INITIAL_STACK_SIZE)) goto error +// +// MAPPING_NODE_INIT(node, tag_copy, pairs.start, pairs.end, +// style, mark, mark) +// if (!PUSH(&context, document.nodes, node)) goto error +// +// return document.nodes.top - document.nodes.start +// +//error: +// STACK_DEL(&context, pairs) +// yaml_free(tag_copy) +// +// return 0 +//} +// +///* +// * Append an item to a sequence node. +// */ +// +//YAML_DECLARE(int) +//yaml_document_append_sequence_item(document *yaml_document_t, +// sequence int, item int) +//{ +// struct { +// error yaml_error_type_t +// } context +// +// assert(document) // Non-NULL document is required. +// assert(sequence > 0 +// && document.nodes.start + sequence <= document.nodes.top) +// // Valid sequence id is required. +// assert(document.nodes.start[sequence-1].type == YAML_SEQUENCE_NODE) +// // A sequence node is required. +// assert(item > 0 && document.nodes.start + item <= document.nodes.top) +// // Valid item id is required. +// +// if (!PUSH(&context, +// document.nodes.start[sequence-1].data.sequence.items, item)) +// return 0 +// +// return 1 +//} +// +///* +// * Append a pair of a key and a value to a mapping node. +// */ +// +//YAML_DECLARE(int) +//yaml_document_append_mapping_pair(document *yaml_document_t, +// mapping int, key int, value int) +//{ +// struct { +// error yaml_error_type_t +// } context +// +// pair yaml_node_pair_t +// +// assert(document) // Non-NULL document is required. +// assert(mapping > 0 +// && document.nodes.start + mapping <= document.nodes.top) +// // Valid mapping id is required. +// assert(document.nodes.start[mapping-1].type == YAML_MAPPING_NODE) +// // A mapping node is required. +// assert(key > 0 && document.nodes.start + key <= document.nodes.top) +// // Valid key id is required. +// assert(value > 0 && document.nodes.start + value <= document.nodes.top) +// // Valid value id is required. +// +// pair.key = key +// pair.value = value +// +// if (!PUSH(&context, +// document.nodes.start[mapping-1].data.mapping.pairs, pair)) +// return 0 +// +// return 1 +//} +// +// diff --git a/Godeps/_workspace/src/gopkg.in/yaml.v2/decode.go b/Godeps/_workspace/src/gopkg.in/yaml.v2/decode.go new file mode 100644 index 000000000..085cddc44 --- /dev/null +++ b/Godeps/_workspace/src/gopkg.in/yaml.v2/decode.go @@ -0,0 +1,683 @@ +package yaml + +import ( + "encoding" + "encoding/base64" + "fmt" + "math" + "reflect" + "strconv" + "time" +) + +const ( + documentNode = 1 << iota + mappingNode + sequenceNode + scalarNode + aliasNode +) + +type node struct { + kind int + line, column int + tag string + value string + implicit bool + children []*node + anchors map[string]*node +} + +// ---------------------------------------------------------------------------- +// Parser, produces a node tree out of a libyaml event stream. + +type parser struct { + parser yaml_parser_t + event yaml_event_t + doc *node +} + +func newParser(b []byte) *parser { + p := parser{} + if !yaml_parser_initialize(&p.parser) { + panic("failed to initialize YAML emitter") + } + + if len(b) == 0 { + b = []byte{'\n'} + } + + yaml_parser_set_input_string(&p.parser, b) + + p.skip() + if p.event.typ != yaml_STREAM_START_EVENT { + panic("expected stream start event, got " + strconv.Itoa(int(p.event.typ))) + } + p.skip() + return &p +} + +func (p *parser) destroy() { + if p.event.typ != yaml_NO_EVENT { + yaml_event_delete(&p.event) + } + yaml_parser_delete(&p.parser) +} + +func (p *parser) skip() { + if p.event.typ != yaml_NO_EVENT { + if p.event.typ == yaml_STREAM_END_EVENT { + failf("attempted to go past the end of stream; corrupted value?") + } + yaml_event_delete(&p.event) + } + if !yaml_parser_parse(&p.parser, &p.event) { + p.fail() + } +} + +func (p *parser) fail() { + var where string + var line int + if p.parser.problem_mark.line != 0 { + line = p.parser.problem_mark.line + } else if p.parser.context_mark.line != 0 { + line = p.parser.context_mark.line + } + if line != 0 { + where = "line " + strconv.Itoa(line) + ": " + } + var msg string + if len(p.parser.problem) > 0 { + msg = p.parser.problem + } else { + msg = "unknown problem parsing YAML content" + } + failf("%s%s", where, msg) +} + +func (p *parser) anchor(n *node, anchor []byte) { + if anchor != nil { + p.doc.anchors[string(anchor)] = n + } +} + +func (p *parser) parse() *node { + switch p.event.typ { + case yaml_SCALAR_EVENT: + return p.scalar() + case yaml_ALIAS_EVENT: + return p.alias() + case yaml_MAPPING_START_EVENT: + return p.mapping() + case yaml_SEQUENCE_START_EVENT: + return p.sequence() + case yaml_DOCUMENT_START_EVENT: + return p.document() + case yaml_STREAM_END_EVENT: + // Happens when attempting to decode an empty buffer. + return nil + default: + panic("attempted to parse unknown event: " + strconv.Itoa(int(p.event.typ))) + } + panic("unreachable") +} + +func (p *parser) node(kind int) *node { + return &node{ + kind: kind, + line: p.event.start_mark.line, + column: p.event.start_mark.column, + } +} + +func (p *parser) document() *node { + n := p.node(documentNode) + n.anchors = make(map[string]*node) + p.doc = n + p.skip() + n.children = append(n.children, p.parse()) + if p.event.typ != yaml_DOCUMENT_END_EVENT { + panic("expected end of document event but got " + strconv.Itoa(int(p.event.typ))) + } + p.skip() + return n +} + +func (p *parser) alias() *node { + n := p.node(aliasNode) + n.value = string(p.event.anchor) + p.skip() + return n +} + +func (p *parser) scalar() *node { + n := p.node(scalarNode) + n.value = string(p.event.value) + n.tag = string(p.event.tag) + n.implicit = p.event.implicit + p.anchor(n, p.event.anchor) + p.skip() + return n +} + +func (p *parser) sequence() *node { + n := p.node(sequenceNode) + p.anchor(n, p.event.anchor) + p.skip() + for p.event.typ != yaml_SEQUENCE_END_EVENT { + n.children = append(n.children, p.parse()) + } + p.skip() + return n +} + +func (p *parser) mapping() *node { + n := p.node(mappingNode) + p.anchor(n, p.event.anchor) + p.skip() + for p.event.typ != yaml_MAPPING_END_EVENT { + n.children = append(n.children, p.parse(), p.parse()) + } + p.skip() + return n +} + +// ---------------------------------------------------------------------------- +// Decoder, unmarshals a node into a provided value. + +type decoder struct { + doc *node + aliases map[string]bool + mapType reflect.Type + terrors []string +} + +var ( + mapItemType = reflect.TypeOf(MapItem{}) + durationType = reflect.TypeOf(time.Duration(0)) + defaultMapType = reflect.TypeOf(map[interface{}]interface{}{}) + ifaceType = defaultMapType.Elem() +) + +func newDecoder() *decoder { + d := &decoder{mapType: defaultMapType} + d.aliases = make(map[string]bool) + return d +} + +func (d *decoder) terror(n *node, tag string, out reflect.Value) { + if n.tag != "" { + tag = n.tag + } + value := n.value + if tag != yaml_SEQ_TAG && tag != yaml_MAP_TAG { + if len(value) > 10 { + value = " `" + value[:7] + "...`" + } else { + value = " `" + value + "`" + } + } + d.terrors = append(d.terrors, fmt.Sprintf("line %d: cannot unmarshal %s%s into %s", n.line+1, shortTag(tag), value, out.Type())) +} + +func (d *decoder) callUnmarshaler(n *node, u Unmarshaler) (good bool) { + terrlen := len(d.terrors) + err := u.UnmarshalYAML(func(v interface{}) (err error) { + defer handleErr(&err) + d.unmarshal(n, reflect.ValueOf(v)) + if len(d.terrors) > terrlen { + issues := d.terrors[terrlen:] + d.terrors = d.terrors[:terrlen] + return &TypeError{issues} + } + return nil + }) + if e, ok := err.(*TypeError); ok { + d.terrors = append(d.terrors, e.Errors...) + return false + } + if err != nil { + fail(err) + } + return true +} + +// d.prepare initializes and dereferences pointers and calls UnmarshalYAML +// if a value is found to implement it. +// It returns the initialized and dereferenced out value, whether +// unmarshalling was already done by UnmarshalYAML, and if so whether +// its types unmarshalled appropriately. +// +// If n holds a null value, prepare returns before doing anything. +func (d *decoder) prepare(n *node, out reflect.Value) (newout reflect.Value, unmarshaled, good bool) { + if n.tag == yaml_NULL_TAG || n.kind == scalarNode && n.tag == "" && (n.value == "null" || n.value == "") { + return out, false, false + } + again := true + for again { + again = false + if out.Kind() == reflect.Ptr { + if out.IsNil() { + out.Set(reflect.New(out.Type().Elem())) + } + out = out.Elem() + again = true + } + if out.CanAddr() { + if u, ok := out.Addr().Interface().(Unmarshaler); ok { + good = d.callUnmarshaler(n, u) + return out, true, good + } + } + } + return out, false, false +} + +func (d *decoder) unmarshal(n *node, out reflect.Value) (good bool) { + switch n.kind { + case documentNode: + return d.document(n, out) + case aliasNode: + return d.alias(n, out) + } + out, unmarshaled, good := d.prepare(n, out) + if unmarshaled { + return good + } + switch n.kind { + case scalarNode: + good = d.scalar(n, out) + case mappingNode: + good = d.mapping(n, out) + case sequenceNode: + good = d.sequence(n, out) + default: + panic("internal error: unknown node kind: " + strconv.Itoa(n.kind)) + } + return good +} + +func (d *decoder) document(n *node, out reflect.Value) (good bool) { + if len(n.children) == 1 { + d.doc = n + d.unmarshal(n.children[0], out) + return true + } + return false +} + +func (d *decoder) alias(n *node, out reflect.Value) (good bool) { + an, ok := d.doc.anchors[n.value] + if !ok { + failf("unknown anchor '%s' referenced", n.value) + } + if d.aliases[n.value] { + failf("anchor '%s' value contains itself", n.value) + } + d.aliases[n.value] = true + good = d.unmarshal(an, out) + delete(d.aliases, n.value) + return good +} + +var zeroValue reflect.Value + +func resetMap(out reflect.Value) { + for _, k := range out.MapKeys() { + out.SetMapIndex(k, zeroValue) + } +} + +func (d *decoder) scalar(n *node, out reflect.Value) (good bool) { + var tag string + var resolved interface{} + if n.tag == "" && !n.implicit { + tag = yaml_STR_TAG + resolved = n.value + } else { + tag, resolved = resolve(n.tag, n.value) + if tag == yaml_BINARY_TAG { + data, err := base64.StdEncoding.DecodeString(resolved.(string)) + if err != nil { + failf("!!binary value contains invalid base64 data") + } + resolved = string(data) + } + } + if resolved == nil { + if out.Kind() == reflect.Map && !out.CanAddr() { + resetMap(out) + } else { + out.Set(reflect.Zero(out.Type())) + } + return true + } + if s, ok := resolved.(string); ok && out.CanAddr() { + if u, ok := out.Addr().Interface().(encoding.TextUnmarshaler); ok { + err := u.UnmarshalText([]byte(s)) + if err != nil { + fail(err) + } + return true + } + } + switch out.Kind() { + case reflect.String: + if tag == yaml_BINARY_TAG { + out.SetString(resolved.(string)) + good = true + } else if resolved != nil { + out.SetString(n.value) + good = true + } + case reflect.Interface: + if resolved == nil { + out.Set(reflect.Zero(out.Type())) + } else { + out.Set(reflect.ValueOf(resolved)) + } + good = true + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + switch resolved := resolved.(type) { + case int: + if !out.OverflowInt(int64(resolved)) { + out.SetInt(int64(resolved)) + good = true + } + case int64: + if !out.OverflowInt(resolved) { + out.SetInt(resolved) + good = true + } + case uint64: + if resolved <= math.MaxInt64 && !out.OverflowInt(int64(resolved)) { + out.SetInt(int64(resolved)) + good = true + } + case float64: + if resolved <= math.MaxInt64 && !out.OverflowInt(int64(resolved)) { + out.SetInt(int64(resolved)) + good = true + } + case string: + if out.Type() == durationType { + d, err := time.ParseDuration(resolved) + if err == nil { + out.SetInt(int64(d)) + good = true + } + } + } + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: + switch resolved := resolved.(type) { + case int: + if resolved >= 0 && !out.OverflowUint(uint64(resolved)) { + out.SetUint(uint64(resolved)) + good = true + } + case int64: + if resolved >= 0 && !out.OverflowUint(uint64(resolved)) { + out.SetUint(uint64(resolved)) + good = true + } + case uint64: + if !out.OverflowUint(uint64(resolved)) { + out.SetUint(uint64(resolved)) + good = true + } + case float64: + if resolved <= math.MaxUint64 && !out.OverflowUint(uint64(resolved)) { + out.SetUint(uint64(resolved)) + good = true + } + } + case reflect.Bool: + switch resolved := resolved.(type) { + case bool: + out.SetBool(resolved) + good = true + } + case reflect.Float32, reflect.Float64: + switch resolved := resolved.(type) { + case int: + out.SetFloat(float64(resolved)) + good = true + case int64: + out.SetFloat(float64(resolved)) + good = true + case uint64: + out.SetFloat(float64(resolved)) + good = true + case float64: + out.SetFloat(resolved) + good = true + } + case reflect.Ptr: + if out.Type().Elem() == reflect.TypeOf(resolved) { + // TODO DOes this make sense? When is out a Ptr except when decoding a nil value? + elem := reflect.New(out.Type().Elem()) + elem.Elem().Set(reflect.ValueOf(resolved)) + out.Set(elem) + good = true + } + } + if !good { + d.terror(n, tag, out) + } + return good +} + +func settableValueOf(i interface{}) reflect.Value { + v := reflect.ValueOf(i) + sv := reflect.New(v.Type()).Elem() + sv.Set(v) + return sv +} + +func (d *decoder) sequence(n *node, out reflect.Value) (good bool) { + l := len(n.children) + + var iface reflect.Value + switch out.Kind() { + case reflect.Slice: + out.Set(reflect.MakeSlice(out.Type(), l, l)) + case reflect.Interface: + // No type hints. Will have to use a generic sequence. + iface = out + out = settableValueOf(make([]interface{}, l)) + default: + d.terror(n, yaml_SEQ_TAG, out) + return false + } + et := out.Type().Elem() + + j := 0 + for i := 0; i < l; i++ { + e := reflect.New(et).Elem() + if ok := d.unmarshal(n.children[i], e); ok { + out.Index(j).Set(e) + j++ + } + } + out.Set(out.Slice(0, j)) + if iface.IsValid() { + iface.Set(out) + } + return true +} + +func (d *decoder) mapping(n *node, out reflect.Value) (good bool) { + switch out.Kind() { + case reflect.Struct: + return d.mappingStruct(n, out) + case reflect.Slice: + return d.mappingSlice(n, out) + case reflect.Map: + // okay + case reflect.Interface: + if d.mapType.Kind() == reflect.Map { + iface := out + out = reflect.MakeMap(d.mapType) + iface.Set(out) + } else { + slicev := reflect.New(d.mapType).Elem() + if !d.mappingSlice(n, slicev) { + return false + } + out.Set(slicev) + return true + } + default: + d.terror(n, yaml_MAP_TAG, out) + return false + } + outt := out.Type() + kt := outt.Key() + et := outt.Elem() + + mapType := d.mapType + if outt.Key() == ifaceType && outt.Elem() == ifaceType { + d.mapType = outt + } + + if out.IsNil() { + out.Set(reflect.MakeMap(outt)) + } + l := len(n.children) + for i := 0; i < l; i += 2 { + if isMerge(n.children[i]) { + d.merge(n.children[i+1], out) + continue + } + k := reflect.New(kt).Elem() + if d.unmarshal(n.children[i], k) { + kkind := k.Kind() + if kkind == reflect.Interface { + kkind = k.Elem().Kind() + } + if kkind == reflect.Map || kkind == reflect.Slice { + failf("invalid map key: %#v", k.Interface()) + } + e := reflect.New(et).Elem() + if d.unmarshal(n.children[i+1], e) { + out.SetMapIndex(k, e) + } + } + } + d.mapType = mapType + return true +} + +func (d *decoder) mappingSlice(n *node, out reflect.Value) (good bool) { + outt := out.Type() + if outt.Elem() != mapItemType { + d.terror(n, yaml_MAP_TAG, out) + return false + } + + mapType := d.mapType + d.mapType = outt + + var slice []MapItem + var l = len(n.children) + for i := 0; i < l; i += 2 { + if isMerge(n.children[i]) { + d.merge(n.children[i+1], out) + continue + } + item := MapItem{} + k := reflect.ValueOf(&item.Key).Elem() + if d.unmarshal(n.children[i], k) { + v := reflect.ValueOf(&item.Value).Elem() + if d.unmarshal(n.children[i+1], v) { + slice = append(slice, item) + } + } + } + out.Set(reflect.ValueOf(slice)) + d.mapType = mapType + return true +} + +func (d *decoder) mappingStruct(n *node, out reflect.Value) (good bool) { + sinfo, err := getStructInfo(out.Type()) + if err != nil { + panic(err) + } + name := settableValueOf("") + l := len(n.children) + + var inlineMap reflect.Value + var elemType reflect.Type + if sinfo.InlineMap != -1 { + inlineMap = out.Field(sinfo.InlineMap) + inlineMap.Set(reflect.New(inlineMap.Type()).Elem()) + elemType = inlineMap.Type().Elem() + } + + for i := 0; i < l; i += 2 { + ni := n.children[i] + if isMerge(ni) { + d.merge(n.children[i+1], out) + continue + } + if !d.unmarshal(ni, name) { + continue + } + if info, ok := sinfo.FieldsMap[name.String()]; ok { + var field reflect.Value + if info.Inline == nil { + field = out.Field(info.Num) + } else { + field = out.FieldByIndex(info.Inline) + } + d.unmarshal(n.children[i+1], field) + } else if sinfo.InlineMap != -1 { + if inlineMap.IsNil() { + inlineMap.Set(reflect.MakeMap(inlineMap.Type())) + } + value := reflect.New(elemType).Elem() + d.unmarshal(n.children[i+1], value) + inlineMap.SetMapIndex(name, value) + } + } + return true +} + +func failWantMap() { + failf("map merge requires map or sequence of maps as the value") +} + +func (d *decoder) merge(n *node, out reflect.Value) { + switch n.kind { + case mappingNode: + d.unmarshal(n, out) + case aliasNode: + an, ok := d.doc.anchors[n.value] + if ok && an.kind != mappingNode { + failWantMap() + } + d.unmarshal(n, out) + case sequenceNode: + // Step backwards as earlier nodes take precedence. + for i := len(n.children) - 1; i >= 0; i-- { + ni := n.children[i] + if ni.kind == aliasNode { + an, ok := d.doc.anchors[ni.value] + if ok && an.kind != mappingNode { + failWantMap() + } + } else if ni.kind != mappingNode { + failWantMap() + } + d.unmarshal(ni, out) + } + default: + failWantMap() + } +} + +func isMerge(n *node) bool { + return n.kind == scalarNode && n.value == "<<" && (n.implicit == true || n.tag == yaml_MERGE_TAG) +} diff --git a/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go b/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go new file mode 100644 index 000000000..2befd553e --- /dev/null +++ b/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go @@ -0,0 +1,1685 @@ +package yaml + +import ( + "bytes" +) + +// Flush the buffer if needed. +func flush(emitter *yaml_emitter_t) bool { + if emitter.buffer_pos+5 >= len(emitter.buffer) { + return yaml_emitter_flush(emitter) + } + return true +} + +// Put a character to the output buffer. +func put(emitter *yaml_emitter_t, value byte) bool { + if emitter.buffer_pos+5 >= len(emitter.buffer) && !yaml_emitter_flush(emitter) { + return false + } + emitter.buffer[emitter.buffer_pos] = value + emitter.buffer_pos++ + emitter.column++ + return true +} + +// Put a line break to the output buffer. +func put_break(emitter *yaml_emitter_t) bool { + if emitter.buffer_pos+5 >= len(emitter.buffer) && !yaml_emitter_flush(emitter) { + return false + } + switch emitter.line_break { + case yaml_CR_BREAK: + emitter.buffer[emitter.buffer_pos] = '\r' + emitter.buffer_pos += 1 + case yaml_LN_BREAK: + emitter.buffer[emitter.buffer_pos] = '\n' + emitter.buffer_pos += 1 + case yaml_CRLN_BREAK: + emitter.buffer[emitter.buffer_pos+0] = '\r' + emitter.buffer[emitter.buffer_pos+1] = '\n' + emitter.buffer_pos += 2 + default: + panic("unknown line break setting") + } + emitter.column = 0 + emitter.line++ + return true +} + +// Copy a character from a string into buffer. +func write(emitter *yaml_emitter_t, s []byte, i *int) bool { + if emitter.buffer_pos+5 >= len(emitter.buffer) && !yaml_emitter_flush(emitter) { + return false + } + p := emitter.buffer_pos + w := width(s[*i]) + switch w { + case 4: + emitter.buffer[p+3] = s[*i+3] + fallthrough + case 3: + emitter.buffer[p+2] = s[*i+2] + fallthrough + case 2: + emitter.buffer[p+1] = s[*i+1] + fallthrough + case 1: + emitter.buffer[p+0] = s[*i+0] + default: + panic("unknown character width") + } + emitter.column++ + emitter.buffer_pos += w + *i += w + return true +} + +// Write a whole string into buffer. +func write_all(emitter *yaml_emitter_t, s []byte) bool { + for i := 0; i < len(s); { + if !write(emitter, s, &i) { + return false + } + } + return true +} + +// Copy a line break character from a string into buffer. +func write_break(emitter *yaml_emitter_t, s []byte, i *int) bool { + if s[*i] == '\n' { + if !put_break(emitter) { + return false + } + *i++ + } else { + if !write(emitter, s, i) { + return false + } + emitter.column = 0 + emitter.line++ + } + return true +} + +// Set an emitter error and return false. +func yaml_emitter_set_emitter_error(emitter *yaml_emitter_t, problem string) bool { + emitter.error = yaml_EMITTER_ERROR + emitter.problem = problem + return false +} + +// Emit an event. +func yaml_emitter_emit(emitter *yaml_emitter_t, event *yaml_event_t) bool { + emitter.events = append(emitter.events, *event) + for !yaml_emitter_need_more_events(emitter) { + event := &emitter.events[emitter.events_head] + if !yaml_emitter_analyze_event(emitter, event) { + return false + } + if !yaml_emitter_state_machine(emitter, event) { + return false + } + yaml_event_delete(event) + emitter.events_head++ + } + return true +} + +// Check if we need to accumulate more events before emitting. +// +// We accumulate extra +// - 1 event for DOCUMENT-START +// - 2 events for SEQUENCE-START +// - 3 events for MAPPING-START +// +func yaml_emitter_need_more_events(emitter *yaml_emitter_t) bool { + if emitter.events_head == len(emitter.events) { + return true + } + var accumulate int + switch emitter.events[emitter.events_head].typ { + case yaml_DOCUMENT_START_EVENT: + accumulate = 1 + break + case yaml_SEQUENCE_START_EVENT: + accumulate = 2 + break + case yaml_MAPPING_START_EVENT: + accumulate = 3 + break + default: + return false + } + if len(emitter.events)-emitter.events_head > accumulate { + return false + } + var level int + for i := emitter.events_head; i < len(emitter.events); i++ { + switch emitter.events[i].typ { + case yaml_STREAM_START_EVENT, yaml_DOCUMENT_START_EVENT, yaml_SEQUENCE_START_EVENT, yaml_MAPPING_START_EVENT: + level++ + case yaml_STREAM_END_EVENT, yaml_DOCUMENT_END_EVENT, yaml_SEQUENCE_END_EVENT, yaml_MAPPING_END_EVENT: + level-- + } + if level == 0 { + return false + } + } + return true +} + +// Append a directive to the directives stack. +func yaml_emitter_append_tag_directive(emitter *yaml_emitter_t, value *yaml_tag_directive_t, allow_duplicates bool) bool { + for i := 0; i < len(emitter.tag_directives); i++ { + if bytes.Equal(value.handle, emitter.tag_directives[i].handle) { + if allow_duplicates { + return true + } + return yaml_emitter_set_emitter_error(emitter, "duplicate %TAG directive") + } + } + + // [Go] Do we actually need to copy this given garbage collection + // and the lack of deallocating destructors? + tag_copy := yaml_tag_directive_t{ + handle: make([]byte, len(value.handle)), + prefix: make([]byte, len(value.prefix)), + } + copy(tag_copy.handle, value.handle) + copy(tag_copy.prefix, value.prefix) + emitter.tag_directives = append(emitter.tag_directives, tag_copy) + return true +} + +// Increase the indentation level. +func yaml_emitter_increase_indent(emitter *yaml_emitter_t, flow, indentless bool) bool { + emitter.indents = append(emitter.indents, emitter.indent) + if emitter.indent < 0 { + if flow { + emitter.indent = emitter.best_indent + } else { + emitter.indent = 0 + } + } else if !indentless { + emitter.indent += emitter.best_indent + } + return true +} + +// State dispatcher. +func yaml_emitter_state_machine(emitter *yaml_emitter_t, event *yaml_event_t) bool { + switch emitter.state { + default: + case yaml_EMIT_STREAM_START_STATE: + return yaml_emitter_emit_stream_start(emitter, event) + + case yaml_EMIT_FIRST_DOCUMENT_START_STATE: + return yaml_emitter_emit_document_start(emitter, event, true) + + case yaml_EMIT_DOCUMENT_START_STATE: + return yaml_emitter_emit_document_start(emitter, event, false) + + case yaml_EMIT_DOCUMENT_CONTENT_STATE: + return yaml_emitter_emit_document_content(emitter, event) + + case yaml_EMIT_DOCUMENT_END_STATE: + return yaml_emitter_emit_document_end(emitter, event) + + case yaml_EMIT_FLOW_SEQUENCE_FIRST_ITEM_STATE: + return yaml_emitter_emit_flow_sequence_item(emitter, event, true) + + case yaml_EMIT_FLOW_SEQUENCE_ITEM_STATE: + return yaml_emitter_emit_flow_sequence_item(emitter, event, false) + + case yaml_EMIT_FLOW_MAPPING_FIRST_KEY_STATE: + return yaml_emitter_emit_flow_mapping_key(emitter, event, true) + + case yaml_EMIT_FLOW_MAPPING_KEY_STATE: + return yaml_emitter_emit_flow_mapping_key(emitter, event, false) + + case yaml_EMIT_FLOW_MAPPING_SIMPLE_VALUE_STATE: + return yaml_emitter_emit_flow_mapping_value(emitter, event, true) + + case yaml_EMIT_FLOW_MAPPING_VALUE_STATE: + return yaml_emitter_emit_flow_mapping_value(emitter, event, false) + + case yaml_EMIT_BLOCK_SEQUENCE_FIRST_ITEM_STATE: + return yaml_emitter_emit_block_sequence_item(emitter, event, true) + + case yaml_EMIT_BLOCK_SEQUENCE_ITEM_STATE: + return yaml_emitter_emit_block_sequence_item(emitter, event, false) + + case yaml_EMIT_BLOCK_MAPPING_FIRST_KEY_STATE: + return yaml_emitter_emit_block_mapping_key(emitter, event, true) + + case yaml_EMIT_BLOCK_MAPPING_KEY_STATE: + return yaml_emitter_emit_block_mapping_key(emitter, event, false) + + case yaml_EMIT_BLOCK_MAPPING_SIMPLE_VALUE_STATE: + return yaml_emitter_emit_block_mapping_value(emitter, event, true) + + case yaml_EMIT_BLOCK_MAPPING_VALUE_STATE: + return yaml_emitter_emit_block_mapping_value(emitter, event, false) + + case yaml_EMIT_END_STATE: + return yaml_emitter_set_emitter_error(emitter, "expected nothing after STREAM-END") + } + panic("invalid emitter state") +} + +// Expect STREAM-START. +func yaml_emitter_emit_stream_start(emitter *yaml_emitter_t, event *yaml_event_t) bool { + if event.typ != yaml_STREAM_START_EVENT { + return yaml_emitter_set_emitter_error(emitter, "expected STREAM-START") + } + if emitter.encoding == yaml_ANY_ENCODING { + emitter.encoding = event.encoding + if emitter.encoding == yaml_ANY_ENCODING { + emitter.encoding = yaml_UTF8_ENCODING + } + } + if emitter.best_indent < 2 || emitter.best_indent > 9 { + emitter.best_indent = 2 + } + if emitter.best_width >= 0 && emitter.best_width <= emitter.best_indent*2 { + emitter.best_width = 80 + } + if emitter.best_width < 0 { + emitter.best_width = 1<<31 - 1 + } + if emitter.line_break == yaml_ANY_BREAK { + emitter.line_break = yaml_LN_BREAK + } + + emitter.indent = -1 + emitter.line = 0 + emitter.column = 0 + emitter.whitespace = true + emitter.indention = true + + if emitter.encoding != yaml_UTF8_ENCODING { + if !yaml_emitter_write_bom(emitter) { + return false + } + } + emitter.state = yaml_EMIT_FIRST_DOCUMENT_START_STATE + return true +} + +// Expect DOCUMENT-START or STREAM-END. +func yaml_emitter_emit_document_start(emitter *yaml_emitter_t, event *yaml_event_t, first bool) bool { + + if event.typ == yaml_DOCUMENT_START_EVENT { + + if event.version_directive != nil { + if !yaml_emitter_analyze_version_directive(emitter, event.version_directive) { + return false + } + } + + for i := 0; i < len(event.tag_directives); i++ { + tag_directive := &event.tag_directives[i] + if !yaml_emitter_analyze_tag_directive(emitter, tag_directive) { + return false + } + if !yaml_emitter_append_tag_directive(emitter, tag_directive, false) { + return false + } + } + + for i := 0; i < len(default_tag_directives); i++ { + tag_directive := &default_tag_directives[i] + if !yaml_emitter_append_tag_directive(emitter, tag_directive, true) { + return false + } + } + + implicit := event.implicit + if !first || emitter.canonical { + implicit = false + } + + if emitter.open_ended && (event.version_directive != nil || len(event.tag_directives) > 0) { + if !yaml_emitter_write_indicator(emitter, []byte("..."), true, false, false) { + return false + } + if !yaml_emitter_write_indent(emitter) { + return false + } + } + + if event.version_directive != nil { + implicit = false + if !yaml_emitter_write_indicator(emitter, []byte("%YAML"), true, false, false) { + return false + } + if !yaml_emitter_write_indicator(emitter, []byte("1.1"), true, false, false) { + return false + } + if !yaml_emitter_write_indent(emitter) { + return false + } + } + + if len(event.tag_directives) > 0 { + implicit = false + for i := 0; i < len(event.tag_directives); i++ { + tag_directive := &event.tag_directives[i] + if !yaml_emitter_write_indicator(emitter, []byte("%TAG"), true, false, false) { + return false + } + if !yaml_emitter_write_tag_handle(emitter, tag_directive.handle) { + return false + } + if !yaml_emitter_write_tag_content(emitter, tag_directive.prefix, true) { + return false + } + if !yaml_emitter_write_indent(emitter) { + return false + } + } + } + + if yaml_emitter_check_empty_document(emitter) { + implicit = false + } + if !implicit { + if !yaml_emitter_write_indent(emitter) { + return false + } + if !yaml_emitter_write_indicator(emitter, []byte("---"), true, false, false) { + return false + } + if emitter.canonical { + if !yaml_emitter_write_indent(emitter) { + return false + } + } + } + + emitter.state = yaml_EMIT_DOCUMENT_CONTENT_STATE + return true + } + + if event.typ == yaml_STREAM_END_EVENT { + if emitter.open_ended { + if !yaml_emitter_write_indicator(emitter, []byte("..."), true, false, false) { + return false + } + if !yaml_emitter_write_indent(emitter) { + return false + } + } + if !yaml_emitter_flush(emitter) { + return false + } + emitter.state = yaml_EMIT_END_STATE + return true + } + + return yaml_emitter_set_emitter_error(emitter, "expected DOCUMENT-START or STREAM-END") +} + +// Expect the root node. +func yaml_emitter_emit_document_content(emitter *yaml_emitter_t, event *yaml_event_t) bool { + emitter.states = append(emitter.states, yaml_EMIT_DOCUMENT_END_STATE) + return yaml_emitter_emit_node(emitter, event, true, false, false, false) +} + +// Expect DOCUMENT-END. +func yaml_emitter_emit_document_end(emitter *yaml_emitter_t, event *yaml_event_t) bool { + if event.typ != yaml_DOCUMENT_END_EVENT { + return yaml_emitter_set_emitter_error(emitter, "expected DOCUMENT-END") + } + if !yaml_emitter_write_indent(emitter) { + return false + } + if !event.implicit { + // [Go] Allocate the slice elsewhere. + if !yaml_emitter_write_indicator(emitter, []byte("..."), true, false, false) { + return false + } + if !yaml_emitter_write_indent(emitter) { + return false + } + } + if !yaml_emitter_flush(emitter) { + return false + } + emitter.state = yaml_EMIT_DOCUMENT_START_STATE + emitter.tag_directives = emitter.tag_directives[:0] + return true +} + +// Expect a flow item node. +func yaml_emitter_emit_flow_sequence_item(emitter *yaml_emitter_t, event *yaml_event_t, first bool) bool { + if first { + if !yaml_emitter_write_indicator(emitter, []byte{'['}, true, true, false) { + return false + } + if !yaml_emitter_increase_indent(emitter, true, false) { + return false + } + emitter.flow_level++ + } + + if event.typ == yaml_SEQUENCE_END_EVENT { + emitter.flow_level-- + emitter.indent = emitter.indents[len(emitter.indents)-1] + emitter.indents = emitter.indents[:len(emitter.indents)-1] + if emitter.canonical && !first { + if !yaml_emitter_write_indicator(emitter, []byte{','}, false, false, false) { + return false + } + if !yaml_emitter_write_indent(emitter) { + return false + } + } + if !yaml_emitter_write_indicator(emitter, []byte{']'}, false, false, false) { + return false + } + emitter.state = emitter.states[len(emitter.states)-1] + emitter.states = emitter.states[:len(emitter.states)-1] + + return true + } + + if !first { + if !yaml_emitter_write_indicator(emitter, []byte{','}, false, false, false) { + return false + } + } + + if emitter.canonical || emitter.column > emitter.best_width { + if !yaml_emitter_write_indent(emitter) { + return false + } + } + emitter.states = append(emitter.states, yaml_EMIT_FLOW_SEQUENCE_ITEM_STATE) + return yaml_emitter_emit_node(emitter, event, false, true, false, false) +} + +// Expect a flow key node. +func yaml_emitter_emit_flow_mapping_key(emitter *yaml_emitter_t, event *yaml_event_t, first bool) bool { + if first { + if !yaml_emitter_write_indicator(emitter, []byte{'{'}, true, true, false) { + return false + } + if !yaml_emitter_increase_indent(emitter, true, false) { + return false + } + emitter.flow_level++ + } + + if event.typ == yaml_MAPPING_END_EVENT { + emitter.flow_level-- + emitter.indent = emitter.indents[len(emitter.indents)-1] + emitter.indents = emitter.indents[:len(emitter.indents)-1] + if emitter.canonical && !first { + if !yaml_emitter_write_indicator(emitter, []byte{','}, false, false, false) { + return false + } + if !yaml_emitter_write_indent(emitter) { + return false + } + } + if !yaml_emitter_write_indicator(emitter, []byte{'}'}, false, false, false) { + return false + } + emitter.state = emitter.states[len(emitter.states)-1] + emitter.states = emitter.states[:len(emitter.states)-1] + return true + } + + if !first { + if !yaml_emitter_write_indicator(emitter, []byte{','}, false, false, false) { + return false + } + } + if emitter.canonical || emitter.column > emitter.best_width { + if !yaml_emitter_write_indent(emitter) { + return false + } + } + + if !emitter.canonical && yaml_emitter_check_simple_key(emitter) { + emitter.states = append(emitter.states, yaml_EMIT_FLOW_MAPPING_SIMPLE_VALUE_STATE) + return yaml_emitter_emit_node(emitter, event, false, false, true, true) + } + if !yaml_emitter_write_indicator(emitter, []byte{'?'}, true, false, false) { + return false + } + emitter.states = append(emitter.states, yaml_EMIT_FLOW_MAPPING_VALUE_STATE) + return yaml_emitter_emit_node(emitter, event, false, false, true, false) +} + +// Expect a flow value node. +func yaml_emitter_emit_flow_mapping_value(emitter *yaml_emitter_t, event *yaml_event_t, simple bool) bool { + if simple { + if !yaml_emitter_write_indicator(emitter, []byte{':'}, false, false, false) { + return false + } + } else { + if emitter.canonical || emitter.column > emitter.best_width { + if !yaml_emitter_write_indent(emitter) { + return false + } + } + if !yaml_emitter_write_indicator(emitter, []byte{':'}, true, false, false) { + return false + } + } + emitter.states = append(emitter.states, yaml_EMIT_FLOW_MAPPING_KEY_STATE) + return yaml_emitter_emit_node(emitter, event, false, false, true, false) +} + +// Expect a block item node. +func yaml_emitter_emit_block_sequence_item(emitter *yaml_emitter_t, event *yaml_event_t, first bool) bool { + if first { + if !yaml_emitter_increase_indent(emitter, false, emitter.mapping_context && !emitter.indention) { + return false + } + } + if event.typ == yaml_SEQUENCE_END_EVENT { + emitter.indent = emitter.indents[len(emitter.indents)-1] + emitter.indents = emitter.indents[:len(emitter.indents)-1] + emitter.state = emitter.states[len(emitter.states)-1] + emitter.states = emitter.states[:len(emitter.states)-1] + return true + } + if !yaml_emitter_write_indent(emitter) { + return false + } + if !yaml_emitter_write_indicator(emitter, []byte{'-'}, true, false, true) { + return false + } + emitter.states = append(emitter.states, yaml_EMIT_BLOCK_SEQUENCE_ITEM_STATE) + return yaml_emitter_emit_node(emitter, event, false, true, false, false) +} + +// Expect a block key node. +func yaml_emitter_emit_block_mapping_key(emitter *yaml_emitter_t, event *yaml_event_t, first bool) bool { + if first { + if !yaml_emitter_increase_indent(emitter, false, false) { + return false + } + } + if event.typ == yaml_MAPPING_END_EVENT { + emitter.indent = emitter.indents[len(emitter.indents)-1] + emitter.indents = emitter.indents[:len(emitter.indents)-1] + emitter.state = emitter.states[len(emitter.states)-1] + emitter.states = emitter.states[:len(emitter.states)-1] + return true + } + if !yaml_emitter_write_indent(emitter) { + return false + } + if yaml_emitter_check_simple_key(emitter) { + emitter.states = append(emitter.states, yaml_EMIT_BLOCK_MAPPING_SIMPLE_VALUE_STATE) + return yaml_emitter_emit_node(emitter, event, false, false, true, true) + } + if !yaml_emitter_write_indicator(emitter, []byte{'?'}, true, false, true) { + return false + } + emitter.states = append(emitter.states, yaml_EMIT_BLOCK_MAPPING_VALUE_STATE) + return yaml_emitter_emit_node(emitter, event, false, false, true, false) +} + +// Expect a block value node. +func yaml_emitter_emit_block_mapping_value(emitter *yaml_emitter_t, event *yaml_event_t, simple bool) bool { + if simple { + if !yaml_emitter_write_indicator(emitter, []byte{':'}, false, false, false) { + return false + } + } else { + if !yaml_emitter_write_indent(emitter) { + return false + } + if !yaml_emitter_write_indicator(emitter, []byte{':'}, true, false, true) { + return false + } + } + emitter.states = append(emitter.states, yaml_EMIT_BLOCK_MAPPING_KEY_STATE) + return yaml_emitter_emit_node(emitter, event, false, false, true, false) +} + +// Expect a node. +func yaml_emitter_emit_node(emitter *yaml_emitter_t, event *yaml_event_t, + root bool, sequence bool, mapping bool, simple_key bool) bool { + + emitter.root_context = root + emitter.sequence_context = sequence + emitter.mapping_context = mapping + emitter.simple_key_context = simple_key + + switch event.typ { + case yaml_ALIAS_EVENT: + return yaml_emitter_emit_alias(emitter, event) + case yaml_SCALAR_EVENT: + return yaml_emitter_emit_scalar(emitter, event) + case yaml_SEQUENCE_START_EVENT: + return yaml_emitter_emit_sequence_start(emitter, event) + case yaml_MAPPING_START_EVENT: + return yaml_emitter_emit_mapping_start(emitter, event) + default: + return yaml_emitter_set_emitter_error(emitter, + "expected SCALAR, SEQUENCE-START, MAPPING-START, or ALIAS") + } + return false +} + +// Expect ALIAS. +func yaml_emitter_emit_alias(emitter *yaml_emitter_t, event *yaml_event_t) bool { + if !yaml_emitter_process_anchor(emitter) { + return false + } + emitter.state = emitter.states[len(emitter.states)-1] + emitter.states = emitter.states[:len(emitter.states)-1] + return true +} + +// Expect SCALAR. +func yaml_emitter_emit_scalar(emitter *yaml_emitter_t, event *yaml_event_t) bool { + if !yaml_emitter_select_scalar_style(emitter, event) { + return false + } + if !yaml_emitter_process_anchor(emitter) { + return false + } + if !yaml_emitter_process_tag(emitter) { + return false + } + if !yaml_emitter_increase_indent(emitter, true, false) { + return false + } + if !yaml_emitter_process_scalar(emitter) { + return false + } + emitter.indent = emitter.indents[len(emitter.indents)-1] + emitter.indents = emitter.indents[:len(emitter.indents)-1] + emitter.state = emitter.states[len(emitter.states)-1] + emitter.states = emitter.states[:len(emitter.states)-1] + return true +} + +// Expect SEQUENCE-START. +func yaml_emitter_emit_sequence_start(emitter *yaml_emitter_t, event *yaml_event_t) bool { + if !yaml_emitter_process_anchor(emitter) { + return false + } + if !yaml_emitter_process_tag(emitter) { + return false + } + if emitter.flow_level > 0 || emitter.canonical || event.sequence_style() == yaml_FLOW_SEQUENCE_STYLE || + yaml_emitter_check_empty_sequence(emitter) { + emitter.state = yaml_EMIT_FLOW_SEQUENCE_FIRST_ITEM_STATE + } else { + emitter.state = yaml_EMIT_BLOCK_SEQUENCE_FIRST_ITEM_STATE + } + return true +} + +// Expect MAPPING-START. +func yaml_emitter_emit_mapping_start(emitter *yaml_emitter_t, event *yaml_event_t) bool { + if !yaml_emitter_process_anchor(emitter) { + return false + } + if !yaml_emitter_process_tag(emitter) { + return false + } + if emitter.flow_level > 0 || emitter.canonical || event.mapping_style() == yaml_FLOW_MAPPING_STYLE || + yaml_emitter_check_empty_mapping(emitter) { + emitter.state = yaml_EMIT_FLOW_MAPPING_FIRST_KEY_STATE + } else { + emitter.state = yaml_EMIT_BLOCK_MAPPING_FIRST_KEY_STATE + } + return true +} + +// Check if the document content is an empty scalar. +func yaml_emitter_check_empty_document(emitter *yaml_emitter_t) bool { + return false // [Go] Huh? +} + +// Check if the next events represent an empty sequence. +func yaml_emitter_check_empty_sequence(emitter *yaml_emitter_t) bool { + if len(emitter.events)-emitter.events_head < 2 { + return false + } + return emitter.events[emitter.events_head].typ == yaml_SEQUENCE_START_EVENT && + emitter.events[emitter.events_head+1].typ == yaml_SEQUENCE_END_EVENT +} + +// Check if the next events represent an empty mapping. +func yaml_emitter_check_empty_mapping(emitter *yaml_emitter_t) bool { + if len(emitter.events)-emitter.events_head < 2 { + return false + } + return emitter.events[emitter.events_head].typ == yaml_MAPPING_START_EVENT && + emitter.events[emitter.events_head+1].typ == yaml_MAPPING_END_EVENT +} + +// Check if the next node can be expressed as a simple key. +func yaml_emitter_check_simple_key(emitter *yaml_emitter_t) bool { + length := 0 + switch emitter.events[emitter.events_head].typ { + case yaml_ALIAS_EVENT: + length += len(emitter.anchor_data.anchor) + case yaml_SCALAR_EVENT: + if emitter.scalar_data.multiline { + return false + } + length += len(emitter.anchor_data.anchor) + + len(emitter.tag_data.handle) + + len(emitter.tag_data.suffix) + + len(emitter.scalar_data.value) + case yaml_SEQUENCE_START_EVENT: + if !yaml_emitter_check_empty_sequence(emitter) { + return false + } + length += len(emitter.anchor_data.anchor) + + len(emitter.tag_data.handle) + + len(emitter.tag_data.suffix) + case yaml_MAPPING_START_EVENT: + if !yaml_emitter_check_empty_mapping(emitter) { + return false + } + length += len(emitter.anchor_data.anchor) + + len(emitter.tag_data.handle) + + len(emitter.tag_data.suffix) + default: + return false + } + return length <= 128 +} + +// Determine an acceptable scalar style. +func yaml_emitter_select_scalar_style(emitter *yaml_emitter_t, event *yaml_event_t) bool { + + no_tag := len(emitter.tag_data.handle) == 0 && len(emitter.tag_data.suffix) == 0 + if no_tag && !event.implicit && !event.quoted_implicit { + return yaml_emitter_set_emitter_error(emitter, "neither tag nor implicit flags are specified") + } + + style := event.scalar_style() + if style == yaml_ANY_SCALAR_STYLE { + style = yaml_PLAIN_SCALAR_STYLE + } + if emitter.canonical { + style = yaml_DOUBLE_QUOTED_SCALAR_STYLE + } + if emitter.simple_key_context && emitter.scalar_data.multiline { + style = yaml_DOUBLE_QUOTED_SCALAR_STYLE + } + + if style == yaml_PLAIN_SCALAR_STYLE { + if emitter.flow_level > 0 && !emitter.scalar_data.flow_plain_allowed || + emitter.flow_level == 0 && !emitter.scalar_data.block_plain_allowed { + style = yaml_SINGLE_QUOTED_SCALAR_STYLE + } + if len(emitter.scalar_data.value) == 0 && (emitter.flow_level > 0 || emitter.simple_key_context) { + style = yaml_SINGLE_QUOTED_SCALAR_STYLE + } + if no_tag && !event.implicit { + style = yaml_SINGLE_QUOTED_SCALAR_STYLE + } + } + if style == yaml_SINGLE_QUOTED_SCALAR_STYLE { + if !emitter.scalar_data.single_quoted_allowed { + style = yaml_DOUBLE_QUOTED_SCALAR_STYLE + } + } + if style == yaml_LITERAL_SCALAR_STYLE || style == yaml_FOLDED_SCALAR_STYLE { + if !emitter.scalar_data.block_allowed || emitter.flow_level > 0 || emitter.simple_key_context { + style = yaml_DOUBLE_QUOTED_SCALAR_STYLE + } + } + + if no_tag && !event.quoted_implicit && style != yaml_PLAIN_SCALAR_STYLE { + emitter.tag_data.handle = []byte{'!'} + } + emitter.scalar_data.style = style + return true +} + +// Write an achor. +func yaml_emitter_process_anchor(emitter *yaml_emitter_t) bool { + if emitter.anchor_data.anchor == nil { + return true + } + c := []byte{'&'} + if emitter.anchor_data.alias { + c[0] = '*' + } + if !yaml_emitter_write_indicator(emitter, c, true, false, false) { + return false + } + return yaml_emitter_write_anchor(emitter, emitter.anchor_data.anchor) +} + +// Write a tag. +func yaml_emitter_process_tag(emitter *yaml_emitter_t) bool { + if len(emitter.tag_data.handle) == 0 && len(emitter.tag_data.suffix) == 0 { + return true + } + if len(emitter.tag_data.handle) > 0 { + if !yaml_emitter_write_tag_handle(emitter, emitter.tag_data.handle) { + return false + } + if len(emitter.tag_data.suffix) > 0 { + if !yaml_emitter_write_tag_content(emitter, emitter.tag_data.suffix, false) { + return false + } + } + } else { + // [Go] Allocate these slices elsewhere. + if !yaml_emitter_write_indicator(emitter, []byte("!<"), true, false, false) { + return false + } + if !yaml_emitter_write_tag_content(emitter, emitter.tag_data.suffix, false) { + return false + } + if !yaml_emitter_write_indicator(emitter, []byte{'>'}, false, false, false) { + return false + } + } + return true +} + +// Write a scalar. +func yaml_emitter_process_scalar(emitter *yaml_emitter_t) bool { + switch emitter.scalar_data.style { + case yaml_PLAIN_SCALAR_STYLE: + return yaml_emitter_write_plain_scalar(emitter, emitter.scalar_data.value, !emitter.simple_key_context) + + case yaml_SINGLE_QUOTED_SCALAR_STYLE: + return yaml_emitter_write_single_quoted_scalar(emitter, emitter.scalar_data.value, !emitter.simple_key_context) + + case yaml_DOUBLE_QUOTED_SCALAR_STYLE: + return yaml_emitter_write_double_quoted_scalar(emitter, emitter.scalar_data.value, !emitter.simple_key_context) + + case yaml_LITERAL_SCALAR_STYLE: + return yaml_emitter_write_literal_scalar(emitter, emitter.scalar_data.value) + + case yaml_FOLDED_SCALAR_STYLE: + return yaml_emitter_write_folded_scalar(emitter, emitter.scalar_data.value) + } + panic("unknown scalar style") +} + +// Check if a %YAML directive is valid. +func yaml_emitter_analyze_version_directive(emitter *yaml_emitter_t, version_directive *yaml_version_directive_t) bool { + if version_directive.major != 1 || version_directive.minor != 1 { + return yaml_emitter_set_emitter_error(emitter, "incompatible %YAML directive") + } + return true +} + +// Check if a %TAG directive is valid. +func yaml_emitter_analyze_tag_directive(emitter *yaml_emitter_t, tag_directive *yaml_tag_directive_t) bool { + handle := tag_directive.handle + prefix := tag_directive.prefix + if len(handle) == 0 { + return yaml_emitter_set_emitter_error(emitter, "tag handle must not be empty") + } + if handle[0] != '!' { + return yaml_emitter_set_emitter_error(emitter, "tag handle must start with '!'") + } + if handle[len(handle)-1] != '!' { + return yaml_emitter_set_emitter_error(emitter, "tag handle must end with '!'") + } + for i := 1; i < len(handle)-1; i += width(handle[i]) { + if !is_alpha(handle, i) { + return yaml_emitter_set_emitter_error(emitter, "tag handle must contain alphanumerical characters only") + } + } + if len(prefix) == 0 { + return yaml_emitter_set_emitter_error(emitter, "tag prefix must not be empty") + } + return true +} + +// Check if an anchor is valid. +func yaml_emitter_analyze_anchor(emitter *yaml_emitter_t, anchor []byte, alias bool) bool { + if len(anchor) == 0 { + problem := "anchor value must not be empty" + if alias { + problem = "alias value must not be empty" + } + return yaml_emitter_set_emitter_error(emitter, problem) + } + for i := 0; i < len(anchor); i += width(anchor[i]) { + if !is_alpha(anchor, i) { + problem := "anchor value must contain alphanumerical characters only" + if alias { + problem = "alias value must contain alphanumerical characters only" + } + return yaml_emitter_set_emitter_error(emitter, problem) + } + } + emitter.anchor_data.anchor = anchor + emitter.anchor_data.alias = alias + return true +} + +// Check if a tag is valid. +func yaml_emitter_analyze_tag(emitter *yaml_emitter_t, tag []byte) bool { + if len(tag) == 0 { + return yaml_emitter_set_emitter_error(emitter, "tag value must not be empty") + } + for i := 0; i < len(emitter.tag_directives); i++ { + tag_directive := &emitter.tag_directives[i] + if bytes.HasPrefix(tag, tag_directive.prefix) { + emitter.tag_data.handle = tag_directive.handle + emitter.tag_data.suffix = tag[len(tag_directive.prefix):] + return true + } + } + emitter.tag_data.suffix = tag + return true +} + +// Check if a scalar is valid. +func yaml_emitter_analyze_scalar(emitter *yaml_emitter_t, value []byte) bool { + var ( + block_indicators = false + flow_indicators = false + line_breaks = false + special_characters = false + + leading_space = false + leading_break = false + trailing_space = false + trailing_break = false + break_space = false + space_break = false + + preceeded_by_whitespace = false + followed_by_whitespace = false + previous_space = false + previous_break = false + ) + + emitter.scalar_data.value = value + + if len(value) == 0 { + emitter.scalar_data.multiline = false + emitter.scalar_data.flow_plain_allowed = false + emitter.scalar_data.block_plain_allowed = true + emitter.scalar_data.single_quoted_allowed = true + emitter.scalar_data.block_allowed = false + return true + } + + if len(value) >= 3 && ((value[0] == '-' && value[1] == '-' && value[2] == '-') || (value[0] == '.' && value[1] == '.' && value[2] == '.')) { + block_indicators = true + flow_indicators = true + } + + preceeded_by_whitespace = true + for i, w := 0, 0; i < len(value); i += w { + w = width(value[i]) + followed_by_whitespace = i+w >= len(value) || is_blank(value, i+w) + + if i == 0 { + switch value[i] { + case '#', ',', '[', ']', '{', '}', '&', '*', '!', '|', '>', '\'', '"', '%', '@', '`': + flow_indicators = true + block_indicators = true + case '?', ':': + flow_indicators = true + if followed_by_whitespace { + block_indicators = true + } + case '-': + if followed_by_whitespace { + flow_indicators = true + block_indicators = true + } + } + } else { + switch value[i] { + case ',', '?', '[', ']', '{', '}': + flow_indicators = true + case ':': + flow_indicators = true + if followed_by_whitespace { + block_indicators = true + } + case '#': + if preceeded_by_whitespace { + flow_indicators = true + block_indicators = true + } + } + } + + if !is_printable(value, i) || !is_ascii(value, i) && !emitter.unicode { + special_characters = true + } + if is_space(value, i) { + if i == 0 { + leading_space = true + } + if i+width(value[i]) == len(value) { + trailing_space = true + } + if previous_break { + break_space = true + } + previous_space = true + previous_break = false + } else if is_break(value, i) { + line_breaks = true + if i == 0 { + leading_break = true + } + if i+width(value[i]) == len(value) { + trailing_break = true + } + if previous_space { + space_break = true + } + previous_space = false + previous_break = true + } else { + previous_space = false + previous_break = false + } + + // [Go]: Why 'z'? Couldn't be the end of the string as that's the loop condition. + preceeded_by_whitespace = is_blankz(value, i) + } + + emitter.scalar_data.multiline = line_breaks + emitter.scalar_data.flow_plain_allowed = true + emitter.scalar_data.block_plain_allowed = true + emitter.scalar_data.single_quoted_allowed = true + emitter.scalar_data.block_allowed = true + + if leading_space || leading_break || trailing_space || trailing_break { + emitter.scalar_data.flow_plain_allowed = false + emitter.scalar_data.block_plain_allowed = false + } + if trailing_space { + emitter.scalar_data.block_allowed = false + } + if break_space { + emitter.scalar_data.flow_plain_allowed = false + emitter.scalar_data.block_plain_allowed = false + emitter.scalar_data.single_quoted_allowed = false + } + if space_break || special_characters { + emitter.scalar_data.flow_plain_allowed = false + emitter.scalar_data.block_plain_allowed = false + emitter.scalar_data.single_quoted_allowed = false + emitter.scalar_data.block_allowed = false + } + if line_breaks { + emitter.scalar_data.flow_plain_allowed = false + emitter.scalar_data.block_plain_allowed = false + } + if flow_indicators { + emitter.scalar_data.flow_plain_allowed = false + } + if block_indicators { + emitter.scalar_data.block_plain_allowed = false + } + return true +} + +// Check if the event data is valid. +func yaml_emitter_analyze_event(emitter *yaml_emitter_t, event *yaml_event_t) bool { + + emitter.anchor_data.anchor = nil + emitter.tag_data.handle = nil + emitter.tag_data.suffix = nil + emitter.scalar_data.value = nil + + switch event.typ { + case yaml_ALIAS_EVENT: + if !yaml_emitter_analyze_anchor(emitter, event.anchor, true) { + return false + } + + case yaml_SCALAR_EVENT: + if len(event.anchor) > 0 { + if !yaml_emitter_analyze_anchor(emitter, event.anchor, false) { + return false + } + } + if len(event.tag) > 0 && (emitter.canonical || (!event.implicit && !event.quoted_implicit)) { + if !yaml_emitter_analyze_tag(emitter, event.tag) { + return false + } + } + if !yaml_emitter_analyze_scalar(emitter, event.value) { + return false + } + + case yaml_SEQUENCE_START_EVENT: + if len(event.anchor) > 0 { + if !yaml_emitter_analyze_anchor(emitter, event.anchor, false) { + return false + } + } + if len(event.tag) > 0 && (emitter.canonical || !event.implicit) { + if !yaml_emitter_analyze_tag(emitter, event.tag) { + return false + } + } + + case yaml_MAPPING_START_EVENT: + if len(event.anchor) > 0 { + if !yaml_emitter_analyze_anchor(emitter, event.anchor, false) { + return false + } + } + if len(event.tag) > 0 && (emitter.canonical || !event.implicit) { + if !yaml_emitter_analyze_tag(emitter, event.tag) { + return false + } + } + } + return true +} + +// Write the BOM character. +func yaml_emitter_write_bom(emitter *yaml_emitter_t) bool { + if !flush(emitter) { + return false + } + pos := emitter.buffer_pos + emitter.buffer[pos+0] = '\xEF' + emitter.buffer[pos+1] = '\xBB' + emitter.buffer[pos+2] = '\xBF' + emitter.buffer_pos += 3 + return true +} + +func yaml_emitter_write_indent(emitter *yaml_emitter_t) bool { + indent := emitter.indent + if indent < 0 { + indent = 0 + } + if !emitter.indention || emitter.column > indent || (emitter.column == indent && !emitter.whitespace) { + if !put_break(emitter) { + return false + } + } + for emitter.column < indent { + if !put(emitter, ' ') { + return false + } + } + emitter.whitespace = true + emitter.indention = true + return true +} + +func yaml_emitter_write_indicator(emitter *yaml_emitter_t, indicator []byte, need_whitespace, is_whitespace, is_indention bool) bool { + if need_whitespace && !emitter.whitespace { + if !put(emitter, ' ') { + return false + } + } + if !write_all(emitter, indicator) { + return false + } + emitter.whitespace = is_whitespace + emitter.indention = (emitter.indention && is_indention) + emitter.open_ended = false + return true +} + +func yaml_emitter_write_anchor(emitter *yaml_emitter_t, value []byte) bool { + if !write_all(emitter, value) { + return false + } + emitter.whitespace = false + emitter.indention = false + return true +} + +func yaml_emitter_write_tag_handle(emitter *yaml_emitter_t, value []byte) bool { + if !emitter.whitespace { + if !put(emitter, ' ') { + return false + } + } + if !write_all(emitter, value) { + return false + } + emitter.whitespace = false + emitter.indention = false + return true +} + +func yaml_emitter_write_tag_content(emitter *yaml_emitter_t, value []byte, need_whitespace bool) bool { + if need_whitespace && !emitter.whitespace { + if !put(emitter, ' ') { + return false + } + } + for i := 0; i < len(value); { + var must_write bool + switch value[i] { + case ';', '/', '?', ':', '@', '&', '=', '+', '$', ',', '_', '.', '~', '*', '\'', '(', ')', '[', ']': + must_write = true + default: + must_write = is_alpha(value, i) + } + if must_write { + if !write(emitter, value, &i) { + return false + } + } else { + w := width(value[i]) + for k := 0; k < w; k++ { + octet := value[i] + i++ + if !put(emitter, '%') { + return false + } + + c := octet >> 4 + if c < 10 { + c += '0' + } else { + c += 'A' - 10 + } + if !put(emitter, c) { + return false + } + + c = octet & 0x0f + if c < 10 { + c += '0' + } else { + c += 'A' - 10 + } + if !put(emitter, c) { + return false + } + } + } + } + emitter.whitespace = false + emitter.indention = false + return true +} + +func yaml_emitter_write_plain_scalar(emitter *yaml_emitter_t, value []byte, allow_breaks bool) bool { + if !emitter.whitespace { + if !put(emitter, ' ') { + return false + } + } + + spaces := false + breaks := false + for i := 0; i < len(value); { + if is_space(value, i) { + if allow_breaks && !spaces && emitter.column > emitter.best_width && !is_space(value, i+1) { + if !yaml_emitter_write_indent(emitter) { + return false + } + i += width(value[i]) + } else { + if !write(emitter, value, &i) { + return false + } + } + spaces = true + } else if is_break(value, i) { + if !breaks && value[i] == '\n' { + if !put_break(emitter) { + return false + } + } + if !write_break(emitter, value, &i) { + return false + } + emitter.indention = true + breaks = true + } else { + if breaks { + if !yaml_emitter_write_indent(emitter) { + return false + } + } + if !write(emitter, value, &i) { + return false + } + emitter.indention = false + spaces = false + breaks = false + } + } + + emitter.whitespace = false + emitter.indention = false + if emitter.root_context { + emitter.open_ended = true + } + + return true +} + +func yaml_emitter_write_single_quoted_scalar(emitter *yaml_emitter_t, value []byte, allow_breaks bool) bool { + + if !yaml_emitter_write_indicator(emitter, []byte{'\''}, true, false, false) { + return false + } + + spaces := false + breaks := false + for i := 0; i < len(value); { + if is_space(value, i) { + if allow_breaks && !spaces && emitter.column > emitter.best_width && i > 0 && i < len(value)-1 && !is_space(value, i+1) { + if !yaml_emitter_write_indent(emitter) { + return false + } + i += width(value[i]) + } else { + if !write(emitter, value, &i) { + return false + } + } + spaces = true + } else if is_break(value, i) { + if !breaks && value[i] == '\n' { + if !put_break(emitter) { + return false + } + } + if !write_break(emitter, value, &i) { + return false + } + emitter.indention = true + breaks = true + } else { + if breaks { + if !yaml_emitter_write_indent(emitter) { + return false + } + } + if value[i] == '\'' { + if !put(emitter, '\'') { + return false + } + } + if !write(emitter, value, &i) { + return false + } + emitter.indention = false + spaces = false + breaks = false + } + } + if !yaml_emitter_write_indicator(emitter, []byte{'\''}, false, false, false) { + return false + } + emitter.whitespace = false + emitter.indention = false + return true +} + +func yaml_emitter_write_double_quoted_scalar(emitter *yaml_emitter_t, value []byte, allow_breaks bool) bool { + spaces := false + if !yaml_emitter_write_indicator(emitter, []byte{'"'}, true, false, false) { + return false + } + + for i := 0; i < len(value); { + if !is_printable(value, i) || (!emitter.unicode && !is_ascii(value, i)) || + is_bom(value, i) || is_break(value, i) || + value[i] == '"' || value[i] == '\\' { + + octet := value[i] + + var w int + var v rune + switch { + case octet&0x80 == 0x00: + w, v = 1, rune(octet&0x7F) + case octet&0xE0 == 0xC0: + w, v = 2, rune(octet&0x1F) + case octet&0xF0 == 0xE0: + w, v = 3, rune(octet&0x0F) + case octet&0xF8 == 0xF0: + w, v = 4, rune(octet&0x07) + } + for k := 1; k < w; k++ { + octet = value[i+k] + v = (v << 6) + (rune(octet) & 0x3F) + } + i += w + + if !put(emitter, '\\') { + return false + } + + var ok bool + switch v { + case 0x00: + ok = put(emitter, '0') + case 0x07: + ok = put(emitter, 'a') + case 0x08: + ok = put(emitter, 'b') + case 0x09: + ok = put(emitter, 't') + case 0x0A: + ok = put(emitter, 'n') + case 0x0b: + ok = put(emitter, 'v') + case 0x0c: + ok = put(emitter, 'f') + case 0x0d: + ok = put(emitter, 'r') + case 0x1b: + ok = put(emitter, 'e') + case 0x22: + ok = put(emitter, '"') + case 0x5c: + ok = put(emitter, '\\') + case 0x85: + ok = put(emitter, 'N') + case 0xA0: + ok = put(emitter, '_') + case 0x2028: + ok = put(emitter, 'L') + case 0x2029: + ok = put(emitter, 'P') + default: + if v <= 0xFF { + ok = put(emitter, 'x') + w = 2 + } else if v <= 0xFFFF { + ok = put(emitter, 'u') + w = 4 + } else { + ok = put(emitter, 'U') + w = 8 + } + for k := (w - 1) * 4; ok && k >= 0; k -= 4 { + digit := byte((v >> uint(k)) & 0x0F) + if digit < 10 { + ok = put(emitter, digit+'0') + } else { + ok = put(emitter, digit+'A'-10) + } + } + } + if !ok { + return false + } + spaces = false + } else if is_space(value, i) { + if allow_breaks && !spaces && emitter.column > emitter.best_width && i > 0 && i < len(value)-1 { + if !yaml_emitter_write_indent(emitter) { + return false + } + if is_space(value, i+1) { + if !put(emitter, '\\') { + return false + } + } + i += width(value[i]) + } else if !write(emitter, value, &i) { + return false + } + spaces = true + } else { + if !write(emitter, value, &i) { + return false + } + spaces = false + } + } + if !yaml_emitter_write_indicator(emitter, []byte{'"'}, false, false, false) { + return false + } + emitter.whitespace = false + emitter.indention = false + return true +} + +func yaml_emitter_write_block_scalar_hints(emitter *yaml_emitter_t, value []byte) bool { + if is_space(value, 0) || is_break(value, 0) { + indent_hint := []byte{'0' + byte(emitter.best_indent)} + if !yaml_emitter_write_indicator(emitter, indent_hint, false, false, false) { + return false + } + } + + emitter.open_ended = false + + var chomp_hint [1]byte + if len(value) == 0 { + chomp_hint[0] = '-' + } else { + i := len(value) - 1 + for value[i]&0xC0 == 0x80 { + i-- + } + if !is_break(value, i) { + chomp_hint[0] = '-' + } else if i == 0 { + chomp_hint[0] = '+' + emitter.open_ended = true + } else { + i-- + for value[i]&0xC0 == 0x80 { + i-- + } + if is_break(value, i) { + chomp_hint[0] = '+' + emitter.open_ended = true + } + } + } + if chomp_hint[0] != 0 { + if !yaml_emitter_write_indicator(emitter, chomp_hint[:], false, false, false) { + return false + } + } + return true +} + +func yaml_emitter_write_literal_scalar(emitter *yaml_emitter_t, value []byte) bool { + if !yaml_emitter_write_indicator(emitter, []byte{'|'}, true, false, false) { + return false + } + if !yaml_emitter_write_block_scalar_hints(emitter, value) { + return false + } + if !put_break(emitter) { + return false + } + emitter.indention = true + emitter.whitespace = true + breaks := true + for i := 0; i < len(value); { + if is_break(value, i) { + if !write_break(emitter, value, &i) { + return false + } + emitter.indention = true + breaks = true + } else { + if breaks { + if !yaml_emitter_write_indent(emitter) { + return false + } + } + if !write(emitter, value, &i) { + return false + } + emitter.indention = false + breaks = false + } + } + + return true +} + +func yaml_emitter_write_folded_scalar(emitter *yaml_emitter_t, value []byte) bool { + if !yaml_emitter_write_indicator(emitter, []byte{'>'}, true, false, false) { + return false + } + if !yaml_emitter_write_block_scalar_hints(emitter, value) { + return false + } + + if !put_break(emitter) { + return false + } + emitter.indention = true + emitter.whitespace = true + + breaks := true + leading_spaces := true + for i := 0; i < len(value); { + if is_break(value, i) { + if !breaks && !leading_spaces && value[i] == '\n' { + k := 0 + for is_break(value, k) { + k += width(value[k]) + } + if !is_blankz(value, k) { + if !put_break(emitter) { + return false + } + } + } + if !write_break(emitter, value, &i) { + return false + } + emitter.indention = true + breaks = true + } else { + if breaks { + if !yaml_emitter_write_indent(emitter) { + return false + } + leading_spaces = is_blank(value, i) + } + if !breaks && is_space(value, i) && !is_space(value, i+1) && emitter.column > emitter.best_width { + if !yaml_emitter_write_indent(emitter) { + return false + } + i += width(value[i]) + } else { + if !write(emitter, value, &i) { + return false + } + } + emitter.indention = false + breaks = false + } + } + return true +} diff --git a/Godeps/_workspace/src/gopkg.in/yaml.v2/encode.go b/Godeps/_workspace/src/gopkg.in/yaml.v2/encode.go new file mode 100644 index 000000000..84f849955 --- /dev/null +++ b/Godeps/_workspace/src/gopkg.in/yaml.v2/encode.go @@ -0,0 +1,306 @@ +package yaml + +import ( + "encoding" + "fmt" + "reflect" + "regexp" + "sort" + "strconv" + "strings" + "time" +) + +type encoder struct { + emitter yaml_emitter_t + event yaml_event_t + out []byte + flow bool +} + +func newEncoder() (e *encoder) { + e = &encoder{} + e.must(yaml_emitter_initialize(&e.emitter)) + yaml_emitter_set_output_string(&e.emitter, &e.out) + yaml_emitter_set_unicode(&e.emitter, true) + e.must(yaml_stream_start_event_initialize(&e.event, yaml_UTF8_ENCODING)) + e.emit() + e.must(yaml_document_start_event_initialize(&e.event, nil, nil, true)) + e.emit() + return e +} + +func (e *encoder) finish() { + e.must(yaml_document_end_event_initialize(&e.event, true)) + e.emit() + e.emitter.open_ended = false + e.must(yaml_stream_end_event_initialize(&e.event)) + e.emit() +} + +func (e *encoder) destroy() { + yaml_emitter_delete(&e.emitter) +} + +func (e *encoder) emit() { + // This will internally delete the e.event value. + if !yaml_emitter_emit(&e.emitter, &e.event) && e.event.typ != yaml_DOCUMENT_END_EVENT && e.event.typ != yaml_STREAM_END_EVENT { + e.must(false) + } +} + +func (e *encoder) must(ok bool) { + if !ok { + msg := e.emitter.problem + if msg == "" { + msg = "unknown problem generating YAML content" + } + failf("%s", msg) + } +} + +func (e *encoder) marshal(tag string, in reflect.Value) { + if !in.IsValid() { + e.nilv() + return + } + iface := in.Interface() + if m, ok := iface.(Marshaler); ok { + v, err := m.MarshalYAML() + if err != nil { + fail(err) + } + if v == nil { + e.nilv() + return + } + in = reflect.ValueOf(v) + } else if m, ok := iface.(encoding.TextMarshaler); ok { + text, err := m.MarshalText() + if err != nil { + fail(err) + } + in = reflect.ValueOf(string(text)) + } + switch in.Kind() { + case reflect.Interface: + if in.IsNil() { + e.nilv() + } else { + e.marshal(tag, in.Elem()) + } + case reflect.Map: + e.mapv(tag, in) + case reflect.Ptr: + if in.IsNil() { + e.nilv() + } else { + e.marshal(tag, in.Elem()) + } + case reflect.Struct: + e.structv(tag, in) + case reflect.Slice: + if in.Type().Elem() == mapItemType { + e.itemsv(tag, in) + } else { + e.slicev(tag, in) + } + case reflect.String: + e.stringv(tag, in) + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + if in.Type() == durationType { + e.stringv(tag, reflect.ValueOf(iface.(time.Duration).String())) + } else { + e.intv(tag, in) + } + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: + e.uintv(tag, in) + case reflect.Float32, reflect.Float64: + e.floatv(tag, in) + case reflect.Bool: + e.boolv(tag, in) + default: + panic("cannot marshal type: " + in.Type().String()) + } +} + +func (e *encoder) mapv(tag string, in reflect.Value) { + e.mappingv(tag, func() { + keys := keyList(in.MapKeys()) + sort.Sort(keys) + for _, k := range keys { + e.marshal("", k) + e.marshal("", in.MapIndex(k)) + } + }) +} + +func (e *encoder) itemsv(tag string, in reflect.Value) { + e.mappingv(tag, func() { + slice := in.Convert(reflect.TypeOf([]MapItem{})).Interface().([]MapItem) + for _, item := range slice { + e.marshal("", reflect.ValueOf(item.Key)) + e.marshal("", reflect.ValueOf(item.Value)) + } + }) +} + +func (e *encoder) structv(tag string, in reflect.Value) { + sinfo, err := getStructInfo(in.Type()) + if err != nil { + panic(err) + } + e.mappingv(tag, func() { + for _, info := range sinfo.FieldsList { + var value reflect.Value + if info.Inline == nil { + value = in.Field(info.Num) + } else { + value = in.FieldByIndex(info.Inline) + } + if info.OmitEmpty && isZero(value) { + continue + } + e.marshal("", reflect.ValueOf(info.Key)) + e.flow = info.Flow + e.marshal("", value) + } + if sinfo.InlineMap >= 0 { + m := in.Field(sinfo.InlineMap) + if m.Len() > 0 { + e.flow = false + keys := keyList(m.MapKeys()) + sort.Sort(keys) + for _, k := range keys { + if _, found := sinfo.FieldsMap[k.String()]; found { + panic(fmt.Sprintf("Can't have key %q in inlined map; conflicts with struct field", k.String())) + } + e.marshal("", k) + e.flow = false + e.marshal("", m.MapIndex(k)) + } + } + } + }) +} + +func (e *encoder) mappingv(tag string, f func()) { + implicit := tag == "" + style := yaml_BLOCK_MAPPING_STYLE + if e.flow { + e.flow = false + style = yaml_FLOW_MAPPING_STYLE + } + e.must(yaml_mapping_start_event_initialize(&e.event, nil, []byte(tag), implicit, style)) + e.emit() + f() + e.must(yaml_mapping_end_event_initialize(&e.event)) + e.emit() +} + +func (e *encoder) slicev(tag string, in reflect.Value) { + implicit := tag == "" + style := yaml_BLOCK_SEQUENCE_STYLE + if e.flow { + e.flow = false + style = yaml_FLOW_SEQUENCE_STYLE + } + e.must(yaml_sequence_start_event_initialize(&e.event, nil, []byte(tag), implicit, style)) + e.emit() + n := in.Len() + for i := 0; i < n; i++ { + e.marshal("", in.Index(i)) + } + e.must(yaml_sequence_end_event_initialize(&e.event)) + e.emit() +} + +// isBase60 returns whether s is in base 60 notation as defined in YAML 1.1. +// +// The base 60 float notation in YAML 1.1 is a terrible idea and is unsupported +// in YAML 1.2 and by this package, but these should be marshalled quoted for +// the time being for compatibility with other parsers. +func isBase60Float(s string) (result bool) { + // Fast path. + if s == "" { + return false + } + c := s[0] + if !(c == '+' || c == '-' || c >= '0' && c <= '9') || strings.IndexByte(s, ':') < 0 { + return false + } + // Do the full match. + return base60float.MatchString(s) +} + +// From http://yaml.org/type/float.html, except the regular expression there +// is bogus. In practice parsers do not enforce the "\.[0-9_]*" suffix. +var base60float = regexp.MustCompile(`^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+(?:\.[0-9_]*)?$`) + +func (e *encoder) stringv(tag string, in reflect.Value) { + var style yaml_scalar_style_t + s := in.String() + rtag, rs := resolve("", s) + if rtag == yaml_BINARY_TAG { + if tag == "" || tag == yaml_STR_TAG { + tag = rtag + s = rs.(string) + } else if tag == yaml_BINARY_TAG { + failf("explicitly tagged !!binary data must be base64-encoded") + } else { + failf("cannot marshal invalid UTF-8 data as %s", shortTag(tag)) + } + } + if tag == "" && (rtag != yaml_STR_TAG || isBase60Float(s)) { + style = yaml_DOUBLE_QUOTED_SCALAR_STYLE + } else if strings.Contains(s, "\n") { + style = yaml_LITERAL_SCALAR_STYLE + } else { + style = yaml_PLAIN_SCALAR_STYLE + } + e.emitScalar(s, "", tag, style) +} + +func (e *encoder) boolv(tag string, in reflect.Value) { + var s string + if in.Bool() { + s = "true" + } else { + s = "false" + } + e.emitScalar(s, "", tag, yaml_PLAIN_SCALAR_STYLE) +} + +func (e *encoder) intv(tag string, in reflect.Value) { + s := strconv.FormatInt(in.Int(), 10) + e.emitScalar(s, "", tag, yaml_PLAIN_SCALAR_STYLE) +} + +func (e *encoder) uintv(tag string, in reflect.Value) { + s := strconv.FormatUint(in.Uint(), 10) + e.emitScalar(s, "", tag, yaml_PLAIN_SCALAR_STYLE) +} + +func (e *encoder) floatv(tag string, in reflect.Value) { + // FIXME: Handle 64 bits here. + s := strconv.FormatFloat(float64(in.Float()), 'g', -1, 32) + switch s { + case "+Inf": + s = ".inf" + case "-Inf": + s = "-.inf" + case "NaN": + s = ".nan" + } + e.emitScalar(s, "", tag, yaml_PLAIN_SCALAR_STYLE) +} + +func (e *encoder) nilv() { + e.emitScalar("null", "", "", yaml_PLAIN_SCALAR_STYLE) +} + +func (e *encoder) emitScalar(value, anchor, tag string, style yaml_scalar_style_t) { + implicit := tag == "" + e.must(yaml_scalar_event_initialize(&e.event, []byte(anchor), []byte(tag), []byte(value), implicit, implicit, style)) + e.emit() +} diff --git a/Godeps/_workspace/src/gopkg.in/yaml.v2/parserc.go b/Godeps/_workspace/src/gopkg.in/yaml.v2/parserc.go new file mode 100644 index 000000000..0a7037ad1 --- /dev/null +++ b/Godeps/_workspace/src/gopkg.in/yaml.v2/parserc.go @@ -0,0 +1,1096 @@ +package yaml + +import ( + "bytes" +) + +// The parser implements the following grammar: +// +// stream ::= STREAM-START implicit_document? explicit_document* STREAM-END +// implicit_document ::= block_node DOCUMENT-END* +// explicit_document ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END* +// block_node_or_indentless_sequence ::= +// ALIAS +// | properties (block_content | indentless_block_sequence)? +// | block_content +// | indentless_block_sequence +// block_node ::= ALIAS +// | properties block_content? +// | block_content +// flow_node ::= ALIAS +// | properties flow_content? +// | flow_content +// properties ::= TAG ANCHOR? | ANCHOR TAG? +// block_content ::= block_collection | flow_collection | SCALAR +// flow_content ::= flow_collection | SCALAR +// block_collection ::= block_sequence | block_mapping +// flow_collection ::= flow_sequence | flow_mapping +// block_sequence ::= BLOCK-SEQUENCE-START (BLOCK-ENTRY block_node?)* BLOCK-END +// indentless_sequence ::= (BLOCK-ENTRY block_node?)+ +// block_mapping ::= BLOCK-MAPPING_START +// ((KEY block_node_or_indentless_sequence?)? +// (VALUE block_node_or_indentless_sequence?)?)* +// BLOCK-END +// flow_sequence ::= FLOW-SEQUENCE-START +// (flow_sequence_entry FLOW-ENTRY)* +// flow_sequence_entry? +// FLOW-SEQUENCE-END +// flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? +// flow_mapping ::= FLOW-MAPPING-START +// (flow_mapping_entry FLOW-ENTRY)* +// flow_mapping_entry? +// FLOW-MAPPING-END +// flow_mapping_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? + +// Peek the next token in the token queue. +func peek_token(parser *yaml_parser_t) *yaml_token_t { + if parser.token_available || yaml_parser_fetch_more_tokens(parser) { + return &parser.tokens[parser.tokens_head] + } + return nil +} + +// Remove the next token from the queue (must be called after peek_token). +func skip_token(parser *yaml_parser_t) { + parser.token_available = false + parser.tokens_parsed++ + parser.stream_end_produced = parser.tokens[parser.tokens_head].typ == yaml_STREAM_END_TOKEN + parser.tokens_head++ +} + +// Get the next event. +func yaml_parser_parse(parser *yaml_parser_t, event *yaml_event_t) bool { + // Erase the event object. + *event = yaml_event_t{} + + // No events after the end of the stream or error. + if parser.stream_end_produced || parser.error != yaml_NO_ERROR || parser.state == yaml_PARSE_END_STATE { + return true + } + + // Generate the next event. + return yaml_parser_state_machine(parser, event) +} + +// Set parser error. +func yaml_parser_set_parser_error(parser *yaml_parser_t, problem string, problem_mark yaml_mark_t) bool { + parser.error = yaml_PARSER_ERROR + parser.problem = problem + parser.problem_mark = problem_mark + return false +} + +func yaml_parser_set_parser_error_context(parser *yaml_parser_t, context string, context_mark yaml_mark_t, problem string, problem_mark yaml_mark_t) bool { + parser.error = yaml_PARSER_ERROR + parser.context = context + parser.context_mark = context_mark + parser.problem = problem + parser.problem_mark = problem_mark + return false +} + +// State dispatcher. +func yaml_parser_state_machine(parser *yaml_parser_t, event *yaml_event_t) bool { + //trace("yaml_parser_state_machine", "state:", parser.state.String()) + + switch parser.state { + case yaml_PARSE_STREAM_START_STATE: + return yaml_parser_parse_stream_start(parser, event) + + case yaml_PARSE_IMPLICIT_DOCUMENT_START_STATE: + return yaml_parser_parse_document_start(parser, event, true) + + case yaml_PARSE_DOCUMENT_START_STATE: + return yaml_parser_parse_document_start(parser, event, false) + + case yaml_PARSE_DOCUMENT_CONTENT_STATE: + return yaml_parser_parse_document_content(parser, event) + + case yaml_PARSE_DOCUMENT_END_STATE: + return yaml_parser_parse_document_end(parser, event) + + case yaml_PARSE_BLOCK_NODE_STATE: + return yaml_parser_parse_node(parser, event, true, false) + + case yaml_PARSE_BLOCK_NODE_OR_INDENTLESS_SEQUENCE_STATE: + return yaml_parser_parse_node(parser, event, true, true) + + case yaml_PARSE_FLOW_NODE_STATE: + return yaml_parser_parse_node(parser, event, false, false) + + case yaml_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE: + return yaml_parser_parse_block_sequence_entry(parser, event, true) + + case yaml_PARSE_BLOCK_SEQUENCE_ENTRY_STATE: + return yaml_parser_parse_block_sequence_entry(parser, event, false) + + case yaml_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE: + return yaml_parser_parse_indentless_sequence_entry(parser, event) + + case yaml_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE: + return yaml_parser_parse_block_mapping_key(parser, event, true) + + case yaml_PARSE_BLOCK_MAPPING_KEY_STATE: + return yaml_parser_parse_block_mapping_key(parser, event, false) + + case yaml_PARSE_BLOCK_MAPPING_VALUE_STATE: + return yaml_parser_parse_block_mapping_value(parser, event) + + case yaml_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE: + return yaml_parser_parse_flow_sequence_entry(parser, event, true) + + case yaml_PARSE_FLOW_SEQUENCE_ENTRY_STATE: + return yaml_parser_parse_flow_sequence_entry(parser, event, false) + + case yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE: + return yaml_parser_parse_flow_sequence_entry_mapping_key(parser, event) + + case yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE: + return yaml_parser_parse_flow_sequence_entry_mapping_value(parser, event) + + case yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE: + return yaml_parser_parse_flow_sequence_entry_mapping_end(parser, event) + + case yaml_PARSE_FLOW_MAPPING_FIRST_KEY_STATE: + return yaml_parser_parse_flow_mapping_key(parser, event, true) + + case yaml_PARSE_FLOW_MAPPING_KEY_STATE: + return yaml_parser_parse_flow_mapping_key(parser, event, false) + + case yaml_PARSE_FLOW_MAPPING_VALUE_STATE: + return yaml_parser_parse_flow_mapping_value(parser, event, false) + + case yaml_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE: + return yaml_parser_parse_flow_mapping_value(parser, event, true) + + default: + panic("invalid parser state") + } + return false +} + +// Parse the production: +// stream ::= STREAM-START implicit_document? explicit_document* STREAM-END +// ************ +func yaml_parser_parse_stream_start(parser *yaml_parser_t, event *yaml_event_t) bool { + token := peek_token(parser) + if token == nil { + return false + } + if token.typ != yaml_STREAM_START_TOKEN { + return yaml_parser_set_parser_error(parser, "did not find expected ", token.start_mark) + } + parser.state = yaml_PARSE_IMPLICIT_DOCUMENT_START_STATE + *event = yaml_event_t{ + typ: yaml_STREAM_START_EVENT, + start_mark: token.start_mark, + end_mark: token.end_mark, + encoding: token.encoding, + } + skip_token(parser) + return true +} + +// Parse the productions: +// implicit_document ::= block_node DOCUMENT-END* +// * +// explicit_document ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END* +// ************************* +func yaml_parser_parse_document_start(parser *yaml_parser_t, event *yaml_event_t, implicit bool) bool { + + token := peek_token(parser) + if token == nil { + return false + } + + // Parse extra document end indicators. + if !implicit { + for token.typ == yaml_DOCUMENT_END_TOKEN { + skip_token(parser) + token = peek_token(parser) + if token == nil { + return false + } + } + } + + if implicit && token.typ != yaml_VERSION_DIRECTIVE_TOKEN && + token.typ != yaml_TAG_DIRECTIVE_TOKEN && + token.typ != yaml_DOCUMENT_START_TOKEN && + token.typ != yaml_STREAM_END_TOKEN { + // Parse an implicit document. + if !yaml_parser_process_directives(parser, nil, nil) { + return false + } + parser.states = append(parser.states, yaml_PARSE_DOCUMENT_END_STATE) + parser.state = yaml_PARSE_BLOCK_NODE_STATE + + *event = yaml_event_t{ + typ: yaml_DOCUMENT_START_EVENT, + start_mark: token.start_mark, + end_mark: token.end_mark, + } + + } else if token.typ != yaml_STREAM_END_TOKEN { + // Parse an explicit document. + var version_directive *yaml_version_directive_t + var tag_directives []yaml_tag_directive_t + start_mark := token.start_mark + if !yaml_parser_process_directives(parser, &version_directive, &tag_directives) { + return false + } + token = peek_token(parser) + if token == nil { + return false + } + if token.typ != yaml_DOCUMENT_START_TOKEN { + yaml_parser_set_parser_error(parser, + "did not find expected ", token.start_mark) + return false + } + parser.states = append(parser.states, yaml_PARSE_DOCUMENT_END_STATE) + parser.state = yaml_PARSE_DOCUMENT_CONTENT_STATE + end_mark := token.end_mark + + *event = yaml_event_t{ + typ: yaml_DOCUMENT_START_EVENT, + start_mark: start_mark, + end_mark: end_mark, + version_directive: version_directive, + tag_directives: tag_directives, + implicit: false, + } + skip_token(parser) + + } else { + // Parse the stream end. + parser.state = yaml_PARSE_END_STATE + *event = yaml_event_t{ + typ: yaml_STREAM_END_EVENT, + start_mark: token.start_mark, + end_mark: token.end_mark, + } + skip_token(parser) + } + + return true +} + +// Parse the productions: +// explicit_document ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END* +// *********** +// +func yaml_parser_parse_document_content(parser *yaml_parser_t, event *yaml_event_t) bool { + token := peek_token(parser) + if token == nil { + return false + } + if token.typ == yaml_VERSION_DIRECTIVE_TOKEN || + token.typ == yaml_TAG_DIRECTIVE_TOKEN || + token.typ == yaml_DOCUMENT_START_TOKEN || + token.typ == yaml_DOCUMENT_END_TOKEN || + token.typ == yaml_STREAM_END_TOKEN { + parser.state = parser.states[len(parser.states)-1] + parser.states = parser.states[:len(parser.states)-1] + return yaml_parser_process_empty_scalar(parser, event, + token.start_mark) + } + return yaml_parser_parse_node(parser, event, true, false) +} + +// Parse the productions: +// implicit_document ::= block_node DOCUMENT-END* +// ************* +// explicit_document ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END* +// +func yaml_parser_parse_document_end(parser *yaml_parser_t, event *yaml_event_t) bool { + token := peek_token(parser) + if token == nil { + return false + } + + start_mark := token.start_mark + end_mark := token.start_mark + + implicit := true + if token.typ == yaml_DOCUMENT_END_TOKEN { + end_mark = token.end_mark + skip_token(parser) + implicit = false + } + + parser.tag_directives = parser.tag_directives[:0] + + parser.state = yaml_PARSE_DOCUMENT_START_STATE + *event = yaml_event_t{ + typ: yaml_DOCUMENT_END_EVENT, + start_mark: start_mark, + end_mark: end_mark, + implicit: implicit, + } + return true +} + +// Parse the productions: +// block_node_or_indentless_sequence ::= +// ALIAS +// ***** +// | properties (block_content | indentless_block_sequence)? +// ********** * +// | block_content | indentless_block_sequence +// * +// block_node ::= ALIAS +// ***** +// | properties block_content? +// ********** * +// | block_content +// * +// flow_node ::= ALIAS +// ***** +// | properties flow_content? +// ********** * +// | flow_content +// * +// properties ::= TAG ANCHOR? | ANCHOR TAG? +// ************************* +// block_content ::= block_collection | flow_collection | SCALAR +// ****** +// flow_content ::= flow_collection | SCALAR +// ****** +func yaml_parser_parse_node(parser *yaml_parser_t, event *yaml_event_t, block, indentless_sequence bool) bool { + //defer trace("yaml_parser_parse_node", "block:", block, "indentless_sequence:", indentless_sequence)() + + token := peek_token(parser) + if token == nil { + return false + } + + if token.typ == yaml_ALIAS_TOKEN { + parser.state = parser.states[len(parser.states)-1] + parser.states = parser.states[:len(parser.states)-1] + *event = yaml_event_t{ + typ: yaml_ALIAS_EVENT, + start_mark: token.start_mark, + end_mark: token.end_mark, + anchor: token.value, + } + skip_token(parser) + return true + } + + start_mark := token.start_mark + end_mark := token.start_mark + + var tag_token bool + var tag_handle, tag_suffix, anchor []byte + var tag_mark yaml_mark_t + if token.typ == yaml_ANCHOR_TOKEN { + anchor = token.value + start_mark = token.start_mark + end_mark = token.end_mark + skip_token(parser) + token = peek_token(parser) + if token == nil { + return false + } + if token.typ == yaml_TAG_TOKEN { + tag_token = true + tag_handle = token.value + tag_suffix = token.suffix + tag_mark = token.start_mark + end_mark = token.end_mark + skip_token(parser) + token = peek_token(parser) + if token == nil { + return false + } + } + } else if token.typ == yaml_TAG_TOKEN { + tag_token = true + tag_handle = token.value + tag_suffix = token.suffix + start_mark = token.start_mark + tag_mark = token.start_mark + end_mark = token.end_mark + skip_token(parser) + token = peek_token(parser) + if token == nil { + return false + } + if token.typ == yaml_ANCHOR_TOKEN { + anchor = token.value + end_mark = token.end_mark + skip_token(parser) + token = peek_token(parser) + if token == nil { + return false + } + } + } + + var tag []byte + if tag_token { + if len(tag_handle) == 0 { + tag = tag_suffix + tag_suffix = nil + } else { + for i := range parser.tag_directives { + if bytes.Equal(parser.tag_directives[i].handle, tag_handle) { + tag = append([]byte(nil), parser.tag_directives[i].prefix...) + tag = append(tag, tag_suffix...) + break + } + } + if len(tag) == 0 { + yaml_parser_set_parser_error_context(parser, + "while parsing a node", start_mark, + "found undefined tag handle", tag_mark) + return false + } + } + } + + implicit := len(tag) == 0 + if indentless_sequence && token.typ == yaml_BLOCK_ENTRY_TOKEN { + end_mark = token.end_mark + parser.state = yaml_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE + *event = yaml_event_t{ + typ: yaml_SEQUENCE_START_EVENT, + start_mark: start_mark, + end_mark: end_mark, + anchor: anchor, + tag: tag, + implicit: implicit, + style: yaml_style_t(yaml_BLOCK_SEQUENCE_STYLE), + } + return true + } + if token.typ == yaml_SCALAR_TOKEN { + var plain_implicit, quoted_implicit bool + end_mark = token.end_mark + if (len(tag) == 0 && token.style == yaml_PLAIN_SCALAR_STYLE) || (len(tag) == 1 && tag[0] == '!') { + plain_implicit = true + } else if len(tag) == 0 { + quoted_implicit = true + } + parser.state = parser.states[len(parser.states)-1] + parser.states = parser.states[:len(parser.states)-1] + + *event = yaml_event_t{ + typ: yaml_SCALAR_EVENT, + start_mark: start_mark, + end_mark: end_mark, + anchor: anchor, + tag: tag, + value: token.value, + implicit: plain_implicit, + quoted_implicit: quoted_implicit, + style: yaml_style_t(token.style), + } + skip_token(parser) + return true + } + if token.typ == yaml_FLOW_SEQUENCE_START_TOKEN { + // [Go] Some of the events below can be merged as they differ only on style. + end_mark = token.end_mark + parser.state = yaml_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE + *event = yaml_event_t{ + typ: yaml_SEQUENCE_START_EVENT, + start_mark: start_mark, + end_mark: end_mark, + anchor: anchor, + tag: tag, + implicit: implicit, + style: yaml_style_t(yaml_FLOW_SEQUENCE_STYLE), + } + return true + } + if token.typ == yaml_FLOW_MAPPING_START_TOKEN { + end_mark = token.end_mark + parser.state = yaml_PARSE_FLOW_MAPPING_FIRST_KEY_STATE + *event = yaml_event_t{ + typ: yaml_MAPPING_START_EVENT, + start_mark: start_mark, + end_mark: end_mark, + anchor: anchor, + tag: tag, + implicit: implicit, + style: yaml_style_t(yaml_FLOW_MAPPING_STYLE), + } + return true + } + if block && token.typ == yaml_BLOCK_SEQUENCE_START_TOKEN { + end_mark = token.end_mark + parser.state = yaml_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE + *event = yaml_event_t{ + typ: yaml_SEQUENCE_START_EVENT, + start_mark: start_mark, + end_mark: end_mark, + anchor: anchor, + tag: tag, + implicit: implicit, + style: yaml_style_t(yaml_BLOCK_SEQUENCE_STYLE), + } + return true + } + if block && token.typ == yaml_BLOCK_MAPPING_START_TOKEN { + end_mark = token.end_mark + parser.state = yaml_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE + *event = yaml_event_t{ + typ: yaml_MAPPING_START_EVENT, + start_mark: start_mark, + end_mark: end_mark, + anchor: anchor, + tag: tag, + implicit: implicit, + style: yaml_style_t(yaml_BLOCK_MAPPING_STYLE), + } + return true + } + if len(anchor) > 0 || len(tag) > 0 { + parser.state = parser.states[len(parser.states)-1] + parser.states = parser.states[:len(parser.states)-1] + + *event = yaml_event_t{ + typ: yaml_SCALAR_EVENT, + start_mark: start_mark, + end_mark: end_mark, + anchor: anchor, + tag: tag, + implicit: implicit, + quoted_implicit: false, + style: yaml_style_t(yaml_PLAIN_SCALAR_STYLE), + } + return true + } + + context := "while parsing a flow node" + if block { + context = "while parsing a block node" + } + yaml_parser_set_parser_error_context(parser, context, start_mark, + "did not find expected node content", token.start_mark) + return false +} + +// Parse the productions: +// block_sequence ::= BLOCK-SEQUENCE-START (BLOCK-ENTRY block_node?)* BLOCK-END +// ******************** *********** * ********* +// +func yaml_parser_parse_block_sequence_entry(parser *yaml_parser_t, event *yaml_event_t, first bool) bool { + if first { + token := peek_token(parser) + parser.marks = append(parser.marks, token.start_mark) + skip_token(parser) + } + + token := peek_token(parser) + if token == nil { + return false + } + + if token.typ == yaml_BLOCK_ENTRY_TOKEN { + mark := token.end_mark + skip_token(parser) + token = peek_token(parser) + if token == nil { + return false + } + if token.typ != yaml_BLOCK_ENTRY_TOKEN && token.typ != yaml_BLOCK_END_TOKEN { + parser.states = append(parser.states, yaml_PARSE_BLOCK_SEQUENCE_ENTRY_STATE) + return yaml_parser_parse_node(parser, event, true, false) + } else { + parser.state = yaml_PARSE_BLOCK_SEQUENCE_ENTRY_STATE + return yaml_parser_process_empty_scalar(parser, event, mark) + } + } + if token.typ == yaml_BLOCK_END_TOKEN { + parser.state = parser.states[len(parser.states)-1] + parser.states = parser.states[:len(parser.states)-1] + parser.marks = parser.marks[:len(parser.marks)-1] + + *event = yaml_event_t{ + typ: yaml_SEQUENCE_END_EVENT, + start_mark: token.start_mark, + end_mark: token.end_mark, + } + + skip_token(parser) + return true + } + + context_mark := parser.marks[len(parser.marks)-1] + parser.marks = parser.marks[:len(parser.marks)-1] + return yaml_parser_set_parser_error_context(parser, + "while parsing a block collection", context_mark, + "did not find expected '-' indicator", token.start_mark) +} + +// Parse the productions: +// indentless_sequence ::= (BLOCK-ENTRY block_node?)+ +// *********** * +func yaml_parser_parse_indentless_sequence_entry(parser *yaml_parser_t, event *yaml_event_t) bool { + token := peek_token(parser) + if token == nil { + return false + } + + if token.typ == yaml_BLOCK_ENTRY_TOKEN { + mark := token.end_mark + skip_token(parser) + token = peek_token(parser) + if token == nil { + return false + } + if token.typ != yaml_BLOCK_ENTRY_TOKEN && + token.typ != yaml_KEY_TOKEN && + token.typ != yaml_VALUE_TOKEN && + token.typ != yaml_BLOCK_END_TOKEN { + parser.states = append(parser.states, yaml_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE) + return yaml_parser_parse_node(parser, event, true, false) + } + parser.state = yaml_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE + return yaml_parser_process_empty_scalar(parser, event, mark) + } + parser.state = parser.states[len(parser.states)-1] + parser.states = parser.states[:len(parser.states)-1] + + *event = yaml_event_t{ + typ: yaml_SEQUENCE_END_EVENT, + start_mark: token.start_mark, + end_mark: token.start_mark, // [Go] Shouldn't this be token.end_mark? + } + return true +} + +// Parse the productions: +// block_mapping ::= BLOCK-MAPPING_START +// ******************* +// ((KEY block_node_or_indentless_sequence?)? +// *** * +// (VALUE block_node_or_indentless_sequence?)?)* +// +// BLOCK-END +// ********* +// +func yaml_parser_parse_block_mapping_key(parser *yaml_parser_t, event *yaml_event_t, first bool) bool { + if first { + token := peek_token(parser) + parser.marks = append(parser.marks, token.start_mark) + skip_token(parser) + } + + token := peek_token(parser) + if token == nil { + return false + } + + if token.typ == yaml_KEY_TOKEN { + mark := token.end_mark + skip_token(parser) + token = peek_token(parser) + if token == nil { + return false + } + if token.typ != yaml_KEY_TOKEN && + token.typ != yaml_VALUE_TOKEN && + token.typ != yaml_BLOCK_END_TOKEN { + parser.states = append(parser.states, yaml_PARSE_BLOCK_MAPPING_VALUE_STATE) + return yaml_parser_parse_node(parser, event, true, true) + } else { + parser.state = yaml_PARSE_BLOCK_MAPPING_VALUE_STATE + return yaml_parser_process_empty_scalar(parser, event, mark) + } + } else if token.typ == yaml_BLOCK_END_TOKEN { + parser.state = parser.states[len(parser.states)-1] + parser.states = parser.states[:len(parser.states)-1] + parser.marks = parser.marks[:len(parser.marks)-1] + *event = yaml_event_t{ + typ: yaml_MAPPING_END_EVENT, + start_mark: token.start_mark, + end_mark: token.end_mark, + } + skip_token(parser) + return true + } + + context_mark := parser.marks[len(parser.marks)-1] + parser.marks = parser.marks[:len(parser.marks)-1] + return yaml_parser_set_parser_error_context(parser, + "while parsing a block mapping", context_mark, + "did not find expected key", token.start_mark) +} + +// Parse the productions: +// block_mapping ::= BLOCK-MAPPING_START +// +// ((KEY block_node_or_indentless_sequence?)? +// +// (VALUE block_node_or_indentless_sequence?)?)* +// ***** * +// BLOCK-END +// +// +func yaml_parser_parse_block_mapping_value(parser *yaml_parser_t, event *yaml_event_t) bool { + token := peek_token(parser) + if token == nil { + return false + } + if token.typ == yaml_VALUE_TOKEN { + mark := token.end_mark + skip_token(parser) + token = peek_token(parser) + if token == nil { + return false + } + if token.typ != yaml_KEY_TOKEN && + token.typ != yaml_VALUE_TOKEN && + token.typ != yaml_BLOCK_END_TOKEN { + parser.states = append(parser.states, yaml_PARSE_BLOCK_MAPPING_KEY_STATE) + return yaml_parser_parse_node(parser, event, true, true) + } + parser.state = yaml_PARSE_BLOCK_MAPPING_KEY_STATE + return yaml_parser_process_empty_scalar(parser, event, mark) + } + parser.state = yaml_PARSE_BLOCK_MAPPING_KEY_STATE + return yaml_parser_process_empty_scalar(parser, event, token.start_mark) +} + +// Parse the productions: +// flow_sequence ::= FLOW-SEQUENCE-START +// ******************* +// (flow_sequence_entry FLOW-ENTRY)* +// * ********** +// flow_sequence_entry? +// * +// FLOW-SEQUENCE-END +// ***************** +// flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? +// * +// +func yaml_parser_parse_flow_sequence_entry(parser *yaml_parser_t, event *yaml_event_t, first bool) bool { + if first { + token := peek_token(parser) + parser.marks = append(parser.marks, token.start_mark) + skip_token(parser) + } + token := peek_token(parser) + if token == nil { + return false + } + if token.typ != yaml_FLOW_SEQUENCE_END_TOKEN { + if !first { + if token.typ == yaml_FLOW_ENTRY_TOKEN { + skip_token(parser) + token = peek_token(parser) + if token == nil { + return false + } + } else { + context_mark := parser.marks[len(parser.marks)-1] + parser.marks = parser.marks[:len(parser.marks)-1] + return yaml_parser_set_parser_error_context(parser, + "while parsing a flow sequence", context_mark, + "did not find expected ',' or ']'", token.start_mark) + } + } + + if token.typ == yaml_KEY_TOKEN { + parser.state = yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE + *event = yaml_event_t{ + typ: yaml_MAPPING_START_EVENT, + start_mark: token.start_mark, + end_mark: token.end_mark, + implicit: true, + style: yaml_style_t(yaml_FLOW_MAPPING_STYLE), + } + skip_token(parser) + return true + } else if token.typ != yaml_FLOW_SEQUENCE_END_TOKEN { + parser.states = append(parser.states, yaml_PARSE_FLOW_SEQUENCE_ENTRY_STATE) + return yaml_parser_parse_node(parser, event, false, false) + } + } + + parser.state = parser.states[len(parser.states)-1] + parser.states = parser.states[:len(parser.states)-1] + parser.marks = parser.marks[:len(parser.marks)-1] + + *event = yaml_event_t{ + typ: yaml_SEQUENCE_END_EVENT, + start_mark: token.start_mark, + end_mark: token.end_mark, + } + + skip_token(parser) + return true +} + +// +// Parse the productions: +// flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? +// *** * +// +func yaml_parser_parse_flow_sequence_entry_mapping_key(parser *yaml_parser_t, event *yaml_event_t) bool { + token := peek_token(parser) + if token == nil { + return false + } + if token.typ != yaml_VALUE_TOKEN && + token.typ != yaml_FLOW_ENTRY_TOKEN && + token.typ != yaml_FLOW_SEQUENCE_END_TOKEN { + parser.states = append(parser.states, yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE) + return yaml_parser_parse_node(parser, event, false, false) + } + mark := token.end_mark + skip_token(parser) + parser.state = yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE + return yaml_parser_process_empty_scalar(parser, event, mark) +} + +// Parse the productions: +// flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? +// ***** * +// +func yaml_parser_parse_flow_sequence_entry_mapping_value(parser *yaml_parser_t, event *yaml_event_t) bool { + token := peek_token(parser) + if token == nil { + return false + } + if token.typ == yaml_VALUE_TOKEN { + skip_token(parser) + token := peek_token(parser) + if token == nil { + return false + } + if token.typ != yaml_FLOW_ENTRY_TOKEN && token.typ != yaml_FLOW_SEQUENCE_END_TOKEN { + parser.states = append(parser.states, yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE) + return yaml_parser_parse_node(parser, event, false, false) + } + } + parser.state = yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE + return yaml_parser_process_empty_scalar(parser, event, token.start_mark) +} + +// Parse the productions: +// flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? +// * +// +func yaml_parser_parse_flow_sequence_entry_mapping_end(parser *yaml_parser_t, event *yaml_event_t) bool { + token := peek_token(parser) + if token == nil { + return false + } + parser.state = yaml_PARSE_FLOW_SEQUENCE_ENTRY_STATE + *event = yaml_event_t{ + typ: yaml_MAPPING_END_EVENT, + start_mark: token.start_mark, + end_mark: token.start_mark, // [Go] Shouldn't this be end_mark? + } + return true +} + +// Parse the productions: +// flow_mapping ::= FLOW-MAPPING-START +// ****************** +// (flow_mapping_entry FLOW-ENTRY)* +// * ********** +// flow_mapping_entry? +// ****************** +// FLOW-MAPPING-END +// **************** +// flow_mapping_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? +// * *** * +// +func yaml_parser_parse_flow_mapping_key(parser *yaml_parser_t, event *yaml_event_t, first bool) bool { + if first { + token := peek_token(parser) + parser.marks = append(parser.marks, token.start_mark) + skip_token(parser) + } + + token := peek_token(parser) + if token == nil { + return false + } + + if token.typ != yaml_FLOW_MAPPING_END_TOKEN { + if !first { + if token.typ == yaml_FLOW_ENTRY_TOKEN { + skip_token(parser) + token = peek_token(parser) + if token == nil { + return false + } + } else { + context_mark := parser.marks[len(parser.marks)-1] + parser.marks = parser.marks[:len(parser.marks)-1] + return yaml_parser_set_parser_error_context(parser, + "while parsing a flow mapping", context_mark, + "did not find expected ',' or '}'", token.start_mark) + } + } + + if token.typ == yaml_KEY_TOKEN { + skip_token(parser) + token = peek_token(parser) + if token == nil { + return false + } + if token.typ != yaml_VALUE_TOKEN && + token.typ != yaml_FLOW_ENTRY_TOKEN && + token.typ != yaml_FLOW_MAPPING_END_TOKEN { + parser.states = append(parser.states, yaml_PARSE_FLOW_MAPPING_VALUE_STATE) + return yaml_parser_parse_node(parser, event, false, false) + } else { + parser.state = yaml_PARSE_FLOW_MAPPING_VALUE_STATE + return yaml_parser_process_empty_scalar(parser, event, token.start_mark) + } + } else if token.typ != yaml_FLOW_MAPPING_END_TOKEN { + parser.states = append(parser.states, yaml_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE) + return yaml_parser_parse_node(parser, event, false, false) + } + } + + parser.state = parser.states[len(parser.states)-1] + parser.states = parser.states[:len(parser.states)-1] + parser.marks = parser.marks[:len(parser.marks)-1] + *event = yaml_event_t{ + typ: yaml_MAPPING_END_EVENT, + start_mark: token.start_mark, + end_mark: token.end_mark, + } + skip_token(parser) + return true +} + +// Parse the productions: +// flow_mapping_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? +// * ***** * +// +func yaml_parser_parse_flow_mapping_value(parser *yaml_parser_t, event *yaml_event_t, empty bool) bool { + token := peek_token(parser) + if token == nil { + return false + } + if empty { + parser.state = yaml_PARSE_FLOW_MAPPING_KEY_STATE + return yaml_parser_process_empty_scalar(parser, event, token.start_mark) + } + if token.typ == yaml_VALUE_TOKEN { + skip_token(parser) + token = peek_token(parser) + if token == nil { + return false + } + if token.typ != yaml_FLOW_ENTRY_TOKEN && token.typ != yaml_FLOW_MAPPING_END_TOKEN { + parser.states = append(parser.states, yaml_PARSE_FLOW_MAPPING_KEY_STATE) + return yaml_parser_parse_node(parser, event, false, false) + } + } + parser.state = yaml_PARSE_FLOW_MAPPING_KEY_STATE + return yaml_parser_process_empty_scalar(parser, event, token.start_mark) +} + +// Generate an empty scalar event. +func yaml_parser_process_empty_scalar(parser *yaml_parser_t, event *yaml_event_t, mark yaml_mark_t) bool { + *event = yaml_event_t{ + typ: yaml_SCALAR_EVENT, + start_mark: mark, + end_mark: mark, + value: nil, // Empty + implicit: true, + style: yaml_style_t(yaml_PLAIN_SCALAR_STYLE), + } + return true +} + +var default_tag_directives = []yaml_tag_directive_t{ + {[]byte("!"), []byte("!")}, + {[]byte("!!"), []byte("tag:yaml.org,2002:")}, +} + +// Parse directives. +func yaml_parser_process_directives(parser *yaml_parser_t, + version_directive_ref **yaml_version_directive_t, + tag_directives_ref *[]yaml_tag_directive_t) bool { + + var version_directive *yaml_version_directive_t + var tag_directives []yaml_tag_directive_t + + token := peek_token(parser) + if token == nil { + return false + } + + for token.typ == yaml_VERSION_DIRECTIVE_TOKEN || token.typ == yaml_TAG_DIRECTIVE_TOKEN { + if token.typ == yaml_VERSION_DIRECTIVE_TOKEN { + if version_directive != nil { + yaml_parser_set_parser_error(parser, + "found duplicate %YAML directive", token.start_mark) + return false + } + if token.major != 1 || token.minor != 1 { + yaml_parser_set_parser_error(parser, + "found incompatible YAML document", token.start_mark) + return false + } + version_directive = &yaml_version_directive_t{ + major: token.major, + minor: token.minor, + } + } else if token.typ == yaml_TAG_DIRECTIVE_TOKEN { + value := yaml_tag_directive_t{ + handle: token.value, + prefix: token.prefix, + } + if !yaml_parser_append_tag_directive(parser, value, false, token.start_mark) { + return false + } + tag_directives = append(tag_directives, value) + } + + skip_token(parser) + token = peek_token(parser) + if token == nil { + return false + } + } + + for i := range default_tag_directives { + if !yaml_parser_append_tag_directive(parser, default_tag_directives[i], true, token.start_mark) { + return false + } + } + + if version_directive_ref != nil { + *version_directive_ref = version_directive + } + if tag_directives_ref != nil { + *tag_directives_ref = tag_directives + } + return true +} + +// Append a tag directive to the directives stack. +func yaml_parser_append_tag_directive(parser *yaml_parser_t, value yaml_tag_directive_t, allow_duplicates bool, mark yaml_mark_t) bool { + for i := range parser.tag_directives { + if bytes.Equal(value.handle, parser.tag_directives[i].handle) { + if allow_duplicates { + return true + } + return yaml_parser_set_parser_error(parser, "found duplicate %TAG directive", mark) + } + } + + // [Go] I suspect the copy is unnecessary. This was likely done + // because there was no way to track ownership of the data. + value_copy := yaml_tag_directive_t{ + handle: make([]byte, len(value.handle)), + prefix: make([]byte, len(value.prefix)), + } + copy(value_copy.handle, value.handle) + copy(value_copy.prefix, value.prefix) + parser.tag_directives = append(parser.tag_directives, value_copy) + return true +} diff --git a/Godeps/_workspace/src/gopkg.in/yaml.v2/readerc.go b/Godeps/_workspace/src/gopkg.in/yaml.v2/readerc.go new file mode 100644 index 000000000..d5fb09727 --- /dev/null +++ b/Godeps/_workspace/src/gopkg.in/yaml.v2/readerc.go @@ -0,0 +1,391 @@ +package yaml + +import ( + "io" +) + +// Set the reader error and return 0. +func yaml_parser_set_reader_error(parser *yaml_parser_t, problem string, offset int, value int) bool { + parser.error = yaml_READER_ERROR + parser.problem = problem + parser.problem_offset = offset + parser.problem_value = value + return false +} + +// Byte order marks. +const ( + bom_UTF8 = "\xef\xbb\xbf" + bom_UTF16LE = "\xff\xfe" + bom_UTF16BE = "\xfe\xff" +) + +// Determine the input stream encoding by checking the BOM symbol. If no BOM is +// found, the UTF-8 encoding is assumed. Return 1 on success, 0 on failure. +func yaml_parser_determine_encoding(parser *yaml_parser_t) bool { + // Ensure that we had enough bytes in the raw buffer. + for !parser.eof && len(parser.raw_buffer)-parser.raw_buffer_pos < 3 { + if !yaml_parser_update_raw_buffer(parser) { + return false + } + } + + // Determine the encoding. + buf := parser.raw_buffer + pos := parser.raw_buffer_pos + avail := len(buf) - pos + if avail >= 2 && buf[pos] == bom_UTF16LE[0] && buf[pos+1] == bom_UTF16LE[1] { + parser.encoding = yaml_UTF16LE_ENCODING + parser.raw_buffer_pos += 2 + parser.offset += 2 + } else if avail >= 2 && buf[pos] == bom_UTF16BE[0] && buf[pos+1] == bom_UTF16BE[1] { + parser.encoding = yaml_UTF16BE_ENCODING + parser.raw_buffer_pos += 2 + parser.offset += 2 + } else if avail >= 3 && buf[pos] == bom_UTF8[0] && buf[pos+1] == bom_UTF8[1] && buf[pos+2] == bom_UTF8[2] { + parser.encoding = yaml_UTF8_ENCODING + parser.raw_buffer_pos += 3 + parser.offset += 3 + } else { + parser.encoding = yaml_UTF8_ENCODING + } + return true +} + +// Update the raw buffer. +func yaml_parser_update_raw_buffer(parser *yaml_parser_t) bool { + size_read := 0 + + // Return if the raw buffer is full. + if parser.raw_buffer_pos == 0 && len(parser.raw_buffer) == cap(parser.raw_buffer) { + return true + } + + // Return on EOF. + if parser.eof { + return true + } + + // Move the remaining bytes in the raw buffer to the beginning. + if parser.raw_buffer_pos > 0 && parser.raw_buffer_pos < len(parser.raw_buffer) { + copy(parser.raw_buffer, parser.raw_buffer[parser.raw_buffer_pos:]) + } + parser.raw_buffer = parser.raw_buffer[:len(parser.raw_buffer)-parser.raw_buffer_pos] + parser.raw_buffer_pos = 0 + + // Call the read handler to fill the buffer. + size_read, err := parser.read_handler(parser, parser.raw_buffer[len(parser.raw_buffer):cap(parser.raw_buffer)]) + parser.raw_buffer = parser.raw_buffer[:len(parser.raw_buffer)+size_read] + if err == io.EOF { + parser.eof = true + } else if err != nil { + return yaml_parser_set_reader_error(parser, "input error: "+err.Error(), parser.offset, -1) + } + return true +} + +// Ensure that the buffer contains at least `length` characters. +// Return true on success, false on failure. +// +// The length is supposed to be significantly less that the buffer size. +func yaml_parser_update_buffer(parser *yaml_parser_t, length int) bool { + if parser.read_handler == nil { + panic("read handler must be set") + } + + // If the EOF flag is set and the raw buffer is empty, do nothing. + if parser.eof && parser.raw_buffer_pos == len(parser.raw_buffer) { + return true + } + + // Return if the buffer contains enough characters. + if parser.unread >= length { + return true + } + + // Determine the input encoding if it is not known yet. + if parser.encoding == yaml_ANY_ENCODING { + if !yaml_parser_determine_encoding(parser) { + return false + } + } + + // Move the unread characters to the beginning of the buffer. + buffer_len := len(parser.buffer) + if parser.buffer_pos > 0 && parser.buffer_pos < buffer_len { + copy(parser.buffer, parser.buffer[parser.buffer_pos:]) + buffer_len -= parser.buffer_pos + parser.buffer_pos = 0 + } else if parser.buffer_pos == buffer_len { + buffer_len = 0 + parser.buffer_pos = 0 + } + + // Open the whole buffer for writing, and cut it before returning. + parser.buffer = parser.buffer[:cap(parser.buffer)] + + // Fill the buffer until it has enough characters. + first := true + for parser.unread < length { + + // Fill the raw buffer if necessary. + if !first || parser.raw_buffer_pos == len(parser.raw_buffer) { + if !yaml_parser_update_raw_buffer(parser) { + parser.buffer = parser.buffer[:buffer_len] + return false + } + } + first = false + + // Decode the raw buffer. + inner: + for parser.raw_buffer_pos != len(parser.raw_buffer) { + var value rune + var width int + + raw_unread := len(parser.raw_buffer) - parser.raw_buffer_pos + + // Decode the next character. + switch parser.encoding { + case yaml_UTF8_ENCODING: + // Decode a UTF-8 character. Check RFC 3629 + // (http://www.ietf.org/rfc/rfc3629.txt) for more details. + // + // The following table (taken from the RFC) is used for + // decoding. + // + // Char. number range | UTF-8 octet sequence + // (hexadecimal) | (binary) + // --------------------+------------------------------------ + // 0000 0000-0000 007F | 0xxxxxxx + // 0000 0080-0000 07FF | 110xxxxx 10xxxxxx + // 0000 0800-0000 FFFF | 1110xxxx 10xxxxxx 10xxxxxx + // 0001 0000-0010 FFFF | 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx + // + // Additionally, the characters in the range 0xD800-0xDFFF + // are prohibited as they are reserved for use with UTF-16 + // surrogate pairs. + + // Determine the length of the UTF-8 sequence. + octet := parser.raw_buffer[parser.raw_buffer_pos] + switch { + case octet&0x80 == 0x00: + width = 1 + case octet&0xE0 == 0xC0: + width = 2 + case octet&0xF0 == 0xE0: + width = 3 + case octet&0xF8 == 0xF0: + width = 4 + default: + // The leading octet is invalid. + return yaml_parser_set_reader_error(parser, + "invalid leading UTF-8 octet", + parser.offset, int(octet)) + } + + // Check if the raw buffer contains an incomplete character. + if width > raw_unread { + if parser.eof { + return yaml_parser_set_reader_error(parser, + "incomplete UTF-8 octet sequence", + parser.offset, -1) + } + break inner + } + + // Decode the leading octet. + switch { + case octet&0x80 == 0x00: + value = rune(octet & 0x7F) + case octet&0xE0 == 0xC0: + value = rune(octet & 0x1F) + case octet&0xF0 == 0xE0: + value = rune(octet & 0x0F) + case octet&0xF8 == 0xF0: + value = rune(octet & 0x07) + default: + value = 0 + } + + // Check and decode the trailing octets. + for k := 1; k < width; k++ { + octet = parser.raw_buffer[parser.raw_buffer_pos+k] + + // Check if the octet is valid. + if (octet & 0xC0) != 0x80 { + return yaml_parser_set_reader_error(parser, + "invalid trailing UTF-8 octet", + parser.offset+k, int(octet)) + } + + // Decode the octet. + value = (value << 6) + rune(octet&0x3F) + } + + // Check the length of the sequence against the value. + switch { + case width == 1: + case width == 2 && value >= 0x80: + case width == 3 && value >= 0x800: + case width == 4 && value >= 0x10000: + default: + return yaml_parser_set_reader_error(parser, + "invalid length of a UTF-8 sequence", + parser.offset, -1) + } + + // Check the range of the value. + if value >= 0xD800 && value <= 0xDFFF || value > 0x10FFFF { + return yaml_parser_set_reader_error(parser, + "invalid Unicode character", + parser.offset, int(value)) + } + + case yaml_UTF16LE_ENCODING, yaml_UTF16BE_ENCODING: + var low, high int + if parser.encoding == yaml_UTF16LE_ENCODING { + low, high = 0, 1 + } else { + high, low = 1, 0 + } + + // The UTF-16 encoding is not as simple as one might + // naively think. Check RFC 2781 + // (http://www.ietf.org/rfc/rfc2781.txt). + // + // Normally, two subsequent bytes describe a Unicode + // character. However a special technique (called a + // surrogate pair) is used for specifying character + // values larger than 0xFFFF. + // + // A surrogate pair consists of two pseudo-characters: + // high surrogate area (0xD800-0xDBFF) + // low surrogate area (0xDC00-0xDFFF) + // + // The following formulas are used for decoding + // and encoding characters using surrogate pairs: + // + // U = U' + 0x10000 (0x01 00 00 <= U <= 0x10 FF FF) + // U' = yyyyyyyyyyxxxxxxxxxx (0 <= U' <= 0x0F FF FF) + // W1 = 110110yyyyyyyyyy + // W2 = 110111xxxxxxxxxx + // + // where U is the character value, W1 is the high surrogate + // area, W2 is the low surrogate area. + + // Check for incomplete UTF-16 character. + if raw_unread < 2 { + if parser.eof { + return yaml_parser_set_reader_error(parser, + "incomplete UTF-16 character", + parser.offset, -1) + } + break inner + } + + // Get the character. + value = rune(parser.raw_buffer[parser.raw_buffer_pos+low]) + + (rune(parser.raw_buffer[parser.raw_buffer_pos+high]) << 8) + + // Check for unexpected low surrogate area. + if value&0xFC00 == 0xDC00 { + return yaml_parser_set_reader_error(parser, + "unexpected low surrogate area", + parser.offset, int(value)) + } + + // Check for a high surrogate area. + if value&0xFC00 == 0xD800 { + width = 4 + + // Check for incomplete surrogate pair. + if raw_unread < 4 { + if parser.eof { + return yaml_parser_set_reader_error(parser, + "incomplete UTF-16 surrogate pair", + parser.offset, -1) + } + break inner + } + + // Get the next character. + value2 := rune(parser.raw_buffer[parser.raw_buffer_pos+low+2]) + + (rune(parser.raw_buffer[parser.raw_buffer_pos+high+2]) << 8) + + // Check for a low surrogate area. + if value2&0xFC00 != 0xDC00 { + return yaml_parser_set_reader_error(parser, + "expected low surrogate area", + parser.offset+2, int(value2)) + } + + // Generate the value of the surrogate pair. + value = 0x10000 + ((value & 0x3FF) << 10) + (value2 & 0x3FF) + } else { + width = 2 + } + + default: + panic("impossible") + } + + // Check if the character is in the allowed range: + // #x9 | #xA | #xD | [#x20-#x7E] (8 bit) + // | #x85 | [#xA0-#xD7FF] | [#xE000-#xFFFD] (16 bit) + // | [#x10000-#x10FFFF] (32 bit) + switch { + case value == 0x09: + case value == 0x0A: + case value == 0x0D: + case value >= 0x20 && value <= 0x7E: + case value == 0x85: + case value >= 0xA0 && value <= 0xD7FF: + case value >= 0xE000 && value <= 0xFFFD: + case value >= 0x10000 && value <= 0x10FFFF: + default: + return yaml_parser_set_reader_error(parser, + "control characters are not allowed", + parser.offset, int(value)) + } + + // Move the raw pointers. + parser.raw_buffer_pos += width + parser.offset += width + + // Finally put the character into the buffer. + if value <= 0x7F { + // 0000 0000-0000 007F . 0xxxxxxx + parser.buffer[buffer_len+0] = byte(value) + } else if value <= 0x7FF { + // 0000 0080-0000 07FF . 110xxxxx 10xxxxxx + parser.buffer[buffer_len+0] = byte(0xC0 + (value >> 6)) + parser.buffer[buffer_len+1] = byte(0x80 + (value & 0x3F)) + } else if value <= 0xFFFF { + // 0000 0800-0000 FFFF . 1110xxxx 10xxxxxx 10xxxxxx + parser.buffer[buffer_len+0] = byte(0xE0 + (value >> 12)) + parser.buffer[buffer_len+1] = byte(0x80 + ((value >> 6) & 0x3F)) + parser.buffer[buffer_len+2] = byte(0x80 + (value & 0x3F)) + } else { + // 0001 0000-0010 FFFF . 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx + parser.buffer[buffer_len+0] = byte(0xF0 + (value >> 18)) + parser.buffer[buffer_len+1] = byte(0x80 + ((value >> 12) & 0x3F)) + parser.buffer[buffer_len+2] = byte(0x80 + ((value >> 6) & 0x3F)) + parser.buffer[buffer_len+3] = byte(0x80 + (value & 0x3F)) + } + buffer_len += width + + parser.unread++ + } + + // On EOF, put NUL into the buffer and return. + if parser.eof { + parser.buffer[buffer_len] = 0 + buffer_len++ + parser.unread++ + break + } + } + parser.buffer = parser.buffer[:buffer_len] + return true +} diff --git a/Godeps/_workspace/src/gopkg.in/yaml.v2/resolve.go b/Godeps/_workspace/src/gopkg.in/yaml.v2/resolve.go new file mode 100644 index 000000000..93a863274 --- /dev/null +++ b/Godeps/_workspace/src/gopkg.in/yaml.v2/resolve.go @@ -0,0 +1,203 @@ +package yaml + +import ( + "encoding/base64" + "math" + "strconv" + "strings" + "unicode/utf8" +) + +type resolveMapItem struct { + value interface{} + tag string +} + +var resolveTable = make([]byte, 256) +var resolveMap = make(map[string]resolveMapItem) + +func init() { + t := resolveTable + t[int('+')] = 'S' // Sign + t[int('-')] = 'S' + for _, c := range "0123456789" { + t[int(c)] = 'D' // Digit + } + for _, c := range "yYnNtTfFoO~" { + t[int(c)] = 'M' // In map + } + t[int('.')] = '.' // Float (potentially in map) + + var resolveMapList = []struct { + v interface{} + tag string + l []string + }{ + {true, yaml_BOOL_TAG, []string{"y", "Y", "yes", "Yes", "YES"}}, + {true, yaml_BOOL_TAG, []string{"true", "True", "TRUE"}}, + {true, yaml_BOOL_TAG, []string{"on", "On", "ON"}}, + {false, yaml_BOOL_TAG, []string{"n", "N", "no", "No", "NO"}}, + {false, yaml_BOOL_TAG, []string{"false", "False", "FALSE"}}, + {false, yaml_BOOL_TAG, []string{"off", "Off", "OFF"}}, + {nil, yaml_NULL_TAG, []string{"", "~", "null", "Null", "NULL"}}, + {math.NaN(), yaml_FLOAT_TAG, []string{".nan", ".NaN", ".NAN"}}, + {math.Inf(+1), yaml_FLOAT_TAG, []string{".inf", ".Inf", ".INF"}}, + {math.Inf(+1), yaml_FLOAT_TAG, []string{"+.inf", "+.Inf", "+.INF"}}, + {math.Inf(-1), yaml_FLOAT_TAG, []string{"-.inf", "-.Inf", "-.INF"}}, + {"<<", yaml_MERGE_TAG, []string{"<<"}}, + } + + m := resolveMap + for _, item := range resolveMapList { + for _, s := range item.l { + m[s] = resolveMapItem{item.v, item.tag} + } + } +} + +const longTagPrefix = "tag:yaml.org,2002:" + +func shortTag(tag string) string { + // TODO This can easily be made faster and produce less garbage. + if strings.HasPrefix(tag, longTagPrefix) { + return "!!" + tag[len(longTagPrefix):] + } + return tag +} + +func longTag(tag string) string { + if strings.HasPrefix(tag, "!!") { + return longTagPrefix + tag[2:] + } + return tag +} + +func resolvableTag(tag string) bool { + switch tag { + case "", yaml_STR_TAG, yaml_BOOL_TAG, yaml_INT_TAG, yaml_FLOAT_TAG, yaml_NULL_TAG: + return true + } + return false +} + +func resolve(tag string, in string) (rtag string, out interface{}) { + if !resolvableTag(tag) { + return tag, in + } + + defer func() { + switch tag { + case "", rtag, yaml_STR_TAG, yaml_BINARY_TAG: + return + } + failf("cannot decode %s `%s` as a %s", shortTag(rtag), in, shortTag(tag)) + }() + + // Any data is accepted as a !!str or !!binary. + // Otherwise, the prefix is enough of a hint about what it might be. + hint := byte('N') + if in != "" { + hint = resolveTable[in[0]] + } + if hint != 0 && tag != yaml_STR_TAG && tag != yaml_BINARY_TAG { + // Handle things we can lookup in a map. + if item, ok := resolveMap[in]; ok { + return item.tag, item.value + } + + // Base 60 floats are a bad idea, were dropped in YAML 1.2, and + // are purposefully unsupported here. They're still quoted on + // the way out for compatibility with other parser, though. + + switch hint { + case 'M': + // We've already checked the map above. + + case '.': + // Not in the map, so maybe a normal float. + floatv, err := strconv.ParseFloat(in, 64) + if err == nil { + return yaml_FLOAT_TAG, floatv + } + + case 'D', 'S': + // Int, float, or timestamp. + plain := strings.Replace(in, "_", "", -1) + intv, err := strconv.ParseInt(plain, 0, 64) + if err == nil { + if intv == int64(int(intv)) { + return yaml_INT_TAG, int(intv) + } else { + return yaml_INT_TAG, intv + } + } + uintv, err := strconv.ParseUint(plain, 0, 64) + if err == nil { + return yaml_INT_TAG, uintv + } + floatv, err := strconv.ParseFloat(plain, 64) + if err == nil { + return yaml_FLOAT_TAG, floatv + } + if strings.HasPrefix(plain, "0b") { + intv, err := strconv.ParseInt(plain[2:], 2, 64) + if err == nil { + if intv == int64(int(intv)) { + return yaml_INT_TAG, int(intv) + } else { + return yaml_INT_TAG, intv + } + } + uintv, err := strconv.ParseUint(plain[2:], 2, 64) + if err == nil { + return yaml_INT_TAG, uintv + } + } else if strings.HasPrefix(plain, "-0b") { + intv, err := strconv.ParseInt(plain[3:], 2, 64) + if err == nil { + if intv == int64(int(intv)) { + return yaml_INT_TAG, -int(intv) + } else { + return yaml_INT_TAG, -intv + } + } + } + // XXX Handle timestamps here. + + default: + panic("resolveTable item not yet handled: " + string(rune(hint)) + " (with " + in + ")") + } + } + if tag == yaml_BINARY_TAG { + return yaml_BINARY_TAG, in + } + if utf8.ValidString(in) { + return yaml_STR_TAG, in + } + return yaml_BINARY_TAG, encodeBase64(in) +} + +// encodeBase64 encodes s as base64 that is broken up into multiple lines +// as appropriate for the resulting length. +func encodeBase64(s string) string { + const lineLen = 70 + encLen := base64.StdEncoding.EncodedLen(len(s)) + lines := encLen/lineLen + 1 + buf := make([]byte, encLen*2+lines) + in := buf[0:encLen] + out := buf[encLen:] + base64.StdEncoding.Encode(in, []byte(s)) + k := 0 + for i := 0; i < len(in); i += lineLen { + j := i + lineLen + if j > len(in) { + j = len(in) + } + k += copy(out[k:], in[i:j]) + if lines > 1 { + out[k] = '\n' + k++ + } + } + return string(out[:k]) +} diff --git a/Godeps/_workspace/src/gopkg.in/yaml.v2/scannerc.go b/Godeps/_workspace/src/gopkg.in/yaml.v2/scannerc.go new file mode 100644 index 000000000..d97d76fa5 --- /dev/null +++ b/Godeps/_workspace/src/gopkg.in/yaml.v2/scannerc.go @@ -0,0 +1,2710 @@ +package yaml + +import ( + "bytes" + "fmt" +) + +// Introduction +// ************ +// +// The following notes assume that you are familiar with the YAML specification +// (http://yaml.org/spec/cvs/current.html). We mostly follow it, although in +// some cases we are less restrictive that it requires. +// +// The process of transforming a YAML stream into a sequence of events is +// divided on two steps: Scanning and Parsing. +// +// The Scanner transforms the input stream into a sequence of tokens, while the +// parser transform the sequence of tokens produced by the Scanner into a +// sequence of parsing events. +// +// The Scanner is rather clever and complicated. The Parser, on the contrary, +// is a straightforward implementation of a recursive-descendant parser (or, +// LL(1) parser, as it is usually called). +// +// Actually there are two issues of Scanning that might be called "clever", the +// rest is quite straightforward. The issues are "block collection start" and +// "simple keys". Both issues are explained below in details. +// +// Here the Scanning step is explained and implemented. We start with the list +// of all the tokens produced by the Scanner together with short descriptions. +// +// Now, tokens: +// +// STREAM-START(encoding) # The stream start. +// STREAM-END # The stream end. +// VERSION-DIRECTIVE(major,minor) # The '%YAML' directive. +// TAG-DIRECTIVE(handle,prefix) # The '%TAG' directive. +// DOCUMENT-START # '---' +// DOCUMENT-END # '...' +// BLOCK-SEQUENCE-START # Indentation increase denoting a block +// BLOCK-MAPPING-START # sequence or a block mapping. +// BLOCK-END # Indentation decrease. +// FLOW-SEQUENCE-START # '[' +// FLOW-SEQUENCE-END # ']' +// BLOCK-SEQUENCE-START # '{' +// BLOCK-SEQUENCE-END # '}' +// BLOCK-ENTRY # '-' +// FLOW-ENTRY # ',' +// KEY # '?' or nothing (simple keys). +// VALUE # ':' +// ALIAS(anchor) # '*anchor' +// ANCHOR(anchor) # '&anchor' +// TAG(handle,suffix) # '!handle!suffix' +// SCALAR(value,style) # A scalar. +// +// The following two tokens are "virtual" tokens denoting the beginning and the +// end of the stream: +// +// STREAM-START(encoding) +// STREAM-END +// +// We pass the information about the input stream encoding with the +// STREAM-START token. +// +// The next two tokens are responsible for tags: +// +// VERSION-DIRECTIVE(major,minor) +// TAG-DIRECTIVE(handle,prefix) +// +// Example: +// +// %YAML 1.1 +// %TAG ! !foo +// %TAG !yaml! tag:yaml.org,2002: +// --- +// +// The correspoding sequence of tokens: +// +// STREAM-START(utf-8) +// VERSION-DIRECTIVE(1,1) +// TAG-DIRECTIVE("!","!foo") +// TAG-DIRECTIVE("!yaml","tag:yaml.org,2002:") +// DOCUMENT-START +// STREAM-END +// +// Note that the VERSION-DIRECTIVE and TAG-DIRECTIVE tokens occupy a whole +// line. +// +// The document start and end indicators are represented by: +// +// DOCUMENT-START +// DOCUMENT-END +// +// Note that if a YAML stream contains an implicit document (without '---' +// and '...' indicators), no DOCUMENT-START and DOCUMENT-END tokens will be +// produced. +// +// In the following examples, we present whole documents together with the +// produced tokens. +// +// 1. An implicit document: +// +// 'a scalar' +// +// Tokens: +// +// STREAM-START(utf-8) +// SCALAR("a scalar",single-quoted) +// STREAM-END +// +// 2. An explicit document: +// +// --- +// 'a scalar' +// ... +// +// Tokens: +// +// STREAM-START(utf-8) +// DOCUMENT-START +// SCALAR("a scalar",single-quoted) +// DOCUMENT-END +// STREAM-END +// +// 3. Several documents in a stream: +// +// 'a scalar' +// --- +// 'another scalar' +// --- +// 'yet another scalar' +// +// Tokens: +// +// STREAM-START(utf-8) +// SCALAR("a scalar",single-quoted) +// DOCUMENT-START +// SCALAR("another scalar",single-quoted) +// DOCUMENT-START +// SCALAR("yet another scalar",single-quoted) +// STREAM-END +// +// We have already introduced the SCALAR token above. The following tokens are +// used to describe aliases, anchors, tag, and scalars: +// +// ALIAS(anchor) +// ANCHOR(anchor) +// TAG(handle,suffix) +// SCALAR(value,style) +// +// The following series of examples illustrate the usage of these tokens: +// +// 1. A recursive sequence: +// +// &A [ *A ] +// +// Tokens: +// +// STREAM-START(utf-8) +// ANCHOR("A") +// FLOW-SEQUENCE-START +// ALIAS("A") +// FLOW-SEQUENCE-END +// STREAM-END +// +// 2. A tagged scalar: +// +// !!float "3.14" # A good approximation. +// +// Tokens: +// +// STREAM-START(utf-8) +// TAG("!!","float") +// SCALAR("3.14",double-quoted) +// STREAM-END +// +// 3. Various scalar styles: +// +// --- # Implicit empty plain scalars do not produce tokens. +// --- a plain scalar +// --- 'a single-quoted scalar' +// --- "a double-quoted scalar" +// --- |- +// a literal scalar +// --- >- +// a folded +// scalar +// +// Tokens: +// +// STREAM-START(utf-8) +// DOCUMENT-START +// DOCUMENT-START +// SCALAR("a plain scalar",plain) +// DOCUMENT-START +// SCALAR("a single-quoted scalar",single-quoted) +// DOCUMENT-START +// SCALAR("a double-quoted scalar",double-quoted) +// DOCUMENT-START +// SCALAR("a literal scalar",literal) +// DOCUMENT-START +// SCALAR("a folded scalar",folded) +// STREAM-END +// +// Now it's time to review collection-related tokens. We will start with +// flow collections: +// +// FLOW-SEQUENCE-START +// FLOW-SEQUENCE-END +// FLOW-MAPPING-START +// FLOW-MAPPING-END +// FLOW-ENTRY +// KEY +// VALUE +// +// The tokens FLOW-SEQUENCE-START, FLOW-SEQUENCE-END, FLOW-MAPPING-START, and +// FLOW-MAPPING-END represent the indicators '[', ']', '{', and '}' +// correspondingly. FLOW-ENTRY represent the ',' indicator. Finally the +// indicators '?' and ':', which are used for denoting mapping keys and values, +// are represented by the KEY and VALUE tokens. +// +// The following examples show flow collections: +// +// 1. A flow sequence: +// +// [item 1, item 2, item 3] +// +// Tokens: +// +// STREAM-START(utf-8) +// FLOW-SEQUENCE-START +// SCALAR("item 1",plain) +// FLOW-ENTRY +// SCALAR("item 2",plain) +// FLOW-ENTRY +// SCALAR("item 3",plain) +// FLOW-SEQUENCE-END +// STREAM-END +// +// 2. A flow mapping: +// +// { +// a simple key: a value, # Note that the KEY token is produced. +// ? a complex key: another value, +// } +// +// Tokens: +// +// STREAM-START(utf-8) +// FLOW-MAPPING-START +// KEY +// SCALAR("a simple key",plain) +// VALUE +// SCALAR("a value",plain) +// FLOW-ENTRY +// KEY +// SCALAR("a complex key",plain) +// VALUE +// SCALAR("another value",plain) +// FLOW-ENTRY +// FLOW-MAPPING-END +// STREAM-END +// +// A simple key is a key which is not denoted by the '?' indicator. Note that +// the Scanner still produce the KEY token whenever it encounters a simple key. +// +// For scanning block collections, the following tokens are used (note that we +// repeat KEY and VALUE here): +// +// BLOCK-SEQUENCE-START +// BLOCK-MAPPING-START +// BLOCK-END +// BLOCK-ENTRY +// KEY +// VALUE +// +// The tokens BLOCK-SEQUENCE-START and BLOCK-MAPPING-START denote indentation +// increase that precedes a block collection (cf. the INDENT token in Python). +// The token BLOCK-END denote indentation decrease that ends a block collection +// (cf. the DEDENT token in Python). However YAML has some syntax pecularities +// that makes detections of these tokens more complex. +// +// The tokens BLOCK-ENTRY, KEY, and VALUE are used to represent the indicators +// '-', '?', and ':' correspondingly. +// +// The following examples show how the tokens BLOCK-SEQUENCE-START, +// BLOCK-MAPPING-START, and BLOCK-END are emitted by the Scanner: +// +// 1. Block sequences: +// +// - item 1 +// - item 2 +// - +// - item 3.1 +// - item 3.2 +// - +// key 1: value 1 +// key 2: value 2 +// +// Tokens: +// +// STREAM-START(utf-8) +// BLOCK-SEQUENCE-START +// BLOCK-ENTRY +// SCALAR("item 1",plain) +// BLOCK-ENTRY +// SCALAR("item 2",plain) +// BLOCK-ENTRY +// BLOCK-SEQUENCE-START +// BLOCK-ENTRY +// SCALAR("item 3.1",plain) +// BLOCK-ENTRY +// SCALAR("item 3.2",plain) +// BLOCK-END +// BLOCK-ENTRY +// BLOCK-MAPPING-START +// KEY +// SCALAR("key 1",plain) +// VALUE +// SCALAR("value 1",plain) +// KEY +// SCALAR("key 2",plain) +// VALUE +// SCALAR("value 2",plain) +// BLOCK-END +// BLOCK-END +// STREAM-END +// +// 2. Block mappings: +// +// a simple key: a value # The KEY token is produced here. +// ? a complex key +// : another value +// a mapping: +// key 1: value 1 +// key 2: value 2 +// a sequence: +// - item 1 +// - item 2 +// +// Tokens: +// +// STREAM-START(utf-8) +// BLOCK-MAPPING-START +// KEY +// SCALAR("a simple key",plain) +// VALUE +// SCALAR("a value",plain) +// KEY +// SCALAR("a complex key",plain) +// VALUE +// SCALAR("another value",plain) +// KEY +// SCALAR("a mapping",plain) +// BLOCK-MAPPING-START +// KEY +// SCALAR("key 1",plain) +// VALUE +// SCALAR("value 1",plain) +// KEY +// SCALAR("key 2",plain) +// VALUE +// SCALAR("value 2",plain) +// BLOCK-END +// KEY +// SCALAR("a sequence",plain) +// VALUE +// BLOCK-SEQUENCE-START +// BLOCK-ENTRY +// SCALAR("item 1",plain) +// BLOCK-ENTRY +// SCALAR("item 2",plain) +// BLOCK-END +// BLOCK-END +// STREAM-END +// +// YAML does not always require to start a new block collection from a new +// line. If the current line contains only '-', '?', and ':' indicators, a new +// block collection may start at the current line. The following examples +// illustrate this case: +// +// 1. Collections in a sequence: +// +// - - item 1 +// - item 2 +// - key 1: value 1 +// key 2: value 2 +// - ? complex key +// : complex value +// +// Tokens: +// +// STREAM-START(utf-8) +// BLOCK-SEQUENCE-START +// BLOCK-ENTRY +// BLOCK-SEQUENCE-START +// BLOCK-ENTRY +// SCALAR("item 1",plain) +// BLOCK-ENTRY +// SCALAR("item 2",plain) +// BLOCK-END +// BLOCK-ENTRY +// BLOCK-MAPPING-START +// KEY +// SCALAR("key 1",plain) +// VALUE +// SCALAR("value 1",plain) +// KEY +// SCALAR("key 2",plain) +// VALUE +// SCALAR("value 2",plain) +// BLOCK-END +// BLOCK-ENTRY +// BLOCK-MAPPING-START +// KEY +// SCALAR("complex key") +// VALUE +// SCALAR("complex value") +// BLOCK-END +// BLOCK-END +// STREAM-END +// +// 2. Collections in a mapping: +// +// ? a sequence +// : - item 1 +// - item 2 +// ? a mapping +// : key 1: value 1 +// key 2: value 2 +// +// Tokens: +// +// STREAM-START(utf-8) +// BLOCK-MAPPING-START +// KEY +// SCALAR("a sequence",plain) +// VALUE +// BLOCK-SEQUENCE-START +// BLOCK-ENTRY +// SCALAR("item 1",plain) +// BLOCK-ENTRY +// SCALAR("item 2",plain) +// BLOCK-END +// KEY +// SCALAR("a mapping",plain) +// VALUE +// BLOCK-MAPPING-START +// KEY +// SCALAR("key 1",plain) +// VALUE +// SCALAR("value 1",plain) +// KEY +// SCALAR("key 2",plain) +// VALUE +// SCALAR("value 2",plain) +// BLOCK-END +// BLOCK-END +// STREAM-END +// +// YAML also permits non-indented sequences if they are included into a block +// mapping. In this case, the token BLOCK-SEQUENCE-START is not produced: +// +// key: +// - item 1 # BLOCK-SEQUENCE-START is NOT produced here. +// - item 2 +// +// Tokens: +// +// STREAM-START(utf-8) +// BLOCK-MAPPING-START +// KEY +// SCALAR("key",plain) +// VALUE +// BLOCK-ENTRY +// SCALAR("item 1",plain) +// BLOCK-ENTRY +// SCALAR("item 2",plain) +// BLOCK-END +// + +// Ensure that the buffer contains the required number of characters. +// Return true on success, false on failure (reader error or memory error). +func cache(parser *yaml_parser_t, length int) bool { + // [Go] This was inlined: !cache(A, B) -> unread < B && !update(A, B) + return parser.unread >= length || yaml_parser_update_buffer(parser, length) +} + +// Advance the buffer pointer. +func skip(parser *yaml_parser_t) { + parser.mark.index++ + parser.mark.column++ + parser.unread-- + parser.buffer_pos += width(parser.buffer[parser.buffer_pos]) +} + +func skip_line(parser *yaml_parser_t) { + if is_crlf(parser.buffer, parser.buffer_pos) { + parser.mark.index += 2 + parser.mark.column = 0 + parser.mark.line++ + parser.unread -= 2 + parser.buffer_pos += 2 + } else if is_break(parser.buffer, parser.buffer_pos) { + parser.mark.index++ + parser.mark.column = 0 + parser.mark.line++ + parser.unread-- + parser.buffer_pos += width(parser.buffer[parser.buffer_pos]) + } +} + +// Copy a character to a string buffer and advance pointers. +func read(parser *yaml_parser_t, s []byte) []byte { + w := width(parser.buffer[parser.buffer_pos]) + if w == 0 { + panic("invalid character sequence") + } + if len(s) == 0 { + s = make([]byte, 0, 32) + } + if w == 1 && len(s)+w <= cap(s) { + s = s[:len(s)+1] + s[len(s)-1] = parser.buffer[parser.buffer_pos] + parser.buffer_pos++ + } else { + s = append(s, parser.buffer[parser.buffer_pos:parser.buffer_pos+w]...) + parser.buffer_pos += w + } + parser.mark.index++ + parser.mark.column++ + parser.unread-- + return s +} + +// Copy a line break character to a string buffer and advance pointers. +func read_line(parser *yaml_parser_t, s []byte) []byte { + buf := parser.buffer + pos := parser.buffer_pos + switch { + case buf[pos] == '\r' && buf[pos+1] == '\n': + // CR LF . LF + s = append(s, '\n') + parser.buffer_pos += 2 + parser.mark.index++ + parser.unread-- + case buf[pos] == '\r' || buf[pos] == '\n': + // CR|LF . LF + s = append(s, '\n') + parser.buffer_pos += 1 + case buf[pos] == '\xC2' && buf[pos+1] == '\x85': + // NEL . LF + s = append(s, '\n') + parser.buffer_pos += 2 + case buf[pos] == '\xE2' && buf[pos+1] == '\x80' && (buf[pos+2] == '\xA8' || buf[pos+2] == '\xA9'): + // LS|PS . LS|PS + s = append(s, buf[parser.buffer_pos:pos+3]...) + parser.buffer_pos += 3 + default: + return s + } + parser.mark.index++ + parser.mark.column = 0 + parser.mark.line++ + parser.unread-- + return s +} + +// Get the next token. +func yaml_parser_scan(parser *yaml_parser_t, token *yaml_token_t) bool { + // Erase the token object. + *token = yaml_token_t{} // [Go] Is this necessary? + + // No tokens after STREAM-END or error. + if parser.stream_end_produced || parser.error != yaml_NO_ERROR { + return true + } + + // Ensure that the tokens queue contains enough tokens. + if !parser.token_available { + if !yaml_parser_fetch_more_tokens(parser) { + return false + } + } + + // Fetch the next token from the queue. + *token = parser.tokens[parser.tokens_head] + parser.tokens_head++ + parser.tokens_parsed++ + parser.token_available = false + + if token.typ == yaml_STREAM_END_TOKEN { + parser.stream_end_produced = true + } + return true +} + +// Set the scanner error and return false. +func yaml_parser_set_scanner_error(parser *yaml_parser_t, context string, context_mark yaml_mark_t, problem string) bool { + parser.error = yaml_SCANNER_ERROR + parser.context = context + parser.context_mark = context_mark + parser.problem = problem + parser.problem_mark = parser.mark + return false +} + +func yaml_parser_set_scanner_tag_error(parser *yaml_parser_t, directive bool, context_mark yaml_mark_t, problem string) bool { + context := "while parsing a tag" + if directive { + context = "while parsing a %TAG directive" + } + return yaml_parser_set_scanner_error(parser, context, context_mark, "did not find URI escaped octet") +} + +func trace(args ...interface{}) func() { + pargs := append([]interface{}{"+++"}, args...) + fmt.Println(pargs...) + pargs = append([]interface{}{"---"}, args...) + return func() { fmt.Println(pargs...) } +} + +// Ensure that the tokens queue contains at least one token which can be +// returned to the Parser. +func yaml_parser_fetch_more_tokens(parser *yaml_parser_t) bool { + // While we need more tokens to fetch, do it. + for { + // Check if we really need to fetch more tokens. + need_more_tokens := false + + if parser.tokens_head == len(parser.tokens) { + // Queue is empty. + need_more_tokens = true + } else { + // Check if any potential simple key may occupy the head position. + if !yaml_parser_stale_simple_keys(parser) { + return false + } + + for i := range parser.simple_keys { + simple_key := &parser.simple_keys[i] + if simple_key.possible && simple_key.token_number == parser.tokens_parsed { + need_more_tokens = true + break + } + } + } + + // We are finished. + if !need_more_tokens { + break + } + // Fetch the next token. + if !yaml_parser_fetch_next_token(parser) { + return false + } + } + + parser.token_available = true + return true +} + +// The dispatcher for token fetchers. +func yaml_parser_fetch_next_token(parser *yaml_parser_t) bool { + // Ensure that the buffer is initialized. + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + + // Check if we just started scanning. Fetch STREAM-START then. + if !parser.stream_start_produced { + return yaml_parser_fetch_stream_start(parser) + } + + // Eat whitespaces and comments until we reach the next token. + if !yaml_parser_scan_to_next_token(parser) { + return false + } + + // Remove obsolete potential simple keys. + if !yaml_parser_stale_simple_keys(parser) { + return false + } + + // Check the indentation level against the current column. + if !yaml_parser_unroll_indent(parser, parser.mark.column) { + return false + } + + // Ensure that the buffer contains at least 4 characters. 4 is the length + // of the longest indicators ('--- ' and '... '). + if parser.unread < 4 && !yaml_parser_update_buffer(parser, 4) { + return false + } + + // Is it the end of the stream? + if is_z(parser.buffer, parser.buffer_pos) { + return yaml_parser_fetch_stream_end(parser) + } + + // Is it a directive? + if parser.mark.column == 0 && parser.buffer[parser.buffer_pos] == '%' { + return yaml_parser_fetch_directive(parser) + } + + buf := parser.buffer + pos := parser.buffer_pos + + // Is it the document start indicator? + if parser.mark.column == 0 && buf[pos] == '-' && buf[pos+1] == '-' && buf[pos+2] == '-' && is_blankz(buf, pos+3) { + return yaml_parser_fetch_document_indicator(parser, yaml_DOCUMENT_START_TOKEN) + } + + // Is it the document end indicator? + if parser.mark.column == 0 && buf[pos] == '.' && buf[pos+1] == '.' && buf[pos+2] == '.' && is_blankz(buf, pos+3) { + return yaml_parser_fetch_document_indicator(parser, yaml_DOCUMENT_END_TOKEN) + } + + // Is it the flow sequence start indicator? + if buf[pos] == '[' { + return yaml_parser_fetch_flow_collection_start(parser, yaml_FLOW_SEQUENCE_START_TOKEN) + } + + // Is it the flow mapping start indicator? + if parser.buffer[parser.buffer_pos] == '{' { + return yaml_parser_fetch_flow_collection_start(parser, yaml_FLOW_MAPPING_START_TOKEN) + } + + // Is it the flow sequence end indicator? + if parser.buffer[parser.buffer_pos] == ']' { + return yaml_parser_fetch_flow_collection_end(parser, + yaml_FLOW_SEQUENCE_END_TOKEN) + } + + // Is it the flow mapping end indicator? + if parser.buffer[parser.buffer_pos] == '}' { + return yaml_parser_fetch_flow_collection_end(parser, + yaml_FLOW_MAPPING_END_TOKEN) + } + + // Is it the flow entry indicator? + if parser.buffer[parser.buffer_pos] == ',' { + return yaml_parser_fetch_flow_entry(parser) + } + + // Is it the block entry indicator? + if parser.buffer[parser.buffer_pos] == '-' && is_blankz(parser.buffer, parser.buffer_pos+1) { + return yaml_parser_fetch_block_entry(parser) + } + + // Is it the key indicator? + if parser.buffer[parser.buffer_pos] == '?' && (parser.flow_level > 0 || is_blankz(parser.buffer, parser.buffer_pos+1)) { + return yaml_parser_fetch_key(parser) + } + + // Is it the value indicator? + if parser.buffer[parser.buffer_pos] == ':' && (parser.flow_level > 0 || is_blankz(parser.buffer, parser.buffer_pos+1)) { + return yaml_parser_fetch_value(parser) + } + + // Is it an alias? + if parser.buffer[parser.buffer_pos] == '*' { + return yaml_parser_fetch_anchor(parser, yaml_ALIAS_TOKEN) + } + + // Is it an anchor? + if parser.buffer[parser.buffer_pos] == '&' { + return yaml_parser_fetch_anchor(parser, yaml_ANCHOR_TOKEN) + } + + // Is it a tag? + if parser.buffer[parser.buffer_pos] == '!' { + return yaml_parser_fetch_tag(parser) + } + + // Is it a literal scalar? + if parser.buffer[parser.buffer_pos] == '|' && parser.flow_level == 0 { + return yaml_parser_fetch_block_scalar(parser, true) + } + + // Is it a folded scalar? + if parser.buffer[parser.buffer_pos] == '>' && parser.flow_level == 0 { + return yaml_parser_fetch_block_scalar(parser, false) + } + + // Is it a single-quoted scalar? + if parser.buffer[parser.buffer_pos] == '\'' { + return yaml_parser_fetch_flow_scalar(parser, true) + } + + // Is it a double-quoted scalar? + if parser.buffer[parser.buffer_pos] == '"' { + return yaml_parser_fetch_flow_scalar(parser, false) + } + + // Is it a plain scalar? + // + // A plain scalar may start with any non-blank characters except + // + // '-', '?', ':', ',', '[', ']', '{', '}', + // '#', '&', '*', '!', '|', '>', '\'', '\"', + // '%', '@', '`'. + // + // In the block context (and, for the '-' indicator, in the flow context + // too), it may also start with the characters + // + // '-', '?', ':' + // + // if it is followed by a non-space character. + // + // The last rule is more restrictive than the specification requires. + // [Go] Make this logic more reasonable. + //switch parser.buffer[parser.buffer_pos] { + //case '-', '?', ':', ',', '?', '-', ',', ':', ']', '[', '}', '{', '&', '#', '!', '*', '>', '|', '"', '\'', '@', '%', '-', '`': + //} + if !(is_blankz(parser.buffer, parser.buffer_pos) || parser.buffer[parser.buffer_pos] == '-' || + parser.buffer[parser.buffer_pos] == '?' || parser.buffer[parser.buffer_pos] == ':' || + parser.buffer[parser.buffer_pos] == ',' || parser.buffer[parser.buffer_pos] == '[' || + parser.buffer[parser.buffer_pos] == ']' || parser.buffer[parser.buffer_pos] == '{' || + parser.buffer[parser.buffer_pos] == '}' || parser.buffer[parser.buffer_pos] == '#' || + parser.buffer[parser.buffer_pos] == '&' || parser.buffer[parser.buffer_pos] == '*' || + parser.buffer[parser.buffer_pos] == '!' || parser.buffer[parser.buffer_pos] == '|' || + parser.buffer[parser.buffer_pos] == '>' || parser.buffer[parser.buffer_pos] == '\'' || + parser.buffer[parser.buffer_pos] == '"' || parser.buffer[parser.buffer_pos] == '%' || + parser.buffer[parser.buffer_pos] == '@' || parser.buffer[parser.buffer_pos] == '`') || + (parser.buffer[parser.buffer_pos] == '-' && !is_blank(parser.buffer, parser.buffer_pos+1)) || + (parser.flow_level == 0 && + (parser.buffer[parser.buffer_pos] == '?' || parser.buffer[parser.buffer_pos] == ':') && + !is_blankz(parser.buffer, parser.buffer_pos+1)) { + return yaml_parser_fetch_plain_scalar(parser) + } + + // If we don't determine the token type so far, it is an error. + return yaml_parser_set_scanner_error(parser, + "while scanning for the next token", parser.mark, + "found character that cannot start any token") +} + +// Check the list of potential simple keys and remove the positions that +// cannot contain simple keys anymore. +func yaml_parser_stale_simple_keys(parser *yaml_parser_t) bool { + // Check for a potential simple key for each flow level. + for i := range parser.simple_keys { + simple_key := &parser.simple_keys[i] + + // The specification requires that a simple key + // + // - is limited to a single line, + // - is shorter than 1024 characters. + if simple_key.possible && (simple_key.mark.line < parser.mark.line || simple_key.mark.index+1024 < parser.mark.index) { + + // Check if the potential simple key to be removed is required. + if simple_key.required { + return yaml_parser_set_scanner_error(parser, + "while scanning a simple key", simple_key.mark, + "could not find expected ':'") + } + simple_key.possible = false + } + } + return true +} + +// Check if a simple key may start at the current position and add it if +// needed. +func yaml_parser_save_simple_key(parser *yaml_parser_t) bool { + // A simple key is required at the current position if the scanner is in + // the block context and the current column coincides with the indentation + // level. + + required := parser.flow_level == 0 && parser.indent == parser.mark.column + + // A simple key is required only when it is the first token in the current + // line. Therefore it is always allowed. But we add a check anyway. + if required && !parser.simple_key_allowed { + panic("should not happen") + } + + // + // If the current position may start a simple key, save it. + // + if parser.simple_key_allowed { + simple_key := yaml_simple_key_t{ + possible: true, + required: required, + token_number: parser.tokens_parsed + (len(parser.tokens) - parser.tokens_head), + } + simple_key.mark = parser.mark + + if !yaml_parser_remove_simple_key(parser) { + return false + } + parser.simple_keys[len(parser.simple_keys)-1] = simple_key + } + return true +} + +// Remove a potential simple key at the current flow level. +func yaml_parser_remove_simple_key(parser *yaml_parser_t) bool { + i := len(parser.simple_keys) - 1 + if parser.simple_keys[i].possible { + // If the key is required, it is an error. + if parser.simple_keys[i].required { + return yaml_parser_set_scanner_error(parser, + "while scanning a simple key", parser.simple_keys[i].mark, + "could not find expected ':'") + } + } + // Remove the key from the stack. + parser.simple_keys[i].possible = false + return true +} + +// Increase the flow level and resize the simple key list if needed. +func yaml_parser_increase_flow_level(parser *yaml_parser_t) bool { + // Reset the simple key on the next level. + parser.simple_keys = append(parser.simple_keys, yaml_simple_key_t{}) + + // Increase the flow level. + parser.flow_level++ + return true +} + +// Decrease the flow level. +func yaml_parser_decrease_flow_level(parser *yaml_parser_t) bool { + if parser.flow_level > 0 { + parser.flow_level-- + parser.simple_keys = parser.simple_keys[:len(parser.simple_keys)-1] + } + return true +} + +// Push the current indentation level to the stack and set the new level +// the current column is greater than the indentation level. In this case, +// append or insert the specified token into the token queue. +func yaml_parser_roll_indent(parser *yaml_parser_t, column, number int, typ yaml_token_type_t, mark yaml_mark_t) bool { + // In the flow context, do nothing. + if parser.flow_level > 0 { + return true + } + + if parser.indent < column { + // Push the current indentation level to the stack and set the new + // indentation level. + parser.indents = append(parser.indents, parser.indent) + parser.indent = column + + // Create a token and insert it into the queue. + token := yaml_token_t{ + typ: typ, + start_mark: mark, + end_mark: mark, + } + if number > -1 { + number -= parser.tokens_parsed + } + yaml_insert_token(parser, number, &token) + } + return true +} + +// Pop indentation levels from the indents stack until the current level +// becomes less or equal to the column. For each indentation level, append +// the BLOCK-END token. +func yaml_parser_unroll_indent(parser *yaml_parser_t, column int) bool { + // In the flow context, do nothing. + if parser.flow_level > 0 { + return true + } + + // Loop through the indentation levels in the stack. + for parser.indent > column { + // Create a token and append it to the queue. + token := yaml_token_t{ + typ: yaml_BLOCK_END_TOKEN, + start_mark: parser.mark, + end_mark: parser.mark, + } + yaml_insert_token(parser, -1, &token) + + // Pop the indentation level. + parser.indent = parser.indents[len(parser.indents)-1] + parser.indents = parser.indents[:len(parser.indents)-1] + } + return true +} + +// Initialize the scanner and produce the STREAM-START token. +func yaml_parser_fetch_stream_start(parser *yaml_parser_t) bool { + + // Set the initial indentation. + parser.indent = -1 + + // Initialize the simple key stack. + parser.simple_keys = append(parser.simple_keys, yaml_simple_key_t{}) + + // A simple key is allowed at the beginning of the stream. + parser.simple_key_allowed = true + + // We have started. + parser.stream_start_produced = true + + // Create the STREAM-START token and append it to the queue. + token := yaml_token_t{ + typ: yaml_STREAM_START_TOKEN, + start_mark: parser.mark, + end_mark: parser.mark, + encoding: parser.encoding, + } + yaml_insert_token(parser, -1, &token) + return true +} + +// Produce the STREAM-END token and shut down the scanner. +func yaml_parser_fetch_stream_end(parser *yaml_parser_t) bool { + + // Force new line. + if parser.mark.column != 0 { + parser.mark.column = 0 + parser.mark.line++ + } + + // Reset the indentation level. + if !yaml_parser_unroll_indent(parser, -1) { + return false + } + + // Reset simple keys. + if !yaml_parser_remove_simple_key(parser) { + return false + } + + parser.simple_key_allowed = false + + // Create the STREAM-END token and append it to the queue. + token := yaml_token_t{ + typ: yaml_STREAM_END_TOKEN, + start_mark: parser.mark, + end_mark: parser.mark, + } + yaml_insert_token(parser, -1, &token) + return true +} + +// Produce a VERSION-DIRECTIVE or TAG-DIRECTIVE token. +func yaml_parser_fetch_directive(parser *yaml_parser_t) bool { + // Reset the indentation level. + if !yaml_parser_unroll_indent(parser, -1) { + return false + } + + // Reset simple keys. + if !yaml_parser_remove_simple_key(parser) { + return false + } + + parser.simple_key_allowed = false + + // Create the YAML-DIRECTIVE or TAG-DIRECTIVE token. + token := yaml_token_t{} + if !yaml_parser_scan_directive(parser, &token) { + return false + } + // Append the token to the queue. + yaml_insert_token(parser, -1, &token) + return true +} + +// Produce the DOCUMENT-START or DOCUMENT-END token. +func yaml_parser_fetch_document_indicator(parser *yaml_parser_t, typ yaml_token_type_t) bool { + // Reset the indentation level. + if !yaml_parser_unroll_indent(parser, -1) { + return false + } + + // Reset simple keys. + if !yaml_parser_remove_simple_key(parser) { + return false + } + + parser.simple_key_allowed = false + + // Consume the token. + start_mark := parser.mark + + skip(parser) + skip(parser) + skip(parser) + + end_mark := parser.mark + + // Create the DOCUMENT-START or DOCUMENT-END token. + token := yaml_token_t{ + typ: typ, + start_mark: start_mark, + end_mark: end_mark, + } + // Append the token to the queue. + yaml_insert_token(parser, -1, &token) + return true +} + +// Produce the FLOW-SEQUENCE-START or FLOW-MAPPING-START token. +func yaml_parser_fetch_flow_collection_start(parser *yaml_parser_t, typ yaml_token_type_t) bool { + // The indicators '[' and '{' may start a simple key. + if !yaml_parser_save_simple_key(parser) { + return false + } + + // Increase the flow level. + if !yaml_parser_increase_flow_level(parser) { + return false + } + + // A simple key may follow the indicators '[' and '{'. + parser.simple_key_allowed = true + + // Consume the token. + start_mark := parser.mark + skip(parser) + end_mark := parser.mark + + // Create the FLOW-SEQUENCE-START of FLOW-MAPPING-START token. + token := yaml_token_t{ + typ: typ, + start_mark: start_mark, + end_mark: end_mark, + } + // Append the token to the queue. + yaml_insert_token(parser, -1, &token) + return true +} + +// Produce the FLOW-SEQUENCE-END or FLOW-MAPPING-END token. +func yaml_parser_fetch_flow_collection_end(parser *yaml_parser_t, typ yaml_token_type_t) bool { + // Reset any potential simple key on the current flow level. + if !yaml_parser_remove_simple_key(parser) { + return false + } + + // Decrease the flow level. + if !yaml_parser_decrease_flow_level(parser) { + return false + } + + // No simple keys after the indicators ']' and '}'. + parser.simple_key_allowed = false + + // Consume the token. + + start_mark := parser.mark + skip(parser) + end_mark := parser.mark + + // Create the FLOW-SEQUENCE-END of FLOW-MAPPING-END token. + token := yaml_token_t{ + typ: typ, + start_mark: start_mark, + end_mark: end_mark, + } + // Append the token to the queue. + yaml_insert_token(parser, -1, &token) + return true +} + +// Produce the FLOW-ENTRY token. +func yaml_parser_fetch_flow_entry(parser *yaml_parser_t) bool { + // Reset any potential simple keys on the current flow level. + if !yaml_parser_remove_simple_key(parser) { + return false + } + + // Simple keys are allowed after ','. + parser.simple_key_allowed = true + + // Consume the token. + start_mark := parser.mark + skip(parser) + end_mark := parser.mark + + // Create the FLOW-ENTRY token and append it to the queue. + token := yaml_token_t{ + typ: yaml_FLOW_ENTRY_TOKEN, + start_mark: start_mark, + end_mark: end_mark, + } + yaml_insert_token(parser, -1, &token) + return true +} + +// Produce the BLOCK-ENTRY token. +func yaml_parser_fetch_block_entry(parser *yaml_parser_t) bool { + // Check if the scanner is in the block context. + if parser.flow_level == 0 { + // Check if we are allowed to start a new entry. + if !parser.simple_key_allowed { + return yaml_parser_set_scanner_error(parser, "", parser.mark, + "block sequence entries are not allowed in this context") + } + // Add the BLOCK-SEQUENCE-START token if needed. + if !yaml_parser_roll_indent(parser, parser.mark.column, -1, yaml_BLOCK_SEQUENCE_START_TOKEN, parser.mark) { + return false + } + } else { + // It is an error for the '-' indicator to occur in the flow context, + // but we let the Parser detect and report about it because the Parser + // is able to point to the context. + } + + // Reset any potential simple keys on the current flow level. + if !yaml_parser_remove_simple_key(parser) { + return false + } + + // Simple keys are allowed after '-'. + parser.simple_key_allowed = true + + // Consume the token. + start_mark := parser.mark + skip(parser) + end_mark := parser.mark + + // Create the BLOCK-ENTRY token and append it to the queue. + token := yaml_token_t{ + typ: yaml_BLOCK_ENTRY_TOKEN, + start_mark: start_mark, + end_mark: end_mark, + } + yaml_insert_token(parser, -1, &token) + return true +} + +// Produce the KEY token. +func yaml_parser_fetch_key(parser *yaml_parser_t) bool { + + // In the block context, additional checks are required. + if parser.flow_level == 0 { + // Check if we are allowed to start a new key (not nessesary simple). + if !parser.simple_key_allowed { + return yaml_parser_set_scanner_error(parser, "", parser.mark, + "mapping keys are not allowed in this context") + } + // Add the BLOCK-MAPPING-START token if needed. + if !yaml_parser_roll_indent(parser, parser.mark.column, -1, yaml_BLOCK_MAPPING_START_TOKEN, parser.mark) { + return false + } + } + + // Reset any potential simple keys on the current flow level. + if !yaml_parser_remove_simple_key(parser) { + return false + } + + // Simple keys are allowed after '?' in the block context. + parser.simple_key_allowed = parser.flow_level == 0 + + // Consume the token. + start_mark := parser.mark + skip(parser) + end_mark := parser.mark + + // Create the KEY token and append it to the queue. + token := yaml_token_t{ + typ: yaml_KEY_TOKEN, + start_mark: start_mark, + end_mark: end_mark, + } + yaml_insert_token(parser, -1, &token) + return true +} + +// Produce the VALUE token. +func yaml_parser_fetch_value(parser *yaml_parser_t) bool { + + simple_key := &parser.simple_keys[len(parser.simple_keys)-1] + + // Have we found a simple key? + if simple_key.possible { + // Create the KEY token and insert it into the queue. + token := yaml_token_t{ + typ: yaml_KEY_TOKEN, + start_mark: simple_key.mark, + end_mark: simple_key.mark, + } + yaml_insert_token(parser, simple_key.token_number-parser.tokens_parsed, &token) + + // In the block context, we may need to add the BLOCK-MAPPING-START token. + if !yaml_parser_roll_indent(parser, simple_key.mark.column, + simple_key.token_number, + yaml_BLOCK_MAPPING_START_TOKEN, simple_key.mark) { + return false + } + + // Remove the simple key. + simple_key.possible = false + + // A simple key cannot follow another simple key. + parser.simple_key_allowed = false + + } else { + // The ':' indicator follows a complex key. + + // In the block context, extra checks are required. + if parser.flow_level == 0 { + + // Check if we are allowed to start a complex value. + if !parser.simple_key_allowed { + return yaml_parser_set_scanner_error(parser, "", parser.mark, + "mapping values are not allowed in this context") + } + + // Add the BLOCK-MAPPING-START token if needed. + if !yaml_parser_roll_indent(parser, parser.mark.column, -1, yaml_BLOCK_MAPPING_START_TOKEN, parser.mark) { + return false + } + } + + // Simple keys after ':' are allowed in the block context. + parser.simple_key_allowed = parser.flow_level == 0 + } + + // Consume the token. + start_mark := parser.mark + skip(parser) + end_mark := parser.mark + + // Create the VALUE token and append it to the queue. + token := yaml_token_t{ + typ: yaml_VALUE_TOKEN, + start_mark: start_mark, + end_mark: end_mark, + } + yaml_insert_token(parser, -1, &token) + return true +} + +// Produce the ALIAS or ANCHOR token. +func yaml_parser_fetch_anchor(parser *yaml_parser_t, typ yaml_token_type_t) bool { + // An anchor or an alias could be a simple key. + if !yaml_parser_save_simple_key(parser) { + return false + } + + // A simple key cannot follow an anchor or an alias. + parser.simple_key_allowed = false + + // Create the ALIAS or ANCHOR token and append it to the queue. + var token yaml_token_t + if !yaml_parser_scan_anchor(parser, &token, typ) { + return false + } + yaml_insert_token(parser, -1, &token) + return true +} + +// Produce the TAG token. +func yaml_parser_fetch_tag(parser *yaml_parser_t) bool { + // A tag could be a simple key. + if !yaml_parser_save_simple_key(parser) { + return false + } + + // A simple key cannot follow a tag. + parser.simple_key_allowed = false + + // Create the TAG token and append it to the queue. + var token yaml_token_t + if !yaml_parser_scan_tag(parser, &token) { + return false + } + yaml_insert_token(parser, -1, &token) + return true +} + +// Produce the SCALAR(...,literal) or SCALAR(...,folded) tokens. +func yaml_parser_fetch_block_scalar(parser *yaml_parser_t, literal bool) bool { + // Remove any potential simple keys. + if !yaml_parser_remove_simple_key(parser) { + return false + } + + // A simple key may follow a block scalar. + parser.simple_key_allowed = true + + // Create the SCALAR token and append it to the queue. + var token yaml_token_t + if !yaml_parser_scan_block_scalar(parser, &token, literal) { + return false + } + yaml_insert_token(parser, -1, &token) + return true +} + +// Produce the SCALAR(...,single-quoted) or SCALAR(...,double-quoted) tokens. +func yaml_parser_fetch_flow_scalar(parser *yaml_parser_t, single bool) bool { + // A plain scalar could be a simple key. + if !yaml_parser_save_simple_key(parser) { + return false + } + + // A simple key cannot follow a flow scalar. + parser.simple_key_allowed = false + + // Create the SCALAR token and append it to the queue. + var token yaml_token_t + if !yaml_parser_scan_flow_scalar(parser, &token, single) { + return false + } + yaml_insert_token(parser, -1, &token) + return true +} + +// Produce the SCALAR(...,plain) token. +func yaml_parser_fetch_plain_scalar(parser *yaml_parser_t) bool { + // A plain scalar could be a simple key. + if !yaml_parser_save_simple_key(parser) { + return false + } + + // A simple key cannot follow a flow scalar. + parser.simple_key_allowed = false + + // Create the SCALAR token and append it to the queue. + var token yaml_token_t + if !yaml_parser_scan_plain_scalar(parser, &token) { + return false + } + yaml_insert_token(parser, -1, &token) + return true +} + +// Eat whitespaces and comments until the next token is found. +func yaml_parser_scan_to_next_token(parser *yaml_parser_t) bool { + + // Until the next token is not found. + for { + // Allow the BOM mark to start a line. + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + if parser.mark.column == 0 && is_bom(parser.buffer, parser.buffer_pos) { + skip(parser) + } + + // Eat whitespaces. + // Tabs are allowed: + // - in the flow context + // - in the block context, but not at the beginning of the line or + // after '-', '?', or ':' (complex value). + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + + for parser.buffer[parser.buffer_pos] == ' ' || ((parser.flow_level > 0 || !parser.simple_key_allowed) && parser.buffer[parser.buffer_pos] == '\t') { + skip(parser) + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + } + + // Eat a comment until a line break. + if parser.buffer[parser.buffer_pos] == '#' { + for !is_breakz(parser.buffer, parser.buffer_pos) { + skip(parser) + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + } + } + + // If it is a line break, eat it. + if is_break(parser.buffer, parser.buffer_pos) { + if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) { + return false + } + skip_line(parser) + + // In the block context, a new line may start a simple key. + if parser.flow_level == 0 { + parser.simple_key_allowed = true + } + } else { + break // We have found a token. + } + } + + return true +} + +// Scan a YAML-DIRECTIVE or TAG-DIRECTIVE token. +// +// Scope: +// %YAML 1.1 # a comment \n +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +// %TAG !yaml! tag:yaml.org,2002: \n +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +// +func yaml_parser_scan_directive(parser *yaml_parser_t, token *yaml_token_t) bool { + // Eat '%'. + start_mark := parser.mark + skip(parser) + + // Scan the directive name. + var name []byte + if !yaml_parser_scan_directive_name(parser, start_mark, &name) { + return false + } + + // Is it a YAML directive? + if bytes.Equal(name, []byte("YAML")) { + // Scan the VERSION directive value. + var major, minor int8 + if !yaml_parser_scan_version_directive_value(parser, start_mark, &major, &minor) { + return false + } + end_mark := parser.mark + + // Create a VERSION-DIRECTIVE token. + *token = yaml_token_t{ + typ: yaml_VERSION_DIRECTIVE_TOKEN, + start_mark: start_mark, + end_mark: end_mark, + major: major, + minor: minor, + } + + // Is it a TAG directive? + } else if bytes.Equal(name, []byte("TAG")) { + // Scan the TAG directive value. + var handle, prefix []byte + if !yaml_parser_scan_tag_directive_value(parser, start_mark, &handle, &prefix) { + return false + } + end_mark := parser.mark + + // Create a TAG-DIRECTIVE token. + *token = yaml_token_t{ + typ: yaml_TAG_DIRECTIVE_TOKEN, + start_mark: start_mark, + end_mark: end_mark, + value: handle, + prefix: prefix, + } + + // Unknown directive. + } else { + yaml_parser_set_scanner_error(parser, "while scanning a directive", + start_mark, "found uknown directive name") + return false + } + + // Eat the rest of the line including any comments. + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + + for is_blank(parser.buffer, parser.buffer_pos) { + skip(parser) + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + } + + if parser.buffer[parser.buffer_pos] == '#' { + for !is_breakz(parser.buffer, parser.buffer_pos) { + skip(parser) + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + } + } + + // Check if we are at the end of the line. + if !is_breakz(parser.buffer, parser.buffer_pos) { + yaml_parser_set_scanner_error(parser, "while scanning a directive", + start_mark, "did not find expected comment or line break") + return false + } + + // Eat a line break. + if is_break(parser.buffer, parser.buffer_pos) { + if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) { + return false + } + skip_line(parser) + } + + return true +} + +// Scan the directive name. +// +// Scope: +// %YAML 1.1 # a comment \n +// ^^^^ +// %TAG !yaml! tag:yaml.org,2002: \n +// ^^^ +// +func yaml_parser_scan_directive_name(parser *yaml_parser_t, start_mark yaml_mark_t, name *[]byte) bool { + // Consume the directive name. + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + + var s []byte + for is_alpha(parser.buffer, parser.buffer_pos) { + s = read(parser, s) + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + } + + // Check if the name is empty. + if len(s) == 0 { + yaml_parser_set_scanner_error(parser, "while scanning a directive", + start_mark, "could not find expected directive name") + return false + } + + // Check for an blank character after the name. + if !is_blankz(parser.buffer, parser.buffer_pos) { + yaml_parser_set_scanner_error(parser, "while scanning a directive", + start_mark, "found unexpected non-alphabetical character") + return false + } + *name = s + return true +} + +// Scan the value of VERSION-DIRECTIVE. +// +// Scope: +// %YAML 1.1 # a comment \n +// ^^^^^^ +func yaml_parser_scan_version_directive_value(parser *yaml_parser_t, start_mark yaml_mark_t, major, minor *int8) bool { + // Eat whitespaces. + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + for is_blank(parser.buffer, parser.buffer_pos) { + skip(parser) + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + } + + // Consume the major version number. + if !yaml_parser_scan_version_directive_number(parser, start_mark, major) { + return false + } + + // Eat '.'. + if parser.buffer[parser.buffer_pos] != '.' { + return yaml_parser_set_scanner_error(parser, "while scanning a %YAML directive", + start_mark, "did not find expected digit or '.' character") + } + + skip(parser) + + // Consume the minor version number. + if !yaml_parser_scan_version_directive_number(parser, start_mark, minor) { + return false + } + return true +} + +const max_number_length = 2 + +// Scan the version number of VERSION-DIRECTIVE. +// +// Scope: +// %YAML 1.1 # a comment \n +// ^ +// %YAML 1.1 # a comment \n +// ^ +func yaml_parser_scan_version_directive_number(parser *yaml_parser_t, start_mark yaml_mark_t, number *int8) bool { + + // Repeat while the next character is digit. + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + var value, length int8 + for is_digit(parser.buffer, parser.buffer_pos) { + // Check if the number is too long. + length++ + if length > max_number_length { + return yaml_parser_set_scanner_error(parser, "while scanning a %YAML directive", + start_mark, "found extremely long version number") + } + value = value*10 + int8(as_digit(parser.buffer, parser.buffer_pos)) + skip(parser) + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + } + + // Check if the number was present. + if length == 0 { + return yaml_parser_set_scanner_error(parser, "while scanning a %YAML directive", + start_mark, "did not find expected version number") + } + *number = value + return true +} + +// Scan the value of a TAG-DIRECTIVE token. +// +// Scope: +// %TAG !yaml! tag:yaml.org,2002: \n +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +// +func yaml_parser_scan_tag_directive_value(parser *yaml_parser_t, start_mark yaml_mark_t, handle, prefix *[]byte) bool { + var handle_value, prefix_value []byte + + // Eat whitespaces. + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + + for is_blank(parser.buffer, parser.buffer_pos) { + skip(parser) + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + } + + // Scan a handle. + if !yaml_parser_scan_tag_handle(parser, true, start_mark, &handle_value) { + return false + } + + // Expect a whitespace. + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + if !is_blank(parser.buffer, parser.buffer_pos) { + yaml_parser_set_scanner_error(parser, "while scanning a %TAG directive", + start_mark, "did not find expected whitespace") + return false + } + + // Eat whitespaces. + for is_blank(parser.buffer, parser.buffer_pos) { + skip(parser) + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + } + + // Scan a prefix. + if !yaml_parser_scan_tag_uri(parser, true, nil, start_mark, &prefix_value) { + return false + } + + // Expect a whitespace or line break. + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + if !is_blankz(parser.buffer, parser.buffer_pos) { + yaml_parser_set_scanner_error(parser, "while scanning a %TAG directive", + start_mark, "did not find expected whitespace or line break") + return false + } + + *handle = handle_value + *prefix = prefix_value + return true +} + +func yaml_parser_scan_anchor(parser *yaml_parser_t, token *yaml_token_t, typ yaml_token_type_t) bool { + var s []byte + + // Eat the indicator character. + start_mark := parser.mark + skip(parser) + + // Consume the value. + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + + for is_alpha(parser.buffer, parser.buffer_pos) { + s = read(parser, s) + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + } + + end_mark := parser.mark + + /* + * Check if length of the anchor is greater than 0 and it is followed by + * a whitespace character or one of the indicators: + * + * '?', ':', ',', ']', '}', '%', '@', '`'. + */ + + if len(s) == 0 || + !(is_blankz(parser.buffer, parser.buffer_pos) || parser.buffer[parser.buffer_pos] == '?' || + parser.buffer[parser.buffer_pos] == ':' || parser.buffer[parser.buffer_pos] == ',' || + parser.buffer[parser.buffer_pos] == ']' || parser.buffer[parser.buffer_pos] == '}' || + parser.buffer[parser.buffer_pos] == '%' || parser.buffer[parser.buffer_pos] == '@' || + parser.buffer[parser.buffer_pos] == '`') { + context := "while scanning an alias" + if typ == yaml_ANCHOR_TOKEN { + context = "while scanning an anchor" + } + yaml_parser_set_scanner_error(parser, context, start_mark, + "did not find expected alphabetic or numeric character") + return false + } + + // Create a token. + *token = yaml_token_t{ + typ: typ, + start_mark: start_mark, + end_mark: end_mark, + value: s, + } + + return true +} + +/* + * Scan a TAG token. + */ + +func yaml_parser_scan_tag(parser *yaml_parser_t, token *yaml_token_t) bool { + var handle, suffix []byte + + start_mark := parser.mark + + // Check if the tag is in the canonical form. + if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) { + return false + } + + if parser.buffer[parser.buffer_pos+1] == '<' { + // Keep the handle as '' + + // Eat '!<' + skip(parser) + skip(parser) + + // Consume the tag value. + if !yaml_parser_scan_tag_uri(parser, false, nil, start_mark, &suffix) { + return false + } + + // Check for '>' and eat it. + if parser.buffer[parser.buffer_pos] != '>' { + yaml_parser_set_scanner_error(parser, "while scanning a tag", + start_mark, "did not find the expected '>'") + return false + } + + skip(parser) + } else { + // The tag has either the '!suffix' or the '!handle!suffix' form. + + // First, try to scan a handle. + if !yaml_parser_scan_tag_handle(parser, false, start_mark, &handle) { + return false + } + + // Check if it is, indeed, handle. + if handle[0] == '!' && len(handle) > 1 && handle[len(handle)-1] == '!' { + // Scan the suffix now. + if !yaml_parser_scan_tag_uri(parser, false, nil, start_mark, &suffix) { + return false + } + } else { + // It wasn't a handle after all. Scan the rest of the tag. + if !yaml_parser_scan_tag_uri(parser, false, handle, start_mark, &suffix) { + return false + } + + // Set the handle to '!'. + handle = []byte{'!'} + + // A special case: the '!' tag. Set the handle to '' and the + // suffix to '!'. + if len(suffix) == 0 { + handle, suffix = suffix, handle + } + } + } + + // Check the character which ends the tag. + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + if !is_blankz(parser.buffer, parser.buffer_pos) { + yaml_parser_set_scanner_error(parser, "while scanning a tag", + start_mark, "did not find expected whitespace or line break") + return false + } + + end_mark := parser.mark + + // Create a token. + *token = yaml_token_t{ + typ: yaml_TAG_TOKEN, + start_mark: start_mark, + end_mark: end_mark, + value: handle, + suffix: suffix, + } + return true +} + +// Scan a tag handle. +func yaml_parser_scan_tag_handle(parser *yaml_parser_t, directive bool, start_mark yaml_mark_t, handle *[]byte) bool { + // Check the initial '!' character. + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + if parser.buffer[parser.buffer_pos] != '!' { + yaml_parser_set_scanner_tag_error(parser, directive, + start_mark, "did not find expected '!'") + return false + } + + var s []byte + + // Copy the '!' character. + s = read(parser, s) + + // Copy all subsequent alphabetical and numerical characters. + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + for is_alpha(parser.buffer, parser.buffer_pos) { + s = read(parser, s) + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + } + + // Check if the trailing character is '!' and copy it. + if parser.buffer[parser.buffer_pos] == '!' { + s = read(parser, s) + } else { + // It's either the '!' tag or not really a tag handle. If it's a %TAG + // directive, it's an error. If it's a tag token, it must be a part of URI. + if directive && !(s[0] == '!' && s[1] == 0) { + yaml_parser_set_scanner_tag_error(parser, directive, + start_mark, "did not find expected '!'") + return false + } + } + + *handle = s + return true +} + +// Scan a tag. +func yaml_parser_scan_tag_uri(parser *yaml_parser_t, directive bool, head []byte, start_mark yaml_mark_t, uri *[]byte) bool { + //size_t length = head ? strlen((char *)head) : 0 + var s []byte + + // Copy the head if needed. + // + // Note that we don't copy the leading '!' character. + if len(head) > 1 { + s = append(s, head[1:]...) + } + + // Scan the tag. + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + + // The set of characters that may appear in URI is as follows: + // + // '0'-'9', 'A'-'Z', 'a'-'z', '_', '-', ';', '/', '?', ':', '@', '&', + // '=', '+', '$', ',', '.', '!', '~', '*', '\'', '(', ')', '[', ']', + // '%'. + // [Go] Convert this into more reasonable logic. + for is_alpha(parser.buffer, parser.buffer_pos) || parser.buffer[parser.buffer_pos] == ';' || + parser.buffer[parser.buffer_pos] == '/' || parser.buffer[parser.buffer_pos] == '?' || + parser.buffer[parser.buffer_pos] == ':' || parser.buffer[parser.buffer_pos] == '@' || + parser.buffer[parser.buffer_pos] == '&' || parser.buffer[parser.buffer_pos] == '=' || + parser.buffer[parser.buffer_pos] == '+' || parser.buffer[parser.buffer_pos] == '$' || + parser.buffer[parser.buffer_pos] == ',' || parser.buffer[parser.buffer_pos] == '.' || + parser.buffer[parser.buffer_pos] == '!' || parser.buffer[parser.buffer_pos] == '~' || + parser.buffer[parser.buffer_pos] == '*' || parser.buffer[parser.buffer_pos] == '\'' || + parser.buffer[parser.buffer_pos] == '(' || parser.buffer[parser.buffer_pos] == ')' || + parser.buffer[parser.buffer_pos] == '[' || parser.buffer[parser.buffer_pos] == ']' || + parser.buffer[parser.buffer_pos] == '%' { + // Check if it is a URI-escape sequence. + if parser.buffer[parser.buffer_pos] == '%' { + if !yaml_parser_scan_uri_escapes(parser, directive, start_mark, &s) { + return false + } + } else { + s = read(parser, s) + } + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + } + + // Check if the tag is non-empty. + if len(s) == 0 { + yaml_parser_set_scanner_tag_error(parser, directive, + start_mark, "did not find expected tag URI") + return false + } + *uri = s + return true +} + +// Decode an URI-escape sequence corresponding to a single UTF-8 character. +func yaml_parser_scan_uri_escapes(parser *yaml_parser_t, directive bool, start_mark yaml_mark_t, s *[]byte) bool { + + // Decode the required number of characters. + w := 1024 + for w > 0 { + // Check for a URI-escaped octet. + if parser.unread < 3 && !yaml_parser_update_buffer(parser, 3) { + return false + } + + if !(parser.buffer[parser.buffer_pos] == '%' && + is_hex(parser.buffer, parser.buffer_pos+1) && + is_hex(parser.buffer, parser.buffer_pos+2)) { + return yaml_parser_set_scanner_tag_error(parser, directive, + start_mark, "did not find URI escaped octet") + } + + // Get the octet. + octet := byte((as_hex(parser.buffer, parser.buffer_pos+1) << 4) + as_hex(parser.buffer, parser.buffer_pos+2)) + + // If it is the leading octet, determine the length of the UTF-8 sequence. + if w == 1024 { + w = width(octet) + if w == 0 { + return yaml_parser_set_scanner_tag_error(parser, directive, + start_mark, "found an incorrect leading UTF-8 octet") + } + } else { + // Check if the trailing octet is correct. + if octet&0xC0 != 0x80 { + return yaml_parser_set_scanner_tag_error(parser, directive, + start_mark, "found an incorrect trailing UTF-8 octet") + } + } + + // Copy the octet and move the pointers. + *s = append(*s, octet) + skip(parser) + skip(parser) + skip(parser) + w-- + } + return true +} + +// Scan a block scalar. +func yaml_parser_scan_block_scalar(parser *yaml_parser_t, token *yaml_token_t, literal bool) bool { + // Eat the indicator '|' or '>'. + start_mark := parser.mark + skip(parser) + + // Scan the additional block scalar indicators. + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + + // Check for a chomping indicator. + var chomping, increment int + if parser.buffer[parser.buffer_pos] == '+' || parser.buffer[parser.buffer_pos] == '-' { + // Set the chomping method and eat the indicator. + if parser.buffer[parser.buffer_pos] == '+' { + chomping = +1 + } else { + chomping = -1 + } + skip(parser) + + // Check for an indentation indicator. + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + if is_digit(parser.buffer, parser.buffer_pos) { + // Check that the indentation is greater than 0. + if parser.buffer[parser.buffer_pos] == '0' { + yaml_parser_set_scanner_error(parser, "while scanning a block scalar", + start_mark, "found an indentation indicator equal to 0") + return false + } + + // Get the indentation level and eat the indicator. + increment = as_digit(parser.buffer, parser.buffer_pos) + skip(parser) + } + + } else if is_digit(parser.buffer, parser.buffer_pos) { + // Do the same as above, but in the opposite order. + + if parser.buffer[parser.buffer_pos] == '0' { + yaml_parser_set_scanner_error(parser, "while scanning a block scalar", + start_mark, "found an indentation indicator equal to 0") + return false + } + increment = as_digit(parser.buffer, parser.buffer_pos) + skip(parser) + + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + if parser.buffer[parser.buffer_pos] == '+' || parser.buffer[parser.buffer_pos] == '-' { + if parser.buffer[parser.buffer_pos] == '+' { + chomping = +1 + } else { + chomping = -1 + } + skip(parser) + } + } + + // Eat whitespaces and comments to the end of the line. + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + for is_blank(parser.buffer, parser.buffer_pos) { + skip(parser) + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + } + if parser.buffer[parser.buffer_pos] == '#' { + for !is_breakz(parser.buffer, parser.buffer_pos) { + skip(parser) + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + } + } + + // Check if we are at the end of the line. + if !is_breakz(parser.buffer, parser.buffer_pos) { + yaml_parser_set_scanner_error(parser, "while scanning a block scalar", + start_mark, "did not find expected comment or line break") + return false + } + + // Eat a line break. + if is_break(parser.buffer, parser.buffer_pos) { + if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) { + return false + } + skip_line(parser) + } + + end_mark := parser.mark + + // Set the indentation level if it was specified. + var indent int + if increment > 0 { + if parser.indent >= 0 { + indent = parser.indent + increment + } else { + indent = increment + } + } + + // Scan the leading line breaks and determine the indentation level if needed. + var s, leading_break, trailing_breaks []byte + if !yaml_parser_scan_block_scalar_breaks(parser, &indent, &trailing_breaks, start_mark, &end_mark) { + return false + } + + // Scan the block scalar content. + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + var leading_blank, trailing_blank bool + for parser.mark.column == indent && !is_z(parser.buffer, parser.buffer_pos) { + // We are at the beginning of a non-empty line. + + // Is it a trailing whitespace? + trailing_blank = is_blank(parser.buffer, parser.buffer_pos) + + // Check if we need to fold the leading line break. + if !literal && !leading_blank && !trailing_blank && len(leading_break) > 0 && leading_break[0] == '\n' { + // Do we need to join the lines by space? + if len(trailing_breaks) == 0 { + s = append(s, ' ') + } + } else { + s = append(s, leading_break...) + } + leading_break = leading_break[:0] + + // Append the remaining line breaks. + s = append(s, trailing_breaks...) + trailing_breaks = trailing_breaks[:0] + + // Is it a leading whitespace? + leading_blank = is_blank(parser.buffer, parser.buffer_pos) + + // Consume the current line. + for !is_breakz(parser.buffer, parser.buffer_pos) { + s = read(parser, s) + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + } + + // Consume the line break. + if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) { + return false + } + + leading_break = read_line(parser, leading_break) + + // Eat the following indentation spaces and line breaks. + if !yaml_parser_scan_block_scalar_breaks(parser, &indent, &trailing_breaks, start_mark, &end_mark) { + return false + } + } + + // Chomp the tail. + if chomping != -1 { + s = append(s, leading_break...) + } + if chomping == 1 { + s = append(s, trailing_breaks...) + } + + // Create a token. + *token = yaml_token_t{ + typ: yaml_SCALAR_TOKEN, + start_mark: start_mark, + end_mark: end_mark, + value: s, + style: yaml_LITERAL_SCALAR_STYLE, + } + if !literal { + token.style = yaml_FOLDED_SCALAR_STYLE + } + return true +} + +// Scan indentation spaces and line breaks for a block scalar. Determine the +// indentation level if needed. +func yaml_parser_scan_block_scalar_breaks(parser *yaml_parser_t, indent *int, breaks *[]byte, start_mark yaml_mark_t, end_mark *yaml_mark_t) bool { + *end_mark = parser.mark + + // Eat the indentation spaces and line breaks. + max_indent := 0 + for { + // Eat the indentation spaces. + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + for (*indent == 0 || parser.mark.column < *indent) && is_space(parser.buffer, parser.buffer_pos) { + skip(parser) + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + } + if parser.mark.column > max_indent { + max_indent = parser.mark.column + } + + // Check for a tab character messing the indentation. + if (*indent == 0 || parser.mark.column < *indent) && is_tab(parser.buffer, parser.buffer_pos) { + return yaml_parser_set_scanner_error(parser, "while scanning a block scalar", + start_mark, "found a tab character where an indentation space is expected") + } + + // Have we found a non-empty line? + if !is_break(parser.buffer, parser.buffer_pos) { + break + } + + // Consume the line break. + if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) { + return false + } + // [Go] Should really be returning breaks instead. + *breaks = read_line(parser, *breaks) + *end_mark = parser.mark + } + + // Determine the indentation level if needed. + if *indent == 0 { + *indent = max_indent + if *indent < parser.indent+1 { + *indent = parser.indent + 1 + } + if *indent < 1 { + *indent = 1 + } + } + return true +} + +// Scan a quoted scalar. +func yaml_parser_scan_flow_scalar(parser *yaml_parser_t, token *yaml_token_t, single bool) bool { + // Eat the left quote. + start_mark := parser.mark + skip(parser) + + // Consume the content of the quoted scalar. + var s, leading_break, trailing_breaks, whitespaces []byte + for { + // Check that there are no document indicators at the beginning of the line. + if parser.unread < 4 && !yaml_parser_update_buffer(parser, 4) { + return false + } + + if parser.mark.column == 0 && + ((parser.buffer[parser.buffer_pos+0] == '-' && + parser.buffer[parser.buffer_pos+1] == '-' && + parser.buffer[parser.buffer_pos+2] == '-') || + (parser.buffer[parser.buffer_pos+0] == '.' && + parser.buffer[parser.buffer_pos+1] == '.' && + parser.buffer[parser.buffer_pos+2] == '.')) && + is_blankz(parser.buffer, parser.buffer_pos+3) { + yaml_parser_set_scanner_error(parser, "while scanning a quoted scalar", + start_mark, "found unexpected document indicator") + return false + } + + // Check for EOF. + if is_z(parser.buffer, parser.buffer_pos) { + yaml_parser_set_scanner_error(parser, "while scanning a quoted scalar", + start_mark, "found unexpected end of stream") + return false + } + + // Consume non-blank characters. + leading_blanks := false + for !is_blankz(parser.buffer, parser.buffer_pos) { + if single && parser.buffer[parser.buffer_pos] == '\'' && parser.buffer[parser.buffer_pos+1] == '\'' { + // Is is an escaped single quote. + s = append(s, '\'') + skip(parser) + skip(parser) + + } else if single && parser.buffer[parser.buffer_pos] == '\'' { + // It is a right single quote. + break + } else if !single && parser.buffer[parser.buffer_pos] == '"' { + // It is a right double quote. + break + + } else if !single && parser.buffer[parser.buffer_pos] == '\\' && is_break(parser.buffer, parser.buffer_pos+1) { + // It is an escaped line break. + if parser.unread < 3 && !yaml_parser_update_buffer(parser, 3) { + return false + } + skip(parser) + skip_line(parser) + leading_blanks = true + break + + } else if !single && parser.buffer[parser.buffer_pos] == '\\' { + // It is an escape sequence. + code_length := 0 + + // Check the escape character. + switch parser.buffer[parser.buffer_pos+1] { + case '0': + s = append(s, 0) + case 'a': + s = append(s, '\x07') + case 'b': + s = append(s, '\x08') + case 't', '\t': + s = append(s, '\x09') + case 'n': + s = append(s, '\x0A') + case 'v': + s = append(s, '\x0B') + case 'f': + s = append(s, '\x0C') + case 'r': + s = append(s, '\x0D') + case 'e': + s = append(s, '\x1B') + case ' ': + s = append(s, '\x20') + case '"': + s = append(s, '"') + case '\'': + s = append(s, '\'') + case '\\': + s = append(s, '\\') + case 'N': // NEL (#x85) + s = append(s, '\xC2') + s = append(s, '\x85') + case '_': // #xA0 + s = append(s, '\xC2') + s = append(s, '\xA0') + case 'L': // LS (#x2028) + s = append(s, '\xE2') + s = append(s, '\x80') + s = append(s, '\xA8') + case 'P': // PS (#x2029) + s = append(s, '\xE2') + s = append(s, '\x80') + s = append(s, '\xA9') + case 'x': + code_length = 2 + case 'u': + code_length = 4 + case 'U': + code_length = 8 + default: + yaml_parser_set_scanner_error(parser, "while parsing a quoted scalar", + start_mark, "found unknown escape character") + return false + } + + skip(parser) + skip(parser) + + // Consume an arbitrary escape code. + if code_length > 0 { + var value int + + // Scan the character value. + if parser.unread < code_length && !yaml_parser_update_buffer(parser, code_length) { + return false + } + for k := 0; k < code_length; k++ { + if !is_hex(parser.buffer, parser.buffer_pos+k) { + yaml_parser_set_scanner_error(parser, "while parsing a quoted scalar", + start_mark, "did not find expected hexdecimal number") + return false + } + value = (value << 4) + as_hex(parser.buffer, parser.buffer_pos+k) + } + + // Check the value and write the character. + if (value >= 0xD800 && value <= 0xDFFF) || value > 0x10FFFF { + yaml_parser_set_scanner_error(parser, "while parsing a quoted scalar", + start_mark, "found invalid Unicode character escape code") + return false + } + if value <= 0x7F { + s = append(s, byte(value)) + } else if value <= 0x7FF { + s = append(s, byte(0xC0+(value>>6))) + s = append(s, byte(0x80+(value&0x3F))) + } else if value <= 0xFFFF { + s = append(s, byte(0xE0+(value>>12))) + s = append(s, byte(0x80+((value>>6)&0x3F))) + s = append(s, byte(0x80+(value&0x3F))) + } else { + s = append(s, byte(0xF0+(value>>18))) + s = append(s, byte(0x80+((value>>12)&0x3F))) + s = append(s, byte(0x80+((value>>6)&0x3F))) + s = append(s, byte(0x80+(value&0x3F))) + } + + // Advance the pointer. + for k := 0; k < code_length; k++ { + skip(parser) + } + } + } else { + // It is a non-escaped non-blank character. + s = read(parser, s) + } + if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) { + return false + } + } + + // Check if we are at the end of the scalar. + if single { + if parser.buffer[parser.buffer_pos] == '\'' { + break + } + } else { + if parser.buffer[parser.buffer_pos] == '"' { + break + } + } + + // Consume blank characters. + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + + for is_blank(parser.buffer, parser.buffer_pos) || is_break(parser.buffer, parser.buffer_pos) { + if is_blank(parser.buffer, parser.buffer_pos) { + // Consume a space or a tab character. + if !leading_blanks { + whitespaces = read(parser, whitespaces) + } else { + skip(parser) + } + } else { + if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) { + return false + } + + // Check if it is a first line break. + if !leading_blanks { + whitespaces = whitespaces[:0] + leading_break = read_line(parser, leading_break) + leading_blanks = true + } else { + trailing_breaks = read_line(parser, trailing_breaks) + } + } + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + } + + // Join the whitespaces or fold line breaks. + if leading_blanks { + // Do we need to fold line breaks? + if len(leading_break) > 0 && leading_break[0] == '\n' { + if len(trailing_breaks) == 0 { + s = append(s, ' ') + } else { + s = append(s, trailing_breaks...) + } + } else { + s = append(s, leading_break...) + s = append(s, trailing_breaks...) + } + trailing_breaks = trailing_breaks[:0] + leading_break = leading_break[:0] + } else { + s = append(s, whitespaces...) + whitespaces = whitespaces[:0] + } + } + + // Eat the right quote. + skip(parser) + end_mark := parser.mark + + // Create a token. + *token = yaml_token_t{ + typ: yaml_SCALAR_TOKEN, + start_mark: start_mark, + end_mark: end_mark, + value: s, + style: yaml_SINGLE_QUOTED_SCALAR_STYLE, + } + if !single { + token.style = yaml_DOUBLE_QUOTED_SCALAR_STYLE + } + return true +} + +// Scan a plain scalar. +func yaml_parser_scan_plain_scalar(parser *yaml_parser_t, token *yaml_token_t) bool { + + var s, leading_break, trailing_breaks, whitespaces []byte + var leading_blanks bool + var indent = parser.indent + 1 + + start_mark := parser.mark + end_mark := parser.mark + + // Consume the content of the plain scalar. + for { + // Check for a document indicator. + if parser.unread < 4 && !yaml_parser_update_buffer(parser, 4) { + return false + } + if parser.mark.column == 0 && + ((parser.buffer[parser.buffer_pos+0] == '-' && + parser.buffer[parser.buffer_pos+1] == '-' && + parser.buffer[parser.buffer_pos+2] == '-') || + (parser.buffer[parser.buffer_pos+0] == '.' && + parser.buffer[parser.buffer_pos+1] == '.' && + parser.buffer[parser.buffer_pos+2] == '.')) && + is_blankz(parser.buffer, parser.buffer_pos+3) { + break + } + + // Check for a comment. + if parser.buffer[parser.buffer_pos] == '#' { + break + } + + // Consume non-blank characters. + for !is_blankz(parser.buffer, parser.buffer_pos) { + + // Check for 'x:x' in the flow context. TODO: Fix the test "spec-08-13". + if parser.flow_level > 0 && + parser.buffer[parser.buffer_pos] == ':' && + !is_blankz(parser.buffer, parser.buffer_pos+1) { + yaml_parser_set_scanner_error(parser, "while scanning a plain scalar", + start_mark, "found unexpected ':'") + return false + } + + // Check for indicators that may end a plain scalar. + if (parser.buffer[parser.buffer_pos] == ':' && is_blankz(parser.buffer, parser.buffer_pos+1)) || + (parser.flow_level > 0 && + (parser.buffer[parser.buffer_pos] == ',' || parser.buffer[parser.buffer_pos] == ':' || + parser.buffer[parser.buffer_pos] == '?' || parser.buffer[parser.buffer_pos] == '[' || + parser.buffer[parser.buffer_pos] == ']' || parser.buffer[parser.buffer_pos] == '{' || + parser.buffer[parser.buffer_pos] == '}')) { + break + } + + // Check if we need to join whitespaces and breaks. + if leading_blanks || len(whitespaces) > 0 { + if leading_blanks { + // Do we need to fold line breaks? + if leading_break[0] == '\n' { + if len(trailing_breaks) == 0 { + s = append(s, ' ') + } else { + s = append(s, trailing_breaks...) + } + } else { + s = append(s, leading_break...) + s = append(s, trailing_breaks...) + } + trailing_breaks = trailing_breaks[:0] + leading_break = leading_break[:0] + leading_blanks = false + } else { + s = append(s, whitespaces...) + whitespaces = whitespaces[:0] + } + } + + // Copy the character. + s = read(parser, s) + + end_mark = parser.mark + if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) { + return false + } + } + + // Is it the end? + if !(is_blank(parser.buffer, parser.buffer_pos) || is_break(parser.buffer, parser.buffer_pos)) { + break + } + + // Consume blank characters. + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + + for is_blank(parser.buffer, parser.buffer_pos) || is_break(parser.buffer, parser.buffer_pos) { + if is_blank(parser.buffer, parser.buffer_pos) { + + // Check for tab character that abuse indentation. + if leading_blanks && parser.mark.column < indent && is_tab(parser.buffer, parser.buffer_pos) { + yaml_parser_set_scanner_error(parser, "while scanning a plain scalar", + start_mark, "found a tab character that violate indentation") + return false + } + + // Consume a space or a tab character. + if !leading_blanks { + whitespaces = read(parser, whitespaces) + } else { + skip(parser) + } + } else { + if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) { + return false + } + + // Check if it is a first line break. + if !leading_blanks { + whitespaces = whitespaces[:0] + leading_break = read_line(parser, leading_break) + leading_blanks = true + } else { + trailing_breaks = read_line(parser, trailing_breaks) + } + } + if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { + return false + } + } + + // Check indentation level. + if parser.flow_level == 0 && parser.mark.column < indent { + break + } + } + + // Create a token. + *token = yaml_token_t{ + typ: yaml_SCALAR_TOKEN, + start_mark: start_mark, + end_mark: end_mark, + value: s, + style: yaml_PLAIN_SCALAR_STYLE, + } + + // Note that we change the 'simple_key_allowed' flag. + if leading_blanks { + parser.simple_key_allowed = true + } + return true +} diff --git a/Godeps/_workspace/src/gopkg.in/yaml.v2/sorter.go b/Godeps/_workspace/src/gopkg.in/yaml.v2/sorter.go new file mode 100644 index 000000000..5958822f9 --- /dev/null +++ b/Godeps/_workspace/src/gopkg.in/yaml.v2/sorter.go @@ -0,0 +1,104 @@ +package yaml + +import ( + "reflect" + "unicode" +) + +type keyList []reflect.Value + +func (l keyList) Len() int { return len(l) } +func (l keyList) Swap(i, j int) { l[i], l[j] = l[j], l[i] } +func (l keyList) Less(i, j int) bool { + a := l[i] + b := l[j] + ak := a.Kind() + bk := b.Kind() + for (ak == reflect.Interface || ak == reflect.Ptr) && !a.IsNil() { + a = a.Elem() + ak = a.Kind() + } + for (bk == reflect.Interface || bk == reflect.Ptr) && !b.IsNil() { + b = b.Elem() + bk = b.Kind() + } + af, aok := keyFloat(a) + bf, bok := keyFloat(b) + if aok && bok { + if af != bf { + return af < bf + } + if ak != bk { + return ak < bk + } + return numLess(a, b) + } + if ak != reflect.String || bk != reflect.String { + return ak < bk + } + ar, br := []rune(a.String()), []rune(b.String()) + for i := 0; i < len(ar) && i < len(br); i++ { + if ar[i] == br[i] { + continue + } + al := unicode.IsLetter(ar[i]) + bl := unicode.IsLetter(br[i]) + if al && bl { + return ar[i] < br[i] + } + if al || bl { + return bl + } + var ai, bi int + var an, bn int64 + for ai = i; ai < len(ar) && unicode.IsDigit(ar[ai]); ai++ { + an = an*10 + int64(ar[ai]-'0') + } + for bi = i; bi < len(br) && unicode.IsDigit(br[bi]); bi++ { + bn = bn*10 + int64(br[bi]-'0') + } + if an != bn { + return an < bn + } + if ai != bi { + return ai < bi + } + return ar[i] < br[i] + } + return len(ar) < len(br) +} + +// keyFloat returns a float value for v if it is a number/bool +// and whether it is a number/bool or not. +func keyFloat(v reflect.Value) (f float64, ok bool) { + switch v.Kind() { + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + return float64(v.Int()), true + case reflect.Float32, reflect.Float64: + return v.Float(), true + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: + return float64(v.Uint()), true + case reflect.Bool: + if v.Bool() { + return 1, true + } + return 0, true + } + return 0, false +} + +// numLess returns whether a < b. +// a and b must necessarily have the same kind. +func numLess(a, b reflect.Value) bool { + switch a.Kind() { + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + return a.Int() < b.Int() + case reflect.Float32, reflect.Float64: + return a.Float() < b.Float() + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: + return a.Uint() < b.Uint() + case reflect.Bool: + return !a.Bool() && b.Bool() + } + panic("not a number") +} diff --git a/Godeps/_workspace/src/gopkg.in/yaml.v2/writerc.go b/Godeps/_workspace/src/gopkg.in/yaml.v2/writerc.go new file mode 100644 index 000000000..190362f25 --- /dev/null +++ b/Godeps/_workspace/src/gopkg.in/yaml.v2/writerc.go @@ -0,0 +1,89 @@ +package yaml + +// Set the writer error and return false. +func yaml_emitter_set_writer_error(emitter *yaml_emitter_t, problem string) bool { + emitter.error = yaml_WRITER_ERROR + emitter.problem = problem + return false +} + +// Flush the output buffer. +func yaml_emitter_flush(emitter *yaml_emitter_t) bool { + if emitter.write_handler == nil { + panic("write handler not set") + } + + // Check if the buffer is empty. + if emitter.buffer_pos == 0 { + return true + } + + // If the output encoding is UTF-8, we don't need to recode the buffer. + if emitter.encoding == yaml_UTF8_ENCODING { + if err := emitter.write_handler(emitter, emitter.buffer[:emitter.buffer_pos]); err != nil { + return yaml_emitter_set_writer_error(emitter, "write error: "+err.Error()) + } + emitter.buffer_pos = 0 + return true + } + + // Recode the buffer into the raw buffer. + var low, high int + if emitter.encoding == yaml_UTF16LE_ENCODING { + low, high = 0, 1 + } else { + high, low = 1, 0 + } + + pos := 0 + for pos < emitter.buffer_pos { + // See the "reader.c" code for more details on UTF-8 encoding. Note + // that we assume that the buffer contains a valid UTF-8 sequence. + + // Read the next UTF-8 character. + octet := emitter.buffer[pos] + + var w int + var value rune + switch { + case octet&0x80 == 0x00: + w, value = 1, rune(octet&0x7F) + case octet&0xE0 == 0xC0: + w, value = 2, rune(octet&0x1F) + case octet&0xF0 == 0xE0: + w, value = 3, rune(octet&0x0F) + case octet&0xF8 == 0xF0: + w, value = 4, rune(octet&0x07) + } + for k := 1; k < w; k++ { + octet = emitter.buffer[pos+k] + value = (value << 6) + (rune(octet) & 0x3F) + } + pos += w + + // Write the character. + if value < 0x10000 { + var b [2]byte + b[high] = byte(value >> 8) + b[low] = byte(value & 0xFF) + emitter.raw_buffer = append(emitter.raw_buffer, b[0], b[1]) + } else { + // Write the character using a surrogate pair (check "reader.c"). + var b [4]byte + value -= 0x10000 + b[high] = byte(0xD8 + (value >> 18)) + b[low] = byte((value >> 10) & 0xFF) + b[high+2] = byte(0xDC + ((value >> 8) & 0xFF)) + b[low+2] = byte(value & 0xFF) + emitter.raw_buffer = append(emitter.raw_buffer, b[0], b[1], b[2], b[3]) + } + } + + // Write the raw buffer. + if err := emitter.write_handler(emitter, emitter.raw_buffer); err != nil { + return yaml_emitter_set_writer_error(emitter, "write error: "+err.Error()) + } + emitter.buffer_pos = 0 + emitter.raw_buffer = emitter.raw_buffer[:0] + return true +} diff --git a/Godeps/_workspace/src/gopkg.in/yaml.v2/yaml.go b/Godeps/_workspace/src/gopkg.in/yaml.v2/yaml.go new file mode 100644 index 000000000..d133edf9d --- /dev/null +++ b/Godeps/_workspace/src/gopkg.in/yaml.v2/yaml.go @@ -0,0 +1,346 @@ +// Package yaml implements YAML support for the Go language. +// +// Source code and other details for the project are available at GitHub: +// +// https://github.com/go-yaml/yaml +// +package yaml + +import ( + "errors" + "fmt" + "reflect" + "strings" + "sync" +) + +// MapSlice encodes and decodes as a YAML map. +// The order of keys is preserved when encoding and decoding. +type MapSlice []MapItem + +// MapItem is an item in a MapSlice. +type MapItem struct { + Key, Value interface{} +} + +// The Unmarshaler interface may be implemented by types to customize their +// behavior when being unmarshaled from a YAML document. The UnmarshalYAML +// method receives a function that may be called to unmarshal the original +// YAML value into a field or variable. It is safe to call the unmarshal +// function parameter more than once if necessary. +type Unmarshaler interface { + UnmarshalYAML(unmarshal func(interface{}) error) error +} + +// The Marshaler interface may be implemented by types to customize their +// behavior when being marshaled into a YAML document. The returned value +// is marshaled in place of the original value implementing Marshaler. +// +// If an error is returned by MarshalYAML, the marshaling procedure stops +// and returns with the provided error. +type Marshaler interface { + MarshalYAML() (interface{}, error) +} + +// Unmarshal decodes the first document found within the in byte slice +// and assigns decoded values into the out value. +// +// Maps and pointers (to a struct, string, int, etc) are accepted as out +// values. If an internal pointer within a struct is not initialized, +// the yaml package will initialize it if necessary for unmarshalling +// the provided data. The out parameter must not be nil. +// +// The type of the decoded values should be compatible with the respective +// values in out. If one or more values cannot be decoded due to a type +// mismatches, decoding continues partially until the end of the YAML +// content, and a *yaml.TypeError is returned with details for all +// missed values. +// +// Struct fields are only unmarshalled if they are exported (have an +// upper case first letter), and are unmarshalled using the field name +// lowercased as the default key. Custom keys may be defined via the +// "yaml" name in the field tag: the content preceding the first comma +// is used as the key, and the following comma-separated options are +// used to tweak the marshalling process (see Marshal). +// Conflicting names result in a runtime error. +// +// For example: +// +// type T struct { +// F int `yaml:"a,omitempty"` +// B int +// } +// var t T +// yaml.Unmarshal([]byte("a: 1\nb: 2"), &t) +// +// See the documentation of Marshal for the format of tags and a list of +// supported tag options. +// +func Unmarshal(in []byte, out interface{}) (err error) { + defer handleErr(&err) + d := newDecoder() + p := newParser(in) + defer p.destroy() + node := p.parse() + if node != nil { + v := reflect.ValueOf(out) + if v.Kind() == reflect.Ptr && !v.IsNil() { + v = v.Elem() + } + d.unmarshal(node, v) + } + if len(d.terrors) > 0 { + return &TypeError{d.terrors} + } + return nil +} + +// Marshal serializes the value provided into a YAML document. The structure +// of the generated document will reflect the structure of the value itself. +// Maps and pointers (to struct, string, int, etc) are accepted as the in value. +// +// Struct fields are only unmarshalled if they are exported (have an upper case +// first letter), and are unmarshalled using the field name lowercased as the +// default key. Custom keys may be defined via the "yaml" name in the field +// tag: the content preceding the first comma is used as the key, and the +// following comma-separated options are used to tweak the marshalling process. +// Conflicting names result in a runtime error. +// +// The field tag format accepted is: +// +// `(...) yaml:"[][,[,]]" (...)` +// +// The following flags are currently supported: +// +// omitempty Only include the field if it's not set to the zero +// value for the type or to empty slices or maps. +// Does not apply to zero valued structs. +// +// flow Marshal using a flow style (useful for structs, +// sequences and maps). +// +// inline Inline the field, which must be a struct or a map, +// causing all of its fields or keys to be processed as if +// they were part of the outer struct. For maps, keys must +// not conflict with the yaml keys of other struct fields. +// +// In addition, if the key is "-", the field is ignored. +// +// For example: +// +// type T struct { +// F int "a,omitempty" +// B int +// } +// yaml.Marshal(&T{B: 2}) // Returns "b: 2\n" +// yaml.Marshal(&T{F: 1}} // Returns "a: 1\nb: 0\n" +// +func Marshal(in interface{}) (out []byte, err error) { + defer handleErr(&err) + e := newEncoder() + defer e.destroy() + e.marshal("", reflect.ValueOf(in)) + e.finish() + out = e.out + return +} + +func handleErr(err *error) { + if v := recover(); v != nil { + if e, ok := v.(yamlError); ok { + *err = e.err + } else { + panic(v) + } + } +} + +type yamlError struct { + err error +} + +func fail(err error) { + panic(yamlError{err}) +} + +func failf(format string, args ...interface{}) { + panic(yamlError{fmt.Errorf("yaml: "+format, args...)}) +} + +// A TypeError is returned by Unmarshal when one or more fields in +// the YAML document cannot be properly decoded into the requested +// types. When this error is returned, the value is still +// unmarshaled partially. +type TypeError struct { + Errors []string +} + +func (e *TypeError) Error() string { + return fmt.Sprintf("yaml: unmarshal errors:\n %s", strings.Join(e.Errors, "\n ")) +} + +// -------------------------------------------------------------------------- +// Maintain a mapping of keys to structure field indexes + +// The code in this section was copied from mgo/bson. + +// structInfo holds details for the serialization of fields of +// a given struct. +type structInfo struct { + FieldsMap map[string]fieldInfo + FieldsList []fieldInfo + + // InlineMap is the number of the field in the struct that + // contains an ,inline map, or -1 if there's none. + InlineMap int +} + +type fieldInfo struct { + Key string + Num int + OmitEmpty bool + Flow bool + + // Inline holds the field index if the field is part of an inlined struct. + Inline []int +} + +var structMap = make(map[reflect.Type]*structInfo) +var fieldMapMutex sync.RWMutex + +func getStructInfo(st reflect.Type) (*structInfo, error) { + fieldMapMutex.RLock() + sinfo, found := structMap[st] + fieldMapMutex.RUnlock() + if found { + return sinfo, nil + } + + n := st.NumField() + fieldsMap := make(map[string]fieldInfo) + fieldsList := make([]fieldInfo, 0, n) + inlineMap := -1 + for i := 0; i != n; i++ { + field := st.Field(i) + if field.PkgPath != "" { + continue // Private field + } + + info := fieldInfo{Num: i} + + tag := field.Tag.Get("yaml") + if tag == "" && strings.Index(string(field.Tag), ":") < 0 { + tag = string(field.Tag) + } + if tag == "-" { + continue + } + + inline := false + fields := strings.Split(tag, ",") + if len(fields) > 1 { + for _, flag := range fields[1:] { + switch flag { + case "omitempty": + info.OmitEmpty = true + case "flow": + info.Flow = true + case "inline": + inline = true + default: + return nil, errors.New(fmt.Sprintf("Unsupported flag %q in tag %q of type %s", flag, tag, st)) + } + } + tag = fields[0] + } + + if inline { + switch field.Type.Kind() { + case reflect.Map: + if inlineMap >= 0 { + return nil, errors.New("Multiple ,inline maps in struct " + st.String()) + } + if field.Type.Key() != reflect.TypeOf("") { + return nil, errors.New("Option ,inline needs a map with string keys in struct " + st.String()) + } + inlineMap = info.Num + case reflect.Struct: + sinfo, err := getStructInfo(field.Type) + if err != nil { + return nil, err + } + for _, finfo := range sinfo.FieldsList { + if _, found := fieldsMap[finfo.Key]; found { + msg := "Duplicated key '" + finfo.Key + "' in struct " + st.String() + return nil, errors.New(msg) + } + if finfo.Inline == nil { + finfo.Inline = []int{i, finfo.Num} + } else { + finfo.Inline = append([]int{i}, finfo.Inline...) + } + fieldsMap[finfo.Key] = finfo + fieldsList = append(fieldsList, finfo) + } + default: + //return nil, errors.New("Option ,inline needs a struct value or map field") + return nil, errors.New("Option ,inline needs a struct value field") + } + continue + } + + if tag != "" { + info.Key = tag + } else { + info.Key = strings.ToLower(field.Name) + } + + if _, found = fieldsMap[info.Key]; found { + msg := "Duplicated key '" + info.Key + "' in struct " + st.String() + return nil, errors.New(msg) + } + + fieldsList = append(fieldsList, info) + fieldsMap[info.Key] = info + } + + sinfo = &structInfo{fieldsMap, fieldsList, inlineMap} + + fieldMapMutex.Lock() + structMap[st] = sinfo + fieldMapMutex.Unlock() + return sinfo, nil +} + +func isZero(v reflect.Value) bool { + switch v.Kind() { + case reflect.String: + return len(v.String()) == 0 + case reflect.Interface, reflect.Ptr: + return v.IsNil() + case reflect.Slice: + return v.Len() == 0 + case reflect.Map: + return v.Len() == 0 + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + return v.Int() == 0 + case reflect.Float32, reflect.Float64: + return v.Float() == 0 + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: + return v.Uint() == 0 + case reflect.Bool: + return !v.Bool() + case reflect.Struct: + vt := v.Type() + for i := v.NumField() - 1; i >= 0; i-- { + if vt.Field(i).PkgPath != "" { + continue // Private field + } + if !isZero(v.Field(i)) { + return false + } + } + return true + } + return false +} diff --git a/Godeps/_workspace/src/gopkg.in/yaml.v2/yamlh.go b/Godeps/_workspace/src/gopkg.in/yaml.v2/yamlh.go new file mode 100644 index 000000000..d60a6b6b0 --- /dev/null +++ b/Godeps/_workspace/src/gopkg.in/yaml.v2/yamlh.go @@ -0,0 +1,716 @@ +package yaml + +import ( + "io" +) + +// The version directive data. +type yaml_version_directive_t struct { + major int8 // The major version number. + minor int8 // The minor version number. +} + +// The tag directive data. +type yaml_tag_directive_t struct { + handle []byte // The tag handle. + prefix []byte // The tag prefix. +} + +type yaml_encoding_t int + +// The stream encoding. +const ( + // Let the parser choose the encoding. + yaml_ANY_ENCODING yaml_encoding_t = iota + + yaml_UTF8_ENCODING // The default UTF-8 encoding. + yaml_UTF16LE_ENCODING // The UTF-16-LE encoding with BOM. + yaml_UTF16BE_ENCODING // The UTF-16-BE encoding with BOM. +) + +type yaml_break_t int + +// Line break types. +const ( + // Let the parser choose the break type. + yaml_ANY_BREAK yaml_break_t = iota + + yaml_CR_BREAK // Use CR for line breaks (Mac style). + yaml_LN_BREAK // Use LN for line breaks (Unix style). + yaml_CRLN_BREAK // Use CR LN for line breaks (DOS style). +) + +type yaml_error_type_t int + +// Many bad things could happen with the parser and emitter. +const ( + // No error is produced. + yaml_NO_ERROR yaml_error_type_t = iota + + yaml_MEMORY_ERROR // Cannot allocate or reallocate a block of memory. + yaml_READER_ERROR // Cannot read or decode the input stream. + yaml_SCANNER_ERROR // Cannot scan the input stream. + yaml_PARSER_ERROR // Cannot parse the input stream. + yaml_COMPOSER_ERROR // Cannot compose a YAML document. + yaml_WRITER_ERROR // Cannot write to the output stream. + yaml_EMITTER_ERROR // Cannot emit a YAML stream. +) + +// The pointer position. +type yaml_mark_t struct { + index int // The position index. + line int // The position line. + column int // The position column. +} + +// Node Styles + +type yaml_style_t int8 + +type yaml_scalar_style_t yaml_style_t + +// Scalar styles. +const ( + // Let the emitter choose the style. + yaml_ANY_SCALAR_STYLE yaml_scalar_style_t = iota + + yaml_PLAIN_SCALAR_STYLE // The plain scalar style. + yaml_SINGLE_QUOTED_SCALAR_STYLE // The single-quoted scalar style. + yaml_DOUBLE_QUOTED_SCALAR_STYLE // The double-quoted scalar style. + yaml_LITERAL_SCALAR_STYLE // The literal scalar style. + yaml_FOLDED_SCALAR_STYLE // The folded scalar style. +) + +type yaml_sequence_style_t yaml_style_t + +// Sequence styles. +const ( + // Let the emitter choose the style. + yaml_ANY_SEQUENCE_STYLE yaml_sequence_style_t = iota + + yaml_BLOCK_SEQUENCE_STYLE // The block sequence style. + yaml_FLOW_SEQUENCE_STYLE // The flow sequence style. +) + +type yaml_mapping_style_t yaml_style_t + +// Mapping styles. +const ( + // Let the emitter choose the style. + yaml_ANY_MAPPING_STYLE yaml_mapping_style_t = iota + + yaml_BLOCK_MAPPING_STYLE // The block mapping style. + yaml_FLOW_MAPPING_STYLE // The flow mapping style. +) + +// Tokens + +type yaml_token_type_t int + +// Token types. +const ( + // An empty token. + yaml_NO_TOKEN yaml_token_type_t = iota + + yaml_STREAM_START_TOKEN // A STREAM-START token. + yaml_STREAM_END_TOKEN // A STREAM-END token. + + yaml_VERSION_DIRECTIVE_TOKEN // A VERSION-DIRECTIVE token. + yaml_TAG_DIRECTIVE_TOKEN // A TAG-DIRECTIVE token. + yaml_DOCUMENT_START_TOKEN // A DOCUMENT-START token. + yaml_DOCUMENT_END_TOKEN // A DOCUMENT-END token. + + yaml_BLOCK_SEQUENCE_START_TOKEN // A BLOCK-SEQUENCE-START token. + yaml_BLOCK_MAPPING_START_TOKEN // A BLOCK-SEQUENCE-END token. + yaml_BLOCK_END_TOKEN // A BLOCK-END token. + + yaml_FLOW_SEQUENCE_START_TOKEN // A FLOW-SEQUENCE-START token. + yaml_FLOW_SEQUENCE_END_TOKEN // A FLOW-SEQUENCE-END token. + yaml_FLOW_MAPPING_START_TOKEN // A FLOW-MAPPING-START token. + yaml_FLOW_MAPPING_END_TOKEN // A FLOW-MAPPING-END token. + + yaml_BLOCK_ENTRY_TOKEN // A BLOCK-ENTRY token. + yaml_FLOW_ENTRY_TOKEN // A FLOW-ENTRY token. + yaml_KEY_TOKEN // A KEY token. + yaml_VALUE_TOKEN // A VALUE token. + + yaml_ALIAS_TOKEN // An ALIAS token. + yaml_ANCHOR_TOKEN // An ANCHOR token. + yaml_TAG_TOKEN // A TAG token. + yaml_SCALAR_TOKEN // A SCALAR token. +) + +func (tt yaml_token_type_t) String() string { + switch tt { + case yaml_NO_TOKEN: + return "yaml_NO_TOKEN" + case yaml_STREAM_START_TOKEN: + return "yaml_STREAM_START_TOKEN" + case yaml_STREAM_END_TOKEN: + return "yaml_STREAM_END_TOKEN" + case yaml_VERSION_DIRECTIVE_TOKEN: + return "yaml_VERSION_DIRECTIVE_TOKEN" + case yaml_TAG_DIRECTIVE_TOKEN: + return "yaml_TAG_DIRECTIVE_TOKEN" + case yaml_DOCUMENT_START_TOKEN: + return "yaml_DOCUMENT_START_TOKEN" + case yaml_DOCUMENT_END_TOKEN: + return "yaml_DOCUMENT_END_TOKEN" + case yaml_BLOCK_SEQUENCE_START_TOKEN: + return "yaml_BLOCK_SEQUENCE_START_TOKEN" + case yaml_BLOCK_MAPPING_START_TOKEN: + return "yaml_BLOCK_MAPPING_START_TOKEN" + case yaml_BLOCK_END_TOKEN: + return "yaml_BLOCK_END_TOKEN" + case yaml_FLOW_SEQUENCE_START_TOKEN: + return "yaml_FLOW_SEQUENCE_START_TOKEN" + case yaml_FLOW_SEQUENCE_END_TOKEN: + return "yaml_FLOW_SEQUENCE_END_TOKEN" + case yaml_FLOW_MAPPING_START_TOKEN: + return "yaml_FLOW_MAPPING_START_TOKEN" + case yaml_FLOW_MAPPING_END_TOKEN: + return "yaml_FLOW_MAPPING_END_TOKEN" + case yaml_BLOCK_ENTRY_TOKEN: + return "yaml_BLOCK_ENTRY_TOKEN" + case yaml_FLOW_ENTRY_TOKEN: + return "yaml_FLOW_ENTRY_TOKEN" + case yaml_KEY_TOKEN: + return "yaml_KEY_TOKEN" + case yaml_VALUE_TOKEN: + return "yaml_VALUE_TOKEN" + case yaml_ALIAS_TOKEN: + return "yaml_ALIAS_TOKEN" + case yaml_ANCHOR_TOKEN: + return "yaml_ANCHOR_TOKEN" + case yaml_TAG_TOKEN: + return "yaml_TAG_TOKEN" + case yaml_SCALAR_TOKEN: + return "yaml_SCALAR_TOKEN" + } + return "" +} + +// The token structure. +type yaml_token_t struct { + // The token type. + typ yaml_token_type_t + + // The start/end of the token. + start_mark, end_mark yaml_mark_t + + // The stream encoding (for yaml_STREAM_START_TOKEN). + encoding yaml_encoding_t + + // The alias/anchor/scalar value or tag/tag directive handle + // (for yaml_ALIAS_TOKEN, yaml_ANCHOR_TOKEN, yaml_SCALAR_TOKEN, yaml_TAG_TOKEN, yaml_TAG_DIRECTIVE_TOKEN). + value []byte + + // The tag suffix (for yaml_TAG_TOKEN). + suffix []byte + + // The tag directive prefix (for yaml_TAG_DIRECTIVE_TOKEN). + prefix []byte + + // The scalar style (for yaml_SCALAR_TOKEN). + style yaml_scalar_style_t + + // The version directive major/minor (for yaml_VERSION_DIRECTIVE_TOKEN). + major, minor int8 +} + +// Events + +type yaml_event_type_t int8 + +// Event types. +const ( + // An empty event. + yaml_NO_EVENT yaml_event_type_t = iota + + yaml_STREAM_START_EVENT // A STREAM-START event. + yaml_STREAM_END_EVENT // A STREAM-END event. + yaml_DOCUMENT_START_EVENT // A DOCUMENT-START event. + yaml_DOCUMENT_END_EVENT // A DOCUMENT-END event. + yaml_ALIAS_EVENT // An ALIAS event. + yaml_SCALAR_EVENT // A SCALAR event. + yaml_SEQUENCE_START_EVENT // A SEQUENCE-START event. + yaml_SEQUENCE_END_EVENT // A SEQUENCE-END event. + yaml_MAPPING_START_EVENT // A MAPPING-START event. + yaml_MAPPING_END_EVENT // A MAPPING-END event. +) + +// The event structure. +type yaml_event_t struct { + + // The event type. + typ yaml_event_type_t + + // The start and end of the event. + start_mark, end_mark yaml_mark_t + + // The document encoding (for yaml_STREAM_START_EVENT). + encoding yaml_encoding_t + + // The version directive (for yaml_DOCUMENT_START_EVENT). + version_directive *yaml_version_directive_t + + // The list of tag directives (for yaml_DOCUMENT_START_EVENT). + tag_directives []yaml_tag_directive_t + + // The anchor (for yaml_SCALAR_EVENT, yaml_SEQUENCE_START_EVENT, yaml_MAPPING_START_EVENT, yaml_ALIAS_EVENT). + anchor []byte + + // The tag (for yaml_SCALAR_EVENT, yaml_SEQUENCE_START_EVENT, yaml_MAPPING_START_EVENT). + tag []byte + + // The scalar value (for yaml_SCALAR_EVENT). + value []byte + + // Is the document start/end indicator implicit, or the tag optional? + // (for yaml_DOCUMENT_START_EVENT, yaml_DOCUMENT_END_EVENT, yaml_SEQUENCE_START_EVENT, yaml_MAPPING_START_EVENT, yaml_SCALAR_EVENT). + implicit bool + + // Is the tag optional for any non-plain style? (for yaml_SCALAR_EVENT). + quoted_implicit bool + + // The style (for yaml_SCALAR_EVENT, yaml_SEQUENCE_START_EVENT, yaml_MAPPING_START_EVENT). + style yaml_style_t +} + +func (e *yaml_event_t) scalar_style() yaml_scalar_style_t { return yaml_scalar_style_t(e.style) } +func (e *yaml_event_t) sequence_style() yaml_sequence_style_t { return yaml_sequence_style_t(e.style) } +func (e *yaml_event_t) mapping_style() yaml_mapping_style_t { return yaml_mapping_style_t(e.style) } + +// Nodes + +const ( + yaml_NULL_TAG = "tag:yaml.org,2002:null" // The tag !!null with the only possible value: null. + yaml_BOOL_TAG = "tag:yaml.org,2002:bool" // The tag !!bool with the values: true and false. + yaml_STR_TAG = "tag:yaml.org,2002:str" // The tag !!str for string values. + yaml_INT_TAG = "tag:yaml.org,2002:int" // The tag !!int for integer values. + yaml_FLOAT_TAG = "tag:yaml.org,2002:float" // The tag !!float for float values. + yaml_TIMESTAMP_TAG = "tag:yaml.org,2002:timestamp" // The tag !!timestamp for date and time values. + + yaml_SEQ_TAG = "tag:yaml.org,2002:seq" // The tag !!seq is used to denote sequences. + yaml_MAP_TAG = "tag:yaml.org,2002:map" // The tag !!map is used to denote mapping. + + // Not in original libyaml. + yaml_BINARY_TAG = "tag:yaml.org,2002:binary" + yaml_MERGE_TAG = "tag:yaml.org,2002:merge" + + yaml_DEFAULT_SCALAR_TAG = yaml_STR_TAG // The default scalar tag is !!str. + yaml_DEFAULT_SEQUENCE_TAG = yaml_SEQ_TAG // The default sequence tag is !!seq. + yaml_DEFAULT_MAPPING_TAG = yaml_MAP_TAG // The default mapping tag is !!map. +) + +type yaml_node_type_t int + +// Node types. +const ( + // An empty node. + yaml_NO_NODE yaml_node_type_t = iota + + yaml_SCALAR_NODE // A scalar node. + yaml_SEQUENCE_NODE // A sequence node. + yaml_MAPPING_NODE // A mapping node. +) + +// An element of a sequence node. +type yaml_node_item_t int + +// An element of a mapping node. +type yaml_node_pair_t struct { + key int // The key of the element. + value int // The value of the element. +} + +// The node structure. +type yaml_node_t struct { + typ yaml_node_type_t // The node type. + tag []byte // The node tag. + + // The node data. + + // The scalar parameters (for yaml_SCALAR_NODE). + scalar struct { + value []byte // The scalar value. + length int // The length of the scalar value. + style yaml_scalar_style_t // The scalar style. + } + + // The sequence parameters (for YAML_SEQUENCE_NODE). + sequence struct { + items_data []yaml_node_item_t // The stack of sequence items. + style yaml_sequence_style_t // The sequence style. + } + + // The mapping parameters (for yaml_MAPPING_NODE). + mapping struct { + pairs_data []yaml_node_pair_t // The stack of mapping pairs (key, value). + pairs_start *yaml_node_pair_t // The beginning of the stack. + pairs_end *yaml_node_pair_t // The end of the stack. + pairs_top *yaml_node_pair_t // The top of the stack. + style yaml_mapping_style_t // The mapping style. + } + + start_mark yaml_mark_t // The beginning of the node. + end_mark yaml_mark_t // The end of the node. + +} + +// The document structure. +type yaml_document_t struct { + + // The document nodes. + nodes []yaml_node_t + + // The version directive. + version_directive *yaml_version_directive_t + + // The list of tag directives. + tag_directives_data []yaml_tag_directive_t + tag_directives_start int // The beginning of the tag directives list. + tag_directives_end int // The end of the tag directives list. + + start_implicit int // Is the document start indicator implicit? + end_implicit int // Is the document end indicator implicit? + + // The start/end of the document. + start_mark, end_mark yaml_mark_t +} + +// The prototype of a read handler. +// +// The read handler is called when the parser needs to read more bytes from the +// source. The handler should write not more than size bytes to the buffer. +// The number of written bytes should be set to the size_read variable. +// +// [in,out] data A pointer to an application data specified by +// yaml_parser_set_input(). +// [out] buffer The buffer to write the data from the source. +// [in] size The size of the buffer. +// [out] size_read The actual number of bytes read from the source. +// +// On success, the handler should return 1. If the handler failed, +// the returned value should be 0. On EOF, the handler should set the +// size_read to 0 and return 1. +type yaml_read_handler_t func(parser *yaml_parser_t, buffer []byte) (n int, err error) + +// This structure holds information about a potential simple key. +type yaml_simple_key_t struct { + possible bool // Is a simple key possible? + required bool // Is a simple key required? + token_number int // The number of the token. + mark yaml_mark_t // The position mark. +} + +// The states of the parser. +type yaml_parser_state_t int + +const ( + yaml_PARSE_STREAM_START_STATE yaml_parser_state_t = iota + + yaml_PARSE_IMPLICIT_DOCUMENT_START_STATE // Expect the beginning of an implicit document. + yaml_PARSE_DOCUMENT_START_STATE // Expect DOCUMENT-START. + yaml_PARSE_DOCUMENT_CONTENT_STATE // Expect the content of a document. + yaml_PARSE_DOCUMENT_END_STATE // Expect DOCUMENT-END. + yaml_PARSE_BLOCK_NODE_STATE // Expect a block node. + yaml_PARSE_BLOCK_NODE_OR_INDENTLESS_SEQUENCE_STATE // Expect a block node or indentless sequence. + yaml_PARSE_FLOW_NODE_STATE // Expect a flow node. + yaml_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE // Expect the first entry of a block sequence. + yaml_PARSE_BLOCK_SEQUENCE_ENTRY_STATE // Expect an entry of a block sequence. + yaml_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE // Expect an entry of an indentless sequence. + yaml_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE // Expect the first key of a block mapping. + yaml_PARSE_BLOCK_MAPPING_KEY_STATE // Expect a block mapping key. + yaml_PARSE_BLOCK_MAPPING_VALUE_STATE // Expect a block mapping value. + yaml_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE // Expect the first entry of a flow sequence. + yaml_PARSE_FLOW_SEQUENCE_ENTRY_STATE // Expect an entry of a flow sequence. + yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE // Expect a key of an ordered mapping. + yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE // Expect a value of an ordered mapping. + yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE // Expect the and of an ordered mapping entry. + yaml_PARSE_FLOW_MAPPING_FIRST_KEY_STATE // Expect the first key of a flow mapping. + yaml_PARSE_FLOW_MAPPING_KEY_STATE // Expect a key of a flow mapping. + yaml_PARSE_FLOW_MAPPING_VALUE_STATE // Expect a value of a flow mapping. + yaml_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE // Expect an empty value of a flow mapping. + yaml_PARSE_END_STATE // Expect nothing. +) + +func (ps yaml_parser_state_t) String() string { + switch ps { + case yaml_PARSE_STREAM_START_STATE: + return "yaml_PARSE_STREAM_START_STATE" + case yaml_PARSE_IMPLICIT_DOCUMENT_START_STATE: + return "yaml_PARSE_IMPLICIT_DOCUMENT_START_STATE" + case yaml_PARSE_DOCUMENT_START_STATE: + return "yaml_PARSE_DOCUMENT_START_STATE" + case yaml_PARSE_DOCUMENT_CONTENT_STATE: + return "yaml_PARSE_DOCUMENT_CONTENT_STATE" + case yaml_PARSE_DOCUMENT_END_STATE: + return "yaml_PARSE_DOCUMENT_END_STATE" + case yaml_PARSE_BLOCK_NODE_STATE: + return "yaml_PARSE_BLOCK_NODE_STATE" + case yaml_PARSE_BLOCK_NODE_OR_INDENTLESS_SEQUENCE_STATE: + return "yaml_PARSE_BLOCK_NODE_OR_INDENTLESS_SEQUENCE_STATE" + case yaml_PARSE_FLOW_NODE_STATE: + return "yaml_PARSE_FLOW_NODE_STATE" + case yaml_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE: + return "yaml_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE" + case yaml_PARSE_BLOCK_SEQUENCE_ENTRY_STATE: + return "yaml_PARSE_BLOCK_SEQUENCE_ENTRY_STATE" + case yaml_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE: + return "yaml_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE" + case yaml_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE: + return "yaml_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE" + case yaml_PARSE_BLOCK_MAPPING_KEY_STATE: + return "yaml_PARSE_BLOCK_MAPPING_KEY_STATE" + case yaml_PARSE_BLOCK_MAPPING_VALUE_STATE: + return "yaml_PARSE_BLOCK_MAPPING_VALUE_STATE" + case yaml_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE: + return "yaml_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE" + case yaml_PARSE_FLOW_SEQUENCE_ENTRY_STATE: + return "yaml_PARSE_FLOW_SEQUENCE_ENTRY_STATE" + case yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE: + return "yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE" + case yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE: + return "yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE" + case yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE: + return "yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE" + case yaml_PARSE_FLOW_MAPPING_FIRST_KEY_STATE: + return "yaml_PARSE_FLOW_MAPPING_FIRST_KEY_STATE" + case yaml_PARSE_FLOW_MAPPING_KEY_STATE: + return "yaml_PARSE_FLOW_MAPPING_KEY_STATE" + case yaml_PARSE_FLOW_MAPPING_VALUE_STATE: + return "yaml_PARSE_FLOW_MAPPING_VALUE_STATE" + case yaml_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE: + return "yaml_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE" + case yaml_PARSE_END_STATE: + return "yaml_PARSE_END_STATE" + } + return "" +} + +// This structure holds aliases data. +type yaml_alias_data_t struct { + anchor []byte // The anchor. + index int // The node id. + mark yaml_mark_t // The anchor mark. +} + +// The parser structure. +// +// All members are internal. Manage the structure using the +// yaml_parser_ family of functions. +type yaml_parser_t struct { + + // Error handling + + error yaml_error_type_t // Error type. + + problem string // Error description. + + // The byte about which the problem occured. + problem_offset int + problem_value int + problem_mark yaml_mark_t + + // The error context. + context string + context_mark yaml_mark_t + + // Reader stuff + + read_handler yaml_read_handler_t // Read handler. + + input_file io.Reader // File input data. + input []byte // String input data. + input_pos int + + eof bool // EOF flag + + buffer []byte // The working buffer. + buffer_pos int // The current position of the buffer. + + unread int // The number of unread characters in the buffer. + + raw_buffer []byte // The raw buffer. + raw_buffer_pos int // The current position of the buffer. + + encoding yaml_encoding_t // The input encoding. + + offset int // The offset of the current position (in bytes). + mark yaml_mark_t // The mark of the current position. + + // Scanner stuff + + stream_start_produced bool // Have we started to scan the input stream? + stream_end_produced bool // Have we reached the end of the input stream? + + flow_level int // The number of unclosed '[' and '{' indicators. + + tokens []yaml_token_t // The tokens queue. + tokens_head int // The head of the tokens queue. + tokens_parsed int // The number of tokens fetched from the queue. + token_available bool // Does the tokens queue contain a token ready for dequeueing. + + indent int // The current indentation level. + indents []int // The indentation levels stack. + + simple_key_allowed bool // May a simple key occur at the current position? + simple_keys []yaml_simple_key_t // The stack of simple keys. + + // Parser stuff + + state yaml_parser_state_t // The current parser state. + states []yaml_parser_state_t // The parser states stack. + marks []yaml_mark_t // The stack of marks. + tag_directives []yaml_tag_directive_t // The list of TAG directives. + + // Dumper stuff + + aliases []yaml_alias_data_t // The alias data. + + document *yaml_document_t // The currently parsed document. +} + +// Emitter Definitions + +// The prototype of a write handler. +// +// The write handler is called when the emitter needs to flush the accumulated +// characters to the output. The handler should write @a size bytes of the +// @a buffer to the output. +// +// @param[in,out] data A pointer to an application data specified by +// yaml_emitter_set_output(). +// @param[in] buffer The buffer with bytes to be written. +// @param[in] size The size of the buffer. +// +// @returns On success, the handler should return @c 1. If the handler failed, +// the returned value should be @c 0. +// +type yaml_write_handler_t func(emitter *yaml_emitter_t, buffer []byte) error + +type yaml_emitter_state_t int + +// The emitter states. +const ( + // Expect STREAM-START. + yaml_EMIT_STREAM_START_STATE yaml_emitter_state_t = iota + + yaml_EMIT_FIRST_DOCUMENT_START_STATE // Expect the first DOCUMENT-START or STREAM-END. + yaml_EMIT_DOCUMENT_START_STATE // Expect DOCUMENT-START or STREAM-END. + yaml_EMIT_DOCUMENT_CONTENT_STATE // Expect the content of a document. + yaml_EMIT_DOCUMENT_END_STATE // Expect DOCUMENT-END. + yaml_EMIT_FLOW_SEQUENCE_FIRST_ITEM_STATE // Expect the first item of a flow sequence. + yaml_EMIT_FLOW_SEQUENCE_ITEM_STATE // Expect an item of a flow sequence. + yaml_EMIT_FLOW_MAPPING_FIRST_KEY_STATE // Expect the first key of a flow mapping. + yaml_EMIT_FLOW_MAPPING_KEY_STATE // Expect a key of a flow mapping. + yaml_EMIT_FLOW_MAPPING_SIMPLE_VALUE_STATE // Expect a value for a simple key of a flow mapping. + yaml_EMIT_FLOW_MAPPING_VALUE_STATE // Expect a value of a flow mapping. + yaml_EMIT_BLOCK_SEQUENCE_FIRST_ITEM_STATE // Expect the first item of a block sequence. + yaml_EMIT_BLOCK_SEQUENCE_ITEM_STATE // Expect an item of a block sequence. + yaml_EMIT_BLOCK_MAPPING_FIRST_KEY_STATE // Expect the first key of a block mapping. + yaml_EMIT_BLOCK_MAPPING_KEY_STATE // Expect the key of a block mapping. + yaml_EMIT_BLOCK_MAPPING_SIMPLE_VALUE_STATE // Expect a value for a simple key of a block mapping. + yaml_EMIT_BLOCK_MAPPING_VALUE_STATE // Expect a value of a block mapping. + yaml_EMIT_END_STATE // Expect nothing. +) + +// The emitter structure. +// +// All members are internal. Manage the structure using the @c yaml_emitter_ +// family of functions. +type yaml_emitter_t struct { + + // Error handling + + error yaml_error_type_t // Error type. + problem string // Error description. + + // Writer stuff + + write_handler yaml_write_handler_t // Write handler. + + output_buffer *[]byte // String output data. + output_file io.Writer // File output data. + + buffer []byte // The working buffer. + buffer_pos int // The current position of the buffer. + + raw_buffer []byte // The raw buffer. + raw_buffer_pos int // The current position of the buffer. + + encoding yaml_encoding_t // The stream encoding. + + // Emitter stuff + + canonical bool // If the output is in the canonical style? + best_indent int // The number of indentation spaces. + best_width int // The preferred width of the output lines. + unicode bool // Allow unescaped non-ASCII characters? + line_break yaml_break_t // The preferred line break. + + state yaml_emitter_state_t // The current emitter state. + states []yaml_emitter_state_t // The stack of states. + + events []yaml_event_t // The event queue. + events_head int // The head of the event queue. + + indents []int // The stack of indentation levels. + + tag_directives []yaml_tag_directive_t // The list of tag directives. + + indent int // The current indentation level. + + flow_level int // The current flow level. + + root_context bool // Is it the document root context? + sequence_context bool // Is it a sequence context? + mapping_context bool // Is it a mapping context? + simple_key_context bool // Is it a simple mapping key context? + + line int // The current line. + column int // The current column. + whitespace bool // If the last character was a whitespace? + indention bool // If the last character was an indentation character (' ', '-', '?', ':')? + open_ended bool // If an explicit document end is required? + + // Anchor analysis. + anchor_data struct { + anchor []byte // The anchor value. + alias bool // Is it an alias? + } + + // Tag analysis. + tag_data struct { + handle []byte // The tag handle. + suffix []byte // The tag suffix. + } + + // Scalar analysis. + scalar_data struct { + value []byte // The scalar value. + multiline bool // Does the scalar contain line breaks? + flow_plain_allowed bool // Can the scalar be expessed in the flow plain style? + block_plain_allowed bool // Can the scalar be expressed in the block plain style? + single_quoted_allowed bool // Can the scalar be expressed in the single quoted style? + block_allowed bool // Can the scalar be expressed in the literal or folded styles? + style yaml_scalar_style_t // The output style. + } + + // Dumper stuff + + opened bool // If the stream was already opened? + closed bool // If the stream was already closed? + + // The information associated with the document nodes. + anchors *struct { + references int // The number of references. + anchor int // The anchor id. + serialized bool // If the node has been emitted? + } + + last_anchor_id int // The last assigned anchor id. + + document *yaml_document_t // The currently emitted document. +} diff --git a/Godeps/_workspace/src/gopkg.in/yaml.v2/yamlprivateh.go b/Godeps/_workspace/src/gopkg.in/yaml.v2/yamlprivateh.go new file mode 100644 index 000000000..8110ce3c3 --- /dev/null +++ b/Godeps/_workspace/src/gopkg.in/yaml.v2/yamlprivateh.go @@ -0,0 +1,173 @@ +package yaml + +const ( + // The size of the input raw buffer. + input_raw_buffer_size = 512 + + // The size of the input buffer. + // It should be possible to decode the whole raw buffer. + input_buffer_size = input_raw_buffer_size * 3 + + // The size of the output buffer. + output_buffer_size = 128 + + // The size of the output raw buffer. + // It should be possible to encode the whole output buffer. + output_raw_buffer_size = (output_buffer_size*2 + 2) + + // The size of other stacks and queues. + initial_stack_size = 16 + initial_queue_size = 16 + initial_string_size = 16 +) + +// Check if the character at the specified position is an alphabetical +// character, a digit, '_', or '-'. +func is_alpha(b []byte, i int) bool { + return b[i] >= '0' && b[i] <= '9' || b[i] >= 'A' && b[i] <= 'Z' || b[i] >= 'a' && b[i] <= 'z' || b[i] == '_' || b[i] == '-' +} + +// Check if the character at the specified position is a digit. +func is_digit(b []byte, i int) bool { + return b[i] >= '0' && b[i] <= '9' +} + +// Get the value of a digit. +func as_digit(b []byte, i int) int { + return int(b[i]) - '0' +} + +// Check if the character at the specified position is a hex-digit. +func is_hex(b []byte, i int) bool { + return b[i] >= '0' && b[i] <= '9' || b[i] >= 'A' && b[i] <= 'F' || b[i] >= 'a' && b[i] <= 'f' +} + +// Get the value of a hex-digit. +func as_hex(b []byte, i int) int { + bi := b[i] + if bi >= 'A' && bi <= 'F' { + return int(bi) - 'A' + 10 + } + if bi >= 'a' && bi <= 'f' { + return int(bi) - 'a' + 10 + } + return int(bi) - '0' +} + +// Check if the character is ASCII. +func is_ascii(b []byte, i int) bool { + return b[i] <= 0x7F +} + +// Check if the character at the start of the buffer can be printed unescaped. +func is_printable(b []byte, i int) bool { + return ((b[i] == 0x0A) || // . == #x0A + (b[i] >= 0x20 && b[i] <= 0x7E) || // #x20 <= . <= #x7E + (b[i] == 0xC2 && b[i+1] >= 0xA0) || // #0xA0 <= . <= #xD7FF + (b[i] > 0xC2 && b[i] < 0xED) || + (b[i] == 0xED && b[i+1] < 0xA0) || + (b[i] == 0xEE) || + (b[i] == 0xEF && // #xE000 <= . <= #xFFFD + !(b[i+1] == 0xBB && b[i+2] == 0xBF) && // && . != #xFEFF + !(b[i+1] == 0xBF && (b[i+2] == 0xBE || b[i+2] == 0xBF)))) +} + +// Check if the character at the specified position is NUL. +func is_z(b []byte, i int) bool { + return b[i] == 0x00 +} + +// Check if the beginning of the buffer is a BOM. +func is_bom(b []byte, i int) bool { + return b[0] == 0xEF && b[1] == 0xBB && b[2] == 0xBF +} + +// Check if the character at the specified position is space. +func is_space(b []byte, i int) bool { + return b[i] == ' ' +} + +// Check if the character at the specified position is tab. +func is_tab(b []byte, i int) bool { + return b[i] == '\t' +} + +// Check if the character at the specified position is blank (space or tab). +func is_blank(b []byte, i int) bool { + //return is_space(b, i) || is_tab(b, i) + return b[i] == ' ' || b[i] == '\t' +} + +// Check if the character at the specified position is a line break. +func is_break(b []byte, i int) bool { + return (b[i] == '\r' || // CR (#xD) + b[i] == '\n' || // LF (#xA) + b[i] == 0xC2 && b[i+1] == 0x85 || // NEL (#x85) + b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA8 || // LS (#x2028) + b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA9) // PS (#x2029) +} + +func is_crlf(b []byte, i int) bool { + return b[i] == '\r' && b[i+1] == '\n' +} + +// Check if the character is a line break or NUL. +func is_breakz(b []byte, i int) bool { + //return is_break(b, i) || is_z(b, i) + return ( // is_break: + b[i] == '\r' || // CR (#xD) + b[i] == '\n' || // LF (#xA) + b[i] == 0xC2 && b[i+1] == 0x85 || // NEL (#x85) + b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA8 || // LS (#x2028) + b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA9 || // PS (#x2029) + // is_z: + b[i] == 0) +} + +// Check if the character is a line break, space, or NUL. +func is_spacez(b []byte, i int) bool { + //return is_space(b, i) || is_breakz(b, i) + return ( // is_space: + b[i] == ' ' || + // is_breakz: + b[i] == '\r' || // CR (#xD) + b[i] == '\n' || // LF (#xA) + b[i] == 0xC2 && b[i+1] == 0x85 || // NEL (#x85) + b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA8 || // LS (#x2028) + b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA9 || // PS (#x2029) + b[i] == 0) +} + +// Check if the character is a line break, space, tab, or NUL. +func is_blankz(b []byte, i int) bool { + //return is_blank(b, i) || is_breakz(b, i) + return ( // is_blank: + b[i] == ' ' || b[i] == '\t' || + // is_breakz: + b[i] == '\r' || // CR (#xD) + b[i] == '\n' || // LF (#xA) + b[i] == 0xC2 && b[i+1] == 0x85 || // NEL (#x85) + b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA8 || // LS (#x2028) + b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA9 || // PS (#x2029) + b[i] == 0) +} + +// Determine the width of the character. +func width(b byte) int { + // Don't replace these by a switch without first + // confirming that it is being inlined. + if b&0x80 == 0x00 { + return 1 + } + if b&0xE0 == 0xC0 { + return 2 + } + if b&0xF0 == 0xE0 { + return 3 + } + if b&0xF8 == 0xF0 { + return 4 + } + return 0 + +} diff --git a/Makefile b/Makefile index ac3526ac9..b64a9696c 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,7 @@ dev: generate # test runs the unit tests and vets the code test: generate - TF_ACC= godep go test $(TEST) $(TESTARGS) -timeout=30s -parallel=4 + TF_ACC= godep go test $(TEST) $(TESTARGS) -timeout=60s -parallel=4 # testacc runs acceptance tests testacc: generate @@ -31,7 +31,7 @@ testacc: generate # testrace runs the race checker testrace: generate - TF_ACC= godep go test -race $(TEST) $(TESTARGS) + CGO_ENABLED=1 TF_ACC= godep go test -race $(TEST) $(TESTARGS) cover: ./scripts/coverage.sh --html diff --git a/README.md b/README.md index 76a977ddd..7f531128d 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ Developing Vault If you wish to work on Vault itself or any of its built-in systems, you'll first need [Go](https://www.golang.org) installed on your -machine (version 1.4+ is *required*). +machine (version 1.5+ is *required*). For local dev first make sure Go is properly installed, including setting up a [GOPATH](https://golang.org/doc/code.html#GOPATH). After setting up Go, you can diff --git a/api/SPEC.md b/api/SPEC.md index e73683e5b..15345f390 100644 --- a/api/SPEC.md +++ b/api/SPEC.md @@ -87,7 +87,7 @@ The following HTTP status codes are used throughout the API. - `200` - Success with data. - `204` - Success, no data returned. - `400` - Invalid request, missing or invalid data. -- `401` - Unauthorized, your authentication details are either +- `403` - Forbidden, your authentication details are either incorrect or you don't have access to this feature. - `404` - Invalid path. This can both mean that the path truly doesn't exist or that you don't have permission to view a diff --git a/api/auth_token.go b/api/auth_token.go index 791e81450..78dc98aac 100644 --- a/api/auth_token.go +++ b/api/auth_token.go @@ -26,7 +26,7 @@ func (c *TokenAuth) Create(opts *TokenCreateRequest) (*Secret, error) { } func (c *TokenAuth) LookupSelf() (*Secret, error) { - r := c.c.NewRequest("POST", "/v1/auth/token/lookup-self") + r := c.c.NewRequest("GET", "/v1/auth/token/lookup-self") resp, err := c.c.RawRequest(r) if err != nil { diff --git a/api/auth_token_test.go b/api/auth_token_test.go index 2511ad201..f2544a632 100644 --- a/api/auth_token_test.go +++ b/api/auth_token_test.go @@ -34,6 +34,35 @@ func TestAuthTokenCreate(t *testing.T) { } } +func TestAuthTokenLookupSelf(t *testing.T) { + core, _, token := vault.TestCoreUnsealed(t) + ln, addr := http.TestServer(t, core) + defer ln.Close() + + config := DefaultConfig() + config.Address = addr + + client, err := NewClient(config) + if err != nil { + t.Fatal(err) + } + client.SetToken(token) + + // you should be able to lookup your own token + secret, err := client.Auth().Token().LookupSelf() + if err != nil { + t.Fatalf("should be allowed to lookup self, err = %v", err) + } + + if secret.Data["id"] != token { + t.Errorf("Did not get back details about our own (self) token, id returned=%s", secret.Data["id"]) + } + if secret.Data["display_name"] != "root" { + t.Errorf("Did not get back details about our own (self) token, display_name returned=%s", secret.Data["display_name"]) + } + +} + func TestAuthTokenRenew(t *testing.T) { core, _, token := vault.TestCoreUnsealed(t) ln, addr := http.TestServer(t, core) diff --git a/api/ssh_agent.go b/api/ssh_agent.go index 9d24043d5..57306a647 100644 --- a/api/ssh_agent.go +++ b/api/ssh_agent.go @@ -5,11 +5,9 @@ import ( "crypto/x509" "fmt" "io/ioutil" - "net" - "net/http" "os" - "time" + "github.com/hashicorp/go-cleanhttp" "github.com/hashicorp/hcl" "github.com/mitchellh/mapstructure" ) @@ -66,15 +64,9 @@ func (c *SSHAgentConfig) SetTLSParameters(clientConfig *Config, certPool *x509.C RootCAs: certPool, } - clientConfig.HttpClient.Transport = &http.Transport{ - Proxy: http.ProxyFromEnvironment, - Dial: (&net.Dialer{ - Timeout: 30 * time.Second, - KeepAlive: 30 * time.Second, - }).Dial, - TLSClientConfig: tlsConfig, - TLSHandshakeTimeout: 10 * time.Second, - } + transport := cleanhttp.DefaultTransport() + transport.TLSClientConfig = tlsConfig + clientConfig.HttpClient.Transport = transport } // NewClient returns a new client for the configuration. This client will be used by the diff --git a/builtin/logical/aws/backend_test.go b/builtin/logical/aws/backend_test.go index 29a5379c0..71b719bac 100644 --- a/builtin/logical/aws/backend_test.go +++ b/builtin/logical/aws/backend_test.go @@ -19,10 +19,15 @@ import ( "github.com/mitchellh/mapstructure" ) +func getBackend(t *testing.T) logical.Backend { + be, _ := Factory(logical.TestBackendConfig()) + return be +} + func TestBackend_basic(t *testing.T) { logicaltest.Test(t, logicaltest.TestCase{ PreCheck: func() { testAccPreCheck(t) }, - Backend: Backend(), + Backend: getBackend(t), Steps: []logicaltest.TestStep{ testAccStepConfig(t), testAccStepWritePolicy(t, "test", testPolicy), @@ -38,7 +43,7 @@ func TestBackend_policyCrud(t *testing.T) { } logicaltest.Test(t, logicaltest.TestCase{ - Backend: Backend(), + Backend: getBackend(t), Steps: []logicaltest.TestStep{ testAccStepConfig(t), testAccStepWritePolicy(t, "test", testPolicy), diff --git a/builtin/logical/cassandra/path_creds_create.go b/builtin/logical/cassandra/path_creds_create.go index 26b7f658f..7b8b15419 100644 --- a/builtin/logical/cassandra/path_creds_create.go +++ b/builtin/logical/cassandra/path_creds_create.go @@ -5,7 +5,7 @@ import ( "strings" "time" - "github.com/hashicorp/uuid" + "github.com/hashicorp/go-uuid" "github.com/hashicorp/vault/logical" "github.com/hashicorp/vault/logical/framework" ) diff --git a/builtin/logical/mysql/path_role_create.go b/builtin/logical/mysql/path_role_create.go index 57a486a74..e9f9db36f 100644 --- a/builtin/logical/mysql/path_role_create.go +++ b/builtin/logical/mysql/path_role_create.go @@ -4,7 +4,7 @@ import ( "fmt" "time" - "github.com/hashicorp/uuid" + "github.com/hashicorp/go-uuid" "github.com/hashicorp/vault/logical" "github.com/hashicorp/vault/logical/framework" _ "github.com/lib/pq" diff --git a/builtin/logical/pki/backend.go b/builtin/logical/pki/backend.go index b97298dff..8a91f6372 100644 --- a/builtin/logical/pki/backend.go +++ b/builtin/logical/pki/backend.go @@ -21,11 +21,6 @@ func Backend() *framework.Backend { Help: strings.TrimSpace(backendHelp), PathsSpecial: &logical.Paths{ - Root: []string{ - "config/*", - "revoke/*", - "crl/rotate", - }, Unauthenticated: []string{ "cert/*", "ca/pem", @@ -37,8 +32,15 @@ func Backend() *framework.Backend { Paths: []*framework.Path{ pathRoles(&b), + pathGenerateRoot(&b), + pathGenerateIntermediate(&b), + pathSetSignedIntermediate(&b), + pathSignIntermediate(&b), pathConfigCA(&b), pathConfigCRL(&b), + pathConfigURLs(&b), + pathSignVerbatim(&b), + pathSign(&b), pathIssue(&b), pathRotateCRL(&b), pathFetchCA(&b), diff --git a/builtin/logical/pki/backend_test.go b/builtin/logical/pki/backend_test.go index ffaafe4a3..44abe137d 100644 --- a/builtin/logical/pki/backend_test.go +++ b/builtin/logical/pki/backend_test.go @@ -1,12 +1,22 @@ package pki import ( + "crypto" + "crypto/ecdsa" + "crypto/elliptic" + "crypto/rand" + "crypto/rsa" "crypto/x509" + "crypto/x509/pkix" + "encoding/base64" "encoding/pem" "fmt" "math" - "math/rand" + mathrand "math/rand" + "net" "os" + "reflect" + "strings" "testing" "time" @@ -22,7 +32,8 @@ var ( ) // Performs basic tests on CA functionality -func TestBackend_basic(t *testing.T) { +// Uses the RSA CA key +func TestBackend_RSAKey(t *testing.T) { defaultLeaseTTLVal := time.Hour * 24 maxLeaseTTLVal := time.Hour * 24 * 30 b, err := Factory(&logical.BackendConfig{ @@ -43,14 +54,16 @@ func TestBackend_basic(t *testing.T) { stepCount += len(testCase.Steps) - testCase.Steps = append(testCase.Steps, generateCASteps(t)...) + intdata := map[string]interface{}{} + reqdata := map[string]interface{}{} + testCase.Steps = append(testCase.Steps, generateCATestingSteps(t, rsaCACert, rsaCAKey, ecCACert, intdata, reqdata)...) logicaltest.Test(t, testCase) } -// Generates and tests steps that walk through the various possibilities -// of role flags to ensure that they are properly restricted -func TestBackend_roles(t *testing.T) { +// Performs basic tests on CA functionality +// Uses the EC CA key +func TestBackend_ECKey(t *testing.T) { defaultLeaseTTLVal := time.Hour * 24 maxLeaseTTLVal := time.Hour * 24 * 30 b, err := Factory(&logical.BackendConfig{ @@ -69,8 +82,146 @@ func TestBackend_roles(t *testing.T) { Steps: []logicaltest.TestStep{}, } - testCase.Steps = append(testCase.Steps, generateCASteps(t)...) - testCase.Steps = append(testCase.Steps, generateRoleSteps(t)...) + stepCount += len(testCase.Steps) + + intdata := map[string]interface{}{} + reqdata := map[string]interface{}{} + testCase.Steps = append(testCase.Steps, generateCATestingSteps(t, ecCACert, ecCAKey, rsaCACert, intdata, reqdata)...) + + logicaltest.Test(t, testCase) +} + +func TestBackend_CSRValues(t *testing.T) { + defaultLeaseTTLVal := time.Hour * 24 + maxLeaseTTLVal := time.Hour * 24 * 30 + b, err := Factory(&logical.BackendConfig{ + Logger: nil, + System: &logical.StaticSystemView{ + DefaultLeaseTTLVal: defaultLeaseTTLVal, + MaxLeaseTTLVal: maxLeaseTTLVal, + }, + }) + if err != nil { + t.Fatalf("Unable to create backend: %s", err) + } + + testCase := logicaltest.TestCase{ + Backend: b, + Steps: []logicaltest.TestStep{}, + } + + stepCount += len(testCase.Steps) + + intdata := map[string]interface{}{} + reqdata := map[string]interface{}{} + testCase.Steps = append(testCase.Steps, generateCSRSteps(t, ecCACert, ecCAKey, intdata, reqdata)...) + + logicaltest.Test(t, testCase) +} + +func TestBackend_URLsCRUD(t *testing.T) { + defaultLeaseTTLVal := time.Hour * 24 + maxLeaseTTLVal := time.Hour * 24 * 30 + b, err := Factory(&logical.BackendConfig{ + Logger: nil, + System: &logical.StaticSystemView{ + DefaultLeaseTTLVal: defaultLeaseTTLVal, + MaxLeaseTTLVal: maxLeaseTTLVal, + }, + }) + if err != nil { + t.Fatalf("Unable to create backend: %s", err) + } + + testCase := logicaltest.TestCase{ + Backend: b, + Steps: []logicaltest.TestStep{}, + } + + stepCount += len(testCase.Steps) + + intdata := map[string]interface{}{} + reqdata := map[string]interface{}{} + testCase.Steps = append(testCase.Steps, generateURLSteps(t, ecCACert, ecCAKey, intdata, reqdata)...) + + logicaltest.Test(t, testCase) +} + +// Generates and tests steps that walk through the various possibilities +// of role flags to ensure that they are properly restricted +// Uses the RSA CA key +func TestBackend_RSARoles(t *testing.T) { + defaultLeaseTTLVal := time.Hour * 24 + maxLeaseTTLVal := time.Hour * 24 * 30 + b, err := Factory(&logical.BackendConfig{ + Logger: nil, + System: &logical.StaticSystemView{ + DefaultLeaseTTLVal: defaultLeaseTTLVal, + MaxLeaseTTLVal: maxLeaseTTLVal, + }, + }) + if err != nil { + t.Fatalf("Unable to create backend: %s", err) + } + + testCase := logicaltest.TestCase{ + Backend: b, + Steps: []logicaltest.TestStep{ + logicaltest.TestStep{ + Operation: logical.WriteOperation, + Path: "config/ca", + Data: map[string]interface{}{ + "pem_bundle": rsaCAKey + rsaCACert, + }, + }, + }, + } + + testCase.Steps = append(testCase.Steps, generateRoleSteps(t, false)...) + testCase.Steps = append(testCase.Steps, generateRoleSteps(t, true)...) + if len(os.Getenv("VAULT_VERBOSE_PKITESTS")) > 0 { + for i, v := range testCase.Steps { + fmt.Printf("Step %d:\n%+v\n\n", i+stepCount, v) + } + } + + stepCount += len(testCase.Steps) + + logicaltest.Test(t, testCase) +} + +// Generates and tests steps that walk through the various possibilities +// of role flags to ensure that they are properly restricted +// Uses the EC CA key +func TestBackend_ECRoles(t *testing.T) { + defaultLeaseTTLVal := time.Hour * 24 + maxLeaseTTLVal := time.Hour * 24 * 30 + b, err := Factory(&logical.BackendConfig{ + Logger: nil, + System: &logical.StaticSystemView{ + DefaultLeaseTTLVal: defaultLeaseTTLVal, + MaxLeaseTTLVal: maxLeaseTTLVal, + }, + }) + if err != nil { + t.Fatalf("Unable to create backend: %s", err) + } + + testCase := logicaltest.TestCase{ + Backend: b, + Steps: []logicaltest.TestStep{ + logicaltest.TestStep{ + Operation: logical.WriteOperation, + Path: "config/ca", + Data: map[string]interface{}{ + "pem_bundle": ecCAKey + ecCACert, + }, + }, + }, + } + + testCase.Steps = append(testCase.Steps, generateRoleSteps(t, false)...) + testCase.Steps = append(testCase.Steps, generateRoleSteps(t, true)...) if len(os.Getenv("VAULT_VERBOSE_PKITESTS")) > 0 { for i, v := range testCase.Steps { fmt.Printf("Step %d:\n%+v\n\n", i+stepCount, v) @@ -83,12 +234,28 @@ func TestBackend_roles(t *testing.T) { } // Performs some validity checking on the returned bundles -func checkCertsAndPrivateKey(keyType string, usage certUsage, validity time.Duration, certBundle *certutil.CertBundle) (*certutil.ParsedCertBundle, error) { +func checkCertsAndPrivateKey(keyType string, key crypto.Signer, usage certUsage, validity time.Duration, certBundle *certutil.CertBundle) (*certutil.ParsedCertBundle, error) { parsedCertBundle, err := certBundle.ToParsedCertBundle() if err != nil { return nil, fmt.Errorf("Error parsing cert bundle: %s", err) } + if key != nil { + switch keyType { + case "rsa": + parsedCertBundle.PrivateKeyType = certutil.RSAPrivateKey + parsedCertBundle.PrivateKey = key + parsedCertBundle.PrivateKeyBytes = x509.MarshalPKCS1PrivateKey(key.(*rsa.PrivateKey)) + case "ec": + parsedCertBundle.PrivateKeyType = certutil.ECPrivateKey + parsedCertBundle.PrivateKey = key + parsedCertBundle.PrivateKeyBytes, err = x509.MarshalECPrivateKey(key.(*ecdsa.PrivateKey)) + if err != nil { + return nil, fmt.Errorf("Error parsing EC key: %s", err) + } + } + } + switch { case parsedCertBundle.Certificate == nil: return nil, fmt.Errorf("Did not find a certificate in the cert bundle") @@ -111,9 +278,13 @@ func checkCertsAndPrivateKey(keyType string, usage certUsage, validity time.Dura // There should only be one usage type, because only one is requested // in the tests if len(cert.ExtKeyUsage) != 1 { - return nil, fmt.Errorf("Got wrong size key usage in generated cert") + return nil, fmt.Errorf("Got wrong size key usage in generated cert; values are %#v", cert.ExtKeyUsage) } switch usage { + case emailProtectionUsage: + if cert.ExtKeyUsage[0] != x509.ExtKeyUsageEmailProtection { + return nil, fmt.Errorf("Bad key usage") + } case serverUsage: if cert.ExtKeyUsage[0] != x509.ExtKeyUsageServerAuth { return nil, fmt.Errorf("Bad key usage") @@ -139,9 +310,230 @@ func checkCertsAndPrivateKey(keyType string, usage certUsage, validity time.Dura return parsedCertBundle, nil } +func generateURLSteps(t *testing.T, caCert, caKey string, intdata, reqdata map[string]interface{}) []logicaltest.TestStep { + expected := urlEntries{ + IssuingCertificates: []string{ + "http://example.com/ca1", + "http://example.com/ca2", + }, + CRLDistributionPoints: []string{ + "http://example.com/crl1", + "http://example.com/crl2", + }, + OCSPServers: []string{ + "http://example.com/ocsp1", + "http://example.com/ocsp2", + }, + } + csrTemplate := x509.CertificateRequest{ + Subject: pkix.Name{ + CommonName: "my@example.com", + }, + } + + priv, _ := rsa.GenerateKey(rand.Reader, 2048) + csr, _ := x509.CreateCertificateRequest(rand.Reader, &csrTemplate, priv) + csrPem := pem.EncodeToMemory(&pem.Block{ + Type: "CERTIFICATE REQUEST", + Bytes: csr, + }) + + ret := []logicaltest.TestStep{ + logicaltest.TestStep{ + Operation: logical.WriteOperation, + Path: "root/generate/exported", + Data: map[string]interface{}{ + "common_name": "Root Cert", + "ttl": "180h", + }, + }, + + logicaltest.TestStep{ + Operation: logical.WriteOperation, + Path: "config/urls", + Data: map[string]interface{}{ + "issuing_certificates": strings.Join(expected.IssuingCertificates, ","), + "crl_distribution_points": strings.Join(expected.CRLDistributionPoints, ","), + "ocsp_servers": strings.Join(expected.OCSPServers, ","), + }, + }, + + logicaltest.TestStep{ + Operation: logical.ReadOperation, + Path: "config/urls", + Check: func(resp *logical.Response) error { + if resp.Data == nil { + return fmt.Errorf("no data returned") + } + var entries urlEntries + err := mapstructure.Decode(resp.Data, &entries) + if err != nil { + return err + } + + if !reflect.DeepEqual(entries, expected) { + return fmt.Errorf("expected urls\n%#v\ndoes not match provided\n%#v\n", expected, entries) + } + + return nil + }, + }, + + logicaltest.TestStep{ + Operation: logical.WriteOperation, + Path: "root/sign-intermediate", + Data: map[string]interface{}{ + "common_name": "Intermediate Cert", + "csr": string(csrPem), + "format": "der", + }, + Check: func(resp *logical.Response) error { + certString := resp.Data["certificate"].(string) + if certString == "" { + return fmt.Errorf("no certificate returned") + } + certBytes, _ := base64.StdEncoding.DecodeString(certString) + certs, err := x509.ParseCertificates(certBytes) + if err != nil { + return fmt.Errorf("returned cert cannot be parsed: %v", err) + } + if len(certs) != 1 { + return fmt.Errorf("unexpected returned length of certificates: %d", len(certs)) + } + cert := certs[0] + + switch { + case !reflect.DeepEqual(expected.IssuingCertificates, cert.IssuingCertificateURL): + return fmt.Errorf("expected\n%#v\ngot\n%#v\n", expected.IssuingCertificates, cert.IssuingCertificateURL) + case !reflect.DeepEqual(expected.CRLDistributionPoints, cert.CRLDistributionPoints): + return fmt.Errorf("expected\n%#v\ngot\n%#v\n", expected.CRLDistributionPoints, cert.CRLDistributionPoints) + case !reflect.DeepEqual(expected.OCSPServers, cert.OCSPServer): + return fmt.Errorf("expected\n%#v\ngot\n%#v\n", expected.OCSPServers, cert.OCSPServer) + } + return nil + }, + }, + } + return ret +} + +func generateCSRSteps(t *testing.T, caCert, caKey string, intdata, reqdata map[string]interface{}) []logicaltest.TestStep { + csrTemplate := x509.CertificateRequest{ + Subject: pkix.Name{ + Country: []string{"MyCountry"}, + PostalCode: []string{"MyPostalCode"}, + SerialNumber: "MySerialNumber", + CommonName: "my@example.com", + }, + DNSNames: []string{ + "name1.example.com", + "name2.example.com", + "name3.example.com", + }, + EmailAddresses: []string{ + "name1@example.com", + "name2@example.com", + "name3@example.com", + }, + IPAddresses: []net.IP{ + net.ParseIP("::ff:1:2:3:4"), + net.ParseIP("::ff:5:6:7:8"), + }, + } + + priv, _ := rsa.GenerateKey(rand.Reader, 2048) + csr, _ := x509.CreateCertificateRequest(rand.Reader, &csrTemplate, priv) + csrPem := pem.EncodeToMemory(&pem.Block{ + Type: "CERTIFICATE REQUEST", + Bytes: csr, + }) + + ret := []logicaltest.TestStep{ + logicaltest.TestStep{ + Operation: logical.WriteOperation, + Path: "root/generate/exported", + Data: map[string]interface{}{ + "common_name": "Root Cert", + "ttl": "180h", + "max_path_length": 0, + }, + }, + + logicaltest.TestStep{ + Operation: logical.WriteOperation, + Path: "root/sign-intermediate", + Data: map[string]interface{}{ + "use_csr_values": true, + "csr": string(csrPem), + "format": "der", + }, + ErrorOk: true, + }, + + logicaltest.TestStep{ + Operation: logical.WriteOperation, + Path: "root/generate/exported", + Data: map[string]interface{}{ + "common_name": "Root Cert", + "ttl": "180h", + "max_path_length": 1, + }, + }, + + logicaltest.TestStep{ + Operation: logical.WriteOperation, + Path: "root/sign-intermediate", + Data: map[string]interface{}{ + "use_csr_values": true, + "csr": string(csrPem), + "format": "der", + }, + Check: func(resp *logical.Response) error { + certString := resp.Data["certificate"].(string) + if certString == "" { + return fmt.Errorf("no certificate returned") + } + certBytes, _ := base64.StdEncoding.DecodeString(certString) + certs, err := x509.ParseCertificates(certBytes) + if err != nil { + return fmt.Errorf("returned cert cannot be parsed: %v", err) + } + if len(certs) != 1 { + return fmt.Errorf("unexpected returned length of certificates: %d", len(certs)) + } + cert := certs[0] + + if cert.MaxPathLen != 0 { + return fmt.Errorf("max path length of %d does not match the requested of 3", cert.MaxPathLen) + } + if !cert.MaxPathLenZero { + return fmt.Errorf("max path length zero is not set") + } + + // We need to set these as they are filled in with unparsed values in the final cert + csrTemplate.Subject.Names = cert.Subject.Names + csrTemplate.Subject.ExtraNames = cert.Subject.ExtraNames + + switch { + case !reflect.DeepEqual(cert.Subject, csrTemplate.Subject): + return fmt.Errorf("cert subject\n%#v\ndoes not match csr subject\n%#v\n", cert.Subject, csrTemplate.Subject) + case !reflect.DeepEqual(cert.DNSNames, csrTemplate.DNSNames): + return fmt.Errorf("cert dns names\n%#v\ndoes not match csr dns names\n%#v\n", cert.DNSNames, csrTemplate.DNSNames) + case !reflect.DeepEqual(cert.EmailAddresses, csrTemplate.EmailAddresses): + return fmt.Errorf("cert email addresses\n%#v\ndoes not match csr email addresses\n%#v\n", cert.EmailAddresses, csrTemplate.EmailAddresses) + case !reflect.DeepEqual(cert.IPAddresses, csrTemplate.IPAddresses): + return fmt.Errorf("cert ip addresses\n%#v\ndoes not match csr ip addresses\n%#v\n", cert.IPAddresses, csrTemplate.IPAddresses) + } + return nil + }, + }, + } + return ret +} + // Generates steps to test out CA configuration -- certificates + CRL expiry, // and ensure that the certificates are readable after storing them -func generateCASteps(t *testing.T) []logicaltest.TestStep { +func generateCATestingSteps(t *testing.T, caCert, caKey, otherCaCert string, intdata, reqdata map[string]interface{}) []logicaltest.TestStep { ret := []logicaltest.TestStep{ logicaltest.TestStep{ Operation: logical.WriteOperation, @@ -218,15 +610,341 @@ func generateCASteps(t *testing.T) []logicaltest.TestStep { return nil }, }, + + // Ensure that both parts of the PEM bundle are required + // Here, just the cert + logicaltest.TestStep{ + Operation: logical.WriteOperation, + Path: "config/ca", + Data: map[string]interface{}{ + "pem_bundle": caCert, + }, + ErrorOk: true, + }, + + // Here, just the key + logicaltest.TestStep{ + Operation: logical.WriteOperation, + Path: "config/ca", + Data: map[string]interface{}{ + "pem_bundle": caKey, + }, + ErrorOk: true, + }, + + // Ensure we can fetch it back via unauthenticated means, in various formats + logicaltest.TestStep{ + Operation: logical.ReadOperation, + Path: "cert/ca", + Unauthenticated: true, + Check: func(resp *logical.Response) error { + if resp.Data["certificate"].(string) != caCert { + return fmt.Errorf("CA certificate:\n%s\ndoes not match original:\n%s\n", resp.Data["certificate"].(string), caCert) + } + return nil + }, + }, + + logicaltest.TestStep{ + Operation: logical.ReadOperation, + Path: "ca/pem", + Unauthenticated: true, + Check: func(resp *logical.Response) error { + rawBytes := resp.Data["http_raw_body"].([]byte) + if string(rawBytes) != caCert { + return fmt.Errorf("CA certificate:\n%s\ndoes not match original:\n%s\n", string(rawBytes), caCert) + } + if resp.Data["http_content_type"].(string) != "application/pkix-cert" { + return fmt.Errorf("Expected application/pkix-cert as content-type, but got %s", resp.Data["http_content_type"].(string)) + } + return nil + }, + }, + + logicaltest.TestStep{ + Operation: logical.ReadOperation, + Path: "ca", + Unauthenticated: true, + Check: func(resp *logical.Response) error { + rawBytes := resp.Data["http_raw_body"].([]byte) + pemBytes := pem.EncodeToMemory(&pem.Block{ + Type: "CERTIFICATE", + Bytes: rawBytes, + }) + if string(pemBytes) != caCert { + return fmt.Errorf("CA certificate:\n%s\ndoes not match original:\n%s\n", string(pemBytes), caCert) + } + if resp.Data["http_content_type"].(string) != "application/pkix-cert" { + return fmt.Errorf("Expected application/pkix-cert as content-type, but got %s", resp.Data["http_content_type"].(string)) + } + return nil + }, + }, + + // Test a bunch of generation stuff + logicaltest.TestStep{ + Operation: logical.WriteOperation, + Path: "root/generate/exported", + Data: map[string]interface{}{ + "common_name": "Root Cert", + "ttl": "180h", + }, + Check: func(resp *logical.Response) error { + intdata["root"] = resp.Data["certificate"].(string) + intdata["rootkey"] = resp.Data["private_key"].(string) + reqdata["pem_bundle"] = intdata["root"].(string) + "\n" + intdata["rootkey"].(string) + return nil + }, + }, + + logicaltest.TestStep{ + Operation: logical.WriteOperation, + Path: "intermediate/generate/exported", + Data: map[string]interface{}{ + "common_name": "Intermediate Cert", + }, + Check: func(resp *logical.Response) error { + intdata["intermediatecsr"] = resp.Data["csr"].(string) + intdata["intermediatekey"] = resp.Data["private_key"].(string) + return nil + }, + }, + + // Re-load the root key in so we can sign it + logicaltest.TestStep{ + Operation: logical.WriteOperation, + Path: "config/ca", + Data: reqdata, + Check: func(resp *logical.Response) error { + delete(reqdata, "pem_bundle") + delete(reqdata, "ttl") + reqdata["csr"] = intdata["intermediatecsr"].(string) + reqdata["common_name"] = "Intermediate Cert" + reqdata["ttl"] = "90h" + return nil + }, + }, + + logicaltest.TestStep{ + Operation: logical.WriteOperation, + Path: "root/sign-intermediate", + Data: reqdata, + Check: func(resp *logical.Response) error { + delete(reqdata, "csr") + delete(reqdata, "common_name") + delete(reqdata, "ttl") + intdata["intermediatecert"] = resp.Data["certificate"].(string) + reqdata["serial_number"] = resp.Data["serial_number"].(string) + reqdata["certificate"] = resp.Data["certificate"].(string) + reqdata["pem_bundle"] = intdata["intermediatekey"].(string) + "\n" + resp.Data["certificate"].(string) + return nil + }, + }, + + // First load in this way to populate the private key + logicaltest.TestStep{ + Operation: logical.WriteOperation, + Path: "config/ca", + Data: reqdata, + Check: func(resp *logical.Response) error { + delete(reqdata, "pem_bundle") + return nil + }, + }, + + // Now test setting the intermediate, signed CA cert + logicaltest.TestStep{ + Operation: logical.WriteOperation, + Path: "intermediate/set-signed", + Data: reqdata, + Check: func(resp *logical.Response) error { + delete(reqdata, "certificate") + return nil + }, + }, + + logicaltest.TestStep{ + Operation: logical.WriteOperation, + Path: "revoke", + Data: reqdata, + }, + + logicaltest.TestStep{ + Operation: logical.ReadOperation, + Path: "crl", + Data: reqdata, + Check: func(resp *logical.Response) error { + crlBytes := resp.Data["http_raw_body"].([]byte) + certList, err := x509.ParseCRL(crlBytes) + if err != nil { + t.Fatalf("err: %s", err) + } + revokedList := certList.TBSCertList.RevokedCertificates + if len(revokedList) != 1 { + t.Fatalf("length of revoked list not 1; %d", len(revokedList)) + } + revokedString := certutil.GetOctalFormatted(revokedList[0].SerialNumber.Bytes(), ":") + if revokedString != reqdata["serial_number"].(string) { + t.Fatalf("got serial %s, expecting %s", revokedString, reqdata["serial_number"].(string)) + } + delete(reqdata, "serial_number") + return nil + }, + }, + + // Do it all again, with EC keys and DER format + logicaltest.TestStep{ + Operation: logical.WriteOperation, + Path: "root/generate/exported", + Data: map[string]interface{}{ + "common_name": "Root Cert", + "ttl": "180h", + "key_type": "ec", + "key_bits": 384, + "format": "der", + }, + Check: func(resp *logical.Response) error { + certBytes, _ := base64.StdEncoding.DecodeString(resp.Data["certificate"].(string)) + certPem := pem.EncodeToMemory(&pem.Block{ + Type: "CERTIFICATE", + Bytes: certBytes, + }) + keyBytes, _ := base64.StdEncoding.DecodeString(resp.Data["private_key"].(string)) + keyPem := pem.EncodeToMemory(&pem.Block{ + Type: "EC PRIVATE KEY", + Bytes: keyBytes, + }) + intdata["root"] = string(certPem) + intdata["rootkey"] = string(keyPem) + reqdata["pem_bundle"] = string(certPem) + "\n" + string(keyPem) + return nil + }, + }, + + logicaltest.TestStep{ + Operation: logical.WriteOperation, + Path: "intermediate/generate/exported", + Data: map[string]interface{}{ + "format": "der", + "key_type": "ec", + "key_bits": 384, + "common_name": "Intermediate Cert", + }, + Check: func(resp *logical.Response) error { + csrBytes, _ := base64.StdEncoding.DecodeString(resp.Data["csr"].(string)) + csrPem := pem.EncodeToMemory(&pem.Block{ + Type: "CERTIFICATE REQUEST", + Bytes: csrBytes, + }) + keyBytes, _ := base64.StdEncoding.DecodeString(resp.Data["private_key"].(string)) + keyPem := pem.EncodeToMemory(&pem.Block{ + Type: "EC PRIVATE KEY", + Bytes: keyBytes, + }) + intdata["intermediatecsr"] = string(csrPem) + intdata["intermediatekey"] = string(keyPem) + return nil + }, + }, + + logicaltest.TestStep{ + Operation: logical.WriteOperation, + Path: "config/ca", + Data: reqdata, + Check: func(resp *logical.Response) error { + delete(reqdata, "pem_bundle") + delete(reqdata, "ttl") + reqdata["csr"] = intdata["intermediatecsr"].(string) + reqdata["common_name"] = "Intermediate Cert" + reqdata["ttl"] = "90h" + return nil + }, + }, + + logicaltest.TestStep{ + Operation: logical.WriteOperation, + Path: "root/sign-intermediate", + Data: reqdata, + Check: func(resp *logical.Response) error { + delete(reqdata, "csr") + delete(reqdata, "common_name") + delete(reqdata, "ttl") + intdata["intermediatecert"] = resp.Data["certificate"].(string) + reqdata["serial_number"] = resp.Data["serial_number"].(string) + reqdata["certificate"] = resp.Data["certificate"].(string) + reqdata["pem_bundle"] = intdata["intermediatekey"].(string) + "\n" + resp.Data["certificate"].(string) + return nil + }, + }, + + // First load in this way to populate the private key + logicaltest.TestStep{ + Operation: logical.WriteOperation, + Path: "config/ca", + Data: reqdata, + Check: func(resp *logical.Response) error { + delete(reqdata, "pem_bundle") + return nil + }, + }, + + // Now test setting the intermediate, signed CA cert + logicaltest.TestStep{ + Operation: logical.WriteOperation, + Path: "intermediate/set-signed", + Data: reqdata, + Check: func(resp *logical.Response) error { + delete(reqdata, "certificate") + return nil + }, + }, + + logicaltest.TestStep{ + Operation: logical.WriteOperation, + Path: "revoke", + Data: reqdata, + }, + + logicaltest.TestStep{ + Operation: logical.ReadOperation, + Path: "crl", + Data: reqdata, + Check: func(resp *logical.Response) error { + crlBytes := resp.Data["http_raw_body"].([]byte) + certList, err := x509.ParseCRL(crlBytes) + if err != nil { + t.Fatalf("err: %s", err) + } + revokedList := certList.TBSCertList.RevokedCertificates + if len(revokedList) != 2 { + t.Fatalf("length of revoked list not 2; %d", len(revokedList)) + } + found := false + for _, revEntry := range revokedList { + revokedString := certutil.GetOctalFormatted(revEntry.SerialNumber.Bytes(), ":") + if revokedString == reqdata["serial_number"].(string) { + found = true + + } + } + if !found { + t.Fatalf("did not find %s in CRL", reqdata["serial_number"].(string)) + } + delete(reqdata, "serial_number") + return nil + }, + }, } return ret } // Generates steps to test out various role permutations -func generateRoleSteps(t *testing.T) []logicaltest.TestStep { +func generateRoleSteps(t *testing.T, useCSRs bool) []logicaltest.TestStep { roleVals := roleEntry{ - MaxTTL: "12h", + MaxTTL: "12h", + KeyType: "rsa", + KeyBits: 2048, } issueVals := certutil.IssueData{} ret := []logicaltest.TestStep{} @@ -235,9 +953,17 @@ func generateRoleSteps(t *testing.T) []logicaltest.TestStep { Operation: logical.WriteOperation, Path: "roles/test", } - issueTestStep := logicaltest.TestStep{ - Operation: logical.WriteOperation, - Path: "issue/test", + var issueTestStep logicaltest.TestStep + if useCSRs { + issueTestStep = logicaltest.TestStep{ + Operation: logical.WriteOperation, + Path: "sign/test", + } + } else { + issueTestStep = logicaltest.TestStep{ + Operation: logical.WriteOperation, + Path: "issue/test", + } } genericErrorOkCheck := func(resp *logical.Response) error { @@ -267,14 +993,14 @@ func generateRoleSteps(t *testing.T) []logicaltest.TestStep { // Returns a TestCheckFunc that performs various validity checks on the // returned certificate information, mostly within checkCertsAndPrivateKey - getCnCheck := func(name, keyType string, usage certUsage, validity time.Duration) logicaltest.TestCheckFunc { + getCnCheck := func(name string, role roleEntry, key crypto.Signer, usage certUsage, validity time.Duration) logicaltest.TestCheckFunc { var certBundle certutil.CertBundle return func(resp *logical.Response) error { err := mapstructure.Decode(resp.Data, &certBundle) if err != nil { return err } - parsedCertBundle, err := checkCertsAndPrivateKey(keyType, usage, validity, &certBundle) + parsedCertBundle, err := checkCertsAndPrivateKey(role.KeyType, key, usage, validity, &certBundle) if err != nil { return fmt.Errorf("Error checking generated certificate: %s", err) } @@ -282,11 +1008,24 @@ func generateRoleSteps(t *testing.T) []logicaltest.TestStep { if cert.Subject.CommonName != name { return fmt.Errorf("Error: returned certificate has CN of %s but %s was requested", cert.Subject.CommonName, name) } - if len(cert.DNSNames) != 1 { - return fmt.Errorf("Error: found more than one DNS SAN but only one was requested") + if strings.Contains(cert.Subject.CommonName, "@") { + if len(cert.DNSNames) != 0 || len(cert.EmailAddresses) != 1 { + return fmt.Errorf("Error: found more than one DNS SAN or not one Email SAN but only one was requested, cert.DNSNames = %#v, cert.EmailAddresses = %#v", cert.DNSNames, cert.EmailAddresses) + } + } else { + if len(cert.DNSNames) != 1 || len(cert.EmailAddresses) != 0 { + return fmt.Errorf("Error: found more than one Email SAN or not one DNS SAN but only one was requested, cert.DNSNames = %#v, cert.EmailAddresses = %#v", cert.DNSNames, cert.EmailAddresses) + } } - if cert.DNSNames[0] != name { - return fmt.Errorf("Error: returned certificate has a DNS SAN of %s but %s was requested", cert.DNSNames[0], name) + var retName string + if len(cert.DNSNames) > 0 { + retName = cert.DNSNames[0] + } + if len(cert.EmailAddresses) > 0 { + retName = cert.EmailAddresses[0] + } + if retName != name { + return fmt.Errorf("Error: returned certificate has a DNS SAN of %s but %s was requested", retName, name) } return nil } @@ -294,13 +1033,15 @@ func generateRoleSteps(t *testing.T) []logicaltest.TestStep { // Common names to test with the various role flags toggled var commonNames struct { - Localhost bool `structs:"localhost"` - BaseDomain bool `structs:"foo.example.com"` - Wildcard bool `structs:"*.example.com"` - Subdomain bool `structs:"foo.bar.example.com"` - SubdomainWildcard bool `structs:"*.bar.example.com"` - NonHostname bool `structs:"daɪˈɛrɨsɨs"` - AnyHost bool `structs:"porkslap.beer"` + Localhost bool `structs:"localhost"` + BareDomain bool `structs:"example.com"` + SecondDomain bool `structs:"foobar.com"` + SubDomain bool `structs:"foo.example.com"` + Wildcard bool `structs:"*.example.com"` + SubSubdomain bool `structs:"foo.bar.example.com"` + SubSubdomainWildcard bool `structs:"*.bar.example.com"` + NonHostname bool `structs:"daɪˈɛrɨsɨs"` + AnyHost bool `structs:"porkslap.beer"` } // Adds a series of tests based on the current selection of @@ -312,7 +1053,7 @@ func generateRoleSteps(t *testing.T) []logicaltest.TestStep { cnMap := structs.New(commonNames).Map() // For the number of tests being run, this is known to hit all // of the various values below - mathRand := rand.New(rand.NewSource(1)) + mathRand := mathrand.New(mathrand.NewSource(1)) for name, allowedInt := range cnMap { roleVals.KeyType = "rsa" roleVals.KeyBits = 2048 @@ -324,9 +1065,13 @@ func generateRoleSteps(t *testing.T) []logicaltest.TestStep { roleVals.ServerFlag = false roleVals.ClientFlag = false roleVals.CodeSigningFlag = false + roleVals.EmailProtectionFlag = false var usage certUsage i := mathRand.Int() switch { + case i%5 == 0: + usage = emailProtectionUsage + roleVals.EmailProtectionFlag = true case i%3 == 0: usage = serverUsage roleVals.ServerFlag = true @@ -340,6 +1085,11 @@ func generateRoleSteps(t *testing.T) []logicaltest.TestStep { allowed := allowedInt.(bool) issueVals.CommonName = name + if roleVals.EmailProtectionFlag { + if !strings.HasPrefix(name, "*") { + issueVals.CommonName = "user@" + issueVals.CommonName + } + } if allowed { issueTestStep.ErrorOk = false } else { @@ -347,7 +1097,43 @@ func generateRoleSteps(t *testing.T) []logicaltest.TestStep { } validity, _ := time.ParseDuration(roleVals.MaxTTL) - addTests(getCnCheck(name, roleVals.KeyType, usage, validity)) + if useCSRs { + var privKey crypto.Signer + switch roleVals.KeyType { + case "rsa": + privKey, _ = rsa.GenerateKey(rand.Reader, roleVals.KeyBits) + case "ec": + var curve elliptic.Curve + switch roleVals.KeyBits { + case 224: + curve = elliptic.P224() + case 256: + curve = elliptic.P256() + case 384: + curve = elliptic.P384() + case 521: + curve = elliptic.P521() + } + privKey, _ = ecdsa.GenerateKey(curve, rand.Reader) + } + templ := &x509.CertificateRequest{ + Subject: pkix.Name{ + CommonName: issueVals.CommonName, + }, + } + csr, err := x509.CreateCertificateRequest(rand.Reader, templ, privKey) + if err != nil { + t.Fatalf("Error creating certificate request: %s", err) + } + block := pem.Block{ + Type: "CERTIFICATE REQUEST", + Bytes: csr, + } + issueVals.CSR = strings.TrimSpace(string(pem.EncodeToMemory(&block))) + addTests(getCnCheck(issueVals.CommonName, roleVals, privKey, usage, validity)) + } else { + addTests(getCnCheck(issueVals.CommonName, roleVals, nil, usage, validity)) + } } } @@ -365,17 +1151,21 @@ func generateRoleSteps(t *testing.T) []logicaltest.TestStep { commonNames.Localhost = true addCnTests() - roleVals.AllowedBaseDomain = "foobar.com" - addCnTests() - - roleVals.AllowedBaseDomain = "example.com" - commonNames.BaseDomain = true - commonNames.Wildcard = true + roleVals.AllowedDomains = "foobar.com" addCnTests() + roleVals.AllowedDomains = "example.com" roleVals.AllowSubdomains = true - commonNames.Subdomain = true - commonNames.SubdomainWildcard = true + commonNames.SubDomain = true + commonNames.Wildcard = true + commonNames.SubSubdomain = true + commonNames.SubSubdomainWildcard = true + addCnTests() + + roleVals.AllowedDomains = "foobar.com,example.com" + commonNames.SecondDomain = true + roleVals.AllowBareDomains = true + commonNames.BareDomain = true addCnTests() roleVals.AllowAnyName = true @@ -387,7 +1177,6 @@ func generateRoleSteps(t *testing.T) []logicaltest.TestStep { commonNames.NonHostname = true addCnTests() } - // IP SAN tests { issueVals.IPSANs = "127.0.0.1,::1" @@ -424,7 +1213,7 @@ func generateRoleSteps(t *testing.T) []logicaltest.TestStep { } const ( - caKey string = `-----BEGIN RSA PRIVATE KEY----- + rsaCAKey string = `-----BEGIN RSA PRIVATE KEY----- MIIEpAIBAAKCAQEA1eKB2nFbRqTFs7KyZjbzB5VRCBbnLZfEXVP1c3bHe+YGjlfl 34cy52dmancUzOf1/Jfo+VglocjTLVy5wHSGJwQYs8b6pEuuvAVo/6wUL5Z7ZlQD R4kDe5Q+xgoRT6Bi/Bs57E+fNYgyUq/YAUY5WLuC+ZliCbJkLnb15ItuP1yVUTDX @@ -452,7 +1241,7 @@ udNtivO4LlRb/PJ+DK6afDyH8aJQdDqe3NpDvyrmKiMSYOY3iVFvan4tbIiofxdQ flwiZUzox814fzXbxheO9Cs6pXz7PUBVU4fN0Y/hXJCfRO4Ns9152A== -----END RSA PRIVATE KEY----- ` - caCert string = `-----BEGIN CERTIFICATE----- + rsaCACert string = `-----BEGIN CERTIFICATE----- MIIDUTCCAjmgAwIBAgIJAKM+z4MSfw2mMA0GCSqGSIb3DQEBCwUAMBsxGTAXBgNV BAMMEFZhdWx0IFRlc3RpbmcgQ0EwHhcNMTUwNjAxMjA1MTUzWhcNMjUwNTI5MjA1 MTUzWjAbMRkwFwYDVQQDDBBWYXVsdCBUZXN0aW5nIENBMIIBIjANBgkqhkiG9w0B @@ -472,5 +1261,34 @@ loN/opnM6+a/O3Zua8RAuMMAv9wyqwn88aVuLvVzDNSMe5qC5kkuLGmRkNgY06rI S/fXIHIOldeQxgYCqhdVmcDWJ1PtVaDfBsKVpRg1GRU8LUGw2E4AY+twd+J2FBfa G/7g4koczXLoUM3OQXd5Aq2cs4SS1vODrYmgbioFsQ3eDHd1fg== -----END CERTIFICATE----- +` + + ecCAKey string = `-----BEGIN EC PRIVATE KEY----- +MIGkAgEBBDBP/t89wrC0RFVs0N+jiRuGPptoxI1Iyu42/PzzZWMKYnO7yCWFG/Qv +zC8cRa8PDqegBwYFK4EEACKhZANiAAQI9e8n9RD6gOd5YpWpDi5AoPbskxQSogxx +dYFzzHwS0RYIucmlcJ2CuJQNc+9E4dUCMsYr2cAnCgA4iUHzGaje3Fa4O667LVH1 +imAyAj5nbfSd89iNzg4XNPkFjuVNBlE= +-----END EC PRIVATE KEY----- +` + + ecCACert string = `-----BEGIN CERTIFICATE----- +MIIDHzCCAqSgAwIBAgIUEQ4L+8Xl9+/uxU3MMCrd3Bw0HMcwCgYIKoZIzj0EAwIw +XzEjMCEGA1UEAxMaVmF1bHQgRUMgdGVzdGluZyByb290IGNlcnQxODA2BgNVBAUT +Lzk3MzY2MDk3NDQ1ODU2MDI3MDY5MDQ0MTkxNjIxODI4NjI0NjM0NTI5MTkzMTU5 +MB4XDTE1MTAwNTE2MzAwMFoXDTM1MDkzMDE2MzAwMFowXzEjMCEGA1UEAxMaVmF1 +bHQgRUMgdGVzdGluZyByb290IGNlcnQxODA2BgNVBAUTLzk3MzY2MDk3NDQ1ODU2 +MDI3MDY5MDQ0MTkxNjIxODI4NjI0NjM0NTI5MTkzMTU5MHYwEAYHKoZIzj0CAQYF +K4EEACIDYgAECPXvJ/UQ+oDneWKVqQ4uQKD27JMUEqIMcXWBc8x8EtEWCLnJpXCd +griUDXPvROHVAjLGK9nAJwoAOIlB8xmo3txWuDuuuy1R9YpgMgI+Z230nfPYjc4O +FzT5BY7lTQZRo4IBHzCCARswDgYDVR0PAQH/BAQDAgGuMBMGA1UdJQQMMAoGCCsG +AQUFBwMJMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFCIBqs15CiKuj7vqmIW5 +L07WSeLhMB8GA1UdIwQYMBaAFCIBqs15CiKuj7vqmIW5L07WSeLhMEIGCCsGAQUF +BwEBBDYwNDAyBggrBgEFBQcwAoYmaHR0cDovL3ZhdWx0LmV4YW1wbGUuY29tL3Yx +L3Jvb3Rwa2kvY2EwJQYDVR0RBB4wHIIaVmF1bHQgRUMgdGVzdGluZyByb290IGNl +cnQwOAYDVR0fBDEwLzAtoCugKYYnaHR0cDovL3ZhdWx0LmV4YW1wbGUuY29tL3Yx +L3Jvb3Rwa2kvY3JsMAoGCCqGSM49BAMCA2kAMGYCMQDRrxXskBtXjuZ1tUTk+qae +3bNVE1oeTDJhe0m3KN7qTykSGslxfEjlv83GYXziiv0CMQDsqu1U9uXPn3ezSbgG +O30prQ/sanDzNAeJhftoGtNPJDspwx0fzclHvKIhgl3JVUc= +-----END CERTIFICATE----- ` ) diff --git a/builtin/logical/pki/ca_util.go b/builtin/logical/pki/ca_util.go new file mode 100644 index 000000000..6e757f014 --- /dev/null +++ b/builtin/logical/pki/ca_util.go @@ -0,0 +1,42 @@ +package pki + +import ( + "github.com/hashicorp/vault/logical" + "github.com/hashicorp/vault/logical/framework" +) + +func (b *backend) getGenerationParams( + data *framework.FieldData, +) (exported bool, format string, role *roleEntry, errorResp *logical.Response) { + exportedStr := data.Get("exported").(string) + switch exportedStr { + case "exported": + exported = true + case "internal": + default: + errorResp = logical.ErrorResponse( + `The "exported" path parameter must be "internal" or "exported"`) + return + } + + format = getFormat(data) + if format == "" { + errorResp = logical.ErrorResponse( + `The "format" path parameter must be "pem" or "der"`) + return + } + + role = &roleEntry{ + TTL: data.Get("ttl").(string), + KeyType: data.Get("key_type").(string), + KeyBits: data.Get("key_bits").(int), + AllowLocalhost: true, + AllowAnyName: true, + AllowIPSANs: true, + EnforceHostnames: false, + } + + errorResp = validateKeyTypeLength(role.KeyType, role.KeyBits) + + return +} diff --git a/builtin/logical/pki/cert_util.go b/builtin/logical/pki/cert_util.go index 63067f87e..f47a6aa2f 100644 --- a/builtin/logical/pki/cert_util.go +++ b/builtin/logical/pki/cert_util.go @@ -1,15 +1,13 @@ package pki import ( - "crypto" - "crypto/ecdsa" - "crypto/elliptic" "crypto/rand" - "crypto/rsa" + "crypto/sha1" "crypto/x509" "crypto/x509/pkix" + "encoding/asn1" + "encoding/pem" "fmt" - "math/big" "net" "regexp" "strings" @@ -17,6 +15,7 @@ import ( "github.com/hashicorp/vault/helper/certutil" "github.com/hashicorp/vault/logical" + "github.com/hashicorp/vault/logical/framework" ) type certUsage int @@ -25,33 +24,106 @@ const ( serverUsage certUsage = 1 << iota clientUsage codeSigningUsage + emailProtectionUsage + caUsage ) -type certCreationBundle struct { - SigningBundle *certutil.ParsedCertBundle - CACert *x509.Certificate - CommonNames []string - IPSANs []net.IP - KeyType string - KeyBits int - TTL time.Duration - Usage certUsage +type creationBundle struct { + CommonName string + DNSNames []string + EmailAddresses []string + IPAddresses []net.IP + IsCA bool + KeyType string + KeyBits int + SigningBundle *caInfoBundle + TTL time.Duration + Usage certUsage + + // Only used when signing a CA cert + UseCSRValues bool + + // URLs to encode into the certificate + URLs *urlEntries + + // The maximum path length to encode + MaxPathLength int +} + +type caInfoBundle struct { + certutil.ParsedCertBundle + URLs *urlEntries +} + +var ( + hostnameRegex = regexp.MustCompile(`^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$`) + oidExtensionBasicConstraints = []int{2, 5, 29, 19} +) + +func oidInExtensions(oid asn1.ObjectIdentifier, extensions []pkix.Extension) bool { + for _, e := range extensions { + if e.Id.Equal(oid) { + return true + } + } + return false +} + +func getFormat(data *framework.FieldData) string { + format := data.Get("format").(string) + switch format { + case "pem": + case "der": + default: + format = "" + } + return format +} + +func validateKeyTypeLength(keyType string, keyBits int) *logical.Response { + switch keyType { + case "rsa": + switch keyBits { + case 1024: + case 2048: + case 4096: + case 8192: + default: + return logical.ErrorResponse(fmt.Sprintf( + "unsupported bit length for RSA key: %d", keyBits)) + } + case "ec": + switch keyBits { + case 224: + case 256: + case 384: + case 521: + default: + return logical.ErrorResponse(fmt.Sprintf( + "unsupported bit length for EC key: %d", keyBits)) + } + default: + return logical.ErrorResponse(fmt.Sprintf( + "unknown key type %s", keyType)) + } + + return nil } // Fetches the CA info. Unlike other certificates, the CA info is stored // in the backend as a CertBundle, because we are storing its private key -func fetchCAInfo(req *logical.Request) (*certutil.ParsedCertBundle, error) { +func fetchCAInfo(req *logical.Request) (*caInfoBundle, error) { bundleEntry, err := req.Storage.Get("config/ca_bundle") if err != nil { - return nil, certutil.InternalError{Err: fmt.Sprintf("Unable to fetch local CA certificate/key: %s", err)} + return nil, certutil.InternalError{Err: fmt.Sprintf("unable to fetch local CA certificate/key: %v", err)} } if bundleEntry == nil { - return nil, certutil.UserError{Err: fmt.Sprintf("Backend must be configured with a CA certificate/key")} + return nil, certutil.UserError{Err: "backend must be configured with a CA certificate/key"} } var bundle certutil.CertBundle if err := bundleEntry.DecodeJSON(&bundle); err != nil { - return nil, certutil.InternalError{Err: fmt.Sprintf("Unable to decode local CA certificate/key: %s", err)} + return nil, certutil.InternalError{Err: fmt.Sprintf("unable to decode local CA certificate/key: %v", err)} } parsedBundle, err := bundle.ToParsedCertBundle() @@ -60,10 +132,25 @@ func fetchCAInfo(req *logical.Request) (*certutil.ParsedCertBundle, error) { } if parsedBundle.Certificate == nil { - return nil, certutil.InternalError{Err: "Stored CA information not able to be parsed"} + return nil, certutil.InternalError{Err: "stored CA information not able to be parsed"} } - return parsedBundle, nil + caInfo := &caInfoBundle{*parsedBundle, nil} + + entries, err := getURLs(req) + if err != nil { + return nil, certutil.InternalError{Err: fmt.Sprintf("unable to fetch URL information: %v", err)} + } + if entries == nil { + entries = &urlEntries{ + IssuingCertificates: []string{}, + CRLDistributionPoints: []string{}, + OCSPServers: []string{}, + } + } + caInfo.URLs = entries + + return caInfo, nil } // Allows fetching certificates from the backend; it handles the slightly @@ -84,11 +171,11 @@ func fetchCertBySerial(req *logical.Request, prefix, serial string) (*logical.St certEntry, err := req.Storage.Get(path) if err != nil || certEntry == nil { - return nil, certutil.InternalError{Err: fmt.Sprintf("Certificate with serial number %s not found", serial)} + return nil, certutil.InternalError{Err: fmt.Sprintf("certificate with serial number %s not found", serial)} } if certEntry.Value == nil || len(certEntry.Value) == 0 { - return nil, certutil.InternalError{Err: fmt.Sprintf("Returned certificate bytes for serial %s were empty", serial)} + return nil, certutil.InternalError{Err: fmt.Sprintf("returned certificate bytes for serial %s were empty", serial)} } return certEntry, nil @@ -97,154 +184,491 @@ func fetchCertBySerial(req *logical.Request, prefix, serial string) (*logical.St // Given a set of requested names for a certificate, verifies that all of them // match the various toggles set in the role for controlling issuance. // If one does not pass, it is returned in the string argument. -func validateCommonNames(req *logical.Request, commonNames []string, role *roleEntry) (string, error) { - hostnameRegex, err := regexp.Compile(`^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$`) - if err != nil { - return "", fmt.Errorf("Error compiling hostname regex: %s", err) - } - subdomainRegex, err := regexp.Compile(`^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9]))*$`) - if err != nil { - return "", fmt.Errorf("Error compiling subdomain regex: %s", err) - } - for _, name := range commonNames { - if role.AllowLocalhost && name == "localhost" { - continue +func validateNames(req *logical.Request, names []string, role *roleEntry) (string, error) { + for _, name := range names { + sanitizedName := name + emailDomain := name + isEmail := false + isWildcard := false + + // If it has an @, assume it is an email address and separate out the + // user from the hostname portion so that we can act on the hostname. + // Note that this matches behavior from the alt_names parameter. If it + // ends up being problematic for users, I guess that could be separated + // into dns_names and email_names in the future to be explicit, but I + // don't think this is likely. + if strings.Contains(name, "@") { + splitEmail := strings.Split(name, "@") + if len(splitEmail) != 2 { + return name, nil + } + sanitizedName = splitEmail[1] + emailDomain = splitEmail[1] + isEmail = true } - sanitizedName := name - isWildcard := false - if strings.HasPrefix(name, "*.") { - sanitizedName = name[2:] + // If we have an asterisk as the first part of the domain name, mark it + // as wildcard and set the sanitized name to the remainder of the + // domain + if strings.HasPrefix(sanitizedName, "*.") { + sanitizedName = sanitizedName[2:] isWildcard = true } + // Email addresses using wildcard domain names do not make sense + if isEmail && isWildcard { + return name, nil + } + + // AllowAnyName is checked after this because EnforceHostnames still + // applies when allowing any name. Also, we check the sanitized name to + // ensure that we are not either checking a full email address or a + // wildcard prefix. if role.EnforceHostnames { if !hostnameRegex.MatchString(sanitizedName) { return name, nil } } + // Self-explanatory if role.AllowAnyName { continue } + // The following blocks all work the same basic way: + // 1) If a role allows a certain class of base (localhost, token + // display name, role-configured domains), perform further tests + // + // 2) If there is a perfect match on either the name itself or it's an + // email address with a perfect match on the hostname portion, allow it + // + // 3) If subdomains are allowed, we check based on the sanitized name; + // note that if not a wildcard, will be equivalent to the email domain + // for email checks, and we already checked above for both a wildcard + // and email address being present in the same name + // 3a) First we check for a non-wildcard subdomain, as in . + // 3b) Then we check if it's a wildcard and the base domain is a match + // + // Variances are noted in-line + + if role.AllowLocalhost { + if name == "localhost" || + name == "localdomain" || + (isEmail && emailDomain == "localhost") || + (isEmail && emailDomain == "localdomain") { + continue + } + + if role.AllowSubdomains { + // It is possible, if unlikely, to have a subdomain of "localhost" + if strings.HasSuffix(sanitizedName, ".localhost") || + (isWildcard && sanitizedName == "localhost") { + continue + } + + // A subdomain of "localdomain" is also not entirely uncommon + if strings.HasSuffix(sanitizedName, ".localdomain") || + (isWildcard && sanitizedName == "localdomain") { + continue + } + } + } + if role.AllowTokenDisplayName { if name == req.DisplayName { continue } if role.AllowSubdomains { - if strings.HasSuffix(name, "."+req.DisplayName) { + if isEmail { + // If it's an email address, we need to parse the token + // display name in order to do a proper comparison of the + // subdomain + if strings.Contains(req.DisplayName, "@") { + splitDisplay := strings.Split(req.DisplayName, "@") + if len(splitDisplay) == 2 { + // Compare the sanitized name against the hostname + // portion of the email address in the roken + // display name + if strings.HasSuffix(sanitizedName, "."+splitDisplay[1]) { + continue + } + } + } + } + + if strings.HasSuffix(sanitizedName, "."+req.DisplayName) || + (isWildcard && sanitizedName == req.DisplayName) { continue } } } - if len(role.AllowedBaseDomain) != 0 { - if strings.HasSuffix(name, "."+role.AllowedBaseDomain) { + if role.AllowedDomains != "" { + valid := false + for _, currDomain := range strings.Split(role.AllowedDomains, ",") { + // If there is, say, a trailing comma, ignore it + if currDomain == "" { + continue + } + + // First, allow an exact match of the base domain if that role flag + // is enabled + if role.AllowBareDomains && + (name == currDomain || + (isEmail && emailDomain == currDomain)) { + valid = true + break + } + if role.AllowSubdomains { - continue - } - - if subdomainRegex.MatchString(strings.TrimSuffix(name, "."+role.AllowedBaseDomain)) { - continue - } - - if isWildcard && role.AllowedBaseDomain == sanitizedName { - continue + if strings.HasSuffix(sanitizedName, "."+currDomain) || + (isWildcard && sanitizedName == currDomain) { + valid = true + break + } } } + if valid { + continue + } } + //panic(fmt.Sprintf("\nName is %s\nRole is\n%#v\n", name, role)) return name, nil } return "", nil } -// Performs the heavy lifting of creating a certificate. Returns -// a fully-filled-in ParsedCertBundle. -func createCertificate(creationInfo *certCreationBundle) (*certutil.ParsedCertBundle, error) { - var clientPrivKey crypto.Signer +func generateCert(b *backend, + role *roleEntry, + signingBundle *caInfoBundle, + isCA bool, + req *logical.Request, + data *framework.FieldData) (*certutil.ParsedCertBundle, error) { + + creationBundle, err := generateCreationBundle(b, role, signingBundle, nil, req, data) + if err != nil { + return nil, err + } + + if isCA { + creationBundle.IsCA = isCA + + if signingBundle == nil { + // Generating a self-signed root certificate + entries, err := getURLs(req) + if err != nil { + return nil, certutil.InternalError{Err: fmt.Sprintf("unable to fetch URL information: %v", err)} + } + if entries == nil { + entries = &urlEntries{ + IssuingCertificates: []string{}, + CRLDistributionPoints: []string{}, + OCSPServers: []string{}, + } + } + creationBundle.URLs = entries + + if role.MaxPathLength == nil { + creationBundle.MaxPathLength = -1 + } else { + creationBundle.MaxPathLength = *role.MaxPathLength + } + } + } + + parsedBundle, err := createCertificate(creationBundle) + if err != nil { + return nil, err + } + + return parsedBundle, nil +} + +// N.B.: This is only meant to be used for generating intermediate CAs. +// It skips some sanity checks. +func generateIntermediateCSR(b *backend, + role *roleEntry, + signingBundle *caInfoBundle, + req *logical.Request, + data *framework.FieldData) (*certutil.ParsedCSRBundle, error) { + + creationBundle, err := generateCreationBundle(b, role, signingBundle, nil, req, data) + if err != nil { + return nil, err + } + + parsedBundle, err := createCSR(creationBundle) + if err != nil { + return nil, err + } + + return parsedBundle, nil +} + +func signCert(b *backend, + role *roleEntry, + signingBundle *caInfoBundle, + isCA bool, + useCSRValues bool, + req *logical.Request, + data *framework.FieldData) (*certutil.ParsedCertBundle, error) { + + csrString := data.Get("csr").(string) + if csrString == "" { + return nil, certutil.UserError{Err: fmt.Sprintf("\"csr\" is empty")} + } + + pemBytes := []byte(csrString) + pemBlock, pemBytes := pem.Decode(pemBytes) + if pemBlock == nil { + return nil, certutil.UserError{Err: "csr contains no data"} + } + csr, err := x509.ParseCertificateRequest(pemBlock.Bytes) + if err != nil { + return nil, certutil.UserError{Err: "certificate request could not be parsed"} + } + + creationBundle, err := generateCreationBundle(b, role, signingBundle, csr, req, data) + if err != nil { + return nil, err + } + + if useCSRValues && !isCA { + return nil, certutil.UserError{Err: "cannot use CSR values with a non-CA certificate"} + } + + creationBundle.IsCA = isCA + creationBundle.UseCSRValues = useCSRValues + + parsedBundle, err := signCertificate(creationBundle, csr) + if err != nil { + return nil, err + } + + return parsedBundle, nil +} + +// generateCreationBundle is a shared function that reads parameters supplied +// from the various endpoints and generates a creationBundle with the +// parameters that can be used to issue or sign +func generateCreationBundle(b *backend, + role *roleEntry, + signingBundle *caInfoBundle, + csr *x509.CertificateRequest, + req *logical.Request, + data *framework.FieldData) (*creationBundle, error) { var err error - result := &certutil.ParsedCertBundle{} + var ok bool - var serialNumber *big.Int - serialNumber, err = rand.Int(rand.Reader, (&big.Int{}).Exp(big.NewInt(2), big.NewInt(159), nil)) - if err != nil { - return nil, certutil.InternalError{Err: fmt.Sprintf("Error getting random serial number")} + // Get the common name + var cn string + { + if csr != nil { + if role.UseCSRCommonName { + cn = csr.Subject.CommonName + } + } + if cn == "" { + cn = data.Get("common_name").(string) + if cn == "" { + return nil, certutil.UserError{Err: `the common_name field is required, or must be provided in a CSR with "use_csr_common_name" set to true`} + } + } } - switch creationInfo.KeyType { - case "rsa": - result.PrivateKeyType = certutil.RSAPrivateKey - clientPrivKey, err = rsa.GenerateKey(rand.Reader, creationInfo.KeyBits) - if err != nil { - return nil, certutil.InternalError{Err: fmt.Sprintf("Error generating RSA private key")} + // Read in alternate names -- DNS and email addresses + dnsNames := []string{} + emailAddresses := []string{} + { + if strings.Contains(cn, "@") { + // Note: emails are not disallowed if the role's email protection + // flag is false, because they may well be included for + // informational purposes; it is up to the verifying party to + // ensure that email addresses in a subject alternate name can be + // used for the purpose for which they are presented + emailAddresses = append(emailAddresses, cn) + } else { + dnsNames = append(dnsNames, cn) } - result.PrivateKey = clientPrivKey - result.PrivateKeyBytes = x509.MarshalPKCS1PrivateKey(clientPrivKey.(*rsa.PrivateKey)) - case "ec": - result.PrivateKeyType = certutil.ECPrivateKey - var curve elliptic.Curve - switch creationInfo.KeyBits { - case 224: - curve = elliptic.P224() - case 256: - curve = elliptic.P256() - case 384: - curve = elliptic.P384() - case 521: - curve = elliptic.P521() + cnAltInt, ok := data.GetOk("alt_names") + if ok { + cnAlt := cnAltInt.(string) + if len(cnAlt) != 0 { + for _, v := range strings.Split(cnAlt, ",") { + if strings.Contains(v, "@") { + emailAddresses = append(emailAddresses, cn) + } else { + dnsNames = append(dnsNames, v) + } + } + } + } + + // Check for bad email and/or DNS names + badName, err := validateNames(req, dnsNames, role) + if len(badName) != 0 { + return nil, certutil.UserError{Err: fmt.Sprintf( + "name %s not allowed by this role", badName)} + } else if err != nil { + return nil, certutil.InternalError{Err: fmt.Sprintf( + "error validating name %s: %s", badName, err)} + } + + badName, err = validateNames(req, emailAddresses, role) + if len(badName) != 0 { + return nil, certutil.UserError{Err: fmt.Sprintf( + "email %s not allowed by this role", badName)} + } else if err != nil { + return nil, certutil.InternalError{Err: fmt.Sprintf( + "error validating name %s: %s", badName, err)} + } + } + + // Get and verify any IP SANs + ipAddresses := []net.IP{} + var ipAltInt interface{} + { + ipAltInt, ok = data.GetOk("ip_sans") + if ok { + ipAlt := ipAltInt.(string) + if len(ipAlt) != 0 { + if !role.AllowIPSANs { + return nil, certutil.UserError{Err: fmt.Sprintf( + "IP Subject Alternative Names are not allowed in this role, but was provided %s", ipAlt)} + } + for _, v := range strings.Split(ipAlt, ",") { + parsedIP := net.ParseIP(v) + if parsedIP == nil { + return nil, certutil.UserError{Err: fmt.Sprintf( + "the value '%s' is not a valid IP address", v)} + } + ipAddresses = append(ipAddresses, parsedIP) + } + } + } + } + + // Get the TTL and very it against the max allowed + var ttlField string + var ttl time.Duration + var maxTTL time.Duration + var ttlFieldInt interface{} + { + ttlFieldInt, ok = data.GetOk("ttl") + if !ok { + ttlField = role.TTL + } else { + ttlField = ttlFieldInt.(string) + } + + if len(ttlField) == 0 { + ttl = b.System().DefaultLeaseTTL() + } else { + ttl, err = time.ParseDuration(ttlField) + if err != nil { + return nil, certutil.UserError{Err: fmt.Sprintf( + "invalid requested ttl: %s", err)} + } + } + + if len(role.MaxTTL) == 0 { + maxTTL = b.System().MaxLeaseTTL() + } else { + maxTTL, err = time.ParseDuration(role.MaxTTL) + if err != nil { + return nil, certutil.UserError{Err: fmt.Sprintf( + "invalid ttl: %s", err)} + } + } + + if ttl > maxTTL { + // Don't error if they were using system defaults, only error if + // they specifically chose a bad TTL + if len(ttlField) == 0 { + ttl = maxTTL + } else { + return nil, certutil.UserError{Err: fmt.Sprintf( + "ttl is larger than maximum allowed (%d)", maxTTL/time.Second)} + } + } + + // If it's not self-signed, verify that the issued certificate won't be + // valid past the lifetime of the CA certificate + if signingBundle != nil && + time.Now().Add(ttl).After(signingBundle.Certificate.NotAfter) { + return nil, certutil.UserError{Err: fmt.Sprintf( + "cannot satisfy request, as TTL is beyond the expiration of the CA certificate")} + } + } + + // Build up usages + var usage certUsage + { + if role.ServerFlag { + usage = usage | serverUsage + } + if role.ClientFlag { + usage = usage | clientUsage + } + if role.CodeSigningFlag { + usage = usage | codeSigningUsage + } + if role.EmailProtectionFlag { + usage = usage | emailProtectionUsage + } + } + + creationBundle := &creationBundle{ + CommonName: cn, + DNSNames: dnsNames, + EmailAddresses: emailAddresses, + IPAddresses: ipAddresses, + KeyType: role.KeyType, + KeyBits: role.KeyBits, + SigningBundle: signingBundle, + TTL: ttl, + Usage: usage, + } + + // Don't deal with URLs or max path length if it's self-signed, as these + // normally come from the signing bundle + if signingBundle == nil { + return creationBundle, nil + } + + // This will have been read in from the getURLs function + creationBundle.URLs = signingBundle.URLs + + // If the max path length in the role is not nil, it was specified at + // generation time with the max_path_length parameter; otherwise derive it + // from the signing certificate + if role.MaxPathLength != nil { + creationBundle.MaxPathLength = *role.MaxPathLength + } else { + switch { + case signingBundle.Certificate.MaxPathLen < 0: + creationBundle.MaxPathLength = -1 + case signingBundle.Certificate.MaxPathLen == 0 && + signingBundle.Certificate.MaxPathLenZero: + // The signing function will ensure that we do not issue a CA cert + creationBundle.MaxPathLength = 0 default: - return nil, certutil.UserError{Err: fmt.Sprintf("Unsupported bit length for EC key: %d", creationInfo.KeyBits)} + // If this takes it to zero, we handle this case later if + // necessary + creationBundle.MaxPathLength = signingBundle.Certificate.MaxPathLen - 1 } - clientPrivKey, err = ecdsa.GenerateKey(curve, rand.Reader) - if err != nil { - return nil, certutil.InternalError{Err: fmt.Sprintf("Error generating EC private key")} - } - result.PrivateKey = clientPrivKey - result.PrivateKeyBytes, err = x509.MarshalECPrivateKey(clientPrivKey.(*ecdsa.PrivateKey)) - if err != nil { - return nil, certutil.InternalError{Err: fmt.Sprintf("Error marshalling EC private key")} - } - default: - return nil, certutil.UserError{Err: fmt.Sprintf("Unknown key type: %s", creationInfo.KeyType)} } - subjKeyID, err := certutil.GetSubjKeyID(result.PrivateKey) - if err != nil { - return nil, certutil.InternalError{Err: fmt.Sprintf("Error getting subject key ID: %s", err)} - } + return creationBundle, nil +} - subject := pkix.Name{ - Country: creationInfo.CACert.Subject.Country, - Organization: creationInfo.CACert.Subject.Organization, - OrganizationalUnit: creationInfo.CACert.Subject.OrganizationalUnit, - Locality: creationInfo.CACert.Subject.Locality, - Province: creationInfo.CACert.Subject.Province, - StreetAddress: creationInfo.CACert.Subject.StreetAddress, - PostalCode: creationInfo.CACert.Subject.PostalCode, - SerialNumber: serialNumber.String(), - CommonName: creationInfo.CommonNames[0], - } - - certTemplate := &x509.Certificate{ - SignatureAlgorithm: x509.SHA256WithRSA, - SerialNumber: serialNumber, - Subject: subject, - NotBefore: time.Now(), - NotAfter: time.Now().Add(creationInfo.TTL), - KeyUsage: x509.KeyUsage(x509.KeyUsageDigitalSignature | x509.KeyUsageKeyEncipherment | x509.KeyUsageKeyAgreement), - BasicConstraintsValid: true, - IsCA: false, - SubjectKeyId: subjKeyID, - DNSNames: creationInfo.CommonNames, - IPAddresses: creationInfo.IPSANs, - PermittedDNSDomainsCritical: false, - PermittedDNSDomains: nil, - CRLDistributionPoints: creationInfo.CACert.CRLDistributionPoints, - } +// addKeyUsages adds approrpiate key usages to the template given the creation +// information +func addKeyUsages(creationInfo *creationBundle, certTemplate *x509.Certificate) { + certTemplate.KeyUsage = x509.KeyUsage(x509.KeyUsageDigitalSignature | x509.KeyUsageKeyEncipherment | x509.KeyUsageKeyAgreement) if creationInfo.Usage&serverUsage != 0 { certTemplate.ExtKeyUsage = append(certTemplate.ExtKeyUsage, x509.ExtKeyUsageServerAuth) @@ -255,16 +679,263 @@ func createCertificate(creationInfo *certCreationBundle) (*certutil.ParsedCertBu if creationInfo.Usage&codeSigningUsage != 0 { certTemplate.ExtKeyUsage = append(certTemplate.ExtKeyUsage, x509.ExtKeyUsageCodeSigning) } - - cert, err := x509.CreateCertificate(rand.Reader, certTemplate, creationInfo.CACert, clientPrivKey.Public(), creationInfo.SigningBundle.PrivateKey) - if err != nil { - return nil, certutil.InternalError{Err: fmt.Sprintf("Unable to create certificate: %s", err)} + if creationInfo.Usage&emailProtectionUsage != 0 { + certTemplate.ExtKeyUsage = append(certTemplate.ExtKeyUsage, x509.ExtKeyUsageEmailProtection) } - result.CertificateBytes = cert - result.Certificate, err = x509.ParseCertificate(cert) + if creationInfo.IsCA { + // Go performs validation not according to spec but according to the Windows + // Crypto API, so we add all usages to CA certs + certTemplate.KeyUsage = x509.KeyUsage(certTemplate.KeyUsage | x509.KeyUsageCertSign | x509.KeyUsageCRLSign) + certTemplate.ExtKeyUsage = []x509.ExtKeyUsage{x509.ExtKeyUsageAny} + } +} + +// Performs the heavy lifting of creating a certificate. Returns +// a fully-filled-in ParsedCertBundle. +func createCertificate(creationInfo *creationBundle) (*certutil.ParsedCertBundle, error) { + var err error + result := &certutil.ParsedCertBundle{} + + serialNumber, err := certutil.GenerateSerialNumber() if err != nil { - return nil, certutil.InternalError{Err: fmt.Sprintf("Unable to parse created certificate: %s", err)} + return nil, err + } + + if err := certutil.GeneratePrivateKey(creationInfo.KeyType, + creationInfo.KeyBits, + result); err != nil { + return nil, err + } + + subjKeyID, err := certutil.GetSubjKeyID(result.PrivateKey) + if err != nil { + return nil, certutil.InternalError{Err: fmt.Sprintf("error getting subject key ID: %s", err)} + } + + subject := pkix.Name{ + CommonName: creationInfo.CommonName, + } + + certTemplate := &x509.Certificate{ + SerialNumber: serialNumber, + Subject: subject, + NotBefore: time.Now(), + NotAfter: time.Now().Add(creationInfo.TTL), + IsCA: false, + SubjectKeyId: subjKeyID, + DNSNames: creationInfo.DNSNames, + EmailAddresses: creationInfo.EmailAddresses, + IPAddresses: creationInfo.IPAddresses, + } + + // Add this before calling addKeyUsages + if creationInfo.SigningBundle == nil { + certTemplate.IsCA = true + } + + addKeyUsages(creationInfo, certTemplate) + + certTemplate.IssuingCertificateURL = creationInfo.URLs.IssuingCertificates + certTemplate.CRLDistributionPoints = creationInfo.URLs.CRLDistributionPoints + certTemplate.OCSPServer = creationInfo.URLs.OCSPServers + + var certBytes []byte + if creationInfo.SigningBundle != nil { + switch creationInfo.SigningBundle.PrivateKeyType { + case certutil.RSAPrivateKey: + certTemplate.SignatureAlgorithm = x509.SHA256WithRSA + case certutil.ECPrivateKey: + certTemplate.SignatureAlgorithm = x509.ECDSAWithSHA256 + } + + caCert := creationInfo.SigningBundle.Certificate + + certBytes, err = x509.CreateCertificate(rand.Reader, certTemplate, caCert, result.PrivateKey.Public(), creationInfo.SigningBundle.PrivateKey) + } else { + // Creating a self-signed root + if creationInfo.MaxPathLength == 0 { + certTemplate.MaxPathLen = 0 + certTemplate.MaxPathLenZero = true + } else { + certTemplate.MaxPathLen = creationInfo.MaxPathLength + } + + switch creationInfo.KeyType { + case "rsa": + certTemplate.SignatureAlgorithm = x509.SHA256WithRSA + case "ec": + certTemplate.SignatureAlgorithm = x509.ECDSAWithSHA256 + } + + certTemplate.BasicConstraintsValid = true + certBytes, err = x509.CreateCertificate(rand.Reader, certTemplate, certTemplate, result.PrivateKey.Public(), result.PrivateKey) + } + + if err != nil { + return nil, certutil.InternalError{Err: fmt.Sprintf("unable to create certificate: %s", err)} + } + + result.CertificateBytes = certBytes + result.Certificate, err = x509.ParseCertificate(certBytes) + if err != nil { + return nil, certutil.InternalError{Err: fmt.Sprintf("unable to parse created certificate: %s", err)} + } + + if creationInfo.SigningBundle != nil { + result.IssuingCABytes = creationInfo.SigningBundle.CertificateBytes + result.IssuingCA = creationInfo.SigningBundle.Certificate + } else { + result.IssuingCABytes = result.CertificateBytes + result.IssuingCA = result.Certificate + } + + return result, nil +} + +// Creates a CSR. This is currently only meant for use when +// generating an intermediate certificate. +func createCSR(creationInfo *creationBundle) (*certutil.ParsedCSRBundle, error) { + var err error + result := &certutil.ParsedCSRBundle{} + + if err := certutil.GeneratePrivateKey(creationInfo.KeyType, + creationInfo.KeyBits, + result); err != nil { + return nil, err + } + + // Like many root CAs, other information is ignored + subject := pkix.Name{ + CommonName: creationInfo.CommonName, + } + + csrTemplate := &x509.CertificateRequest{ + Subject: subject, + DNSNames: creationInfo.DNSNames, + EmailAddresses: creationInfo.EmailAddresses, + IPAddresses: creationInfo.IPAddresses, + } + + switch creationInfo.KeyType { + case "rsa": + csrTemplate.SignatureAlgorithm = x509.SHA256WithRSA + case "ec": + csrTemplate.SignatureAlgorithm = x509.ECDSAWithSHA256 + } + + csr, err := x509.CreateCertificateRequest(rand.Reader, csrTemplate, result.PrivateKey) + if err != nil { + return nil, certutil.InternalError{Err: fmt.Sprintf("unable to create certificate: %s", err)} + } + + result.CSRBytes = csr + result.CSR, err = x509.ParseCertificateRequest(csr) + if err != nil { + return nil, certutil.InternalError{Err: fmt.Sprintf("unable to parse created certificate: %s", err)} + } + + return result, nil +} + +// Performs the heavy lifting of generating a certificate from a CSR. +// Returns a ParsedCertBundle sans private keys. +func signCertificate(creationInfo *creationBundle, + csr *x509.CertificateRequest) (*certutil.ParsedCertBundle, error) { + switch { + case creationInfo == nil: + return nil, certutil.UserError{Err: "nil creation info given to signCertificate"} + case creationInfo.SigningBundle == nil: + return nil, certutil.UserError{Err: "nil signing bundle given to signCertificate"} + case csr == nil: + return nil, certutil.UserError{Err: "nil csr given to signCertificate"} + } + + err := csr.CheckSignature() + if err != nil { + return nil, certutil.UserError{Err: "request signature invalid"} + } + + result := &certutil.ParsedCertBundle{} + + serialNumber, err := certutil.GenerateSerialNumber() + if err != nil { + return nil, err + } + + marshaledKey, err := x509.MarshalPKIXPublicKey(csr.PublicKey) + if err != nil { + return nil, certutil.InternalError{Err: fmt.Sprintf("error marshalling public key: %s", err)} + } + subjKeyID := sha1.Sum(marshaledKey) + + subject := pkix.Name{ + CommonName: creationInfo.CommonName, + } + + certTemplate := &x509.Certificate{ + SerialNumber: serialNumber, + Subject: subject, + NotBefore: time.Now(), + NotAfter: time.Now().Add(creationInfo.TTL), + SubjectKeyId: subjKeyID[:], + } + + switch creationInfo.SigningBundle.PrivateKeyType { + case certutil.RSAPrivateKey: + certTemplate.SignatureAlgorithm = x509.SHA256WithRSA + case certutil.ECPrivateKey: + certTemplate.SignatureAlgorithm = x509.ECDSAWithSHA256 + } + + if creationInfo.UseCSRValues { + certTemplate.Subject = csr.Subject + + certTemplate.DNSNames = csr.DNSNames + certTemplate.EmailAddresses = csr.EmailAddresses + certTemplate.IPAddresses = csr.IPAddresses + + certTemplate.ExtraExtensions = csr.Extensions + } else { + certTemplate.DNSNames = creationInfo.DNSNames + certTemplate.EmailAddresses = creationInfo.EmailAddresses + certTemplate.IPAddresses = creationInfo.IPAddresses + } + + addKeyUsages(creationInfo, certTemplate) + + var certBytes []byte + caCert := creationInfo.SigningBundle.Certificate + + certTemplate.IssuingCertificateURL = creationInfo.URLs.IssuingCertificates + certTemplate.CRLDistributionPoints = creationInfo.URLs.CRLDistributionPoints + certTemplate.OCSPServer = creationInfo.SigningBundle.URLs.OCSPServers + + if creationInfo.IsCA { + certTemplate.BasicConstraintsValid = true + certTemplate.IsCA = true + + if creationInfo.SigningBundle.Certificate.MaxPathLen == 0 && + creationInfo.SigningBundle.Certificate.MaxPathLenZero { + return nil, certutil.UserError{Err: "signing certificate has a max path length of zero, and cannot issue further CA certificates"} + } + + certTemplate.MaxPathLen = creationInfo.MaxPathLength + if certTemplate.MaxPathLen == 0 { + certTemplate.MaxPathLenZero = true + } + } + + certBytes, err = x509.CreateCertificate(rand.Reader, certTemplate, caCert, csr.PublicKey, creationInfo.SigningBundle.PrivateKey) + + if err != nil { + return nil, certutil.InternalError{Err: fmt.Sprintf("unable to create certificate: %s", err)} + } + + result.CertificateBytes = certBytes + result.Certificate, err = x509.ParseCertificate(certBytes) + if err != nil { + return nil, certutil.InternalError{Err: fmt.Sprintf("unable to parse created certificate: %s", err)} } result.IssuingCABytes = creationInfo.SigningBundle.CertificateBytes diff --git a/builtin/logical/pki/fields.go b/builtin/logical/pki/fields.go new file mode 100644 index 000000000..cef49144e --- /dev/null +++ b/builtin/logical/pki/fields.go @@ -0,0 +1,138 @@ +package pki + +import "github.com/hashicorp/vault/logical/framework" + +// addIssueAndSignCommonFields adds fields common to both CA and non-CA issuing +// and signing +func addIssueAndSignCommonFields(fields map[string]*framework.FieldSchema) map[string]*framework.FieldSchema { + fields["format"] = &framework.FieldSchema{ + Type: framework.TypeString, + Default: "pem", + Description: `Format for returned data. Can be "pem" or "der"; +defaults to "pem".`, + } + + fields["ip_sans"] = &framework.FieldSchema{ + Type: framework.TypeString, + Description: `The requested IP SANs, if any, in a +comma-delimited list`, + } + + return fields +} + +// addNonCACommonFields adds fields with help text specific to non-CA +// certificate issuing and signing +func addNonCACommonFields(fields map[string]*framework.FieldSchema) map[string]*framework.FieldSchema { + fields = addIssueAndSignCommonFields(fields) + + fields["role"] = &framework.FieldSchema{ + Type: framework.TypeString, + Description: `The desired role with configuration for this +request`, + } + + fields["common_name"] = &framework.FieldSchema{ + Type: framework.TypeString, + Description: `The requested common name; if you want more than +one, specify the alternative names in the +alt_names map. If email protection is enabled +in the role, this may be an email address.`, + } + + fields["alt_names"] = &framework.FieldSchema{ + Type: framework.TypeString, + Description: `The requested Subject Alternative Names, if any, +in a comma-delimited list. If email protection +is enabled for the role, this may contain +email addresses.`, + } + + fields["ttl"] = &framework.FieldSchema{ + Type: framework.TypeString, + Description: `The requested Time To Live for the certificate; +sets the expiration date. If not specified +the role default, backend default, or system +default TTL is used, in that order. Cannot +be later than the role max TTL.`, + } + + return fields +} + +// addCACommonFields adds fields with help text specific to CA +// certificate issuing and signing +func addCACommonFields(fields map[string]*framework.FieldSchema) map[string]*framework.FieldSchema { + fields = addIssueAndSignCommonFields(fields) + + fields["alt_names"] = &framework.FieldSchema{ + Type: framework.TypeString, + Description: `The requested Subject Alternative Names, if any, +in a comma-delimited list. May contain both +DNS names and email addresses.`, + } + + fields["common_name"] = &framework.FieldSchema{ + Type: framework.TypeString, + Description: `The requested common name; if you want more than +one, specify the alternative names in the alt_names +map. If not specified when signing, the common +name will be taken from the CSR; other names +must still be specified in alt_names or ip_sans.`, + } + + fields["ttl"] = &framework.FieldSchema{ + Type: framework.TypeString, + Description: `The requested Time To Live for the certificate; +sets the expiration date. If not specified +the role default, backend default, or system +default TTL is used, in that order. Cannot +be larger than the mount max TTL. Note: +this only has an effect when generating +a CA cert or signing a CA cert, not when +generating a CSR for an intermediate CA.`, + } + + return fields +} + +// addCAKeyGenerationFields adds fields with help text specific to CA key +// generation and exporting +func addCAKeyGenerationFields(fields map[string]*framework.FieldSchema) map[string]*framework.FieldSchema { + fields["exported"] = &framework.FieldSchema{ + Type: framework.TypeString, + Description: `Must be "internal" or "exported". If set to +"exported", the generated private key will be +returned. This is your *only* chance to retrieve +the private key!`, + } + + fields["key_bits"] = &framework.FieldSchema{ + Type: framework.TypeInt, + Default: 2048, + Description: `The number of bits to use. You will almost +certainly want to change this if you adjust +the key_type.`, + } + + fields["key_type"] = &framework.FieldSchema{ + Type: framework.TypeString, + Default: "rsa", + Description: `The type of key to use; defaults to RSA. "rsa" +and "ec" are the only valid values.`, + } + + return fields +} + +// addCAIssueFields adds fields common to CA issuing, e.g. when returning +// an actual certificate +func addCAIssueFields(fields map[string]*framework.FieldSchema) map[string]*framework.FieldSchema { + fields["max_path_length"] = &framework.FieldSchema{ + Type: framework.TypeInt, + Default: -1, + Description: "The maximum allowable path length", + } + + return fields +} diff --git a/builtin/logical/pki/path_config_ca.go b/builtin/logical/pki/path_config_ca.go index a21b1991a..586c321e6 100644 --- a/builtin/logical/pki/path_config_ca.go +++ b/builtin/logical/pki/path_config_ca.go @@ -14,8 +14,10 @@ func pathConfigCA(b *backend) *framework.Path { Fields: map[string]*framework.FieldSchema{ "pem_bundle": &framework.FieldSchema{ Type: framework.TypeString, - Description: `PEM-format, concatenated unencrypted secret key -and certificate`, + Description: `PEM-format, concatenated unencrypted +secret key and certificate, or, if a +CSR was generated with the "generate" +endpoint, just the signed certificate.`, }, }, @@ -29,8 +31,8 @@ and certificate`, } func (b *backend) pathCAWrite( - req *logical.Request, d *framework.FieldData) (*logical.Response, error) { - pemBundle := d.Get("pem_bundle").(string) + req *logical.Request, data *framework.FieldData) (*logical.Response, error) { + pemBundle := data.Get("pem_bundle").(string) parsedBundle, err := certutil.ParsePEMBundle(pemBundle) if err != nil { @@ -42,27 +44,39 @@ func (b *backend) pathCAWrite( } } - // Handle the case of a self-signed certificate - if parsedBundle.Certificate == nil && parsedBundle.IssuingCA != nil { + if parsedBundle.PrivateKey == nil || + parsedBundle.PrivateKeyType == certutil.UnknownPrivateKey { + return logical.ErrorResponse("private key not found in the PEM bundle"), nil + } + + // Handle the case of a self-signed certificate; the parsing function will + // see the CA and put it into the issuer + if parsedBundle.Certificate == nil && + parsedBundle.IssuingCA != nil { + equal, err := certutil.ComparePublicKeys(parsedBundle.IssuingCA.PublicKey, parsedBundle.PrivateKey.Public()) + if err != nil { + return logical.ErrorResponse(fmt.Sprintf( + "got only a CA and private key but could not verify the public keys match: %v", err)), nil + } + if !equal { + return logical.ErrorResponse( + "got only a CA and private key but keys do not match"), nil + } parsedBundle.Certificate = parsedBundle.IssuingCA parsedBundle.CertificateBytes = parsedBundle.IssuingCABytes } - // TODO?: CRLs can only be generated with RSA keys right now, in the - // Go standard library. The plubming is here to support non-RSA keys - // if the library gets support - - if parsedBundle.PrivateKeyType != certutil.RSAPrivateKey { - return logical.ErrorResponse("Currently, only RSA keys are supported for the CA certificate"), nil + if parsedBundle.Certificate == nil { + return logical.ErrorResponse("no certificate found in the PEM bundle"), nil } if !parsedBundle.Certificate.IsCA { - return logical.ErrorResponse("The given certificate is not marked for CA use and cannot be used with this backend"), nil + return logical.ErrorResponse("the given certificate is not marked for CA use and cannot be used with this backend"), nil } cb, err := parsedBundle.ToCertBundle() if err != nil { - return nil, fmt.Errorf("Error converting raw values into cert bundle: %s", err) + return nil, fmt.Errorf("error converting raw values into cert bundle: %s", err) } entry, err := logical.StorageEntryJSON("config/ca_bundle", cb) @@ -75,7 +89,7 @@ func (b *backend) pathCAWrite( } // For ease of later use, also store just the certificate at a known - // location, plus a blank CRL + // location, plus a fresh CRL entry.Key = "ca" entry.Value = parsedBundle.CertificateBytes err = req.Storage.Put(entry) @@ -83,24 +97,53 @@ func (b *backend) pathCAWrite( return nil, err } - entry.Key = "crl" - entry.Value = []byte{} - err = req.Storage.Put(entry) - if err != nil { - return nil, err - } + err = buildCRL(b, req) - return nil, nil + return nil, err } const pathConfigCAHelpSyn = ` -Configure the CA certificate and private key used for generated credentials. +Set the CA certificate and private key used for generated credentials. ` const pathConfigCAHelpDesc = ` -This configures the CA information used for credentials -generated by this backend. This must be a PEM-format, concatenated -unencrypted secret key and certificate. +This sets the CA information used for credentials generated by this +by this mount. This must be a PEM-format, concatenated unencrypted +secret key and certificate. -For security reasons, you can only view the certificate when reading this endpoint. +For security reasons, the secret key cannot be retrieved later. +` + +const pathConfigCAGenerateHelpSyn = ` +Generate a new CA certificate and private key used for signing. +` + +const pathConfigCAGenerateHelpDesc = ` +This path generates a CA certificate and private key to be used for +credentials generated by this mount. The path can either +end in "internal" or "exported"; this controls whether the +unencrypted private key is exported after generation. This will +be your only chance to export the private key; for security reasons +it cannot be read or exported later. + +If the "type" option is set to "self-signed", the generated +certificate will be a self-signed root CA. Otherwise, this mount +will act as an intermediate CA; a CSR will be returned, to be signed +by your chosen CA (which could be another mount of this backend). +Note that the CRL path will be set to this mount's CRL path; if you +need further customization it is recommended that you create a CSR +separately and get it signed. Either way, use the "config/ca/set" +endpoint to load the signed certificate into Vault. +` + +const pathConfigCASignHelpSyn = ` +Generate a signed CA certificate from a CSR. +` + +const pathConfigCASignHelpDesc = ` +This path generates a CA certificate to be used for credentials +generated by the certificate's destination mount. + +Use the "config/ca/set" endpoint to load the signed certificate +into Vault another Vault mount. ` diff --git a/builtin/logical/pki/path_config_crl.go b/builtin/logical/pki/path_config_crl.go index 616864ec2..72de0e78c 100644 --- a/builtin/logical/pki/path_config_crl.go +++ b/builtin/logical/pki/path_config_crl.go @@ -4,7 +4,6 @@ import ( "fmt" "time" - "github.com/fatih/structs" "github.com/hashicorp/vault/logical" "github.com/hashicorp/vault/logical/framework" ) @@ -64,7 +63,9 @@ func (b *backend) pathCRLRead( } return &logical.Response{ - Data: structs.New(config).Map(), + Data: map[string]interface{}{ + "expiry": config.Expiry, + }, }, nil } diff --git a/builtin/logical/pki/path_config_urls.go b/builtin/logical/pki/path_config_urls.go new file mode 100644 index 000000000..d6723f1e9 --- /dev/null +++ b/builtin/logical/pki/path_config_urls.go @@ -0,0 +1,167 @@ +package pki + +import ( + "fmt" + "strings" + + "github.com/asaskevich/govalidator" + "github.com/fatih/structs" + "github.com/hashicorp/vault/logical" + "github.com/hashicorp/vault/logical/framework" +) + +func pathConfigURLs(b *backend) *framework.Path { + return &framework.Path{ + Pattern: "config/urls", + Fields: map[string]*framework.FieldSchema{ + "issuing_certificates": &framework.FieldSchema{ + Type: framework.TypeString, + Description: `Comma-separated list of URLs to be used +for the issuing certificate attribute`, + }, + + "crl_distribution_points": &framework.FieldSchema{ + Type: framework.TypeString, + Description: `Comma-separated list of URLs to be used +for the CRL distribution points attribute`, + }, + + "ocsp_servers": &framework.FieldSchema{ + Type: framework.TypeString, + Description: `Comma-separated list of URLs to be used +for the OCSP servers attribute`, + }, + }, + + Callbacks: map[logical.Operation]framework.OperationFunc{ + logical.WriteOperation: b.pathWriteURL, + logical.ReadOperation: b.pathReadURL, + }, + + HelpSynopsis: pathConfigURLsHelpSyn, + HelpDescription: pathConfigURLsHelpDesc, + } +} + +func validateURLs(urls []string) string { + for _, curr := range urls { + if !govalidator.IsURL(curr) { + return curr + } + } + + return "" +} + +func getURLs(req *logical.Request) (*urlEntries, error) { + entry, err := req.Storage.Get("urls") + if err != nil { + return nil, err + } + if entry == nil { + return nil, nil + } + + var entries urlEntries + if err := entry.DecodeJSON(&entries); err != nil { + return nil, err + } + + return &entries, nil +} + +func writeURLs(req *logical.Request, entries *urlEntries) error { + entry, err := logical.StorageEntryJSON("urls", entries) + if err != nil { + return err + } + if entry == nil { + return fmt.Errorf("Unable to marshal entry into JSON") + } + + err = req.Storage.Put(entry) + if err != nil { + return err + } + + return nil +} + +func (b *backend) pathReadURL( + req *logical.Request, data *framework.FieldData) (*logical.Response, error) { + entries, err := getURLs(req) + if err != nil { + return nil, err + } + if entries == nil { + return nil, nil + } + + resp := &logical.Response{ + Data: structs.New(entries).Map(), + } + + return resp, nil +} + +func (b *backend) pathWriteURL( + req *logical.Request, data *framework.FieldData) (*logical.Response, error) { + entries, err := getURLs(req) + if err != nil { + return nil, err + } + if entries == nil { + entries = &urlEntries{ + IssuingCertificates: []string{}, + CRLDistributionPoints: []string{}, + OCSPServers: []string{}, + } + } + + if urlsInt, ok := data.GetOk("issuing_certificates"); ok { + splitURLs := strings.Split(urlsInt.(string), ",") + entries.IssuingCertificates = splitURLs + if badUrl := validateURLs(entries.IssuingCertificates); badUrl != "" { + return logical.ErrorResponse(fmt.Sprintf( + "invalid URL found in issuing certificates: %s", badUrl)), nil + } + } + if urlsInt, ok := data.GetOk("crl_distribution_points"); ok { + splitURLs := strings.Split(urlsInt.(string), ",") + entries.CRLDistributionPoints = splitURLs + if badUrl := validateURLs(entries.CRLDistributionPoints); badUrl != "" { + return logical.ErrorResponse(fmt.Sprintf( + "invalid URL found in CRL distribution points: %s", badUrl)), nil + } + } + if urlsInt, ok := data.GetOk("ocsp_servers"); ok { + splitURLs := strings.Split(urlsInt.(string), ",") + entries.OCSPServers = splitURLs + if badUrl := validateURLs(entries.OCSPServers); badUrl != "" { + return logical.ErrorResponse(fmt.Sprintf( + "invalid URL found in OCSP servers: %s", badUrl)), nil + } + } + + return nil, writeURLs(req, entries) +} + +type urlEntries struct { + IssuingCertificates []string `json:"issuing_certificates" structs:"issuing_certificates" mapstructure:"issuing_certificates"` + CRLDistributionPoints []string `json:"crl_distribution_points" structs:"crl_distribution_points" mapstructure:"crl_distribution_points"` + OCSPServers []string `json:"ocsp_servers" structs:"ocsp_servers" mapstructure:"ocsp_servers"` +} + +const pathConfigURLsHelpSyn = ` +Set the URLs for the issuing CA, CRL distribution points, and OCSP servers. +` + +const pathConfigURLsHelpDesc = ` +This path allows you to set the issuing CA, CRL distribution points, and +OCSP server URLs that will be encoded into issued certificates. If these +values are not set, no such information will be encoded in the issued +certificates. To delete URLs, simply re-set the appropriate value with an +empty string. + +Multiple URLs can be specified for each type; use commas to separate them. +` diff --git a/builtin/logical/pki/path_intermediate.go b/builtin/logical/pki/path_intermediate.go new file mode 100644 index 000000000..b4401abe4 --- /dev/null +++ b/builtin/logical/pki/path_intermediate.go @@ -0,0 +1,232 @@ +package pki + +import ( + "encoding/base64" + "fmt" + + "github.com/hashicorp/vault/helper/certutil" + "github.com/hashicorp/vault/logical" + "github.com/hashicorp/vault/logical/framework" +) + +func pathGenerateIntermediate(b *backend) *framework.Path { + ret := &framework.Path{ + Pattern: "intermediate/generate/" + framework.GenericNameRegex("exported"), + + Callbacks: map[logical.Operation]framework.OperationFunc{ + logical.WriteOperation: b.pathGenerateIntermediate, + }, + + HelpSynopsis: pathGenerateIntermediateHelpSyn, + HelpDescription: pathGenerateIntermediateHelpDesc, + } + + ret.Fields = addCACommonFields(map[string]*framework.FieldSchema{}) + ret.Fields = addCAKeyGenerationFields(ret.Fields) + + return ret +} + +func pathSetSignedIntermediate(b *backend) *framework.Path { + ret := &framework.Path{ + Pattern: "intermediate/set-signed", + + Fields: map[string]*framework.FieldSchema{ + "certificate": &framework.FieldSchema{ + Type: framework.TypeString, + Description: `PEM-format certificate. This must be a CA +certificate with a public key matching the +previously-generated key from the generation +endpoint.`, + }, + }, + + Callbacks: map[logical.Operation]framework.OperationFunc{ + logical.WriteOperation: b.pathSetSignedIntermediate, + }, + + HelpSynopsis: pathSetSignedIntermediateHelpSyn, + HelpDescription: pathSetSignedIntermediateHelpDesc, + } + + return ret +} + +func (b *backend) pathGenerateIntermediate( + req *logical.Request, data *framework.FieldData) (*logical.Response, error) { + var err error + + exported, format, role, errorResp := b.getGenerationParams(data) + if errorResp != nil { + return errorResp, nil + } + + var resp *logical.Response + parsedBundle, err := generateIntermediateCSR(b, role, nil, req, data) + if err != nil { + switch err.(type) { + case certutil.UserError: + return logical.ErrorResponse(err.Error()), nil + case certutil.InternalError: + return nil, err + } + } + + csrb, err := parsedBundle.ToCSRBundle() + if err != nil { + return nil, fmt.Errorf("Error converting raw CSR bundle to CSR bundle: %s", err) + } + + resp = &logical.Response{ + Data: map[string]interface{}{}, + } + + switch format { + case "pem": + resp.Data["csr"] = csrb.CSR + if exported { + resp.Data["private_key"] = csrb.PrivateKey + resp.Data["private_key_type"] = csrb.PrivateKeyType + } + case "der": + resp.Data["csr"] = base64.StdEncoding.EncodeToString(parsedBundle.CSRBytes) + if exported { + resp.Data["private_key"] = base64.StdEncoding.EncodeToString(parsedBundle.PrivateKeyBytes) + resp.Data["private_key_type"] = csrb.PrivateKeyType + } + } + + cb := &certutil.CertBundle{} + cb.PrivateKey = csrb.PrivateKey + cb.PrivateKeyType = csrb.PrivateKeyType + + entry, err := logical.StorageEntryJSON("config/ca_bundle", cb) + if err != nil { + return nil, err + } + err = req.Storage.Put(entry) + if err != nil { + return nil, err + } + + return resp, nil +} + +func (b *backend) pathSetSignedIntermediate( + req *logical.Request, data *framework.FieldData) (*logical.Response, error) { + cert := data.Get("certificate").(string) + + if cert == "" { + return logical.ErrorResponse("no certificate provided in the \"certficate\" parameter"), nil + } + + inputBundle, err := certutil.ParsePEMBundle(cert) + if err != nil { + switch err.(type) { + case certutil.InternalError: + return nil, err + default: + return logical.ErrorResponse(err.Error()), nil + } + } + + // If only one certificate is provided and it's a CA + // the parsing will assign it to the IssuingCA, so move it over + if inputBundle.Certificate == nil && inputBundle.IssuingCA != nil { + inputBundle.Certificate = inputBundle.IssuingCA + inputBundle.IssuingCA = nil + inputBundle.CertificateBytes = inputBundle.IssuingCABytes + inputBundle.IssuingCABytes = nil + } + + if inputBundle.Certificate == nil { + return logical.ErrorResponse("supplied certificate could not be successfully parsed"), nil + } + + cb := &certutil.CertBundle{} + entry, err := req.Storage.Get("config/ca_bundle") + if err != nil { + return nil, err + } + if entry == nil { + return logical.ErrorResponse("could not find any existing entry with a private key"), nil + } + + err = entry.DecodeJSON(cb) + if err != nil { + return nil, err + } + + if len(cb.PrivateKey) == 0 || cb.PrivateKeyType == "" { + return logical.ErrorResponse("could not find an existing privat key"), nil + } + + parsedCB, err := cb.ToParsedCertBundle() + if err != nil { + return nil, err + } + if parsedCB.PrivateKey == nil { + return nil, fmt.Errorf("saved key could not be parsed successfully") + } + + equal, err := certutil.ComparePublicKeys(parsedCB.PrivateKey.Public(), inputBundle.Certificate.PublicKey) + if err != nil { + return logical.ErrorResponse(fmt.Sprintf( + "error matching public keys: %v", err)), nil + } + if !equal { + return logical.ErrorResponse("key in certificate does not match stored key"), nil + } + + inputBundle.PrivateKey = parsedCB.PrivateKey + inputBundle.PrivateKeyType = parsedCB.PrivateKeyType + inputBundle.PrivateKeyBytes = parsedCB.PrivateKeyBytes + + if !inputBundle.Certificate.IsCA { + return logical.ErrorResponse("the given certificate is not marked for CA use and cannot be used with this backend"), nil + } + + cb, err = inputBundle.ToCertBundle() + if err != nil { + return nil, fmt.Errorf("error converting raw values into cert bundle: %s", err) + } + + entry, err = logical.StorageEntryJSON("config/ca_bundle", cb) + if err != nil { + return nil, err + } + err = req.Storage.Put(entry) + if err != nil { + return nil, err + } + + // For ease of later use, also store just the certificate at a known + // location + entry.Key = "ca" + entry.Value = inputBundle.CertificateBytes + err = req.Storage.Put(entry) + if err != nil { + return nil, err + } + + // Build a fresh CRL + err = buildCRL(b, req) + + return nil, err +} + +const pathGenerateIntermediateHelpSyn = ` +Generate a new CSR and private key used for signing. +` + +const pathGenerateIntermediateHelpDesc = ` +See the API documentation for more information. +` + +const pathSetSignedIntermediateHelpSyn = ` +Provide the signed intermediate CA cert. +` + +const pathSetSignedIntermediateHelpDesc = ` +See the API documentation for more information. +` diff --git a/builtin/logical/pki/path_issue.go b/builtin/logical/pki/path_issue.go deleted file mode 100644 index d97e5d70b..000000000 --- a/builtin/logical/pki/path_issue.go +++ /dev/null @@ -1,229 +0,0 @@ -package pki - -import ( - "fmt" - "net" - "strings" - "time" - - "github.com/fatih/structs" - "github.com/hashicorp/vault/helper/certutil" - "github.com/hashicorp/vault/logical" - "github.com/hashicorp/vault/logical/framework" -) - -func pathIssue(b *backend) *framework.Path { - return &framework.Path{ - Pattern: "issue/" + framework.GenericNameRegex("role"), - Fields: map[string]*framework.FieldSchema{ - "role": &framework.FieldSchema{ - Type: framework.TypeString, - Description: `The desired role with configuration for this -request`, - }, - "common_name": &framework.FieldSchema{ - Type: framework.TypeString, - Description: `The requested common name; if you want more than -one, specify the alternative names in the -alt_names map`, - }, - "alt_names": &framework.FieldSchema{ - Type: framework.TypeString, - Description: `The requested Subject Alternative Names, if any, -in a comma-delimited list`, - }, - "ip_sans": &framework.FieldSchema{ - Type: framework.TypeString, - Description: `The requested IP SANs, if any, in a -common-delimited list`, - }, - "lease": &framework.FieldSchema{ - Type: framework.TypeString, - Description: `The requested lease. DEPRECATED: use "ttl" instead.`, - }, - "ttl": &framework.FieldSchema{ - Type: framework.TypeString, - Description: `The requested Time To Live for the certificate; -sets the expiration date. If not specified -the role default, backend default, or system -default TTL is used, in that order. Cannot -be later than the role max TTL.`, - }, - }, - - Callbacks: map[logical.Operation]framework.OperationFunc{ - logical.WriteOperation: b.pathIssueCert, - }, - - HelpSynopsis: pathIssueCertHelpSyn, - HelpDescription: pathIssueCertHelpDesc, - } -} - -func (b *backend) pathIssueCert( - req *logical.Request, data *framework.FieldData) (*logical.Response, error) { - roleName := data.Get("role").(string) - - // Get the common name(s) - var commonNames []string - cn := data.Get("common_name").(string) - if len(cn) == 0 { - return logical.ErrorResponse("The common_name field is required"), nil - } - commonNames = []string{cn} - - cnAlt := data.Get("alt_names").(string) - if len(cnAlt) != 0 { - for _, v := range strings.Split(cnAlt, ",") { - commonNames = append(commonNames, v) - } - } - - // Get the role - role, err := b.getRole(req.Storage, roleName) - if err != nil { - return nil, err - } - if role == nil { - return logical.ErrorResponse(fmt.Sprintf("Unknown role: %s", roleName)), nil - } - - // Get any IP SANs - ipSANs := []net.IP{} - - ipAlt := data.Get("ip_sans").(string) - if len(ipAlt) != 0 { - if !role.AllowIPSANs { - return logical.ErrorResponse(fmt.Sprintf("IP Subject Alternative Names are not allowed in this role, but was provided %s", ipAlt)), nil - } - for _, v := range strings.Split(ipAlt, ",") { - parsedIP := net.ParseIP(v) - if parsedIP == nil { - return logical.ErrorResponse(fmt.Sprintf("The value '%s' is not a valid IP address", v)), nil - } - ipSANs = append(ipSANs, parsedIP) - } - } - - ttlField := data.Get("ttl").(string) - if len(ttlField) == 0 { - ttlField = data.Get("lease").(string) - if len(ttlField) == 0 { - ttlField = role.TTL - } - } - - var ttl time.Duration - if len(ttlField) == 0 { - ttl = b.System().DefaultLeaseTTL() - } else { - ttl, err = time.ParseDuration(ttlField) - if err != nil { - return logical.ErrorResponse(fmt.Sprintf( - "Invalid requested ttl: %s", err)), nil - } - } - - var maxTTL time.Duration - if len(role.MaxTTL) == 0 { - maxTTL = b.System().MaxLeaseTTL() - } else { - maxTTL, err = time.ParseDuration(role.MaxTTL) - if err != nil { - return logical.ErrorResponse(fmt.Sprintf( - "Invalid ttl: %s", err)), nil - } - } - - if ttl > maxTTL { - // Don't error if they were using system defaults, only error if - // they specifically chose a bad TTL - if len(ttlField) == 0 { - ttl = maxTTL - } else { - return logical.ErrorResponse("TTL is larger than maximum allowed by this role"), nil - } - } - - badName, err := validateCommonNames(req, commonNames, role) - if len(badName) != 0 { - return logical.ErrorResponse(fmt.Sprintf("Name %s not allowed by this role", badName)), nil - } else if err != nil { - return nil, fmt.Errorf("Error validating name %s: %s", badName, err) - } - - signingBundle, caErr := fetchCAInfo(req) - switch caErr.(type) { - case certutil.UserError: - return logical.ErrorResponse(fmt.Sprintf("Could not fetch the CA certificate: %s", caErr)), nil - case certutil.InternalError: - return nil, fmt.Errorf("Error fetching CA certificate: %s", caErr) - } - - if time.Now().Add(ttl).After(signingBundle.Certificate.NotAfter) { - return logical.ErrorResponse(fmt.Sprintf("Cannot satisfy request, as TTL is beyond the expiration of the CA certificate")), nil - } - - var usage certUsage - if role.ServerFlag { - usage = usage | serverUsage - } - if role.ClientFlag { - usage = usage | clientUsage - } - if role.CodeSigningFlag { - usage = usage | codeSigningUsage - } - - creationBundle := &certCreationBundle{ - SigningBundle: signingBundle, - CACert: signingBundle.Certificate, - CommonNames: commonNames, - IPSANs: ipSANs, - KeyType: role.KeyType, - KeyBits: role.KeyBits, - TTL: ttl, - Usage: usage, - } - - parsedBundle, err := createCertificate(creationBundle) - switch err.(type) { - case certutil.UserError: - return logical.ErrorResponse(err.Error()), nil - case certutil.InternalError: - return nil, err - } - - cb, err := parsedBundle.ToCertBundle() - if err != nil { - return nil, fmt.Errorf("Error converting raw cert bundle to cert bundle: %s", err) - } - - resp := b.Secret(SecretCertsType).Response( - structs.New(cb).Map(), - map[string]interface{}{ - "serial_number": cb.SerialNumber, - }) - - resp.Secret.TTL = ttl - - err = req.Storage.Put(&logical.StorageEntry{ - Key: "certs/" + cb.SerialNumber, - Value: parsedBundle.CertificateBytes, - }) - if err != nil { - return nil, fmt.Errorf("Unable to store certificate locally") - } - - return resp, nil -} - -const pathIssueCertHelpSyn = ` -Request certificates using a certain role with the provided common name. -` - -const pathIssueCertHelpDesc = ` -This path allows requesting certificates to be issued according to the -policy of the given role. The certificate will only be issued if the -requested common name is allowed by the role policy. -` diff --git a/builtin/logical/pki/path_issue_sign.go b/builtin/logical/pki/path_issue_sign.go new file mode 100644 index 000000000..65b49a861 --- /dev/null +++ b/builtin/logical/pki/path_issue_sign.go @@ -0,0 +1,232 @@ +package pki + +import ( + "encoding/base64" + "fmt" + "time" + + "github.com/hashicorp/vault/helper/certutil" + "github.com/hashicorp/vault/logical" + "github.com/hashicorp/vault/logical/framework" +) + +func pathIssue(b *backend) *framework.Path { + ret := &framework.Path{ + Pattern: "issue/" + framework.GenericNameRegex("role"), + + Callbacks: map[logical.Operation]framework.OperationFunc{ + logical.WriteOperation: b.pathIssue, + }, + + HelpSynopsis: pathIssueHelpSyn, + HelpDescription: pathIssueHelpDesc, + } + + ret.Fields = addNonCACommonFields(map[string]*framework.FieldSchema{}) + + return ret +} + +func pathSign(b *backend) *framework.Path { + ret := &framework.Path{ + Pattern: "sign/" + framework.GenericNameRegex("role"), + + Callbacks: map[logical.Operation]framework.OperationFunc{ + logical.WriteOperation: b.pathSign, + }, + + HelpSynopsis: pathSignHelpSyn, + HelpDescription: pathSignHelpDesc, + } + + ret.Fields = addNonCACommonFields(map[string]*framework.FieldSchema{}) + + ret.Fields["csr"] = &framework.FieldSchema{ + Type: framework.TypeString, + Default: "", + Description: `PEM-format CSR to be signed.`, + } + + return ret +} + +func pathSignVerbatim(b *backend) *framework.Path { + ret := &framework.Path{ + Pattern: "sign-verbatim/" + framework.GenericNameRegex("role"), + + Callbacks: map[logical.Operation]framework.OperationFunc{ + logical.WriteOperation: b.pathSignVerbatim, + }, + + HelpSynopsis: pathSignHelpSyn, + HelpDescription: pathSignHelpDesc, + } + + ret.Fields = addNonCACommonFields(map[string]*framework.FieldSchema{}) + + ret.Fields["csr"] = &framework.FieldSchema{ + Type: framework.TypeString, + Default: "", + Description: `PEM-format CSR to be signed. Values will be +taken verbatim from the CSR, except for +basic constraints.`, + } + + return ret +} + +// pathIssue issues a certificate and private key from given parameters, +// subject to role restrictions +func (b *backend) pathIssue( + req *logical.Request, data *framework.FieldData) (*logical.Response, error) { + roleName := data.Get("role").(string) + + // Get the role + role, err := b.getRole(req.Storage, roleName) + if err != nil { + return nil, err + } + if role == nil { + return logical.ErrorResponse(fmt.Sprintf("Unknown role: %s", roleName)), nil + } + + return b.pathIssueSignCert(req, data, role, false, false) +} + +// pathSign issues a certificate from a submitted CSR, subject to role +// restrictions +func (b *backend) pathSign( + req *logical.Request, data *framework.FieldData) (*logical.Response, error) { + roleName := data.Get("role").(string) + + // Get the role + role, err := b.getRole(req.Storage, roleName) + if err != nil { + return nil, err + } + if role == nil { + return logical.ErrorResponse(fmt.Sprintf("Unknown role: %s", roleName)), nil + } + + return b.pathIssueSignCert(req, data, role, true, false) +} + +// pathSignVerbatim issues a certificate from a submitted CSR, *not* subject to +// role restrictions +func (b *backend) pathSignVerbatim( + req *logical.Request, data *framework.FieldData) (*logical.Response, error) { + + ttl := b.System().DefaultLeaseTTL() + role := &roleEntry{ + TTL: ttl.String(), + AllowLocalhost: true, + AllowAnyName: true, + AllowIPSANs: true, + EnforceHostnames: false, + } + + return b.pathIssueSignCert(req, data, role, true, true) +} + +func (b *backend) pathIssueSignCert( + req *logical.Request, data *framework.FieldData, role *roleEntry, useCSR, useCSRValues bool) (*logical.Response, error) { + format := getFormat(data) + if format == "" { + return logical.ErrorResponse( + `The "format" path parameter must be "pem" or "der"`), nil + } + + var caErr error + signingBundle, caErr := fetchCAInfo(req) + switch caErr.(type) { + case certutil.UserError: + return nil, certutil.UserError{Err: fmt.Sprintf( + "Could not fetch the CA certificate (was one set?): %s", caErr)} + case certutil.InternalError: + return nil, certutil.InternalError{Err: fmt.Sprintf( + "Error fetching CA certificate: %s", caErr)} + } + + var parsedBundle *certutil.ParsedCertBundle + var err error + if useCSR { + parsedBundle, err = signCert(b, role, signingBundle, false, useCSRValues, req, data) + } else { + parsedBundle, err = generateCert(b, role, signingBundle, false, req, data) + } + if err != nil { + switch err.(type) { + case certutil.UserError: + return logical.ErrorResponse(err.Error()), nil + case certutil.InternalError: + return nil, err + } + } + + cb, err := parsedBundle.ToCertBundle() + if err != nil { + return nil, fmt.Errorf("Error converting raw cert bundle to cert bundle: %s", err) + } + + resp := b.Secret(SecretCertsType).Response( + map[string]interface{}{ + "certificate": cb.Certificate, + "issuing_ca": cb.IssuingCA, + "serial_number": cb.SerialNumber, + }, + map[string]interface{}{ + "serial_number": cb.SerialNumber, + }) + + if !useCSR { + resp.Data["private_key"] = cb.PrivateKey + resp.Data["private_key_type"] = cb.PrivateKeyType + } + + if format == "der" { + resp.Data["certificate"] = base64.StdEncoding.EncodeToString(parsedBundle.CertificateBytes) + resp.Data["issuing_ca"] = base64.StdEncoding.EncodeToString(parsedBundle.IssuingCABytes) + if !useCSR { + resp.Data["private_key"] = base64.StdEncoding.EncodeToString(parsedBundle.PrivateKeyBytes) + } + } + + resp.Secret.TTL = parsedBundle.Certificate.NotAfter.Sub(time.Now()) + + err = req.Storage.Put(&logical.StorageEntry{ + Key: "certs/" + cb.SerialNumber, + Value: parsedBundle.CertificateBytes, + }) + if err != nil { + return nil, fmt.Errorf("Unable to store certificate locally") + } + + return resp, nil +} + +const pathIssueHelpSyn = ` +Request a certificate using a certain role with the provided details. +` + +const pathIssueHelpDesc = ` +This path allows requesting a certificate to be issued according to the +policy of the given role. The certificate will only be issued if the +requested details are allowed by the role policy. + +This path returns a certificate and a private key. If you want a workflow +that does not expose a private key, generate a CSR locally and use the +sign path instead. +` + +const pathSignHelpSyn = ` +Request certificates using a certain role with the provided details. +` + +const pathSignHelpDesc = ` +This path allows requesting certificates to be issued according to the +policy of the given role. The certificate will only be issued if the +requested common name is allowed by the role policy. + +This path requires a CSR; if you want Vault to generate a private key +for you, use the issue path instead. +` diff --git a/builtin/logical/pki/path_roles.go b/builtin/logical/pki/path_roles.go index e4714e077..61b3d3ba6 100644 --- a/builtin/logical/pki/path_roles.go +++ b/builtin/logical/pki/path_roles.go @@ -2,6 +2,7 @@ package pki import ( "fmt" + "strings" "time" "github.com/fatih/structs" @@ -18,22 +19,6 @@ func pathRoles(b *backend) *framework.Path { Description: "Name of the role", }, - "lease": &framework.FieldSchema{ - Type: framework.TypeString, - Default: "", - Description: `The lease length if no specific lease length is -requested. The lease length controls the expiration -of certificates issued by this backend. Defaults to -the value of lease_max. DEPRECATED: use "ttl" instead.`, - }, - - "lease_max": &framework.FieldSchema{ - Type: framework.TypeString, - Default: "", - Description: `The maximum allowed lease length. -DEPRECATED: use "ttl" instead.`, - }, - "ttl": &framework.FieldSchema{ Type: framework.TypeString, Default: "", @@ -56,21 +41,23 @@ the value of max_ttl.`, name in a request`, }, - "allowed_base_domain": &framework.FieldSchema{ + "allowed_domains": &framework.FieldSchema{ Type: framework.TypeString, Default: "", Description: `If set, clients can request certificates for -subdomains directly beneath this base domain, including -the wildcard subdomain. See the documentation for more -information.`, +subdomains directly beneath these domains, including +the wildcard subdomains. See the documentation for more +information. This parameter accepts a comma-separated list +of domains.`, }, - "allow_token_displayname": &framework.FieldSchema{ + "allow_bare_domains": &framework.FieldSchema{ Type: framework.TypeBool, Default: false, - Description: `If set, clients can request certificates for -matching the value of the Display Name on the requesting -token. See the documentation for more information.`, + Description: `If set, clients can request certificates +for the base domains themselves, e.g. "example.com". +This is a separate option as in some cases this can +be considered a security threat.`, }, "allow_subdomains": &framework.FieldSchema{ @@ -92,9 +79,9 @@ information.`, "enforce_hostnames": &framework.FieldSchema{ Type: framework.TypeBool, - Default: false, + Default: true, Description: `If set, only valid host names are allowed for -CN and SANs.`, +CN and SANs. Defaults to true.`, }, "allow_ip_sans": &framework.FieldSchema{ @@ -107,14 +94,14 @@ Any valid IP is accepted.`, "server_flag": &framework.FieldSchema{ Type: framework.TypeBool, Default: true, - Description: `If set, certificates are flagged for server use. + Description: `If set, certificates are flagged for server auth use. Defaults to true.`, }, "client_flag": &framework.FieldSchema{ Type: framework.TypeBool, Default: true, - Description: `If set, certificates are flagged for client use. + Description: `If set, certificates are flagged for client auth use. Defaults to true.`, }, @@ -125,6 +112,13 @@ Defaults to true.`, use. Defaults to false.`, }, + "email_protection_flag": &framework.FieldSchema{ + Type: framework.TypeBool, + Default: false, + Description: `If set, certificates are flagged for email +protection use. Defaults to false.`, + }, + "key_type": &framework.FieldSchema{ Type: framework.TypeString, Default: "rsa", @@ -139,6 +133,15 @@ and "ec" are the only valid values.`, certainly want to change this if you adjust the key_type.`, }, + + "use_csr_common_name": &framework.FieldSchema{ + Type: framework.TypeBool, + Default: true, + Description: `If set, when used with a signing profile, +the common name in the CSR will be used. This +does *not* include any requested Subject Alternative +Names. Defaults to true.`, + }, }, Callbacks: map[logical.Operation]framework.OperationFunc{ @@ -178,6 +181,33 @@ func (b *backend) getRole(s logical.Storage, n string) (*roleEntry, error) { result.LeaseMax = "" modified = true } + if result.AllowBaseDomain { + result.AllowBaseDomain = false + result.AllowBareDomains = true + modified = true + } + if result.AllowedBaseDomain != "" { + found := false + allowedDomains := strings.Split(result.AllowedDomains, ",") + if len(allowedDomains) != 0 { + for _, v := range allowedDomains { + if v == result.AllowedBaseDomain { + found = true + break + } + } + } + if !found { + if result.AllowedDomains == "" { + result.AllowedDomains = result.AllowedBaseDomain + } else { + result.AllowedDomains += "," + result.AllowedBaseDomain + } + result.AllowedBaseDomain = "" + modified = true + } + } + if modified { jsonEntry, err := logical.StorageEntryJSON("role/"+n, &result) if err != nil { @@ -237,25 +267,24 @@ func (b *backend) pathRoleCreate( name := data.Get("name").(string) entry := &roleEntry{ - MaxTTL: data.Get("max_ttl").(string), - TTL: data.Get("ttl").(string), - AllowLocalhost: data.Get("allow_localhost").(bool), - AllowedBaseDomain: data.Get("allowed_base_domain").(string), - AllowTokenDisplayName: data.Get("allow_token_displayname").(bool), - AllowSubdomains: data.Get("allow_subdomains").(bool), - AllowAnyName: data.Get("allow_any_name").(bool), - EnforceHostnames: data.Get("enforce_hostnames").(bool), - AllowIPSANs: data.Get("allow_ip_sans").(bool), - ServerFlag: data.Get("server_flag").(bool), - ClientFlag: data.Get("client_flag").(bool), - CodeSigningFlag: data.Get("code_signing_flag").(bool), - KeyType: data.Get("key_type").(string), - KeyBits: data.Get("key_bits").(int), + MaxTTL: data.Get("max_ttl").(string), + TTL: data.Get("ttl").(string), + AllowLocalhost: data.Get("allow_localhost").(bool), + AllowedDomains: data.Get("allowed_domains").(string), + AllowBareDomains: data.Get("allow_bare_domains").(bool), + AllowSubdomains: data.Get("allow_subdomains").(bool), + AllowAnyName: data.Get("allow_any_name").(bool), + EnforceHostnames: data.Get("enforce_hostnames").(bool), + AllowIPSANs: data.Get("allow_ip_sans").(bool), + ServerFlag: data.Get("server_flag").(bool), + ClientFlag: data.Get("client_flag").(bool), + CodeSigningFlag: data.Get("code_signing_flag").(bool), + EmailProtectionFlag: data.Get("email_protection_flag").(bool), + KeyType: data.Get("key_type").(string), + KeyBits: data.Get("key_bits").(int), + UseCSRCommonName: data.Get("use_csr_common_name").(bool), } - if len(entry.MaxTTL) == 0 { - entry.MaxTTL = data.Get("lease_max").(string) - } var maxTTL time.Duration maxSystemTTL := b.System().MaxLeaseTTL() if len(entry.MaxTTL) == 0 { @@ -271,9 +300,6 @@ func (b *backend) pathRoleCreate( return logical.ErrorResponse("Requested max TTL is higher than backend maximum"), nil } - if len(entry.TTL) == 0 { - entry.TTL = data.Get("lease").(string) - } ttl := b.System().DefaultLeaseTTL() if len(entry.TTL) != 0 { ttl, err = time.ParseDuration(entry.TTL) @@ -288,30 +314,14 @@ func (b *backend) pathRoleCreate( if len(entry.TTL) == 0 { ttl = maxTTL } else { - return logical.ErrorResponse("\"ttl\" value must be less than \"max_ttl\" and/or backend default max lease TTL value"), nil + return logical.ErrorResponse( + `"ttl" value must be less than "max_ttl" and/or backend default max lease TTL value`, + ), nil } } - if len(entry.KeyType) == 0 { - entry.KeyType = "rsa" - } - if entry.KeyBits == 0 { - entry.KeyBits = 2048 - } - - switch entry.KeyType { - case "rsa": - case "ec": - switch entry.KeyBits { - case 224: - case 256: - case 384: - case 521: - default: - return logical.ErrorResponse(fmt.Sprintf("Unsupported bit length for EC key: %d", entry.KeyBits)), nil - } - default: - return logical.ErrorResponse(fmt.Sprintf("Unknown key type %s", entry.KeyType)), nil + if errResp := validateKeyTypeLength(entry.KeyType, entry.KeyBits); errResp != nil { + return errResp, nil } // Store it @@ -333,6 +343,9 @@ type roleEntry struct { TTL string `json:"ttl" structs:"ttl" mapstructure:"ttl"` AllowLocalhost bool `json:"allow_localhost" structs:"allow_localhost" mapstructure:"allow_localhost"` AllowedBaseDomain string `json:"allowed_base_domain" structs:"allowed_base_domain" mapstructure:"allowed_base_domain"` + AllowedDomains string `json:"allowed_domains" structs:"allowed_domains" mapstructure:"allowed_domains"` + AllowBaseDomain bool `json:"allow_base_domain" structs:"allow_base_domain" mapstructure:"allow_base_domain"` + AllowBareDomains bool `json:"allow_bare_domains" structs:"allow_bare_domains" mapstructure:"allow_bare_domains"` AllowTokenDisplayName bool `json:"allow_token_displayname" structs:"allow_token_displayname" mapstructure:"allow_token_displayname"` AllowSubdomains bool `json:"allow_subdomains" structs:"allow_subdomains" mapstructure:"allow_subdomains"` AllowAnyName bool `json:"allow_any_name" structs:"allow_any_name" mapstructure:"allow_any_name"` @@ -341,8 +354,11 @@ type roleEntry struct { ServerFlag bool `json:"server_flag" structs:"server_flag" mapstructure:"server_flag"` ClientFlag bool `json:"client_flag" structs:"client_flag" mapstructure:"client_flag"` CodeSigningFlag bool `json:"code_signing_flag" structs:"code_signing_flag" mapstructure:"code_signing_flag"` + EmailProtectionFlag bool `json:"email_protection_flag" structs:"email_protection_flag" mapstructure:"email_protection_flag"` + UseCSRCommonName bool `json:"use_csr_common_name" structs:"use_csr_common_name" mapstructure:"use_csr_common_name"` KeyType string `json:"key_type" structs:"key_type" mapstructure:"key_type"` KeyBits int `json:"key_bits" structs:"key_bits" mapstructure:"key_bits"` + MaxPathLength *int `json:",omitempty" structs:",omitempty"` } const pathRoleHelpSyn = ` diff --git a/builtin/logical/pki/path_root.go b/builtin/logical/pki/path_root.go new file mode 100644 index 000000000..bd1f571dd --- /dev/null +++ b/builtin/logical/pki/path_root.go @@ -0,0 +1,274 @@ +package pki + +import ( + "encoding/base64" + "fmt" + "time" + + "github.com/hashicorp/vault/helper/certutil" + "github.com/hashicorp/vault/logical" + "github.com/hashicorp/vault/logical/framework" +) + +func pathGenerateRoot(b *backend) *framework.Path { + ret := &framework.Path{ + Pattern: "root/generate/" + framework.GenericNameRegex("exported"), + + Callbacks: map[logical.Operation]framework.OperationFunc{ + logical.WriteOperation: b.pathCAGenerateRoot, + }, + + HelpSynopsis: pathGenerateRootHelpSyn, + HelpDescription: pathGenerateRootHelpDesc, + } + + ret.Fields = addCACommonFields(map[string]*framework.FieldSchema{}) + ret.Fields = addCAKeyGenerationFields(ret.Fields) + ret.Fields = addCAIssueFields(ret.Fields) + + return ret +} + +func pathSignIntermediate(b *backend) *framework.Path { + ret := &framework.Path{ + Pattern: "root/sign-intermediate", + + Callbacks: map[logical.Operation]framework.OperationFunc{ + logical.WriteOperation: b.pathCASignIntermediate, + }, + + HelpSynopsis: pathSignIntermediateHelpSyn, + HelpDescription: pathSignIntermediateHelpDesc, + } + + ret.Fields = addCACommonFields(map[string]*framework.FieldSchema{}) + ret.Fields = addCAIssueFields(ret.Fields) + + ret.Fields["csr"] = &framework.FieldSchema{ + Type: framework.TypeString, + Default: "", + Description: `PEM-format CSR to be signed.`, + } + + ret.Fields["use_csr_values"] = &framework.FieldSchema{ + Type: framework.TypeBool, + Default: false, + Description: `If true, then: +1) Subject information, including names and alternate +names, will be preserved from the CSR rather than +using values provided in the other parameters to +this path; +2) Any key usages requested in the CSR will be +added to the basic set of key usages used for CA +certs signed by this path; for instance, +the non-repudiation flag.`, + } + + return ret +} + +func (b *backend) pathCAGenerateRoot( + req *logical.Request, data *framework.FieldData) (*logical.Response, error) { + var err error + + exported, format, role, errorResp := b.getGenerationParams(data) + if errorResp != nil { + return errorResp, nil + } + + maxPathLengthIface, ok := data.GetOk("max_path_length") + if ok { + maxPathLength := maxPathLengthIface.(int) + role.MaxPathLength = &maxPathLength + } + + parsedBundle, err := generateCert(b, role, nil, true, req, data) + if err != nil { + switch err.(type) { + case certutil.UserError: + return logical.ErrorResponse(err.Error()), nil + case certutil.InternalError: + return nil, err + } + } + + cb, err := parsedBundle.ToCertBundle() + if err != nil { + return nil, fmt.Errorf("error converting raw cert bundle to cert bundle: %s", err) + } + + resp := b.Secret(SecretCertsType).Response( + map[string]interface{}{ + "expiration": int64(parsedBundle.Certificate.NotAfter.Unix()), + "serial_number": cb.SerialNumber, + "certificate": cb.Certificate, + "issuing_ca": cb.IssuingCA, + }, + map[string]interface{}{ + "serial_number": cb.SerialNumber, + }) + + switch format { + case "pem": + if exported { + resp.Data["private_key"] = cb.PrivateKey + resp.Data["private_key_type"] = cb.PrivateKeyType + } + case "der": + resp.Data["certificate"] = base64.StdEncoding.EncodeToString(parsedBundle.CertificateBytes) + resp.Data["issuing_ca"] = base64.StdEncoding.EncodeToString(parsedBundle.IssuingCABytes) + if exported { + resp.Data["private_key"] = base64.StdEncoding.EncodeToString(parsedBundle.PrivateKeyBytes) + resp.Data["private_key_type"] = cb.PrivateKeyType + } + } + + resp.Secret.TTL = parsedBundle.Certificate.NotAfter.Sub(time.Now()) + + // Store it as the CA bundle + entry, err := logical.StorageEntryJSON("config/ca_bundle", cb) + if err != nil { + return nil, err + } + err = req.Storage.Put(entry) + if err != nil { + return nil, err + } + + // Also store it as just the certificate identified by serial number, so it + // can be revoked + err = req.Storage.Put(&logical.StorageEntry{ + Key: "certs/" + cb.SerialNumber, + Value: parsedBundle.CertificateBytes, + }) + if err != nil { + return nil, fmt.Errorf("Unable to store certificate locally") + } + + // For ease of later use, also store just the certificate at a known + // location + entry.Key = "ca" + entry.Value = parsedBundle.CertificateBytes + err = req.Storage.Put(entry) + if err != nil { + return nil, err + } + + // Build a fresh CRL + err = buildCRL(b, req) + if err != nil { + return nil, err + } + + if parsedBundle.Certificate.MaxPathLen == 0 { + resp.AddWarning("Max path length of the generated certificate is zero. This certificate cannot be used to issue intermediate CA certificates.") + } + + return resp, nil +} + +func (b *backend) pathCASignIntermediate( + req *logical.Request, data *framework.FieldData) (*logical.Response, error) { + var err error + + format := getFormat(data) + if format == "" { + return logical.ErrorResponse( + `The "format" path parameter must be "pem" or "der"`, + ), nil + } + + role := &roleEntry{ + TTL: data.Get("ttl").(string), + AllowLocalhost: true, + AllowAnyName: true, + AllowIPSANs: true, + EnforceHostnames: false, + } + + if cn := data.Get("common_name").(string); len(cn) == 0 { + role.UseCSRCommonName = true + } + + var caErr error + signingBundle, caErr := fetchCAInfo(req) + switch caErr.(type) { + case certutil.UserError: + return nil, certutil.UserError{Err: fmt.Sprintf( + "could not fetch the CA certificate (was one set?): %s", caErr)} + case certutil.InternalError: + return nil, certutil.InternalError{Err: fmt.Sprintf( + "error fetching CA certificate: %s", caErr)} + } + + useCSRValues := data.Get("use_csr_values").(bool) + + maxPathLengthIface, ok := data.GetOk("max_path_length") + if ok { + maxPathLength := maxPathLengthIface.(int) + role.MaxPathLength = &maxPathLength + } + + parsedBundle, err := signCert(b, role, signingBundle, true, useCSRValues, req, data) + if err != nil { + switch err.(type) { + case certutil.UserError: + return logical.ErrorResponse(err.Error()), nil + case certutil.InternalError: + return nil, err + } + } + + cb, err := parsedBundle.ToCertBundle() + if err != nil { + return nil, fmt.Errorf("Error converting raw cert bundle to cert bundle: %s", err) + } + + resp := b.Secret(SecretCertsType).Response( + map[string]interface{}{ + "expiration": int64(parsedBundle.Certificate.NotAfter.Unix()), + "serial_number": cb.SerialNumber, + "certificate": cb.Certificate, + "issuing_ca": cb.IssuingCA, + }, + map[string]interface{}{ + "serial_number": cb.SerialNumber, + }) + + if format == "der" { + resp.Data["certificate"] = base64.StdEncoding.EncodeToString(parsedBundle.CertificateBytes) + resp.Data["issuing_ca"] = base64.StdEncoding.EncodeToString(parsedBundle.IssuingCABytes) + } + + resp.Secret.TTL = parsedBundle.Certificate.NotAfter.Sub(time.Now()) + + err = req.Storage.Put(&logical.StorageEntry{ + Key: "certs/" + cb.SerialNumber, + Value: parsedBundle.CertificateBytes, + }) + if err != nil { + return nil, fmt.Errorf("Unable to store certificate locally") + } + + if parsedBundle.Certificate.MaxPathLen == 0 { + resp.AddWarning("Max path length of the signed certificate is zero. This certificate cannot be used to issue intermediate CA certificates.") + } + + return resp, nil +} + +const pathGenerateRootHelpSyn = ` +Generate a new CA certificate and private key used for signing. +` + +const pathGenerateRootHelpDesc = ` +See the API documentation for more information. +` + +const pathSignIntermediateHelpSyn = ` +Issue an intermediate CA certificate based on the provided CSR. +` + +const pathSignIntermediateHelpDesc = ` +See the API documentation for more information. +` diff --git a/builtin/logical/pki/secret_certs.go b/builtin/logical/pki/secret_certs.go index 06be0caa5..80ddf390e 100644 --- a/builtin/logical/pki/secret_certs.go +++ b/builtin/logical/pki/secret_certs.go @@ -33,7 +33,7 @@ reference`, }, DefaultDuration: 168 * time.Hour, - DefaultGracePeriod: 10 * time.Minute, + DefaultGracePeriod: time.Duration(0), Revoke: b.secretCredsRevoke, } diff --git a/builtin/logical/postgresql/path_role_create.go b/builtin/logical/postgresql/path_role_create.go index 79826b5c6..fa55331f5 100644 --- a/builtin/logical/postgresql/path_role_create.go +++ b/builtin/logical/postgresql/path_role_create.go @@ -4,7 +4,7 @@ import ( "fmt" "time" - "github.com/hashicorp/uuid" + "github.com/hashicorp/go-uuid" "github.com/hashicorp/vault/logical" "github.com/hashicorp/vault/logical/framework" _ "github.com/lib/pq" diff --git a/builtin/logical/ssh/path_creds_create.go b/builtin/logical/ssh/path_creds_create.go index 3c0ecdb11..030e5af07 100644 --- a/builtin/logical/ssh/path_creds_create.go +++ b/builtin/logical/ssh/path_creds_create.go @@ -6,7 +6,7 @@ import ( "strings" "time" - "github.com/hashicorp/uuid" + "github.com/hashicorp/go-uuid" "github.com/hashicorp/vault/logical" "github.com/hashicorp/vault/logical/framework" ) diff --git a/command/auth.go b/command/auth.go index 1735d1a34..6327e10e2 100644 --- a/command/auth.go +++ b/command/auth.go @@ -180,7 +180,7 @@ func (c *AuthCommand) Run(args []string) int { } // Verify the token - secret, err := client.Logical().Read("auth/token/lookup-self") + secret, err := client.Auth().Token().LookupSelf() if err != nil { c.Ui.Error(fmt.Sprintf( "Error validating token: %s", err)) diff --git a/command/format.go b/command/format.go index 4edb44091..0839efda1 100644 --- a/command/format.go +++ b/command/format.go @@ -4,8 +4,11 @@ import ( "bytes" "encoding/json" "fmt" + "sort" "strconv" + "strings" + "github.com/ghodss/yaml" "github.com/hashicorp/vault/api" "github.com/mitchellh/cli" "github.com/ryanuber/columnize" @@ -15,10 +18,13 @@ func OutputSecret(ui cli.Ui, format string, secret *api.Secret) int { switch format { case "json": return outputFormatJSON(ui, secret) + case "yaml": + return outputFormatYAML(ui, secret) case "table": - fallthrough - default: return outputFormatTable(ui, secret, true) + default: + ui.Error(fmt.Sprintf("Invalid output format: %s", format)) + return 1 } } @@ -36,6 +42,18 @@ func outputFormatJSON(ui cli.Ui, s *api.Secret) int { return 0 } +func outputFormatYAML(ui cli.Ui, s *api.Secret) int { + b, err := yaml.Marshal(s) + if err != nil { + ui.Error(fmt.Sprintf( + "Error formatting secret: %s", err)) + return 1 + } + + ui.Output(strings.TrimSpace(string(b))) + return 0 +} + func outputFormatTable(ui cli.Ui, s *api.Secret, whitespace bool) int { config := columnize.DefaultConfig() config.Delim = "♨" @@ -68,8 +86,14 @@ func outputFormatTable(ui cli.Ui, s *api.Secret, whitespace bool) int { } } - for k, v := range s.Data { - input = append(input, fmt.Sprintf("%s %s %v", k, config.Delim, v)) + keys := make([]string, 0, len(s.Data)) + for k := range s.Data { + keys = append(keys, k) + } + sort.Strings(keys) + + for _, k := range keys { + input = append(input, fmt.Sprintf("%s %s %v", k, config.Delim, s.Data[k])) } if len(s.Warnings) != 0 { diff --git a/command/read.go b/command/read.go index 7a13764a1..c862a7ab6 100644 --- a/command/read.go +++ b/command/read.go @@ -100,7 +100,7 @@ General Options: Read Options: -format=table The format for output. By default it is a whitespace- - delimited table. This can also be json. + delimited table. This can also be json or yaml. -field=field If included, the raw value of the specified field will be output raw to stdout. diff --git a/command/renew.go b/command/renew.go index 9135f79b7..f0474d3c7 100644 --- a/command/renew.go +++ b/command/renew.go @@ -84,7 +84,7 @@ General Options: Renew Options: -format=table The format for output. By default it is a whitespace- - delimited table. This can also be json. + delimited table. This can also be json or yaml. ` return strings.TrimSpace(helpText) } diff --git a/command/server.go b/command/server.go index 99f3ba351..a6ecffa77 100644 --- a/command/server.go +++ b/command/server.go @@ -39,12 +39,13 @@ type ServerCommand struct { } func (c *ServerCommand) Run(args []string) int { - var dev bool + var dev, verifyOnly bool var configPath []string var logLevel string flags := c.Meta.FlagSet("server", FlagSetDefault) flags.BoolVar(&dev, "dev", false, "") flags.StringVar(&logLevel, "log-level", "info", "") + flags.BoolVar(&verifyOnly, "verify-only", false, "") flags.Usage = func() { c.Ui.Error(c.Help()) } flags.Var((*sliceflag.StringFlag)(&configPath), "config", "config") if err := flags.Parse(args); err != nil { @@ -103,6 +104,14 @@ func (c *ServerCommand) Run(args []string) int { Writer: logGate, }, "", log.LstdFlags) + // Initialize telemetry; if this is done after the core is created, + // because we are using a global telemetry object, it can be a data + // race between writing metrics from core and the object being set + if err := c.setupTelementry(config); err != nil { + c.Ui.Error(fmt.Sprintf("Error initializing telemetry: %s", err)) + return 1 + } + // Initialize the backend backend, err := physical.NewBackend( config.Backend.Type, config.Backend.Config) @@ -113,22 +122,10 @@ func (c *ServerCommand) Run(args []string) int { return 1 } - // Attempt to detect the advertise address possible - if detect, ok := backend.(physical.AdvertiseDetect); ok && config.Backend.AdvertiseAddr == "" { - advertise, err := c.detectAdvertise(detect, config) - if err != nil { - c.Ui.Error(fmt.Sprintf("Error detecting advertise address: %s", err)) - } else if advertise == "" { - c.Ui.Error("Failed to detect advertise address.") - } else { - config.Backend.AdvertiseAddr = advertise - } - } - - // Initialize the core - core, err := vault.NewCore(&vault.CoreConfig{ - AdvertiseAddr: config.Backend.AdvertiseAddr, + coreConfig := &vault.CoreConfig{ Physical: backend, + AdvertiseAddr: config.Backend.AdvertiseAddr, + HAPhysical: nil, AuditBackends: c.AuditBackends, CredentialBackends: c.CredentialBackends, LogicalBackends: c.LogicalBackends, @@ -137,7 +134,52 @@ func (c *ServerCommand) Run(args []string) int { DisableMlock: config.DisableMlock, MaxLeaseTTL: config.MaxLeaseTTL, DefaultLeaseTTL: config.DefaultLeaseTTL, - }) + } + + // Initialize the separate HA physical backend, if it exists + if config.HABackend != nil { + habackend, err := physical.NewBackend( + config.HABackend.Type, config.HABackend.Config) + if err != nil { + c.Ui.Error(fmt.Sprintf( + "Error initializing backend of type %s: %s", + config.HABackend.Type, err)) + return 1 + } + + var ok bool + if coreConfig.HAPhysical, ok = habackend.(physical.HABackend); !ok { + c.Ui.Error("Specified HA backend does not support HA") + return 1 + } + coreConfig.AdvertiseAddr = config.HABackend.AdvertiseAddr + } + + if envAA := os.Getenv("VAULT_ADVERTISE_ADDR"); envAA != "" { + coreConfig.AdvertiseAddr = envAA + } + + // Attempt to detect the advertise address possible + var detect physical.AdvertiseDetect + var ok bool + if coreConfig.HAPhysical != nil { + detect, ok = coreConfig.HAPhysical.(physical.AdvertiseDetect) + } else { + detect, ok = coreConfig.Physical.(physical.AdvertiseDetect) + } + if ok && coreConfig.AdvertiseAddr == "" { + advertise, err := c.detectAdvertise(detect, config) + if err != nil { + c.Ui.Error(fmt.Sprintf("Error detecting advertise address: %s", err)) + } else if advertise == "" { + c.Ui.Error("Failed to detect advertise address.") + } else { + coreConfig.AdvertiseAddr = advertise + } + } + + // Initialize the core + core, err := vault.NewCore(coreConfig) if err != nil { c.Ui.Error(fmt.Sprintf("Error initializing core: %s", err)) return 1 @@ -186,17 +228,17 @@ func (c *ServerCommand) Run(args []string) int { mlock.Supported(), !config.DisableMlock) infoKeys = append(infoKeys, "log level", "mlock", "backend") - // If the backend supports HA, then note it - if _, ok := backend.(physical.HABackend); ok { - info["backend"] += " (HA available)" - info["advertise address"] = config.Backend.AdvertiseAddr - infoKeys = append(infoKeys, "advertise address") - } - - // Initialize the telemetry - if err := c.setupTelementry(config); err != nil { - c.Ui.Error(fmt.Sprintf("Error initializing telemetry: %s", err)) - return 1 + if config.HABackend != nil { + info["HA backend"] = config.HABackend.Type + info["advertise address"] = coreConfig.AdvertiseAddr + infoKeys = append(infoKeys, "HA backend", "advertise address") + } else { + // If the backend supports HA, then note it + if coreConfig.HAPhysical != nil { + info["backend"] += " (HA available)" + info["advertise address"] = coreConfig.AdvertiseAddr + infoKeys = append(infoKeys, "advertise address") + } } // Initialize the listeners @@ -225,6 +267,10 @@ func (c *ServerCommand) Run(args []string) int { lns = append(lns, ln) } + if verifyOnly { + return 0 + } + // Initialize the HTTP server server := &http.Server{} server.Handler = vaulthttp.Handler(core) @@ -308,6 +354,11 @@ func (c *ServerCommand) detectAdvertise(detect physical.AdvertiseDetect, return "", err } + // set [] for ipv6 addresses + if strings.Contains(host, ":") && !strings.Contains(host, "]") { + host = "[" + host + "]" + } + // Default the port and scheme scheme := "https" port := 8200 diff --git a/command/server/config.go b/command/server/config.go index 073b42e02..253bfc55f 100644 --- a/command/server/config.go +++ b/command/server/config.go @@ -17,6 +17,7 @@ import ( type Config struct { Listeners []*Listener `hcl:"-"` Backend *Backend `hcl:"-"` + HABackend *Backend `hcl:"-"` DisableCache bool `hcl:"disable_cache"` DisableMlock bool `hcl:"disable_mlock"` @@ -191,6 +192,12 @@ func LoadConfigFile(path string) (*Config, error) { return nil, err } } + if objs := obj.Get("ha_backend", false); objs != nil { + result.HABackend, err = loadBackend(objs) + if err != nil { + return nil, err + } + } // A little hacky but upgrades the old stats config directives to the new way if result.Telemetry == nil { diff --git a/command/server/config_test.go b/command/server/config_test.go index 020493def..b29654700 100644 --- a/command/server/config_test.go +++ b/command/server/config_test.go @@ -30,6 +30,14 @@ func TestLoadConfigFile(t *testing.T) { }, }, + HABackend: &Backend{ + Type: "consul", + AdvertiseAddr: "snafu", + Config: map[string]string{ + "bar": "baz", + }, + }, + Telemetry: &Telemetry{ StatsdAddr: "bar", StatsiteAddr: "foo", @@ -111,6 +119,13 @@ func TestLoadConfigFile_json2(t *testing.T) { }, }, + HABackend: &Backend{ + Type: "consul", + Config: map[string]string{ + "bar": "baz", + }, + }, + Telemetry: &Telemetry{ StatsiteAddr: "foo", StatsdAddr: "bar", diff --git a/command/server/test-fixtures/config.hcl b/command/server/test-fixtures/config.hcl index e945d612c..a591b838e 100644 --- a/command/server/test-fixtures/config.hcl +++ b/command/server/test-fixtures/config.hcl @@ -12,5 +12,10 @@ backend "consul" { advertise_addr = "foo" } +ha_backend "consul" { + bar = "baz" + advertise_addr = "snafu" +} + max_lease_ttl = "10h" default_lease_ttl = "10h" diff --git a/command/server/test-fixtures/config2.hcl.json b/command/server/test-fixtures/config2.hcl.json index 534317ff2..736448017 100644 --- a/command/server/test-fixtures/config2.hcl.json +++ b/command/server/test-fixtures/config2.hcl.json @@ -11,6 +11,12 @@ } }, + "ha_backend": { + "consul": { + "bar": "baz" + } + }, + "telemetry": { "statsd_address": "bar", "statsite_address": "foo", diff --git a/command/server_test.go b/command/server_test.go new file mode 100644 index 000000000..203eb5276 --- /dev/null +++ b/command/server_test.go @@ -0,0 +1,87 @@ +package command + +import ( + "io/ioutil" + "os" + "testing" + + "github.com/mitchellh/cli" +) + +var ( + basehcl = ` +disable_mlock = true + +listener "tcp" { + address = "127.0.0.1:8200" + tls_disable = "true" +} +` + + consulhcl = ` +backend "consul" { + prefix = "foo/" + advertise_addr = "http://127.0.0.1:8200" +} +` + haconsulhcl = ` +ha_backend "consul" { + prefix = "bar/" + advertise_addr = "http://127.0.0.1:8200" +} +` + + badhaconsulhcl = ` +ha_backend "file" { + path = "/dev/null" +} +` +) + +func TestServer_GoodSeparateHA(t *testing.T) { + ui := new(cli.MockUi) + c := &ServerCommand{ + Meta: Meta{ + Ui: ui, + }, + } + + tmpfile, err := ioutil.TempFile("", "") + if err != nil { + t.Fatalf("error creating temp dir: %v", err) + } + + tmpfile.WriteString(basehcl + consulhcl + haconsulhcl) + tmpfile.Close() + defer os.Remove(tmpfile.Name()) + + args := []string{"-config", tmpfile.Name(), "-verify-only", "true"} + + if code := c.Run(args); code != 0 { + t.Fatalf("bad: %d\n\n%s", code, ui.ErrorWriter.String()) + } +} + +func TestServer_BadSeparateHA(t *testing.T) { + ui := new(cli.MockUi) + c := &ServerCommand{ + Meta: Meta{ + Ui: ui, + }, + } + + tmpfile, err := ioutil.TempFile("", "") + if err != nil { + t.Fatalf("error creating temp dir: %v", err) + } + + tmpfile.WriteString(basehcl + consulhcl + badhaconsulhcl) + tmpfile.Close() + defer os.Remove(tmpfile.Name()) + + args := []string{"-config", tmpfile.Name()} + + if code := c.Run(args); code == 0 { + t.Fatalf("bad: should have gotten an error on a bad HA config") + } +} diff --git a/command/token_create.go b/command/token_create.go index fb3ffcfc7..b0400a11e 100644 --- a/command/token_create.go +++ b/command/token_create.go @@ -134,7 +134,7 @@ Token Options: it is automatically revoked. -format=table The format for output. By default it is a whitespace- - delimited table. This can also be json. + delimited table. This can also be json or yaml. ` return strings.TrimSpace(helpText) diff --git a/command/token_renew.go b/command/token_renew.go index c140baf59..c9f3273f4 100644 --- a/command/token_renew.go +++ b/command/token_renew.go @@ -82,7 +82,7 @@ General Options: Token Renew Options: -format=table The format for output. By default it is a whitespace- - delimited table. This can also be json. + delimited table. This can also be json or yaml. ` return strings.TrimSpace(helpText) diff --git a/helper/certutil/certutil_test.go b/helper/certutil/certutil_test.go index 5d8bac1b7..1a90213b4 100644 --- a/helper/certutil/certutil_test.go +++ b/helper/certutil/certutil_test.go @@ -18,13 +18,28 @@ import ( func TestCertBundleConversion(t *testing.T) { cbuts := []*CertBundle{ refreshRSACertBundle(), + refreshRSA8CertBundle(), refreshECCertBundle(), + refreshEC8CertBundle(), } - for _, cbut := range cbuts { + for i, cbut := range cbuts { pcbut, err := cbut.ToParsedCertBundle() if err != nil { - t.Fatalf("Error converting to parsed cert bundle: %s", err) + t.Logf("Error occurred with bundle %d in test array (index %d).\n", i+1, i) + t.Errorf("Error converting to parsed cert bundle: %s", err) + continue + } + + err = compareCertBundleToParsedCertBundle(cbut, pcbut) + if err != nil { + t.Logf("Error occurred with bundle %d in test array (index %d).\n", i+1, i) + t.Errorf(err.Error()) + } + + cbut, err := pcbut.ToCertBundle() + if err != nil { + t.Fatalf("Error converting to cert bundle: %s", err) } err = compareCertBundleToParsedCertBundle(cbut, pcbut) @@ -34,6 +49,244 @@ func TestCertBundleConversion(t *testing.T) { } } +func BenchmarkCertBundleParsing(b *testing.B) { + for i := 0; i < b.N; i++ { + cbuts := []*CertBundle{ + refreshRSACertBundle(), + refreshRSA8CertBundle(), + refreshECCertBundle(), + refreshEC8CertBundle(), + } + + for i, cbut := range cbuts { + pcbut, err := cbut.ToParsedCertBundle() + if err != nil { + b.Logf("Error occurred with bundle %d in test array (index %d).\n", i+1, i) + b.Errorf("Error converting to parsed cert bundle: %s", err) + continue + } + + cbut, err = pcbut.ToCertBundle() + if err != nil { + b.Fatalf("Error converting to cert bundle: %s", err) + } + } + } +} + +func TestCertBundleParsing(t *testing.T) { + jsonBundle := refreshRSACertBundle() + jsonString, err := json.Marshal(jsonBundle) + if err != nil { + t.Fatalf("Error marshaling testing certbundle to JSON: %s", err) + } + pcbut, err := ParsePKIJSON(jsonString) + if err != nil { + t.Fatalf("Error during JSON bundle handling: %s", err) + } + err = compareCertBundleToParsedCertBundle(jsonBundle, pcbut) + if err != nil { + t.Fatalf(err.Error()) + } + + secret := &api.Secret{ + Data: structs.New(jsonBundle).Map(), + } + pcbut, err = ParsePKIMap(secret.Data) + if err != nil { + t.Fatalf("Error during JSON bundle handling: %s", err) + } + err = compareCertBundleToParsedCertBundle(jsonBundle, pcbut) + if err != nil { + t.Fatalf(err.Error()) + } + + pemBundle := strings.Join([]string{ + jsonBundle.Certificate, + jsonBundle.IssuingCA, + jsonBundle.PrivateKey, + }, "\n") + pcbut, err = ParsePEMBundle(pemBundle) + if err != nil { + t.Fatalf("Error during JSON bundle handling: %s", err) + } + err = compareCertBundleToParsedCertBundle(jsonBundle, pcbut) + if err != nil { + t.Fatalf(err.Error()) + } +} + +func compareCertBundleToParsedCertBundle(cbut *CertBundle, pcbut *ParsedCertBundle) error { + if cbut == nil { + return fmt.Errorf("Got nil bundle") + } + if pcbut == nil { + return fmt.Errorf("Got nil parsed bundle") + } + + switch { + case pcbut.Certificate == nil: + return fmt.Errorf("Parsed bundle has nil certificate") + case pcbut.PrivateKey == nil: + return fmt.Errorf("Parsed bundle has nil private key") + case pcbut.IssuingCA == nil: + return fmt.Errorf("Parsed bundle has nil issuing CA") + } + + switch cbut.PrivateKey { + case privRSAKeyPem: + if pcbut.PrivateKeyType != RSAPrivateKey { + return fmt.Errorf("Parsed bundle has wrong private key type: %v, should be 'rsa' (%v)", pcbut.PrivateKeyType, RSAPrivateKey) + } + case privRSA8KeyPem: + if pcbut.PrivateKeyType != RSAPrivateKey { + return fmt.Errorf("Parsed bundle has wrong pkcs8 private key type: %v, should be 'rsa' (%v)", pcbut.PrivateKeyType, RSAPrivateKey) + } + case privECKeyPem: + if pcbut.PrivateKeyType != ECPrivateKey { + return fmt.Errorf("Parsed bundle has wrong private key type: %v, should be 'ec' (%v)", pcbut.PrivateKeyType, ECPrivateKey) + } + case privEC8KeyPem: + if pcbut.PrivateKeyType != ECPrivateKey { + return fmt.Errorf("Parsed bundle has wrong pkcs8 private key type: %v, should be 'ec' (%v)", pcbut.PrivateKeyType, ECPrivateKey) + } + default: + return fmt.Errorf("Parsed bundle has unknown private key type") + } + + subjKeyID, err := GetSubjKeyID(pcbut.PrivateKey) + if err != nil { + return fmt.Errorf("Error when getting subject key id: %s", err) + } + if bytes.Compare(subjKeyID, pcbut.Certificate.SubjectKeyId) != 0 { + return fmt.Errorf("Parsed bundle private key does not match subject key id") + } + + cb, err := pcbut.ToCertBundle() + if err != nil { + return fmt.Errorf("Thrown error during parsed bundle conversion: %s\n\nInput was: %#v", err, *pcbut) + } + + switch { + case len(cb.Certificate) == 0: + return fmt.Errorf("Bundle has nil certificate") + case len(cb.PrivateKey) == 0: + return fmt.Errorf("Bundle has nil private key") + case len(cb.IssuingCA) == 0: + return fmt.Errorf("Bundle has nil issuing CA") + } + + switch pcbut.PrivateKeyType { + case RSAPrivateKey: + if cb.PrivateKey != privRSAKeyPem && cb.PrivateKey != privRSA8KeyPem { + return fmt.Errorf("Bundle private key does not match") + } + case ECPrivateKey: + if cb.PrivateKey != privECKeyPem && cb.PrivateKey != privEC8KeyPem { + return fmt.Errorf("Bundle private key does not match") + } + default: + return fmt.Errorf("CertBundle has unknown private key type") + } + + if cb.SerialNumber != GetOctalFormatted(pcbut.Certificate.SerialNumber.Bytes(), ":") { + return fmt.Errorf("Bundle serial number does not match") + } + + return nil +} + +func TestCSRBundleConversion(t *testing.T) { + csrbuts := []*CSRBundle{ + refreshRSACSRBundle(), + refreshECCSRBundle(), + } + + for _, csrbut := range csrbuts { + pcsrbut, err := csrbut.ToParsedCSRBundle() + if err != nil { + t.Fatalf("Error converting to parsed CSR bundle: %v", err) + } + + err = compareCSRBundleToParsedCSRBundle(csrbut, pcsrbut) + if err != nil { + t.Fatalf(err.Error()) + } + + csrbut, err = pcsrbut.ToCSRBundle() + if err != nil { + t.Fatalf("Error converting to CSR bundle: %v", err) + } + + err = compareCSRBundleToParsedCSRBundle(csrbut, pcsrbut) + if err != nil { + t.Fatalf(err.Error()) + } + } +} + +func compareCSRBundleToParsedCSRBundle(csrbut *CSRBundle, pcsrbut *ParsedCSRBundle) error { + if csrbut == nil { + return fmt.Errorf("Got nil bundle") + } + if pcsrbut == nil { + return fmt.Errorf("Got nil parsed bundle") + } + + switch { + case pcsrbut.CSR == nil: + return fmt.Errorf("Parsed bundle has nil csr") + case pcsrbut.PrivateKey == nil: + return fmt.Errorf("Parsed bundle has nil private key") + } + + switch csrbut.PrivateKey { + case privRSAKeyPem: + if pcsrbut.PrivateKeyType != RSAPrivateKey { + return fmt.Errorf("Parsed bundle has wrong private key type") + } + case privECKeyPem: + if pcsrbut.PrivateKeyType != ECPrivateKey { + return fmt.Errorf("Parsed bundle has wrong private key type") + } + default: + return fmt.Errorf("Parsed bundle has unknown private key type") + } + + csrb, err := pcsrbut.ToCSRBundle() + if err != nil { + return fmt.Errorf("Thrown error during parsed bundle conversion: %s\n\nInput was: %#v", err, *pcsrbut) + } + + switch { + case len(csrb.CSR) == 0: + return fmt.Errorf("Bundle has nil certificate") + case len(csrb.PrivateKey) == 0: + return fmt.Errorf("Bundle has nil private key") + } + + switch csrb.PrivateKeyType { + case "rsa": + if pcsrbut.PrivateKeyType != RSAPrivateKey { + return fmt.Errorf("Bundle has wrong private key type") + } + if csrb.PrivateKey != privRSAKeyPem { + return fmt.Errorf("Bundle private key does not match") + } + case "ec": + if pcsrbut.PrivateKeyType != ECPrivateKey { + return fmt.Errorf("Bundle has wrong private key type") + } + if csrb.PrivateKey != privECKeyPem { + return fmt.Errorf("Bundle private key does not match") + } + default: + return fmt.Errorf("Bundle has unknown private key type") + } + + return nil +} + func TestTLSConfig(t *testing.T) { cbut := refreshRSACertBundle() @@ -105,143 +358,86 @@ func TestTLSConfig(t *testing.T) { } } -func TestCertBundleParsing(t *testing.T) { - jsonBundle := refreshRSACertBundle() - jsonString, err := json.Marshal(jsonBundle) - if err != nil { - t.Fatalf("Error marshaling testing certbundle to JSON: %s", err) - } - pcbut, err := ParsePKIJSON(jsonString) - if err != nil { - t.Fatalf("Error during JSON bundle handling: %s", err) - } - err = compareCertBundleToParsedCertBundle(jsonBundle, pcbut) - if err != nil { - t.Fatalf(err.Error()) - } - - secret := &api.Secret{ - Data: structs.New(jsonBundle).Map(), - } - pcbut, err = ParsePKIMap(secret.Data) - if err != nil { - t.Fatalf("Error during JSON bundle handling: %s", err) - } - err = compareCertBundleToParsedCertBundle(jsonBundle, pcbut) - if err != nil { - t.Fatalf(err.Error()) - } - - pemBundle := strings.Join([]string{ - jsonBundle.Certificate, - jsonBundle.IssuingCA, - jsonBundle.PrivateKey, - }, "\n") - pcbut, err = ParsePEMBundle(pemBundle) - if err != nil { - t.Fatalf("Error during JSON bundle handling: %s", err) - } - err = compareCertBundleToParsedCertBundle(jsonBundle, pcbut) - if err != nil { - t.Fatalf(err.Error()) - } -} - -func compareCertBundleToParsedCertBundle(cbut *CertBundle, pcbut *ParsedCertBundle) error { - if cbut == nil { - return fmt.Errorf("Got nil bundle") - } - if pcbut == nil { - return fmt.Errorf("Got nil parsed bundle") - } - - switch { - case pcbut.Certificate == nil: - return fmt.Errorf("Parsed bundle has nil certificate") - case pcbut.PrivateKey == nil: - return fmt.Errorf("Parsed bundle has nil private key") - case pcbut.IssuingCA == nil: - return fmt.Errorf("Parsed bundle has nil issuing CA") - } - - switch cbut.PrivateKey { - case privRSAKeyPem: - if pcbut.PrivateKeyType != RSAPrivateKey { - return fmt.Errorf("Parsed bundle has wrong private key type") - } - case privECKeyPem: - if pcbut.PrivateKeyType != ECPrivateKey { - return fmt.Errorf("Parsed bundle has wrong private key type") - } - default: - return fmt.Errorf("Parsed bundle has unknown private key type") - } - - subjKeyID, err := GetSubjKeyID(pcbut.PrivateKey) - if err != nil { - return fmt.Errorf("Error when getting subject key id: %s", err) - } - if bytes.Compare(subjKeyID, pcbut.Certificate.SubjectKeyId) != 0 { - return fmt.Errorf("Parsed bundle private key does not match subject key id") - } - - cb, err := pcbut.ToCertBundle() - if err != nil { - return fmt.Errorf("Thrown error during parsed bundle conversion: %s\n\nInput was: %#v", err, *pcbut) - } - - switch { - case len(cb.Certificate) == 0: - return fmt.Errorf("Bundle has nil certificate") - case len(cb.PrivateKey) == 0: - return fmt.Errorf("Bundle has nil private key") - case len(cb.IssuingCA) == 0: - return fmt.Errorf("Bundle has nil issuing CA") - } - - switch cb.PrivateKeyType { - case "rsa": - if pcbut.PrivateKeyType != RSAPrivateKey { - return fmt.Errorf("Bundle has wrong private key type") - } - if cb.PrivateKey != privRSAKeyPem { - return fmt.Errorf("Bundle private key does not match") - } - case "ec": - if pcbut.PrivateKeyType != ECPrivateKey { - return fmt.Errorf("Bundle has wrong private key type") - } - if cb.PrivateKey != privECKeyPem { - return fmt.Errorf("Bundle private key does not match") - } - default: - return fmt.Errorf("Bundle has unknown private key type") - } - - if cb.SerialNumber != GetOctalFormatted(pcbut.Certificate.SerialNumber.Bytes(), ":") { - return fmt.Errorf("Bundle serial number does not match") - } - - return nil -} - -func refreshRSACertBundle() *CertBundle { +func refreshRSA8CertBundle() *CertBundle { return &CertBundle{ Certificate: certRSAPem, - PrivateKey: privRSAKeyPem, + PrivateKey: privRSA8KeyPem, IssuingCA: issuingCaPem, } } +func refreshRSACertBundle() *CertBundle { + ret := &CertBundle{ + Certificate: certRSAPem, + IssuingCA: issuingCaPem, + } + ret.PrivateKey = privRSAKeyPem + return ret +} + func refreshECCertBundle() *CertBundle { + ret := &CertBundle{ + Certificate: certECPem, + IssuingCA: issuingCaPem, + } + ret.PrivateKey = privECKeyPem + return ret +} + +func refreshRSACSRBundle() *CSRBundle { + ret := &CSRBundle{ + CSR: csrRSAPem, + } + ret.PrivateKey = privRSAKeyPem + return ret +} + +func refreshECCSRBundle() *CSRBundle { + ret := &CSRBundle{ + CSR: csrECPem, + } + ret.PrivateKey = privECKeyPem + return ret +} + +func refreshEC8CertBundle() *CertBundle { return &CertBundle{ Certificate: certECPem, - PrivateKey: privECKeyPem, + PrivateKey: privEC8KeyPem, IssuingCA: issuingCaPem, } } const ( + privRSA8KeyPem = `-----BEGIN PRIVATE KEY----- +MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC3dklRrO0JGJWD +zs/TLxPtAw0VCLrUEJIgp6nFddZzvOLkklIx9ACy1ckSoFiJKGxKlibqyiJPqFfT +vi3vBAAcZLf67uo2iBamZMBRNSc0gz5ALEfY1z+TNjFpZqO6lXOAa8t6KpTd3i0h +ST9mR+29YmvKvaFlzzMQ3cLikZL/YX5FD7M6/4GkAjUF1tAaEXub3a+fopL+Jayq +bAcb2gKGC9Z4EeNZQjyoZq4Fz6K3hLlHF83wkkgFdQhm1tqoVnOCO/yRQPKqhAa+ +Rj/gJ7UrRsUmwzvCYw+/7lCxwgEXgpaA3SRNIw89d+ef9AgB+FphCRP0yPAavr4H +dI4M0YJNAgMBAAECggEAe1LCGmsZs2GZL88XmKguxsWkR51kqSSydcz+rEN38rjn +9Cn/oqCYz54x2Zl7qkdH9CNW6cESq2VIFIfkrKSNxohVvBJZ0mpMf3F+bZhDUGNg +txaM/VBD5hspv+ZE7SmFSLAtSWPSSgoNYDCys3hqcUH1n4U1NxC/DPllBZRBsfSd +5C1Y7WcO8uxJyC7WRyGgTMkQloU5DX4d8Z5bEPvrp9nKplCLn5wuuE6oc4ZKU74g +VV7SGC6IQcWv0sQ9NdeRm05HjBN/uPVSzyzUpD+O/TWzH1LscRtkm6vMiNLbc7LA +RR0l3USwgTaUlXZBTBKICw9hk5JBmWA4bM9VEpWQaQKBgQDW76lU/av7FLFjLwpx +1xEJ0YYGHTRUvHXIlEdZnliMXnqGnRHRwb7EYtqvkoJ0GmviMmdAYivHyXDdIMK3 +gReXGAnGK1eUG2IoHIzv+ZhFF9RGv1YxGvjzwZCVYNujZdqWe5pzSqWQWpUiDQFp +b5nXkD8TUvr1pTFpHSjOUD0mXwKBgQDag0DkXai2rOj141i5w0COKFWEBN3XUMQJ +C9shCn/RsQl7RmefOr9AgYg5VqkLRUoYHAE/kO4svU/+dM+OMT9mGMW6Ew0zk/ML +qhsCMGH6AKlz5z7bVB6u/tEpROLawZPNEe6WlxxEN+4XxuHMPqUCjnQWlKY8T+i9 +nNv34ixe0wKBgFWdR0z0cqHjvzjrzvRDn6TSkdkzntm17BDGh5k6Crl3FMU0IZn0 +28EsQ0G2UUJgF+MVAq3RrPC627spRoaD5FqqF5KZRxxWwAWMQdOBD1dOQ58erf2H +aezmiGoIF9UBSE2y1HXiIQrcGhVjKtHNw3DrI0TWQ+K/N2xQUiXELmdvAoGANRSN +PuxBf56hOJnxg66aj+3cWCWWfidwd4IZyPzz78xBsWB464Up0FGm9cbHaaV7SkAD +TZ23Pcb/F6DoinIMJJD/9yOJoW3fLIY16WI3arOedjlGW6Ejkv7zcEL7mIhNjxM8 +EfjDNQ8hF0WItETDcMuKB7I0b5I5x1XDWYPno2ECgYEAsWHewaSG8+Ij8b+L/m0Z +lUD91L/gNVc6gdbjf5kMdYTCqI3q9N/9VWJyb7yRx8tjUTl9J//h7uYhCrujmpWf +1jcdaxqNLUUV7OcmM+PglprUe96A1zJwDOxc5DvHLbf/zBS6mA14PWYV1IUJdDdR +52wm5UEewSU9zlbvirgXj4U= +-----END PRIVATE KEY-----` + privRSAKeyPem = `-----BEGIN RSA PRIVATE KEY----- MIIEowIBAAKCAQEAt3ZJUaztCRiVg87P0y8T7QMNFQi61BCSIKepxXXWc7zi5JJS MfQAstXJEqBYiShsSpYm6soiT6hX074t7wQAHGS3+u7qNogWpmTAUTUnNIM+QCxH @@ -270,6 +466,23 @@ cm+8kcfLY1E5fSf/4e7mIQq7o5qVn9Y3HWsajS1FFeznJjPj4Jaa1HvegNcycAzs XOQ7xy23/8wUupgNeD1mFdSFCXQ3UedsJuVBHsElPc5W74q4F4+F -----END RSA PRIVATE KEY-----` + csrRSAPem = `-----BEGIN CERTIFICATE REQUEST----- +MIICijCCAXICAQAwRTELMAkGA1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUx +ITAfBgNVBAoMGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDCCASIwDQYJKoZIhvcN +AQEBBQADggEPADCCAQoCggEBALd2SVGs7QkYlYPOz9MvE+0DDRUIutQQkiCnqcV1 +1nO84uSSUjH0ALLVyRKgWIkobEqWJurKIk+oV9O+Le8EABxkt/ru6jaIFqZkwFE1 +JzSDPkAsR9jXP5M2MWlmo7qVc4Bry3oqlN3eLSFJP2ZH7b1ia8q9oWXPMxDdwuKR +kv9hfkUPszr/gaQCNQXW0BoRe5vdr5+ikv4lrKpsBxvaAoYL1ngR41lCPKhmrgXP +oreEuUcXzfCSSAV1CGbW2qhWc4I7/JFA8qqEBr5GP+AntStGxSbDO8JjD7/uULHC +AReCloDdJE0jDz1355/0CAH4WmEJE/TI8Bq+vgd0jgzRgk0CAwEAAaAAMA0GCSqG +SIb3DQEBCwUAA4IBAQAR8U1vZMJf7YFvGU69QvoWPTDe/o8SwYy1j+++AAO9Y7H2 +C7nb+9tnEMtXm+3pkY0aJIecAnq8H4QWimOrJa/ZsoZLzz9LKW2nzARdWo63j4nB +jKld/EDBzQ/nQSTyoX7s9JiDiSC9yqTXBrPHSXruPbh7sE0yXROar+6atjNdCpDp +uLw86gwewDJrMaB1aFAmDvwaRQQDONwRy0zG1UdMxLQxsxpKOHaGM/ZvV3FPir2B +7mKupki/dvap5UW0lTMJBlKf3qhoeHKMHFo9i5vGCIkWUIv+XgTF0NjbYv9i7bfq +WdW905v4wiuWRlddNwqFtLx9Pf1/fRJVT5mBbjIx +-----END CERTIFICATE REQUEST-----` + certRSAPem = `-----BEGIN CERTIFICATE----- MIID+jCCAuSgAwIBAgIUcFCL9ESWTKLE6RqSYV7iZ78f1KcwCwYJKoZIhvcNAQEL MBsxGTAXBgNVBAMMEFZhdWx0IFRlc3RpbmcgQ0EwHhcNMTUwNjE5MTcyMzA0WhcN @@ -301,6 +514,20 @@ AATBZ3VXwBE9oeSREpM5b25PW6WiuLb4EXWpKZyjj552QYKYe7QBuGe9wvvgOeCB ovN3tSuGKzTiUA== -----END EC PRIVATE KEY-----` + csrECPem = `-----BEGIN CERTIFICATE REQUEST----- +MIHsMIGcAgEAMEUxCzAJBgNVBAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEw +HwYDVQQKDBhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQwTjAQBgcqhkjOPQIBBgUr +gQQAIQM6AATBZ3VXwBE9oeSREpM5b25PW6WiuLb4EXWpKZyjj552QYKYe7QBuGe9 +wvvgOeCBovN3tSuGKzTiUKAAMAoGCCqGSM49BAMCAz8AMDwCHFap/5XDuqtXCG1g +ljbYH5OWGBqGYCfL2k2+/6cCHAuk1bmOkGx7JAq/fSPd09i0DQIqUu7WHQHms48= +-----END CERTIFICATE REQUEST-----` + + privEC8KeyPem = `-----BEGIN PRIVATE KEY----- +MHgCAQAwEAYHKoZIzj0CAQYFK4EEACEEYTBfAgEBBBzN57mC5a72sATfYRlXLvZq +WghK+yzHuOGu6EDsoTwDOgAEwWd1V8ARPaHkkRKTOW9uT1ulori2+BF1qSmco4+e +dkGCmHu0AbhnvcL74DnggaLzd7Urhis04lA= +-----END PRIVATE KEY-----` + certECPem = `-----BEGIN CERTIFICATE----- MIIDJDCCAg6gAwIBAgIUM3J02tw0ZvpHUVHv6t8kcoft2/MwCwYJKoZIhvcNAQEL MBsxGTAXBgNVBAMMEFZhdWx0IFRlc3RpbmcgQ0EwHhcNMTUwNjE5MTcyODQyWhcN diff --git a/helper/certutil/helpers.go b/helper/certutil/helpers.go index 9795c70bb..eeb0f8074 100644 --- a/helper/certutil/helpers.go +++ b/helper/certutil/helpers.go @@ -3,11 +3,16 @@ package certutil import ( "bytes" "crypto" + "crypto/ecdsa" + "crypto/elliptic" + "crypto/rand" + "crypto/rsa" "crypto/sha1" "crypto/x509" "encoding/json" "encoding/pem" "fmt" + "math/big" "strconv" "strings" @@ -47,12 +52,12 @@ func ParseHexFormatted(in, sep string) []byte { // of the marshaled public key func GetSubjKeyID(privateKey crypto.Signer) ([]byte, error) { if privateKey == nil { - return nil, InternalError{"Passed-in private key is nil"} + return nil, InternalError{"passed-in private key is nil"} } marshaledKey, err := x509.MarshalPKIXPublicKey(privateKey.Public()) if err != nil { - return nil, InternalError{fmt.Sprintf("Error marshalling public key: %s", err)} + return nil, InternalError{fmt.Sprintf("error marshalling public key: %s", err)} } subjKeyID := sha1.Sum(marshaledKey) @@ -72,8 +77,7 @@ func ParsePKIMap(data map[string]interface{}) (*ParsedCertBundle, error) { return result.ToParsedCertBundle() } -// ParsePKIJSON takes a JSON-encoded string and returns a CertBundle -// ParsedCertBundle. +// ParsePKIJSON takes a JSON-encoded string and returns a ParsedCertBundle. // // This can be either the output of an // issue call from the PKI backend or just its data member; or, @@ -93,7 +97,7 @@ func ParsePKIJSON(input []byte) (*ParsedCertBundle, error) { return ParsePKIMap(secret.Data) } - return nil, UserError{"Unable to parse out of either secret data or a secret object"} + return nil, UserError{"unable to parse out of either secret data or a secret object"} } // ParsePEMBundle takes a string of concatenated PEM-format certificate @@ -102,7 +106,7 @@ func ParsePKIJSON(input []byte) (*ParsedCertBundle, error) { // issuing certificate) and one private key. func ParsePEMBundle(pemBundle string) (*ParsedCertBundle, error) { if len(pemBundle) == 0 { - return nil, UserError{"Empty PEM bundle"} + return nil, UserError{"empty pem bundle"} } pemBytes := []byte(pemBundle) @@ -112,29 +116,46 @@ func ParsePEMBundle(pemBundle string) (*ParsedCertBundle, error) { for { pemBlock, pemBytes = pem.Decode(pemBytes) if pemBlock == nil { - return nil, UserError{"No data found"} + return nil, UserError{"no data found"} } if signer, err := x509.ParseECPrivateKey(pemBlock.Bytes); err == nil { if parsedBundle.PrivateKeyType != UnknownPrivateKey { - return nil, UserError{"More than one private key given; provide only one private key in the bundle"} + return nil, UserError{"more than one private key given; provide only one private key in the bundle"} } + parsedBundle.PrivateKeyFormat = ECBlock parsedBundle.PrivateKeyType = ECPrivateKey parsedBundle.PrivateKeyBytes = pemBlock.Bytes parsedBundle.PrivateKey = signer } else if signer, err := x509.ParsePKCS1PrivateKey(pemBlock.Bytes); err == nil { if parsedBundle.PrivateKeyType != UnknownPrivateKey { - return nil, UserError{"More than one private key given; provide only one private key in the bundle"} + return nil, UserError{"more than one private key given; provide only one private key in the bundle"} } parsedBundle.PrivateKeyType = RSAPrivateKey + parsedBundle.PrivateKeyFormat = PKCS1Block parsedBundle.PrivateKeyBytes = pemBlock.Bytes parsedBundle.PrivateKey = signer + } else if signer, err := x509.ParsePKCS8PrivateKey(pemBlock.Bytes); err == nil { + parsedBundle.PrivateKeyFormat = PKCS8Block + if parsedBundle.PrivateKeyType != UnknownPrivateKey { + return nil, UserError{"More than one private key given; provide only one private key in the bundle"} + } + switch signer := signer.(type) { + case *rsa.PrivateKey: + parsedBundle.PrivateKey = signer + parsedBundle.PrivateKeyType = RSAPrivateKey + parsedBundle.PrivateKeyBytes = pemBlock.Bytes + case *ecdsa.PrivateKey: + parsedBundle.PrivateKey = signer + parsedBundle.PrivateKeyType = ECPrivateKey + parsedBundle.PrivateKeyBytes = pemBlock.Bytes + } } else if certificates, err := x509.ParseCertificates(pemBlock.Bytes); err == nil { switch len(certificates) { case 0: - return nil, UserError{"PEM block cannot be decoded to a private key or certificate"} + return nil, UserError{"pem block cannot be decoded to a private key or certificate"} case 1: if parsedBundle.Certificate != nil { @@ -167,7 +188,7 @@ func ParsePEMBundle(pemBundle string) (*ParsedCertBundle, error) { } default: - return nil, UserError{"Too many certificates given; provide a maximum of two certificates in the bundle"} + return nil, UserError{"too many certificates given; provide a maximum of two certificates in the bundle"} } } @@ -178,3 +199,102 @@ func ParsePEMBundle(pemBundle string) (*ParsedCertBundle, error) { return parsedBundle, nil } + +// GeneratePrivateKey generates a private key with the specified type and key bits +func GeneratePrivateKey(keyType string, keyBits int, container ParsedPrivateKeyContainer) error { + var err error + var privateKeyType PrivateKeyType + var privateKeyBytes []byte + var privateKey crypto.Signer + + switch keyType { + case "rsa": + privateKeyType = RSAPrivateKey + privateKey, err = rsa.GenerateKey(rand.Reader, keyBits) + if err != nil { + return InternalError{Err: fmt.Sprintf("error generating RSA private key: %v", err)} + } + privateKeyBytes = x509.MarshalPKCS1PrivateKey(privateKey.(*rsa.PrivateKey)) + case "ec": + privateKeyType = ECPrivateKey + var curve elliptic.Curve + switch keyBits { + case 224: + curve = elliptic.P224() + case 256: + curve = elliptic.P256() + case 384: + curve = elliptic.P384() + case 521: + curve = elliptic.P521() + default: + return UserError{Err: fmt.Sprintf("unsupported bit length for EC key: %d", keyBits)} + } + privateKey, err = ecdsa.GenerateKey(curve, rand.Reader) + if err != nil { + return InternalError{Err: fmt.Sprintf("error generating EC private key: %v", err)} + } + privateKeyBytes, err = x509.MarshalECPrivateKey(privateKey.(*ecdsa.PrivateKey)) + if err != nil { + return InternalError{Err: fmt.Sprintf("error marshalling EC private key: %v", err)} + } + default: + return UserError{Err: fmt.Sprintf("unknown key type: %s", keyType)} + } + + container.SetParsedPrivateKey(privateKey, privateKeyType, privateKeyBytes) + return nil +} + +// GenerateSerialNumber generates a serial number suitable for a certificate +func GenerateSerialNumber() (*big.Int, error) { + serial, err := rand.Int(rand.Reader, (&big.Int{}).Exp(big.NewInt(2), big.NewInt(159), nil)) + if err != nil { + return nil, InternalError{Err: fmt.Sprintf("error generating serial number: %v", err)} + } + return serial, nil +} + +// ComparePublicKeys compares two public keys and returns true if they match +func ComparePublicKeys(key1Iface, key2Iface crypto.PublicKey) (bool, error) { + switch key1Iface.(type) { + case *rsa.PublicKey: + key1 := key1Iface.(*rsa.PublicKey) + key2, ok := key2Iface.(*rsa.PublicKey) + if !ok { + return false, fmt.Errorf("key types do not match: %T and %T", key1Iface, key2Iface) + } + if key1.N.Cmp(key2.N) != 0 || + key1.E != key2.E { + return false, nil + } + return true, nil + + case *ecdsa.PublicKey: + key1 := key1Iface.(*ecdsa.PublicKey) + key2, ok := key2Iface.(*ecdsa.PublicKey) + if !ok { + return false, fmt.Errorf("key types do not match: %T and %T", key1Iface, key2Iface) + } + if key1.X.Cmp(key2.X) != 0 || + key1.Y.Cmp(key2.Y) != 0 { + return false, nil + } + key1Params := key1.Params() + key2Params := key2.Params() + if key1Params.P.Cmp(key2Params.P) != 0 || + key1Params.N.Cmp(key2Params.N) != 0 || + key1Params.B.Cmp(key2Params.B) != 0 || + key1Params.Gx.Cmp(key2Params.Gx) != 0 || + key1Params.Gy.Cmp(key2Params.Gy) != 0 || + key1Params.BitSize != key2Params.BitSize { + return false, nil + } + return true, nil + + default: + return false, fmt.Errorf("cannot compare key with type %T", key1Iface) + } + + return false, fmt.Errorf("undefined error comparing public keys") +} diff --git a/helper/certutil/types.go b/helper/certutil/types.go index 8ece20c2b..92ae652dd 100644 --- a/helper/certutil/types.go +++ b/helper/certutil/types.go @@ -3,13 +3,13 @@ // includes helpers for converting a certificate/private key bundle // between DER and PEM, printing certificate serial numbers, and more. // -// Functionality specific to the PKI backend includes some types -// and helper methods to make requesting certificates from the -// backend easy. +// Functionality specific to the PKI backend includes some types // and helper methods to make requesting certificates from the // backend easy. package certutil import ( "crypto" + "crypto/ecdsa" + "crypto/rsa" "crypto/tls" "crypto/x509" "encoding/pem" @@ -23,24 +23,40 @@ type Secret struct { Data map[string]interface{} `json:"data"` } +// PrivateKeyType holds a string representation of the type of private key (ec +// or rsa) referenced in CertBundle and ParsedCertBundle. This uses colloquial +// names rather than official names, to eliminate confusion +type PrivateKeyType string + +//Well-known PrivateKeyTypes +const ( + UnknownPrivateKey PrivateKeyType = "" + RSAPrivateKey PrivateKeyType = "rsa" + ECPrivateKey PrivateKeyType = "ec" +) + // TLSUsage controls whether the intended usage of a *tls.Config // returned from ParsedCertBundle.GetTLSConfig is for server use, // client use, or both, which affects which values are set type TLSUsage int -// The type of of the Private Key referenced in CertBundle -// and ParsedCertBundle. This uses colloquial names rather than -// official names, to eliminate confusion +//Well-known TLSUsage types const ( - UnknownPrivateKey = iota - RSAPrivateKey - ECPrivateKey - TLSUnknown TLSUsage = 0 TLSServer TLSUsage = 1 << iota TLSClient ) +//BlockType indicates the serialization format of the key +type BlockType string + +//Well-known formats +const ( + PKCS1Block BlockType = "RSA PRIVATE KEY" + PKCS8Block BlockType = "PRIVATE KEY" + ECBlock BlockType = "EC PRIVATE KEY" +) + // UserError represents an error generated due to invalid user input type UserError struct { Err string @@ -60,21 +76,27 @@ func (e InternalError) Error() string { return e.Err } +//ParsedPrivateKeyContainer allows common key setting for certs and CSRs +type ParsedPrivateKeyContainer interface { + SetParsedPrivateKey(crypto.Signer, PrivateKeyType, []byte) +} + // CertBundle contains a key type, a PEM-encoded private key, // a PEM-encoded certificate, and a string-encoded serial number, // returned from a successful Issue request type CertBundle struct { - PrivateKeyType string `json:"private_key_type" structs:"private_key_type" mapstructure:"private_key_type"` - Certificate string `json:"certificate" structs:"certificate" mapstructure:"certificate"` - IssuingCA string `json:"issuing_ca" structs:"issuing_ca" mapstructure:"issuing_ca"` - PrivateKey string `json:"private_key" structs:"private_key" mapstructure:"private_key"` - SerialNumber string `json:"serial_number" structs:"serial_number" mapstructure:"serial_number"` + PrivateKeyType PrivateKeyType `json:"private_key_type" structs:"private_key_type" mapstructure:"private_key_type"` + Certificate string `json:"certificate" structs:"certificate" mapstructure:"certificate"` + IssuingCA string `json:"issuing_ca" structs:"issuing_ca" mapstructure:"issuing_ca"` + PrivateKey string `json:"private_key" structs:"private_key" mapstructure:"private_key"` + SerialNumber string `json:"serial_number" structs:"serial_number" mapstructure:"serial_number"` } // ParsedCertBundle contains a key type, a DER-encoded private key, -// a DER-encoded certificate, and a big.Int serial number +// and a DER-encoded certificate type ParsedCertBundle struct { - PrivateKeyType int + PrivateKeyType PrivateKeyType + PrivateKeyFormat BlockType PrivateKeyBytes []byte PrivateKey crypto.Signer IssuingCABytes []byte @@ -83,6 +105,24 @@ type ParsedCertBundle struct { Certificate *x509.Certificate } +// CSRBundle contains a key type, a PEM-encoded private key, +// and a PEM-encoded CSR +type CSRBundle struct { + PrivateKeyType PrivateKeyType `json:"private_key_type" structs:"private_key_type" mapstructure:"private_key_type"` + CSR string `json:"csr" structs:"csr" mapstructure:"csr"` + PrivateKey string `json:"private_key" structs:"private_key" mapstructure:"private_key"` +} + +// ParsedCSRBundle contains a key type, a DER-encoded private key, +// and a DER-encoded certificate request +type ParsedCSRBundle struct { + PrivateKeyType PrivateKeyType + PrivateKeyBytes []byte + PrivateKey crypto.Signer + CSRBytes []byte + CSR *x509.CertificateRequest +} + // ToParsedCertBundle converts a string-based certificate bundle // to a byte-based raw certificate bundle func (c *CertBundle) ToParsedCertBundle() (*ParsedCertBundle, error) { @@ -95,24 +135,29 @@ func (c *CertBundle) ToParsedCertBundle() (*ParsedCertBundle, error) { if pemBlock == nil { return nil, UserError{"Error decoding private key from cert bundle"} } - result.PrivateKeyBytes = pemBlock.Bytes - switch c.PrivateKeyType { - case "ec": - result.PrivateKeyType = ECPrivateKey - case "rsa": - result.PrivateKeyType = RSAPrivateKey - default: - // Try to figure it out and correct - if _, err := x509.ParseECPrivateKey(pemBlock.Bytes); err == nil { - result.PrivateKeyType = ECPrivateKey - c.PrivateKeyType = "ec" - } else if _, err := x509.ParsePKCS1PrivateKey(pemBlock.Bytes); err == nil { - result.PrivateKeyType = RSAPrivateKey - c.PrivateKeyType = "rsa" - } else { - return nil, UserError{fmt.Sprintf("Unknown private key type in bundle: %s", c.PrivateKeyType)} + result.PrivateKeyBytes = pemBlock.Bytes + result.PrivateKeyFormat = BlockType(strings.TrimSpace(pemBlock.Type)) + + switch result.PrivateKeyFormat { + case ECBlock: + result.PrivateKeyType, c.PrivateKeyType = ECPrivateKey, ECPrivateKey + case PKCS1Block: + c.PrivateKeyType, result.PrivateKeyType = RSAPrivateKey, RSAPrivateKey + case PKCS8Block: + t, err := getPKCS8Type(pemBlock.Bytes) + if err != nil { + return nil, UserError{fmt.Sprintf("Error getting key type from pkcs#8: %v", err)} } + result.PrivateKeyType = t + switch t { + case ECPrivateKey: + c.PrivateKeyType = ECPrivateKey + case RSAPrivateKey: + c.PrivateKeyType = RSAPrivateKey + } + default: + return nil, UserError{fmt.Sprintf("Unsupported key block type: %s", pemBlock.Type)} } result.PrivateKey, err = result.getSigner() @@ -174,6 +219,157 @@ func (p *ParsedCertBundle) ToCertBundle() (*CertBundle, error) { result.IssuingCA = strings.TrimSpace(string(pem.EncodeToMemory(&block))) } + if p.PrivateKeyBytes != nil && len(p.PrivateKeyBytes) > 0 { + block.Type = string(p.PrivateKeyFormat) + block.Bytes = p.PrivateKeyBytes + result.PrivateKeyType = p.PrivateKeyType + + //Handle bundle not parsed by us + if block.Type == "" { + switch p.PrivateKeyType { + case ECPrivateKey: + block.Type = string(ECBlock) + case RSAPrivateKey: + block.Type = string(PKCS1Block) + } + } + + result.PrivateKey = strings.TrimSpace(string(pem.EncodeToMemory(&block))) + } + + return result, nil +} + +// GetSigner returns a crypto.Signer corresponding to the private key +// contained in this ParsedCertBundle. The Signer contains a Public() function +// for getting the corresponding public. The Signer can also be +// type-converted to private keys +func (p *ParsedCertBundle) getSigner() (crypto.Signer, error) { + var signer crypto.Signer + var err error + + if p.PrivateKeyBytes == nil || len(p.PrivateKeyBytes) == 0 { + return nil, UserError{"Given parsed cert bundle does not have private key information"} + } + + switch p.PrivateKeyFormat { + case ECBlock: + signer, err = x509.ParseECPrivateKey(p.PrivateKeyBytes) + if err != nil { + return nil, UserError{fmt.Sprintf("Unable to parse CA's private EC key: %s", err)} + } + + case PKCS1Block: + signer, err = x509.ParsePKCS1PrivateKey(p.PrivateKeyBytes) + if err != nil { + return nil, UserError{fmt.Sprintf("Unable to parse CA's private RSA key: %s", err)} + } + + case PKCS8Block: + if k, err := x509.ParsePKCS8PrivateKey(p.PrivateKeyBytes); err == nil { + switch k := k.(type) { + case *rsa.PrivateKey, *ecdsa.PrivateKey: + return k.(crypto.Signer), nil + default: + return nil, UserError{"Found unknown private key type in pkcs#8 wrapping"} + } + } + return nil, UserError{fmt.Sprintf("Failed to parse pkcs#8 key: %v", err)} + default: + return nil, UserError{"Unable to determine type of private key; only RSA and EC are supported"} + } + return signer, nil +} + +// SetParsedPrivateKey sets the private key parameters on the bundle +func (p *ParsedCertBundle) SetParsedPrivateKey(privateKey crypto.Signer, privateKeyType PrivateKeyType, privateKeyBytes []byte) { + p.PrivateKey = privateKey + p.PrivateKeyType = privateKeyType + p.PrivateKeyBytes = privateKeyBytes +} + +func getPKCS8Type(bs []byte) (PrivateKeyType, error) { + k, err := x509.ParsePKCS8PrivateKey(bs) + if err != nil { + return UnknownPrivateKey, UserError{fmt.Sprintf("Failed to parse pkcs#8 key: %v", err)} + } + + switch k.(type) { + case *ecdsa.PrivateKey: + return ECPrivateKey, nil + case *rsa.PrivateKey: + return RSAPrivateKey, nil + default: + return UnknownPrivateKey, UserError{"Found unknown private key type in pkcs#8 wrapping"} + } +} + +// ToParsedCSRBundle converts a string-based CSR bundle +// to a byte-based raw CSR bundle +func (c *CSRBundle) ToParsedCSRBundle() (*ParsedCSRBundle, error) { + result := &ParsedCSRBundle{} + var err error + var pemBlock *pem.Block + + if len(c.PrivateKey) > 0 { + pemBlock, _ = pem.Decode([]byte(c.PrivateKey)) + if pemBlock == nil { + return nil, UserError{"Error decoding private key from cert bundle"} + } + result.PrivateKeyBytes = pemBlock.Bytes + + switch BlockType(pemBlock.Type) { + case ECBlock: + result.PrivateKeyType = ECPrivateKey + case PKCS1Block: + result.PrivateKeyType = RSAPrivateKey + default: + // Try to figure it out and correct + if _, err := x509.ParseECPrivateKey(pemBlock.Bytes); err == nil { + result.PrivateKeyType = ECPrivateKey + c.PrivateKeyType = "ec" + } else if _, err := x509.ParsePKCS1PrivateKey(pemBlock.Bytes); err == nil { + result.PrivateKeyType = RSAPrivateKey + c.PrivateKeyType = "rsa" + } else { + return nil, UserError{fmt.Sprintf("Unknown private key type in bundle: %s", c.PrivateKeyType)} + } + } + + result.PrivateKey, err = result.getSigner() + if err != nil { + return nil, UserError{fmt.Sprintf("Error getting signer: %s", err)} + } + } + + if len(c.CSR) > 0 { + pemBlock, _ = pem.Decode([]byte(c.CSR)) + if pemBlock == nil { + return nil, UserError{"Error decoding certificate from cert bundle"} + } + result.CSRBytes = pemBlock.Bytes + result.CSR, err = x509.ParseCertificateRequest(result.CSRBytes) + if err != nil { + return nil, UserError{"Error encountered parsing certificate bytes from raw bundle"} + } + } + + return result, nil +} + +// ToCSRBundle converts a byte-based raw DER certificate bundle +// to a PEM-based string certificate bundle +func (p *ParsedCSRBundle) ToCSRBundle() (*CSRBundle, error) { + result := &CSRBundle{} + block := pem.Block{ + Type: "CERTIFICATE REQUEST", + } + + if p.CSRBytes != nil && len(p.CSRBytes) > 0 { + block.Bytes = p.CSRBytes + result.CSR = strings.TrimSpace(string(pem.EncodeToMemory(&block))) + } + if p.PrivateKeyBytes != nil && len(p.PrivateKeyBytes) > 0 { block.Bytes = p.PrivateKeyBytes switch p.PrivateKeyType { @@ -193,10 +389,10 @@ func (p *ParsedCertBundle) ToCertBundle() (*CertBundle, error) { } // GetSigner returns a crypto.Signer corresponding to the private key -// contained in this ParsedCertBundle. The Signer contains a Public() function +// contained in this ParsedCSRBundle. The Signer contains a Public() function // for getting the corresponding public. The Signer can also be // type-converted to private keys -func (p *ParsedCertBundle) getSigner() (crypto.Signer, error) { +func (p *ParsedCSRBundle) getSigner() (crypto.Signer, error) { var signer crypto.Signer var err error @@ -223,6 +419,13 @@ func (p *ParsedCertBundle) getSigner() (crypto.Signer, error) { return signer, nil } +// SetParsedPrivateKey sets the private key parameters on the bundle +func (p *ParsedCSRBundle) SetParsedPrivateKey(privateKey crypto.Signer, privateKeyType PrivateKeyType, privateKeyBytes []byte) { + p.PrivateKey = privateKey + p.PrivateKeyType = privateKeyType + p.PrivateKeyBytes = privateKeyBytes +} + // GetTLSConfig returns a TLS config generally suitable for client // authentiation. The returned TLS config can be modified slightly // to be made suitable for a server requiring client authentication; @@ -284,8 +487,9 @@ func (p *ParsedCertBundle) GetTLSConfig(usage TLSUsage) (*tls.Config, error) { // IssueData is a structure that is suitable for marshaling into a request; // either via JSON, or into a map[string]interface{} via the structs package type IssueData struct { - Lease string `json:"lease" structs:"lease" mapstructure:"lease"` + TTL string `json:"ttl" structs:"ttl" mapstructure:"ttl"` CommonName string `json:"common_name" structs:"common_name" mapstructure:"common_name"` AltNames string `json:"alt_names" structs:"alt_names" mapstructure:"alt_names"` IPSANs string `json:"ip_sans" structs:"ip_sans" mapstructure:"ip_sans"` + CSR string `json:"csr" structs:"csr" mapstructure:"csr"` } diff --git a/helper/mlock/mlock_solaris.go b/helper/mlock/mlock_solaris.go new file mode 100644 index 000000000..29602ad6e --- /dev/null +++ b/helper/mlock/mlock_solaris.go @@ -0,0 +1,17 @@ +// +build solaris + +package mlock + +import ( + "syscall" + "golang.org/x/sys/unix" +) + +func init() { + supported = true +} + +func lockMemory() error { + // Mlockall prevents all current and future pages from being swapped out. + return unix.Mlockall(syscall.MCL_CURRENT | syscall.MCL_FUTURE) +} diff --git a/helper/mlock/mlock_unavail.go b/helper/mlock/mlock_unavail.go index a5768b4dc..b63f67a19 100644 --- a/helper/mlock/mlock_unavail.go +++ b/helper/mlock/mlock_unavail.go @@ -1,4 +1,4 @@ -// +build windows plan9 darwin freebsd openbsd solaris +// +build windows plan9 darwin freebsd openbsd package mlock diff --git a/helper/salt/salt.go b/helper/salt/salt.go index 0abd9054b..9c1874519 100644 --- a/helper/salt/salt.go +++ b/helper/salt/salt.go @@ -8,7 +8,7 @@ import ( "fmt" "hash" - "github.com/hashicorp/uuid" + "github.com/hashicorp/go-uuid" "github.com/hashicorp/vault/logical" ) diff --git a/helper/salt/salt_test.go b/helper/salt/salt_test.go index 6eb8d7195..f7726f6a8 100644 --- a/helper/salt/salt_test.go +++ b/helper/salt/salt_test.go @@ -5,7 +5,7 @@ import ( "crypto/sha256" "testing" - "github.com/hashicorp/uuid" + "github.com/hashicorp/go-uuid" "github.com/hashicorp/vault/logical" ) diff --git a/http/logical_test.go b/http/logical_test.go index 0edf44f19..d38b61658 100644 --- a/http/logical_test.go +++ b/http/logical_test.go @@ -69,9 +69,10 @@ func TestLogical_StandbyRedirect(t *testing.T) { defer ln2.Close() // Create an HA Vault - inm := physical.NewInmemHA() + inmha := physical.NewInmemHA() conf := &vault.CoreConfig{ - Physical: inm, + Physical: inmha, + HAPhysical: inmha, AdvertiseAddr: addr1, DisableMlock: true, } @@ -86,7 +87,8 @@ func TestLogical_StandbyRedirect(t *testing.T) { // Create a second HA Vault conf2 := &vault.CoreConfig{ - Physical: inm, + Physical: inmha, + HAPhysical: inmha, AdvertiseAddr: addr2, DisableMlock: true, } diff --git a/physical/consul.go b/physical/consul.go index e2305da3b..fe0731cfa 100644 --- a/physical/consul.go +++ b/physical/consul.go @@ -3,7 +3,6 @@ package physical import ( "fmt" "io/ioutil" - "net/http" "sort" "strconv" "strings" @@ -15,6 +14,7 @@ import ( "github.com/armon/go-metrics" "github.com/hashicorp/consul/api" "github.com/hashicorp/errwrap" + "github.com/hashicorp/go-cleanhttp" ) // ConsulBackend is a physical backend that stores data at specific @@ -53,9 +53,6 @@ func newConsulBackend(conf map[string]string) (Backend, error) { if scheme, ok := conf["scheme"]; ok { consulConf.Scheme = scheme } - if dc, ok := conf["datacenter"]; ok { - consulConf.Datacenter = dc - } if token, ok := conf["token"]; ok { consulConf.Token = token } @@ -66,9 +63,9 @@ func newConsulBackend(conf map[string]string) (Backend, error) { return nil, err } - consulConf.HttpClient.Transport = &http.Transport{ - TLSClientConfig: tlsClientConfig, - } + transport := cleanhttp.DefaultTransport() + transport.TLSClientConfig = tlsClientConfig + consulConf.HttpClient.Transport = transport } client, err := api.NewClient(consulConf) @@ -206,9 +203,10 @@ func (c *ConsulBackend) List(prefix string) ([]string, error) { func (c *ConsulBackend) LockWith(key, value string) (Lock, error) { // Create the lock opts := &api.LockOptions{ - Key: c.path + key, - Value: []byte(value), - SessionName: "Vault Lock", + Key: c.path + key, + Value: []byte(value), + SessionName: "Vault Lock", + MonitorRetries: 5, } lock, err := c.client.LockOpts(opts) if err != nil { diff --git a/physical/etcd.go b/physical/etcd.go index fc110af62..ecd76e825 100644 --- a/physical/etcd.go +++ b/physical/etcd.go @@ -4,6 +4,7 @@ import ( "encoding/base64" "errors" "net/url" + "os" "path/filepath" "strings" "sync" @@ -53,8 +54,8 @@ var ( // errorIsMissingKey returns true if the given error is an etcd error with an // error code corresponding to a missing key. func errorIsMissingKey(err error) bool { - etcdErr, ok := err.(*client.Error) - return ok && etcdErr.Code == 100 + etcdErr, ok := err.(client.Error) + return ok && etcdErr.Code == client.ErrorCodeKeyNotFound } // EtcdBackend is a physical backend that stores data at specific @@ -121,6 +122,22 @@ func newEtcdBackend(conf map[string]string) (Backend, error) { Transport: cTransport, } + // Set credentials. + username := os.Getenv("ETCD_USERNAME") + if username == "" { + username, _ = conf["username"] + } + + password := os.Getenv("ETCD_PASSWORD") + if password == "" { + password, _ = conf["password"] + } + + if username != "" && password != "" { + cfg.Username = username + cfg.Password = password + } + c, err := client.New(cfg) if err != nil { return nil, err diff --git a/physical/inmem_ha.go b/physical/inmem_ha.go index 92ee314f7..36e09a087 100644 --- a/physical/inmem_ha.go +++ b/physical/inmem_ha.go @@ -32,6 +32,12 @@ func (i *InmemHABackend) LockWith(key, value string) (Lock, error) { return l, nil } +// LockMapSize is used in some tests to determine whether this backend has ever +// been used for HA purposes rather than simply for storage +func (i *InmemHABackend) LockMapSize() int { + return len(i.locks) +} + // InmemLock is an in-memory Lock implementation for the HABackend type InmemLock struct { in *InmemHABackend diff --git a/physical/s3.go b/physical/s3.go index 3b82a418a..1413303d2 100644 --- a/physical/s3.go +++ b/physical/s3.go @@ -14,6 +14,7 @@ import ( "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/aws/credentials" "github.com/aws/aws-sdk-go/aws/credentials/ec2rolecreds" + "github.com/aws/aws-sdk-go/aws/ec2metadata" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/s3" ) @@ -30,9 +31,9 @@ type S3Backend struct { // from the environment, AWS credential files or by IAM role. func newS3Backend(conf map[string]string) (Backend, error) { - bucket, ok := conf["bucket"] - if !ok { - bucket = os.Getenv("AWS_S3_BUCKET") + bucket := os.Getenv("AWS_S3_BUCKET") + if bucket == "" { + bucket = conf["bucket"] if bucket == "" { return nil, fmt.Errorf("'bucket' must be set") } @@ -50,13 +51,13 @@ func newS3Backend(conf map[string]string) (Backend, error) { if !ok { session_token = "" } - endpoint, ok := conf["endpoint"] - if !ok { - endpoint = os.Getenv("AWS_S3_ENDPOINT") + endpoint := os.Getenv("AWS_S3_ENDPOINT") + if endpoint == "" { + endpoint = conf["endpoint"] } - region, ok := conf["region"] - if !ok { - region = os.Getenv("AWS_DEFAULT_REGION") + region := os.Getenv("AWS_DEFAULT_REGION") + if region == "" { + region = conf["region"] if region == "" { region = "us-east-1" } @@ -70,7 +71,7 @@ func newS3Backend(conf map[string]string) (Backend, error) { }}, &credentials.EnvProvider{}, &credentials.SharedCredentialsProvider{Filename: "", Profile: ""}, - &ec2rolecreds.EC2RoleProvider{}, + &ec2rolecreds.EC2RoleProvider{Client: ec2metadata.New(session.New())}, }) s3conn := s3.New(session.New(&aws.Config{ diff --git a/scripts/cross/Dockerfile b/scripts/cross/Dockerfile index 8908ddf82..81accfdc4 100644 --- a/scripts/cross/Dockerfile +++ b/scripts/cross/Dockerfile @@ -10,7 +10,7 @@ RUN apt-get update -y && apt-get install --no-install-recommends -y -q \ git mercurial bzr \ && rm -rf /var/lib/apt/lists/* -ENV GOVERSION 1.5.1 +ENV GOVERSION 1.5.2 RUN mkdir /goroot && mkdir /gopath RUN curl https://storage.googleapis.com/golang/go${GOVERSION}.linux-amd64.tar.gz \ | tar xvzf - -C /goroot --strip-components=1 diff --git a/scripts/dist.sh b/scripts/dist.sh index d1a8ce192..9e428b125 100755 --- a/scripts/dist.sh +++ b/scripts/dist.sh @@ -8,9 +8,14 @@ if [ -z $VERSION ]; then exit 1 fi -# Make sure we have a bintray API key -if [ -z $BINTRAY_API_KEY ] && [ ! -z $BINTRAY ]; then - echo "Please set your bintray API key in the BINTRAY_API_KEY env var." +# Make sure we have AWS API keys +if ([ -z $AWS_ACCESS_KEY_ID ] || [ -z $AWS_SECRET_ACCESS_KEY ]) && [ ! -z $HC_RELEASE ]; then + echo "Please set your AWS access key information in the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY env vars." + exit 1 +fi + +if [ -z $NOBUILD ] && [ -z $DOCKER_CROSS_IMAGE ]; then + echo "Please set the Docker cross-compile image in DOCKER_CROSS_IMAGE" exit 1 fi @@ -22,17 +27,21 @@ DIR="$( cd -P "$( dirname "$SOURCE" )/.." && pwd )" # Change into that dir because we expect that cd $DIR +if [ -z $RELBRANCH ]; then + RELBRANCH=master +fi + # Tag, unless told not to if [ -z $NOTAG ]; then echo "==> Tagging..." git commit --allow-empty -a --gpg-sign=348FFC4C -m "Cut version $VERSION" - git tag -a -m "Version $VERSION" -s -u 348FFC4C "v${VERSION}" master + git tag -a -m "Version $VERSION" -s -u 348FFC4C "v${VERSION}" $RELBRANCH fi # Build the packages if [ -z $NOBUILD ]; then -# Yes, jefferai/gox should be parameterized; it's just a local build of the Dockerfile in the cross dir - docker run --rm -v "$(pwd)":/gopath/src/github.com/hashicorp/vault -w /gopath/src/github.com/hashicorp/vault jefferai/gox:1.5.1 + # This should be a local build of the Dockerfile in the cross dir + docker run --rm -v "$(pwd)":/gopath/src/github.com/hashicorp/vault -w /gopath/src/github.com/hashicorp/vault ${DOCKER_CROSS_IMAGE} fi # Zip all the files @@ -53,16 +62,8 @@ if [ -z $NOSIGN ]; then fi # Upload -if [ ! -z $BINTRAY ]; then - for ARCHIVE in ./pkg/dist/*; do - ARCHIVE_NAME=$(basename ${ARCHIVE}) - - echo Uploading: $ARCHIVE_NAME - curl \ - -T ${ARCHIVE} \ - -umitchellh:${BINTRAY_API_KEY} \ - "https://api.bintray.com/content/mitchellh/vault/vault/${VERSION}/${ARCHIVE_NAME}" - done +if [ ! -z $HC_RELEASE ]; then + hc-releases -upload $DIR/pkg/dist --publish --purge fi exit 0 diff --git a/terraform/aws/main.tf b/terraform/aws/main.tf index b65774c62..279b0bfc8 100644 --- a/terraform/aws/main.tf +++ b/terraform/aws/main.tf @@ -1,5 +1,5 @@ resource "template_file" "install" { - filename = "${path.module}/scripts/install.sh.tpl" + template = "${file("${path.module}/scripts/install.sh.tpl")}" vars { download_url = "${var.download-url}" diff --git a/vault/audit.go b/vault/audit.go index 96e225348..40d2e1a94 100644 --- a/vault/audit.go +++ b/vault/audit.go @@ -11,7 +11,7 @@ import ( "time" "github.com/armon/go-metrics" - "github.com/hashicorp/uuid" + "github.com/hashicorp/go-uuid" "github.com/hashicorp/vault/audit" "github.com/hashicorp/vault/helper/salt" "github.com/hashicorp/vault/logical" diff --git a/vault/auth.go b/vault/auth.go index caad2a6ae..18e077f1f 100644 --- a/vault/auth.go +++ b/vault/auth.go @@ -6,7 +6,7 @@ import ( "fmt" "strings" - "github.com/hashicorp/uuid" + "github.com/hashicorp/go-uuid" "github.com/hashicorp/vault/logical" ) diff --git a/vault/core.go b/vault/core.go index eaa349d00..c3ffa32be 100644 --- a/vault/core.go +++ b/vault/core.go @@ -19,7 +19,7 @@ import ( "github.com/armon/go-metrics" "github.com/hashicorp/errwrap" "github.com/hashicorp/go-multierror" - "github.com/hashicorp/uuid" + "github.com/hashicorp/go-uuid" "github.com/hashicorp/vault/audit" "github.com/hashicorp/vault/helper/mlock" "github.com/hashicorp/vault/helper/pgpkeys" @@ -273,6 +273,7 @@ type CoreConfig struct { CredentialBackends map[string]logical.Factory AuditBackends map[string]audit.Factory Physical physical.Backend + HAPhysical physical.HABackend // May be nil, which disables HA operations Logger *log.Logger DisableCache bool // Disables the LRU cache on the physical backend DisableMlock bool // Disables mlock syscall @@ -284,12 +285,7 @@ type CoreConfig struct { // NewCore is used to construct a new core func NewCore(conf *CoreConfig) (*Core, error) { - // Check if this backend supports an HA configuraiton - var haBackend physical.HABackend - if ha, ok := conf.Physical.(physical.HABackend); ok { - haBackend = ha - } - if haBackend != nil && conf.AdvertiseAddr == "" { + if conf.HAPhysical != nil && conf.AdvertiseAddr == "" { return nil, fmt.Errorf("missing advertisement address") } @@ -299,7 +295,6 @@ func NewCore(conf *CoreConfig) (*Core, error) { if conf.MaxLeaseTTL == 0 { conf.MaxLeaseTTL = maxLeaseTTL } - if conf.DefaultLeaseTTL > conf.MaxLeaseTTL { return nil, fmt.Errorf("cannot have DefaultLeaseTTL larger than MaxLeaseTTL") } @@ -355,7 +350,7 @@ func NewCore(conf *CoreConfig) (*Core, error) { // Setup the core c := &Core{ - ha: haBackend, + ha: conf.HAPhysical, advertiseAddr: conf.AdvertiseAddr, physical: conf.Physical, barrier: barrier, @@ -1066,13 +1061,13 @@ func (c *Core) Unseal(key []byte) (bool, error) { // Do post-unseal setup if HA is not enabled if c.ha == nil { - c.standby = false if err := c.postUnseal(); err != nil { c.logger.Printf("[ERR] core: post-unseal setup failed: %v", err) c.barrier.Seal() c.logger.Printf("[WARN] core: vault is sealed") return false, err } + c.standby = false } else { // Go to standby mode, wait until we are active to unseal c.standbyDoneCh = make(chan struct{}) diff --git a/vault/core_test.go b/vault/core_test.go index 887b5c8ba..1bd565a43 100644 --- a/vault/core_test.go +++ b/vault/core_test.go @@ -5,7 +5,7 @@ import ( "testing" "time" - "github.com/hashicorp/uuid" + "github.com/hashicorp/go-uuid" "github.com/hashicorp/vault/audit" "github.com/hashicorp/vault/logical" "github.com/hashicorp/vault/physical" @@ -1110,10 +1110,12 @@ func TestCore_LimitedUseToken(t *testing.T) { func TestCore_CleanLeaderPrefix(t *testing.T) { // Create the first core and initialize it - inm := physical.NewInmemHA() + inm := physical.NewInmem() + inmha := physical.NewInmemHA() advertiseOriginal := "http://127.0.0.1:8200" core, err := NewCore(&CoreConfig{ Physical: inm, + HAPhysical: inmha, AdvertiseAddr: advertiseOriginal, DisableMlock: true, }) @@ -1172,6 +1174,7 @@ func TestCore_CleanLeaderPrefix(t *testing.T) { advertiseOriginal2 := "http://127.0.0.1:8500" core2, err := NewCore(&CoreConfig{ Physical: inm, + HAPhysical: inmha, AdvertiseAddr: advertiseOriginal2, DisableMlock: true, }) @@ -1255,11 +1258,20 @@ func TestCore_CleanLeaderPrefix(t *testing.T) { } func TestCore_Standby(t *testing.T) { + inmha := physical.NewInmemHA() + testCore_Standby_Common(t, inmha, inmha) +} + +func TestCore_Standby_SeparateHA(t *testing.T) { + testCore_Standby_Common(t, physical.NewInmemHA(), physical.NewInmemHA()) +} + +func testCore_Standby_Common(t *testing.T, inm physical.Backend, inmha physical.HABackend) { // Create the first core and initialize it - inm := physical.NewInmemHA() advertiseOriginal := "http://127.0.0.1:8200" core, err := NewCore(&CoreConfig{ Physical: inm, + HAPhysical: inmha, AdvertiseAddr: advertiseOriginal, DisableMlock: true, }) @@ -1313,6 +1325,7 @@ func TestCore_Standby(t *testing.T) { advertiseOriginal2 := "http://127.0.0.1:8500" core2, err := NewCore(&CoreConfig{ Physical: inm, + HAPhysical: inmha, AdvertiseAddr: advertiseOriginal2, DisableMlock: true, }) @@ -1404,6 +1417,23 @@ func TestCore_Standby(t *testing.T) { if advertise != advertiseOriginal2 { t.Fatalf("Bad advertise: %v", advertise) } + + if inm.(*physical.InmemHABackend) == inmha.(*physical.InmemHABackend) { + lockSize := inm.(*physical.InmemHABackend).LockMapSize() + if lockSize == 0 { + t.Fatalf("locks not used with only one HA backend") + } + } else { + lockSize := inmha.(*physical.InmemHABackend).LockMapSize() + if lockSize == 0 { + t.Fatalf("locks not used with expected HA backend") + } + + lockSize = inm.(*physical.InmemHABackend).LockMapSize() + if lockSize != 0 { + t.Fatalf("locks used with unexpected HA backend") + } + } } // Ensure that InternalData is never returned @@ -2003,10 +2033,12 @@ func testWaitActive(t *testing.T, core *Core) { func TestCore_Standby_Rotate(t *testing.T) { // Create the first core and initialize it - inm := physical.NewInmemHA() + inm := physical.NewInmem() + inmha := physical.NewInmemHA() advertiseOriginal := "http://127.0.0.1:8200" core, err := NewCore(&CoreConfig{ Physical: inm, + HAPhysical: inmha, AdvertiseAddr: advertiseOriginal, DisableMlock: true, }) @@ -2025,6 +2057,7 @@ func TestCore_Standby_Rotate(t *testing.T) { advertiseOriginal2 := "http://127.0.0.1:8500" core2, err := NewCore(&CoreConfig{ Physical: inm, + HAPhysical: inmha, AdvertiseAddr: advertiseOriginal2, DisableMlock: true, }) @@ -2074,10 +2107,12 @@ func TestCore_Standby_Rotate(t *testing.T) { func TestCore_Standby_Rekey(t *testing.T) { // Create the first core and initialize it - inm := physical.NewInmemHA() + inm := physical.NewInmem() + inmha := physical.NewInmemHA() advertiseOriginal := "http://127.0.0.1:8200" core, err := NewCore(&CoreConfig{ Physical: inm, + HAPhysical: inmha, AdvertiseAddr: advertiseOriginal, DisableMlock: true, }) @@ -2096,6 +2131,7 @@ func TestCore_Standby_Rekey(t *testing.T) { advertiseOriginal2 := "http://127.0.0.1:8500" core2, err := NewCore(&CoreConfig{ Physical: inm, + HAPhysical: inmha, AdvertiseAddr: advertiseOriginal2, DisableMlock: true, }) diff --git a/vault/expiration.go b/vault/expiration.go index 9b287cb5e..871061791 100644 --- a/vault/expiration.go +++ b/vault/expiration.go @@ -11,7 +11,7 @@ import ( "time" "github.com/armon/go-metrics" - "github.com/hashicorp/uuid" + "github.com/hashicorp/go-uuid" "github.com/hashicorp/vault/logical" ) diff --git a/vault/expiration_test.go b/vault/expiration_test.go index a5d52c801..734e03996 100644 --- a/vault/expiration_test.go +++ b/vault/expiration_test.go @@ -7,7 +7,7 @@ import ( "testing" "time" - "github.com/hashicorp/uuid" + "github.com/hashicorp/go-uuid" "github.com/hashicorp/vault/logical" ) diff --git a/vault/logical_cubbyhole_test.go b/vault/logical_cubbyhole_test.go index 53c3dc111..ac5b645ef 100644 --- a/vault/logical_cubbyhole_test.go +++ b/vault/logical_cubbyhole_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - "github.com/hashicorp/uuid" + "github.com/hashicorp/go-uuid" "github.com/hashicorp/vault/logical" ) diff --git a/vault/logical_passthrough.go b/vault/logical_passthrough.go index eda8998e0..f643d2ce1 100644 --- a/vault/logical_passthrough.go +++ b/vault/logical_passthrough.go @@ -149,7 +149,7 @@ func (b *PassthroughBackend) handleWrite( req *logical.Request, data *framework.FieldData) (*logical.Response, error) { // Check that some fields are given if len(req.Data) == 0 { - return nil, fmt.Errorf("missing data fields") + return logical.ErrorResponse("missing data fields"), nil } // Check if there is a ttl key; verify parseability if so diff --git a/vault/mount.go b/vault/mount.go index 6e9d98b79..d021a7c99 100644 --- a/vault/mount.go +++ b/vault/mount.go @@ -8,7 +8,7 @@ import ( "strings" "time" - "github.com/hashicorp/uuid" + "github.com/hashicorp/go-uuid" "github.com/hashicorp/vault/logical" ) diff --git a/vault/rollback_test.go b/vault/rollback_test.go index 1cb5742d0..e6d1e7b0c 100644 --- a/vault/rollback_test.go +++ b/vault/rollback_test.go @@ -7,7 +7,7 @@ import ( "testing" "time" - "github.com/hashicorp/uuid" + "github.com/hashicorp/go-uuid" ) // mockRollback returns a mock rollback manager diff --git a/vault/router_test.go b/vault/router_test.go index f64df6eff..2ea757251 100644 --- a/vault/router_test.go +++ b/vault/router_test.go @@ -7,7 +7,7 @@ import ( "testing" "time" - "github.com/hashicorp/uuid" + "github.com/hashicorp/go-uuid" "github.com/hashicorp/vault/logical" ) diff --git a/vault/token_store.go b/vault/token_store.go index c43bf4580..3074031a7 100644 --- a/vault/token_store.go +++ b/vault/token_store.go @@ -8,7 +8,7 @@ import ( "time" "github.com/armon/go-metrics" - "github.com/hashicorp/uuid" + "github.com/hashicorp/go-uuid" "github.com/hashicorp/vault/helper/salt" "github.com/hashicorp/vault/logical" "github.com/hashicorp/vault/logical/framework" diff --git a/vault/token_store_test.go b/vault/token_store_test.go index b44ca0160..a9faee181 100644 --- a/vault/token_store_test.go +++ b/vault/token_store_test.go @@ -7,7 +7,7 @@ import ( "testing" "time" - "github.com/hashicorp/uuid" + "github.com/hashicorp/go-uuid" "github.com/hashicorp/vault/logical" ) diff --git a/version/version.go b/version/version.go index d4b49836f..6f92e05cd 100644 --- a/version/version.go +++ b/version/version.go @@ -10,7 +10,7 @@ var GitCommit string var GitDescribe string // The main version number that is being run at the moment. -const Version = "0.4.0" +const Version = "0.5.0" // A pre-release marker for the version. If this is "" (empty string) // then it means that it is a final release. Otherwise, this is a pre-release diff --git a/website/config.rb b/website/config.rb index 550e7e1e8..fdf880ee5 100644 --- a/website/config.rb +++ b/website/config.rb @@ -2,7 +2,7 @@ set :base_url, "https://www.vaultproject.io/" activate :hashicorp do |h| h.name = "vault" - h.version = "0.3.1" + h.version = "0.4.0" h.github_slug = "hashicorp/vault" h.website_root = "website" diff --git a/website/source/assets/javascripts/application.js b/website/source/assets/javascripts/application.js index 5c7b3aede..382db385a 100644 --- a/website/source/assets/javascripts/application.js +++ b/website/source/assets/javascripts/application.js @@ -11,7 +11,6 @@ //= require lib/Chainable //= require lib/dbg -//= require docs //= require app/Sidebar //= require app/DotLockup //= require app/Init diff --git a/website/source/assets/javascripts/docs.js b/website/source/assets/javascripts/docs.js deleted file mode 100644 index d00adc0c2..000000000 --- a/website/source/assets/javascripts/docs.js +++ /dev/null @@ -1,46 +0,0 @@ -(function(){ - -var Init = { - - start: function(){ - var classname = this.hasClass(document.body, 'page-sub'); - - if (classname) { - this.addEventListeners(); - } - }, - - hasClass: function (elem, className) { - return new RegExp(' ' + className + ' ').test(' ' + elem.className + ' '); - }, - - addEventListeners: function(){ - var _this = this; - //console.log(document.querySelectorAll('.navbar-static-top')[0]); - window.addEventListener('resize', _this.resizeImage, false); - - this.resizeImage(); - }, - - resizeImage: function(){ - - var header = document.getElementById('header'), - footer = document.getElementById('footer'), - main = document.getElementById('main-content'), - vp = window.innerHeight, - bodyHeight = document.body.clientHeight, - hHeight = header.clientHeight, - fHeight = footer.clientHeight, - withMinHeight = hHeight + fHeight + 830; - - if(withMinHeight > bodyHeight ){ - var newHeight = (vp - (hHeight+fHeight)) + 'px'; - main.style.height = newHeight; - } - } - -}; - -Init.start(); - -})(); diff --git a/website/source/assets/stylesheets/_docs.scss b/website/source/assets/stylesheets/_docs.scss index 70454a605..30d77e3b1 100755 --- a/website/source/assets/stylesheets/_docs.scss +++ b/website/source/assets/stylesheets/_docs.scss @@ -17,10 +17,13 @@ body.layout-docs, body.layout-inner, body.layout-downloads, body.layout-intro{ - //background: $light-black image-url('sidebar-wire.png') left 62px no-repeat; + display: flex; + flex-direction: column; + >.container{ + flex: 1 0 auto; + .col-md-8[role=main]{ - min-height: 800px; background-color: white; >div{ @@ -272,4 +275,3 @@ body.layout-intro{ } } } - diff --git a/website/source/assets/stylesheets/_footer.scss b/website/source/assets/stylesheets/_footer.scss index b9285ef43..a6d2741b5 100644 --- a/website/source/assets/stylesheets/_footer.scss +++ b/website/source/assets/stylesheets/_footer.scss @@ -9,10 +9,16 @@ body.page-sub{ } #footer{ + flex-shrink:0; padding: 64px 0; .hashicorp-project{ margin-top: 24px; + @include project-by-hashicorp-style(); + + &:hover{ + color: $black; + } } .pull-right{ diff --git a/website/source/assets/stylesheets/_global.scss b/website/source/assets/stylesheets/_global.scss index bb23866d3..6fff1dceb 100755 --- a/website/source/assets/stylesheets/_global.scss +++ b/website/source/assets/stylesheets/_global.scss @@ -6,8 +6,12 @@ text-rendering: optimizeLegibility; -webkit-font-smoothing: antialiased; }*/ +html{ + min-height: 100%; +} body { + min-height: 100%; -webkit-font-smoothing: antialiased; color: $black; background-color: $white; diff --git a/website/source/assets/stylesheets/_header.scss b/website/source/assets/stylesheets/_header.scss index 6cf3db933..aa78842d6 100755 --- a/website/source/assets/stylesheets/_header.scss +++ b/website/source/assets/stylesheets/_header.scss @@ -5,6 +5,8 @@ // -------------------------------------------------- #header { + flex-shrink:0; + .navbar-brand { .logo{ width: $project-logo-width; diff --git a/website/source/assets/stylesheets/hashicorp-shared/_hashicorp-header.scss b/website/source/assets/stylesheets/hashicorp-shared/_hashicorp-header.scss index 0ee146e48..dd8d06dc3 100755 --- a/website/source/assets/stylesheets/hashicorp-shared/_hashicorp-header.scss +++ b/website/source/assets/stylesheets/hashicorp-shared/_hashicorp-header.scss @@ -159,9 +159,6 @@ polygon{ fill: white; } - line{ - stroke: white; - } } &:focus, @@ -205,8 +202,7 @@ @include transition(all 300ms ease-in); } } - line{ - stroke: black; + .svg-bg-line{ @include transition(all 300ms ease-in); &:hover{ @@ -284,6 +280,13 @@ fill: $black; @include transition(all 300ms ease-in); + &:hover{ + @include transition(all 300ms ease-in); + } + } + .svg-bg-line{ + @include transition(all 300ms ease-in); + &:hover{ @include transition(all 300ms ease-in); } diff --git a/website/source/assets/stylesheets/hashicorp-shared/_project-utility.scss b/website/source/assets/stylesheets/hashicorp-shared/_project-utility.scss index ff3f9633c..44282e62e 100755 --- a/website/source/assets/stylesheets/hashicorp-shared/_project-utility.scss +++ b/website/source/assets/stylesheets/hashicorp-shared/_project-utility.scss @@ -24,7 +24,6 @@ $blue: darken($blue, 5%); } @mixin project-footer-a-style{ - &:hover{ } @@ -43,9 +42,15 @@ $blue: darken($blue, 5%); } @mixin project-by-hashicorp-style{ + @include transition(all 300ms ease-in); + &:hover{ - line{ - stroke: $blue; + @include transition(all 300ms ease-in); + + svg{ + .svg-bg-line{ + fill: $blue; + } } } } diff --git a/website/source/docs/auth/app-id.html.md b/website/source/docs/auth/app-id.html.md index 579930fc8..e51cec4fa 100644 --- a/website/source/docs/auth/app-id.html.md +++ b/website/source/docs/auth/app-id.html.md @@ -67,7 +67,7 @@ App ID authentication is not allowed via the CLI. #### Via the API -The endpoint for the App ID login is `/login`. The client is expected +The endpoint for the App ID login is `auth/app-id/login`. The client is expected to provide the `app_id` and `user_id` parameters as part of the request. ## Configuration diff --git a/website/source/docs/auth/cert.html.md b/website/source/docs/auth/cert.html.md index 08dc1380b..bdafc2eba 100644 --- a/website/source/docs/auth/cert.html.md +++ b/website/source/docs/auth/cert.html.md @@ -53,6 +53,10 @@ mount of the backend. The workaround here is to mount multiple copies of the `cert` backend, configure each with one CA/CRL, and have clients connect to the appropriate mount. +In addition, since the backend does not fetch the CRLs itself, the CRL's +designated time to next update is not considered. If a CRL is no longer in use, +it is up to the administrator to remove it from the backend. + ## Authentication ### Via the CLI @@ -266,7 +270,7 @@ of the header should be "X-Vault-Token" and the value should be the token.
Gets information associated with the named CRL (currently, the serial numbers contained within). As the serials can be integers up to an arbitrary size, these are returned as strings. Requires - `sudo` access. + `sudo` access.
Method
diff --git a/website/source/docs/commands/environment.html.md b/website/source/docs/commands/environment.html.md index a623f23ca..ebd31fde6 100644 --- a/website/source/docs/commands/environment.html.md +++ b/website/source/docs/commands/environment.html.md @@ -27,6 +27,9 @@ The following table describes them: VAULT_ADDR The address of the Vault server. + + VAULT_ADVERTISE_ADDR + The advertised address of the server to use for client request forwarding when running in High Availability mode. VAULT_CACERT Path to a PEM-encoded CA cert file to use to verify the Vault server SSL certificate. diff --git a/website/source/docs/concepts/ha.html.markdown b/website/source/docs/concepts/ha.html.markdown index 0058aed43..3d6050470 100644 --- a/website/source/docs/concepts/ha.html.markdown +++ b/website/source/docs/concepts/ha.html.markdown @@ -35,7 +35,7 @@ including Consul, ZooKeeper and etcd. These may change over time, and the [configuration page](/docs/config/index.html) should be referenced. The Consul backend is the recommended HA backend, as it is used in production -by HashiCorp and it's customers with commercial support. +by HashiCorp and its customers with commercial support. If you're interested in implementing another backend or adding HA support to another backend, we'd love your contributions. Adding HA support diff --git a/website/source/docs/config/index.html.md b/website/source/docs/config/index.html.md index d454e91c5..6930b4e06 100644 --- a/website/source/docs/config/index.html.md +++ b/website/source/docs/config/index.html.md @@ -38,6 +38,11 @@ to specify where the configuration is. is stored. There are multiple options available for storage backends, and they're documented below. +* `ha_backend` (optional) - Configures the storage backend where Vault HA + coordination will take place. Must be an HA-supporting backend using the + configuration options as documented below. If not set, HA will be attempted + on the backend given in the `backend` parameter. + * `listener` (required) - Configures how Vault is listening for API requests. "tcp" is currently the only option available. A full reference for the inner syntax is below. @@ -71,152 +76,6 @@ the Vault executable access to the `mlock` syscall on Linux systems: sudo setcap cap_ipc_lock=+ep $(readlink -f $(which vault)) ``` -## Backend Reference - -For the `backend` section, the supported backends are shown below. -Vault requires that the backend itself will be responsible for backups, -durability, etc. - - * `consul` - Store data within [Consul](http://www.consul.io). This - backend supports HA. It is the most recommended backend for Vault - and has been shown to work at high scale under heavy load. - - * `etcd` - Store data within [etcd](https://coreos.com/etcd/). - This backend supports HA. - - * `zookeeper` - Store data within [Zookeeper](https://zookeeper.apache.org/). - This backend supports HA. - - * `s3` - Store data within an S3 bucket [S3](http://aws.amazon.com/s3/). - This backend does not support HA. - - * `mysql` - Store data within MySQL. This backend does not support HA. - - * `inmem` - Store data in-memory. This is only really useful for - development and experimentation. Data is lost whenever Vault is - restarted. - - * `file` - Store data on the filesystem using a directory structure. - This backend does not support HA. - -#### Common Backend Options - -All backends support the following options: - - * `advertise_addr` (optional) - For backends that support HA, this - is the address to advertise to other Vault servers in the cluster - for request forwarding. Most HA backends will attempt to determine - the advertise address if not provided. - -#### Backend Reference: Consul - -For Consul, the following options are supported: - - * `path` (optional) - The path within Consul where data will be stored. - Defaults to "vault/". - - * `address` (optional) - The address of the Consul agent to talk to. - Defaults to the local agent address, if available. - - * `scheme` (optional) - "http" or "https" for talking to Consul. - - * `datacenter` (optional) - The datacenter within Consul to write to. - This defaults to the local datacenter. - - * `token` (optional) - An access token to use to write data to Consul. - - * `max_parallel` (optional) - The maximum number of connections to Consul; - defaults to "128". - - * `tls_skip_verify` (optional) - If non-empty, then TLS host verification - will be disabled for Consul communication. - Defaults to false. - - The following settings should be set according to your [Consul encryption settings](https://www.consul.io/docs/agent/encryption.html): - - * `tls_ca_file` (optional) - The path to the CA certificate used for Consul communication. - Defaults to system bundle if not specified. - Set accordingly to the [ca_file](https://www.consul.io/docs/agent/options.html#ca_file) setting in Consul. - - * `tls_cert_file` (optional) - The path to the certificate for Consul communication. - Set accordingly to the [cert_file](https://www.consul.io/docs/agent/options.html#cert_file) setting in Consul. - - * `tls_key_file` (optional) - The path to the private key for Consul communication. - Set accordingly to the [key_file](https://www.consul.io/docs/agent/options.html#key_file) setting in Consul. - -#### Backend Reference: Zookeeper - -For Zookeeper, the following options are supported: - - * `path` (optional) - The path within Zookeeper where data will be stored. - Defaults to "vault/". - - * `address` (optional) - The address(es) of the Zookeeper instance(s) to talk to. - Can be comma separated list (host:port) of many Zookeeper instances. - Defaults to "localhost:2181" if not specified. - -#### Backend Reference: etcd - -For etcd, the following options are supported: - - * `path` (optional) - The path within etcd where data will be stored. - Defaults to "vault/". - - * `address` (optional) - The address(es) of the etcd instance(s) to talk to. - Can be comma separated list (protocol://host:port) of many etcd instances. - Defaults to "http://localhost:2379" if not specified. - -#### Backend Reference: S3 - -For S3, the following options are supported: - - * `bucket` (required) - The name of the S3 bucket to use. It must be provided, but it can also be sourced from the `AWS_S3_BUCKET` environment variable. - - * `access_key` - (required) The AWS access key. It must be provided, but it can also be sourced from the `AWS_ACCESS_KEY_ID` environment variable. - - * `secret_key` - (required) The AWS secret key. It must be provided, but it can also be sourced from the `AWS_SECRET_ACCESS_KEY` environment variable. - - * `session_token` - (optional) The AWS session token. It can also be sourced from the `AWS_SESSION_TOKEN` environment variable. - - * `endpoint` - (optional) An alternative (AWS compatible) S3 endpoint to use. It can also be sourced from the `AWS_S3_ENDPOINT` environment variable. - - * `region` (optional) - The AWS region. It can be sourced from the `AWS_DEFAULT_REGION` environment variable and will default to "us-east-1" if not specified. - -If you are running your Vault server on an EC2 instance, you can also make use -of the EC2 instance profile service to provide the credentials Vault will use to -make S3 API calls. Leaving the `access_key` and `secret_key` fields empty -will cause Vault to attempt to retrieve credentials from the metadata service. -You are responsible for ensuring your instance is launched with the appropriate -profile enabled. Vault will handle renewing profile credentials as they rotate. - -#### Backend Reference: MySQL - -The MySQL backend has the following options: - - * `username` (required) - The MySQL username to connect with. - - * `password` (required) - The MySQL password to connect with. - - * `address` (optional) - The address of the MySQL host. Defaults to - "127.0.0.1:3306. - - * `database` (optional) - The name of the database to use. Defaults to "vault". - - * `table` (optional) - The name of the table to use. Defaults to "vault". - - * `tls_ca_file` (optional) - The path to the CA certificate to connect using TLS - -#### Backend Reference: Inmem - -The in-memory backend has no configuration options. - -#### Backend Reference: File - -The file backend has the following options: - - * `path` (required) - The path on disk to a directory where the - data will be stored. - ## Listener Reference For the `listener` section, the only supported listener currently @@ -258,3 +117,166 @@ is within the object itself. * `disable_hostname` (optional) - Whether or not to prepend runtime telemetry with the machines hostname. This is a global option. Defaults to false. + +## Backend Reference + +For the `backend` section, the supported physical backends are shown below. +Vault requires that the backend itself will be responsible for backups, +durability, etc. + +__*Please note*__: The only physical backends actively maintained by HashiCorp +are `consul`, `inmem`, and `file`. The other backends are community-derived and +community-supported. We include them in the hope that they will be useful to +those users that wish to utilize them, but they receive minimal validation and +testing from HashiCorp, and HashiCorp staff may not be knowledgeable about the +data store being utilized. If you encounter problems with them, we will attempt +to help you, but may refer you to the backend author. + + * `consul` - Store data within [Consul](http://www.consul.io). This + backend supports HA. It is the most recommended backend for Vault and has + been shown to work at high scale under heavy load. + + * `etcd` - Store data within [etcd](https://coreos.com/etcd/). + This backend supports HA. This is a community-supported backend. + + * `zookeeper` - Store data within [Zookeeper](https://zookeeper.apache.org/). + This backend supports HA. This is a community-supported backend. + + * `s3` - Store data within an S3 bucket [S3](http://aws.amazon.com/s3/). + This backend does not support HA. This is a community-supported backend. + + * `mysql` - Store data within MySQL. This backend does not support HA. This + is a community-supported backend. + + * `inmem` - Store data in-memory. This is only really useful for + development and experimentation. Data is lost whenever Vault is + restarted. + + * `file` - Store data on the filesystem using a directory structure. + This backend does not support HA. + + +#### Common Backend Options + +All backends support the following options: + + * `advertise_addr` (optional) - For backends that support HA, this + is the address to advertise to other Vault servers in the cluster + for request forwarding. Most HA backends will attempt to determine + the advertise address if not provided. This can also be set via + the `VAULT_ADVERTISE_ADDR` environment variable. + +#### Backend Reference: Consul + +For Consul, the following options are supported: + + * `path` (optional) - The path within Consul where data will be stored. + Defaults to "vault/". + + * `address` (optional) - The address of the Consul agent to talk to. + Defaults to the local agent address, if available. + + * `scheme` (optional) - "http" or "https" for talking to Consul. + + * `token` (optional) - An access token to use to write data to Consul. + + * `max_parallel` (optional) - The maximum number of connections to Consul; + defaults to "128". + + * `tls_skip_verify` (optional) - If non-empty, then TLS host verification + will be disabled for Consul communication. + Defaults to false. + + The following settings should be set according to your [Consul encryption settings](https://www.consul.io/docs/agent/encryption.html): + + * `tls_ca_file` (optional) - The path to the CA certificate used for Consul communication. + Defaults to system bundle if not specified. + Set accordingly to the [ca_file](https://www.consul.io/docs/agent/options.html#ca_file) setting in Consul. + + * `tls_cert_file` (optional) - The path to the certificate for Consul communication. + Set accordingly to the [cert_file](https://www.consul.io/docs/agent/options.html#cert_file) setting in Consul. + + * `tls_key_file` (optional) - The path to the private key for Consul communication. + Set accordingly to the [key_file](https://www.consul.io/docs/agent/options.html#key_file) setting in Consul. + +#### Backend Reference: Zookeeper (Community-Supported) + +For Zookeeper, the following options are supported: + + * `path` (optional) - The path within Zookeeper where data will be stored. + Defaults to "vault/". + + * `address` (optional) - The address(es) of the Zookeeper instance(s) to talk to. + Can be comma separated list (host:port) of many Zookeeper instances. + Defaults to "localhost:2181" if not specified. + +#### Backend Reference: etcd (Community-Supported) + +For etcd, the following options are supported: + + * `path` (optional) - The path within etcd where data will be stored. + Defaults to "vault/". + + * `address` (optional) - The address(es) of the etcd instance(s) to talk to. + Can be comma separated list (protocol://host:port) of many etcd instances. + Defaults to "http://localhost:2379" if not specified. + + * `tls_ca_file` (optional) - The path to the CA certificate used for etcd communication. + Defaults to system bundle if not specified. + + * `tls_cert_file` (optional) - The path to the certificate for etcd communication. + + * `tls_key_file` (optional) - The path to the private key for etcd communication. + +#### Backend Reference: S3 (Community-Supported) + +For S3, the following options are supported: + + * `bucket` (required) - The name of the S3 bucket to use. It must be provided, but it can also be sourced from the `AWS_S3_BUCKET` environment variable. + + * `access_key` - (required) The AWS access key. It must be provided, but it can also be sourced from the `AWS_ACCESS_KEY_ID` environment variable. + + * `secret_key` - (required) The AWS secret key. It must be provided, but it can also be sourced from the `AWS_SECRET_ACCESS_KEY` environment variable. + + * `session_token` - (optional) The AWS session token. It can also be sourced from the `AWS_SESSION_TOKEN` environment variable. + + * `endpoint` - (optional) An alternative (AWS compatible) S3 endpoint to use. It can also be sourced from the `AWS_S3_ENDPOINT` environment variable. + + * `region` (optional) - The AWS region. It can be sourced from the `AWS_DEFAULT_REGION` environment variable and will default to "us-east-1" if not specified. + +If you are running your Vault server on an EC2 instance, you can also make use +of the EC2 instance profile service to provide the credentials Vault will use to +make S3 API calls. Leaving the `access_key` and `secret_key` fields empty +will cause Vault to attempt to retrieve credentials from the metadata service. +You are responsible for ensuring your instance is launched with the appropriate +profile enabled. Vault will handle renewing profile credentials as they rotate. + +#### Backend Reference: MySQL (Community-Supported) + +The MySQL backend has the following options: + + * `username` (required) - The MySQL username to connect with. + + * `password` (required) - The MySQL password to connect with. + + * `address` (optional) - The address of the MySQL host. Defaults to + "127.0.0.1:3306. + + * `database` (optional) - The name of the database to use. Defaults to "vault". + + * `table` (optional) - The name of the table to use. Defaults to "vault". + + * `tls_ca_file` (optional) - The path to the CA certificate to connect using TLS + +#### Backend Reference: Inmem + +The in-memory backend has no configuration options. + +#### Backend Reference: File + +The file backend has the following options: + + * `path` (required) - The path on disk to a directory where the + data will be stored. + + diff --git a/website/source/docs/http/index.html.md b/website/source/docs/http/index.html.md index 19064b63f..0c180774d 100644 --- a/website/source/docs/http/index.html.md +++ b/website/source/docs/http/index.html.md @@ -133,7 +133,7 @@ The following HTTP status codes are used throughout the API. - `204` - Success, no data returned. - `400` - Invalid request, missing or invalid data. See the "validation" section for more details on the error response. -- `401` - Unauthorized, your authentication details are either +- `403` - Forbidden, your authentication details are either incorrect or you don't have access to this feature. - `404` - Invalid path. This can both mean that the path truly doesn't exist or that you don't have permission to view a diff --git a/website/source/docs/http/libraries.html.md b/website/source/docs/http/libraries.html.md index 26ed42b19..798dc105f 100644 --- a/website/source/docs/http/libraries.html.md +++ b/website/source/docs/http/libraries.html.md @@ -27,3 +27,7 @@ Some are officially maintained while others are provided by the community. * [node-vault](https://github.com/kr1sp1n/node-vault) * [vaulted](https://github.com/chiefy/vaulted) + +## Java + +* [vault-java](https://github.com/jhaals/vault-java) diff --git a/website/source/docs/secrets/aws/index.html.md b/website/source/docs/secrets/aws/index.html.md index 21d648ec2..17a69e9c2 100644 --- a/website/source/docs/secrets/aws/index.html.md +++ b/website/source/docs/secrets/aws/index.html.md @@ -145,6 +145,13 @@ Note that this policy example is unrelated to the policy you wrote to `aws/roles If you get stuck at any time, simply run `vault path-help aws` or with a subpath for interactive help output. +## A Note on Consistency + +Unfortunately, IAM credentials are eventually consistent with respect to other +Amazon services. If you are planning on using these credential in a pipeline, +you may need to add a delay of 5-10 seconds (or more) after fetching +credentials before they can be used successfully. + ## API ### /aws/config/root diff --git a/website/source/docs/secrets/consul/index.html.md b/website/source/docs/secrets/consul/index.html.md index af64f53cf..4e8304c8d 100644 --- a/website/source/docs/secrets/consul/index.html.md +++ b/website/source/docs/secrets/consul/index.html.md @@ -27,13 +27,31 @@ $ vault mount consul Successfully mounted 'consul' at 'consul'! ``` +[Acquire a management token from +Consul](https://consul.io/docs/agent/http/acl.html#acl_create), using the +`acl_master_token` from your Consul configuration file or any other management +token: + +```shell +$ curl \ + -H "X-Consul-Token: secret" \ + -X PUT \ + -d '{"Name": "sample", "Type": "management"}' \ + http://127.0.0.1:8500/v1/acl/create +``` +```javascript +{ + "ID": "adf4238a-882b-9ddc-4a9d-5b6758e4159e" +} +``` + Next, we must configure Vault to know how to contact Consul. This is done by writing the access information: ``` $ vault write consul/config/access \ address=127.0.0.1:8500 \ - token=root + token=adf4238a-882b-9ddc-4a9d-5b6758e4159e Success! Data written to: consul/config/access ``` @@ -52,9 +70,10 @@ $ echo $POLICY | base64 | vault write consul/roles/readonly policy=- Success! Data written to: consul/roles/readonly ``` -The backend expects the policy to be base64 encoded, so we need to encode -it properly before writing. The policy language is -[documented by Consul](https://consul.io/docs/internals/acl.html), but we've defined a read-only policy. +The backend expects the policy to be base64 encoded, so we need to encode it +properly before writing. The policy language is [documented by +Consul](https://consul.io/docs/internals/acl.html), but we've defined a +read-only policy. To generate a new set Consul ACL token, we simply read from that role: @@ -143,12 +162,21 @@ Permission denied
  • policy required - The base64 encoded Consul ACL policy. This is documented in [more detail here](https://consul.io/docs/internals/acl.html). + The base64 encoded Consul ACL policy. This is documented in [more + detail here](https://consul.io/docs/internals/acl.html). Required + unless the `token_type` is `management`. +
  • +
  • + token_type + optional + The type of token to create using this role: `client` or `management`. + If `management`, the `policy` parameter is not required.
  • lease optional - The lease value provided as a string duration with time suffix. Hour is the largest suffix. + The lease value provided as a string duration with time suffix. Hour is + the largest suffix.
  • diff --git a/website/source/docs/secrets/pki/index.html.md b/website/source/docs/secrets/pki/index.html.md index 4da6dbb43..54490a09d 100644 --- a/website/source/docs/secrets/pki/index.html.md +++ b/website/source/docs/secrets/pki/index.html.md @@ -10,126 +10,329 @@ description: |- Name: `pki` -The PKI secret backend for Vault generates X.509 certificates dynamically based on configured roles. This means services can get certificates needed for both client and server authentication without going through the usual manual process of generating a private key and CSR, submitting to a CA, and waiting for a verification and signing process to complete. Vault's built-in authentication and authorization mechanisms provide the verification functionality. +The PKI secret backend for Vault generates X.509 certificates dynamically based +on configured roles. This means services can get certificates needed for both +client and server authentication without going through the usual manual process +of generating a private key and CSR, submitting to a CA, and waiting for a +verification and signing process to complete. Vault's built-in authentication +and authorization mechanisms provide the verification functionality. -By keeping TTLs relatively short, revocations are less likely to be needed, keeping CRLs short and helping the backend scale to large workloads. This in turn allows each instance of a running application to have a unique certificate, eliminating sharing and the accompanying pain of revocation and rollover. +By keeping TTLs relatively short, revocations are less likely to be needed, +keeping CRLs short and helping the backend scale to large workloads. This in +turn allows each instance of a running application to have a unique +certificate, eliminating sharing and the accompanying pain of revocation and +rollover. -In addition, by allowing revocation to mostly be forgone, this backend allows for ephemeral certificates; certificates can be fetched and stored in memory upon application startup and discarded upon shutdown, without ever being written to disk. +In addition, by allowing revocation to mostly be forgone, this backend allows +for ephemeral certificates; certificates can be fetched and stored in memory +upon application startup and discarded upon shutdown, without ever being +written to disk. -This page will show a quick start for this backend. For detailed documentation on every path, use `vault path-help` after mounting the backend. +This page will show a quick start for this backend. For detailed documentation +on every path, use `vault path-help` after mounting the backend. ## Considerations -To successfully deploy this backend, there are a number of important considerations to be aware of, as well as some preparatory steps that should be undertaken. You should read all of these *before* using this backend or generating the CA to use with this backend. +To successfully deploy this backend, there are a number of important +considerations to be aware of, as well as some preparatory steps that should be +undertaken. You should read all of these *before* using this backend or +generating the CA to use with this backend. -### Never use root CAs +### Be Careful with Root CAs -Vault storage is secure, but not as secure as a piece of paper in a bank vault. It is, after all, networked software. Your long-lived self-signed root CA's private key should instead be used to issue a shorter-lived intermediate CA certificate, and this is what you should put into Vault. This aligns with industry best practices. +Vault storage is secure, but not as secure as a piece of paper in a bank vault. +It is, after all, networked software. If your root CA is hosted outside of +Vault, don't put it in Vault as well; instead, issue a shorter-lived +intermediate CA certificate and put this into Vault. This aligns with industry +best practices. + +Since 0.4, the backend supports generating self-signed root CAs and creating +and signing CSRs for intermediate CAs. In each instance, for security reasons, +the private key can *only* be exported at generation time, and the ability to +do so is part of the command path (so it can be put into ACL policies). + +If you plan on using intermediate CAs with Vault, it is suggested that you let +Vault create CSRs and do not export the private key, then sign those with your +root CA (which may be a second mount of the `pki` backend). ### One CA Certificate, One Backend -In order to vastly simplify both the configuration and codebase of the PKI backend, only one CA certificate is allowed per backend. If you want to issue certificates from multiple CAs, mount the PKI backend at multiple mount points with separate CA certificates in each. +In order to vastly simplify both the configuration and codebase of the PKI +backend, only one CA certificate is allowed per backend. If you want to issue +certificates from multiple CAs, mount the PKI backend at multiple mount points +with separate CA certificates in each. -This also provides a convenient method of switching to a new CA certificate while keeping CRLs valid from the old CA certificate; simply mount a new backend and issue from there. +This also provides a convenient method of switching to a new CA certificate +while keeping CRLs valid from the old CA certificate; simply mount a new +backend and issue from there. + +A common pattern is to have one mount act as your root CA, and which is only +used for signing intermediate CA CSRs mounted at other locations. ### Keep certificate lifetimes short, for CRL's sake -This backend aligns with Vault's philosophy of short-lived secrets. As such it is not expected that CRLs will grow large; the only place a private key is ever returned is to the requesting client (this backend does *not* store generated private keys). In most cases, if the key is lost, the certificate can simply be ignored, as it will expire shortly. +This backend aligns with Vault's philosophy of short-lived secrets. As such it +is not expected that CRLs will grow large; the only place a private key is ever +returned is to the requesting client (this backend does *not* store generated +private keys, except for CA certificates). In most cases, if the key is lost, +the certificate can simply be ignored, as it will expire shortly. -If a certificate must truly be revoked, the normal Vault revocation function can be used; alternately a root token can be used to revoke the certificate using the certificate's serial number. Any revocation action will cause the CRL to be regenerated. When the CRL is regenerated, any expired certificates are removed from the CRL (and any revoked, expired certificate are removed from backend storage). +If a certificate must truly be revoked, the normal Vault revocation function +can be used; alternately a root token can be used to revoke the certificate +using the certificate's serial number. Any revocation action will cause the CRL +to be regenerated. When the CRL is regenerated, any expired certificates are +removed from the CRL (and any revoked, expired certificate are removed from +backend storage). -This backend does not support multiple CRL endpoints with sliding date windows; often such mechanisms will have the transition point a few days apart, but this gets into the expected realm of the actual certificate validity periods issued from this backend. A good rule of thumb for this backend would be to simply not issue certificates with a validity period greater than your maximum comfortable CRL lifetime. Alternately, you can control CRL caching behavior on the client to ensure that checks happen more often. +This backend does not support multiple CRL endpoints with sliding date windows; +often such mechanisms will have the transition point a few days apart, but this +gets into the expected realm of the actual certificate validity periods issued +from this backend. A good rule of thumb for this backend would be to simply not +issue certificates with a validity period greater than your maximum comfortable +CRL lifetime. Alternately, you can control CRL caching behavior on the client +to ensure that checks happen more often. -Often multiple endpoints are used in case a single CRL endpoint is down so that clients don't have to figure out what to do with a lack of response. Run Vault in HA mode, and the CRL endpoint should be available even if a particular node is down. +Often multiple endpoints are used in case a single CRL endpoint is down so that +clients don't have to figure out what to do with a lack of response. Run Vault +in HA mode, and the CRL endpoint should be available even if a particular node +is down. -### You must configure CRL information *in advance* +### You must configure issuing/CRL/OCSP information *in advance* -This backend serves CRLs from a predictable location. That location must be encoded into your CA certificate if you want to allow applications to use the CRL endpoint encoded in certificates to find the CRL. Instructions for doing so are below. If you need to adjust this later, you will have to generate a new CA certificate using the same private key if you want to keep validity for already-issued certificates. +This backend serves CRLs from a predictable location, but it is not possible +for the backend to know where it is running. Therefore, you must configure +desired URLs for the issuing certificate, CRL distribution points, and OCSP +servers manually using the `config/urls` endpoint. It is supported to have more +than one of each of these by passing in the multiple URLs as a comma-separated +string parameter. ### No OCSP support, yet -Vault's architecture does not currently allow for a binary protocol such as OCSP to be supported by a backend. As such, you should configure your software to use CRLs for revocation information, with a caching lifetime that feels good to you. Since you are following the advice above about keeping lifetimes short (right?), CRLs should not grow too large. +Vault's architecture does not currently allow for a binary protocol such as +OCSP to be supported by a backend. As such, you should configure your software +to use CRLs for revocation information, with a caching lifetime that feels good +to you. Since you are following the advice above about keeping lifetimes short +(right?), CRLs should not grow too large, however, you can configure alternate +CRL and/or OCSP servers using `config/urls` if you wish. + +If you are using issued certificates for client authentication to Vault, note +that as of 0.4, the `cert` authentication endpoint supports being pushed CRLs, +but it cannot read CRLs directly from this backend. ## Quick Start -### CA certificate +#### Mount the backend -In order for this backend to serve CRL information at the expected location, you will need to generate your CA certificate with this information. For OpenSSL, this means putting a value in the CA section with the appropriate URL; in this example the PKI backend is mounted at `pki`: - -```text -crlDistributionPoints = URI:https://vault.example.com:8200/v1/pki/crl -``` - -Adjust the URI as appropriate. - -### Vault - -The first step to using the PKI backend is to mount it. Unlike the `generic` backend, the `pki` backend is not mounted by default. +The first step to using the PKI backend is to mount it. Unlike the `generic` +backend, the `pki` backend is not mounted by default. ```text $ vault mount pki Successfully mounted 'pki' at 'pki'! ``` -Next, Vault must be configured with a root certificate and associated private key. This is done by writing the contents of a file or *stdin*: +#### Configure a CA certificate + +Next, Vault must be configured with a CA certificate and associated private +key. We'll take advantage of the backend's self-signed root generation support, +but Vault also supports generating an intermediate CA (with a CSR for signing) +or setting a PEM-encoded certificate and private key bundle directly into the +backend. + +Generally you'll want a root certificate to only be used to sign CA +intermediate certificates, but for this example we'll proceed as if you will +issue certificates directly from the root. As it's a root, we'll want to set a +long maximum life time for the certificate; since it honors the maximum mount +TTL, first we adjust that: ```text -$ vault write pki/config/ca \ - pem_bundle="@ca_bundle.pem" -Success! Data written to: pki/config/ca +$ vault mount-tune -max-lease-ttl=87600h pki +Successfully tuned mount 'pki'! ``` -or +That sets the maximum TTL for secrets issued from the mount to 10 years. (Note +that roles can further restrict the maximum TTL.) -``` -$ cat bundle.pem | vault write pki/config/ca pem_bundle="-" -Success! Data written to: pki/config/ca +Now, we generate our root certificate: + +```text +$ vault write pki/root/generate/internal common_name=myvault.com ttl=87600h +Key Value +lease_id pki/root/generate/internal/aa959dd4-467e-e5ff-642b-371add518b40 +lease_duration 315359999 +certificate -----BEGIN CERTIFICATE----- +MIIDvTCCAqWgAwIBAgIUAsza+fvOw+Xh9ifYQ0gNN0ruuWcwDQYJKoZIhvcNAQEL +BQAwFjEUMBIGA1UEAxMLbXl2YXVsdC5jb20wHhcNMTUxMTE5MTYwNDU5WhcNMjUx +MTE2MTYwNDU5WjAWMRQwEgYDVQQDEwtteXZhdWx0LmNvbTCCASIwDQYJKoZIhvcN +AQEBBQADggEPADCCAQoCggEBAMUhH4OLf/sa6GuJONGC/CWLY7nDbfH8jAaCKgqV +eJ81KrmcgP8WPhoFsYHFQEQXQZcrJagwYfm19jYn3CaqrYPbciv9bcWi+ECxZV3x +Hs/YdCFk7KgDGCci37w+cy6fSB943FKJqqVbvPv0odmq6LvgGGgneznvuvkIrOWG +qVDrDdvbEZ01XAyzUQJaaiJXExN+6xm1HcBoypCP8ZjjnXHcFQvw2QBItLRU7iUd +ESFgbrkrSPW3HA6KF0ov2qFMoHTiQ6aM4KaHPmXcFPicugYR9owZfZ4lwWJCqT7j +EkhokaMgHnvyRScuiRZhQm8ppHZoYsqrc3glfEuxGHkS+0cCAwEAAaOCAQEwgf4w +DgYDVR0PAQH/BAQDAgGuMBMGA1UdJQQMMAoGCCsGAQUFBwMJMA8GA1UdEwEB/wQF +MAMBAf8wHQYDVR0OBBYEFLvAbt0eUUOoo7hjKiQM2bRqDKrZMB8GA1UdIwQYMBaA +FLvAbt0eUUOoo7hjKiQM2bRqDKrZMDsGCCsGAQUFBwEBBC8wLTArBggrBgEFBQcw +AoYfaHR0cDovLzEyNy4wLjAuMTo4MjAwL3YxL3BraS9jYTAWBgNVHREEDzANggtt +eXZhdWx0LmNvbTAxBgNVHR8EKjAoMCagJKAihiBodHRwOi8vMTI3LjAuMC4xOjgy +MDAvdjEvcGtpL2NybDANBgkqhkiG9w0BAQsFAAOCAQEAVSgIRl6XJs95D7iXGzeQ +Ab8OIei779k0pD7xxS/+knY3TM6733zL/LXs4BEL3wfcQWoDrMtCW0Ook455sAOE +PSnTaZYQSH/F74VawWhSee4ZyiWq+sTUI4IzqYG3IS36mCyb0t6RxEb3aoQ87WHs +BHIB6uWbj6WoGHYM8ESxY89aY9jnX3xSs1HuluVW1uPrpIoa/eudpyV40Y1+9RNM +6fCX5LHGM7vKYxqvudYe+7G1MdKVBQg17h6XuieiUswVt2/HvDlNr+9DHrUla9Ve +Ig43v+grirlG7DrAr6Aiu/MVWKJP6CvNwG/XzrGaqd6KqSsE+8oIGR9tCTuPxI6v +SQ== +-----END CERTIFICATE----- +expiration 1.763309099e+09 +issuing_ca -----BEGIN CERTIFICATE----- +MIIDvTCCAqWgAwIBAgIUAsza+fvOw+Xh9ifYQ0gNN0ruuWcwDQYJKoZIhvcNAQEL +BQAwFjEUMBIGA1UEAxMLbXl2YXVsdC5jb20wHhcNMTUxMTE5MTYwNDU5WhcNMjUx +MTE2MTYwNDU5WjAWMRQwEgYDVQQDEwtteXZhdWx0LmNvbTCCASIwDQYJKoZIhvcN +AQEBBQADggEPADCCAQoCggEBAMUhH4OLf/sa6GuJONGC/CWLY7nDbfH8jAaCKgqV +eJ81KrmcgP8WPhoFsYHFQEQXQZcrJagwYfm19jYn3CaqrYPbciv9bcWi+ECxZV3x +Hs/YdCFk7KgDGCci37w+cy6fSB943FKJqqVbvPv0odmq6LvgGGgneznvuvkIrOWG +qVDrDdvbEZ01XAyzUQJaaiJXExN+6xm1HcBoypCP8ZjjnXHcFQvw2QBItLRU7iUd +ESFgbrkrSPW3HA6KF0ov2qFMoHTiQ6aM4KaHPmXcFPicugYR9owZfZ4lwWJCqT7j +EkhokaMgHnvyRScuiRZhQm8ppHZoYsqrc3glfEuxGHkS+0cCAwEAAaOCAQEwgf4w +DgYDVR0PAQH/BAQDAgGuMBMGA1UdJQQMMAoGCCsGAQUFBwMJMA8GA1UdEwEB/wQF +MAMBAf8wHQYDVR0OBBYEFLvAbt0eUUOoo7hjKiQM2bRqDKrZMB8GA1UdIwQYMBaA +FLvAbt0eUUOoo7hjKiQM2bRqDKrZMDsGCCsGAQUFBwEBBC8wLTArBggrBgEFBQcw +AoYfaHR0cDovLzEyNy4wLjAuMTo4MjAwL3YxL3BraS9jYTAWBgNVHREEDzANggtt +eXZhdWx0LmNvbTAxBgNVHR8EKjAoMCagJKAihiBodHRwOi8vMTI3LjAuMC4xOjgy +MDAvdjEvcGtpL2NybDANBgkqhkiG9w0BAQsFAAOCAQEAVSgIRl6XJs95D7iXGzeQ +Ab8OIei779k0pD7xxS/+knY3TM6733zL/LXs4BEL3wfcQWoDrMtCW0Ook455sAOE +PSnTaZYQSH/F74VawWhSee4ZyiWq+sTUI4IzqYG3IS36mCyb0t6RxEb3aoQ87WHs +BHIB6uWbj6WoGHYM8ESxY89aY9jnX3xSs1HuluVW1uPrpIoa/eudpyV40Y1+9RNM +6fCX5LHGM7vKYxqvudYe+7G1MdKVBQg17h6XuieiUswVt2/HvDlNr+9DHrUla9Ve +Ig43v+grirlG7DrAr6Aiu/MVWKJP6CvNwG/XzrGaqd6KqSsE+8oIGR9tCTuPxI6v +SQ== +-----END CERTIFICATE----- +serial_number 02:cc:da:f9:fb:ce:c3:e5:e1:f6:27:d8:43:48:0d:37:4a:ee:b9:67 ``` -Although in this example the value being piped into *stdin* could be passed directly into the Vault CLI command, a more complex usage might be to use [Ansible](http://www.ansible.com) to securely store the certificate and private key in an `ansible-vault` file, then have an `ansible-playbook` command decrypt this value and pass it in to Vault. +The returned certificate is purely informational; it and its private key are +safely stored in the backend mount. -The next step is to configure a role. A role is a logical name that maps to a policy used to generated those credentials. For example, let's create an "example-dot-com" role: +#### Set URL configuration + +Generated certificates can have the CRL location and the location of the +issuing certificate encoded. These values must be set manually, but can be +changed at any time. + +```text +$ vault write pki/config/urls issuing_certificates="http://127.0.0.1:8200/v1/pki/ca" crl_distribution_points="http://127.0.0.1:8200/v1/pki/crl" +Success! Data written to: pki/ca/urls +``` + +#### Configure a role + +The next step is to configure a role. A role is a logical name that maps to a +policy used to generated those credentials. For example, let's create an +"example-dot-com" role: ```text $ vault write pki/roles/example-dot-com \ - allowed_base_domain="example.com" \ + allowed_domains="example.com" \ allow_subdomains="true" max_ttl="72h" Success! Data written to: pki/roles/example-dot-com ``` -By writing to the `roles/example-dot-com` path we are defining the `example-dot-com` role. To generate a new set of credentials, we simply write to the `issue` endpoint with that role name: Vault is now configured to create and manage certificates! +#### Generate credentials + +By writing to the `roles/example-dot-com` path we are defining the +`example-dot-com` role. To generate a new set of credentials, we simply write +to the `issue` endpoint with that role name: Vault is now configured to create +and manage certificates! ```text $ vault write pki/issue/example-dot-com \ common_name=blah.example.com -Key Value -lease_id pki/issue/example-dot-com/819393b5-e1a1-9efd-b72f-4dc3a1972e31 -lease_duration 259200 -lease_renewable false -certificate -----BEGIN CERTIFICATE----- -MIIECDCCAvKgAwIBAgIUXmLrLkTdBIOOIYg2/BXO7docKfUwCwYJKoZIhvcNAQEL -... -az3gfwlOqVTdgi/ZVAtIzhSEJ0OY136bq4NOaw== +Key Value +lease_id pki/issue/example-dot-com/32db49a9-61dd-f9ca-f4a6-aaefafe53739 +lease_duration 259199 +lease_renewable false +certificate -----BEGIN CERTIFICATE----- +MIIDVDCCAjygAwIBAgIUFMne7ro1DyvpZV+URHMPtz3vv9MwDQYJKoZIhvcNAQEL +BQAwGzEZMBcGA1UEAxMQaW50ZXJtZWRpYXRlLmNvbTAeFw0xNTExMjAxODEzMDNa +Fw0xNTExMjMxODEzMDNaMBsxGTAXBgNVBAMTEGJsYWguZXhhbXBsZS5jb20wggEi +MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDEfl5iimLtEkyZiKYs+PfoaAbe +VhtZxTYWFA+B7IIlr8iPTEZDuf72OOf0Nu/8TNrV6Zkoq0EuHvBtNi1ut3usYt6V +i9lrcofD/Qjn0EH6aOZnE5J7c+gmsODhlxflLfz8uEytonKxofwOw26J9+subuSI +migMbpbTP/BL2n29K4NJoKdhh8VMxNCFPQxgu5ACEdJ9GsiPO5wBb7ifdIq0HcSU +0ONe6uZqDXeKiqfrTg6eap4EaALogkJhuk8BcAJv9aSbJswOSXTGROa4XChtCXEu +D3yVOoZOOm7JSm60y7ntf/dxZF5xcZXjRe6GkXJAIADOL9E5dOlgTFlojYjpAgMB +AAGjgY8wgYwwDgYDVR0PAQH/BAQDAgOoMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggr +BgEFBQcDAjAdBgNVHQ4EFgQUXSgxVNG7knU9Od1iKh3eCjE/P9UwHwYDVR0jBBgw +FoAU83Ovrk0BzVapM+C/fA25dv/Ju34wGwYDVR0RBBQwEoIQYmxhaC5leGFtcGxl +LmNvbTANBgkqhkiG9w0BAQsFAAOCAQEAJwwnK+GH+X2CK18qzv3fuPzbsR4pWKTB +aaSweW83+QUiRgsR6sgdNqYH0bE1BO/nysDC8hj2IH77KtOfJJgcqG8w709022rh +DtZVB33lU17oZC4LUIhq/Ym0JEwYryKck8ClxJpWYKy/kcNwt/WcoAY+aX07c+a4 +0ACCpzTX8vUAxFxcp6ZCwebbSTbv56KHDxMRUSiWiwcDaLlqECsqfETN6eCN/M6A +GlPoswzIHjXSrAhI8KADOQf4oHI2cOj7ecJX9EqTq5snxFKblS8B12q1javiQGJS +7eni6Irw6x/enuPxp2VdPJOxPkMSf/+BcADDQ4mOrFtYg7u7+AvWBw== -----END CERTIFICATE----- -issuing_ca -----BEGIN CERTIFICATE----- -MIIDUTCCAjmgAwIBAgIJAKM+z4MSfw2mMA0GCSqGSIb3DQEBCwUAMBsxGTAXBgNV -... +issuing_ca -----BEGIN CERTIFICATE----- +MIIDUzCCAjugAwIBAgIUaJJpBnXW+GkzJ6k6fQ9mqVKkEmQwDQYJKoZIhvcNAQEL +BQAwEzERMA8GA1UEAxMIcm9vdC5jb20wHhcNMTUxMTIwMTgxMDU2WhcNMzUxMTE1 +MTcxMDU2WjAbMRkwFwYDVQQDExBpbnRlcm1lZGlhdGUuY29tMIIBIjANBgkqhkiG +9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzTR8agj+uOYCvOSDsNYYb186aDo9QLPHAr96 +tDPjQFyp5Yjr60I6+say7zRPPGLgd3BealJ9EFeO7qlXeqi5z3H0wLzrMYqcGlok +2vSzdbs03+0/QXOys2R1Bzb+FOd4VoUSTiZ+a8wf07tmusNJCDE5/kI32+etQa8l +5a9ZQlwpgIWZSQmQjCA5B/0T6WQVwnELHOAGv+mJk7bAY/LVQkjUHzvimySsUmSb +sB20BPKhammJUDEcObwuJxA+f7NbkXzEypnR0pGULM32TR5Bmzij/iX33XDt3JKi +I9e0gJIT7bk91heWXLpEv2/+7g/lcXm/Hl9KvtX5WUtVPNENUQIDAQABo4GWMIGT +MA4GA1UdDwEB/wQEAwIBrjATBgNVHSUEDDAKBggrBgEFBQcDCTAPBgNVHRMBAf8E +BTADAQH/MB0GA1UdDgQWBBTzc6+uTQHNVqkz4L98Dbl2/8m7fjAfBgNVHSMEGDAW +gBSmqzdLJm2brQl3mpyIDRTohpQrMDAbBgNVHREEFDASghBpbnRlcm1lZGlhdGUu +Y29tMA0GCSqGSIb3DQEBCwUAA4IBAQAubC0cuwbitp2Fq5FgH8Mu/Fzhf5qWftxE +a7VagVExs2uxP5yD57bWck6vZrks03SVk4GFR9yyIVbOIUAVEm1Rw1/PK77l9/2c +fYhy0OQVZweO+olOgEfC8gYLaBT5Vo3D1CjV/Vb2VGCct3dmMsXuD04HOy1mTz2p +3yPx1wPoUYNaEu+7gzvUxh+8AM3JmCcrsaa1R9AsayAXtLuCJm9Fy6bU4I3wbxBp +zTOT7fmkjpjCV4acfgcPF2F90TfcesHl9oUgNsu4tChABiPENA4h2A4yVku9onaQ +JrNqv2SnJaYH4OTgtguC0cLB7hvr/Sc73pU55OSs2KZWhLZRWAJv -----END CERTIFICATE----- -private_key -----BEGIN RSA PRIVATE KEY----- -MIIEowIBAAKCAQEA0cczc7Y2yIu7aD/IaDi23Io+tvvDS9XaXXDUFW1kqd58P83r -... -3xhCNnZ3CMQaM2I48sloVK/XoikMLb5MZwOUQn/V+TrhWP4Lu7qD +private_key -----BEGIN RSA PRIVATE KEY----- +MIIEpQIBAAKCAQEAxH5eYopi7RJMmYimLPj36GgG3lYbWcU2FhQPgeyCJa/Ij0xG +Q7n+9jjn9Dbv/Eza1emZKKtBLh7wbTYtbrd7rGLelYvZa3KHw/0I59BB+mjmZxOS +e3PoJrDg4ZcX5S38/LhMraJysaH8DsNuiffrLm7kiJooDG6W0z/wS9p9vSuDSaCn +YYfFTMTQhT0MYLuQAhHSfRrIjzucAW+4n3SKtB3ElNDjXurmag13ioqn604Onmqe +BGgC6IJCYbpPAXACb/WkmybMDkl0xkTmuFwobQlxLg98lTqGTjpuyUputMu57X/3 +cWRecXGV40XuhpFyQCAAzi/ROXTpYExZaI2I6QIDAQABAoIBAQC11Rc060kmh6OZ +BOp6fZ60U+ffQiGnTieCAOhk29+IToYzjWsMa4d0hS6pQVmNyfVMtRJFn0z/CCSH +e/ZJGcR5vzipfTQjCWZ3yKXAF2mm+AIW6vbIBXeUrmQ8fpzfOVJ+73IN0GGA3hyp +8NJPHLxnSLl1a+qZrpEmRmnxV+y563Uporr7KriwUTDO+F/4YoJ92deDgW6FTR1/ +vB6QIeSoTa1bXrkz+jvNyFh/Z+c3DKAyndzjCRfMTOygwbxJQdrZv1yNfkNSym6/ +lGjZ6GnG/3hkh9nDldHLNJeJ4FbKyN5dbGnXrj2BI156KDE0jnO88TciX0khlRkp +efj9LcOBAoGBANB2HvtNp0eKDfGtey8Qxl6HP48mwg3pYLEATZtRowBFkyThfOoJ +Kf8ANNZHCPI/EilEYT6Xin3gdZNpC19gh3K86bCG8Uvq5TRtahO2oM4CenNOJAhe +utGfv5TfBBRodSRk2939masuavPLEqORKsBt3GSTv6Z1+Pfa+SjLm5F5AoGBAPFN +kvwXBvNkJOx594C9RVYmznD8z+IxVgqSIInpvu47SXJOWoS/hEwxfTCzCldl2ejK +eZ+mhJFud+wMbryF7AsW58+JfXr3lNJj7RquNx5cN+DSDV+1fESm9Me6e8XTxEqH ++ZoVPe/TRG6zJ+k7S99IDR1rE6D/oEjNpB/NxsbxAoGBAJ0Sc9O9Ni8UWd9hbTEQ +fbfaRszxUkSzNZUI+nDuuVhKFE40zS93CjrHCAjw60/EsEWB7ZgBDWw9hbo160jJ +biXJLHhDpWsjqeKwEr6Z3F59xZA+L65S2od6zBs7U1KhRqrOiFCjdndieVoLCJdQ +mZr27JqoLT8bIyZ2y0iu6iBZAoGADyTQMbP8QrApRRIOf2zhehurXxnurgJspPMw +yZb63Zao8FyMf8JJOkLs2W6TGpMQzvROF7/ql/n32r+Y/4nkG3oPiE3Xqyz4kQ+m +ZMNEQEqHUzu7jSMlrmVP/WztsaetrQPFnW7x2ShIJi5mNdP72gJ6mDsNG1CPraIC +R+CxNfECgYEAkqjs3j8Div/XnjPs3TuYtef7B/vgamzQujVkRR6+WkTvnZ1Hp9ge +vWrnOH3LbV8kfzzq0nbLK0iF7q4gl0czMJioVusaWrga2xkIfiI4yuHrIGatdTos +nPDHwoPZeRqBv/9OXSfQkYu+FiJnLEoztMb6f1Z1cPjvbuou2FB1p18= -----END RSA PRIVATE KEY----- -serial 5e:62:eb:2e:44:dd:04:83:8e:21:88:36:fc:15:ce:ed:da:1c:29:f5 +private_key_type rsa +serial_number 14:c9:de:ee:ba:35:0f:2b:e9:65:5f:94:44:73:0f:b7:3d:ef:bf:d3 ``` -Note that this is a write, not a read, to allow values to be passed in at request time. +Vault has now generated a new set of credentials using the `example-dot-com` +role configuration. Here we see the dynamically generated private key and +certificate. The issuing CA certificate is returned as well. -Vault has now generated a new set of credentials using the `example-dot-com` role configuration. Here we see the dynamically generated private key and certificate. The issuing CA certificate is returned as well. +Using ACLs, it is possible to restrict using the pki backend such that trusted +operators can manage the role definitions, and both users and applications are +restricted in the credentials they are allowed to read. -Using ACLs, it is possible to restrict using the pki backend such that trusted operators can manage the role definitions, and both users and applications are restricted in the credentials they are allowed to read. +If you get stuck at any time, simply run `vault path-help pki` or with a +subpath for interactive help output. -If you get stuck at any time, simply run `vault path-help pki` or with a subpath for interactive help output. ## API @@ -139,11 +342,10 @@ If you get stuck at any time, simply run `vault path-help pki` or with a subpath
    Description
    - Retrieves the CA certificate *in raw DER-encoded form*. - This is a bare endpoint that does not return a - standard Vault data structure. If `/pem` is added to the - endpoint, the CA certificate is returned in PEM format. -

    This is an unauthenticated endpoint. + Retrieves the CA certificate *in raw DER-encoded form*. This is a bare + endpoint that does not return a standard Vault data structure. If `/pem` is + added to the endpoint, the CA certificate is returned in PEM format.
    +
    This is an unauthenticated endpoint.
    Method
    @@ -173,12 +375,11 @@ If you get stuck at any time, simply run `vault path-help pki` or with a subpath
    Description
    - Retrieves one of a selection of certificates. Valid values: `ca` - for the CA certificate, `crl` for the current CRL, or a serial - number in either hyphen-separated or colon-separated octal format. - This endpoint returns the certificate in PEM formatting in the - `certificate` key of the JSON object. -

    This is an unauthenticated endpoint. + Retrieves one of a selection of certificates. Valid values: `ca` for the CA + certificate, `crl` for the current CRL, or a serial number in either + hyphen-separated or colon-separated octal format. This endpoint returns + the certificate in PEM formatting in the `certificate` key of the JSON + object.

    This is an unauthenticated endpoint.
    Method
    @@ -213,11 +414,14 @@ If you get stuck at any time, simply run `vault path-help pki` or with a subpath
    Description
    - A PEM file containing the issuing CA certificate - and its private key, concatenated. -

    This is a root-protected endpoint. -

    The information can be provided from a file via a `curl` - command similar to the following:
    + Allows submitting the CA information for the backend via a PEM file + containing the CA certificate and its private key, concatenated. Not needed + if you are generating a self-signed root certificate, and not used if you + have a signed intermediate CA certificate with a generated key (use the + `/pki/intermediate/set-signed` endpoint for that). _If you have already set + a certificate and key, they will be overridden._

    The information + can be provided from a file via a `curl` command similar to the + following:
    ```text $ curl \ @@ -260,6 +464,165 @@ If you get stuck at any time, simply run `vault path-help pki` or with a subpath
    + +### /pki/config/crl +#### GET + +
    +
    Description
    +
    + Allows getting the duration for which the generated CRL should be marked + valid. +
    + +
    Method
    +
    GET
    + +
    URL
    +
    `/pki/config/crl`
    + +
    Parameters
    +
    + None +
    + +
    Returns
    +
    + + ```javascript + { + "lease_id": "", + "renewable": false, + "lease_duration": 0, + "data": { + "expiry": "72h" + }, + "auth": null + } + ``` + +
    +
    + +#### POST + +
    +
    Description
    +
    + Allows setting the duration for which the generated CRL should be marked + valid. +
    + +
    Method
    +
    POST
    + +
    URL
    +
    `/pki/config/crl`
    + +
    Parameters
    +
    +
      +
    • +
    • + expiry + required + The time until expiration. Defaults to `72h`. +
    • +
    +
    + +
    Returns
    +
    + A `204` response code. +
    +
    + +### /pki/config/urls + +#### GET + +
    +
    Description
    +
    + Fetch the URLs to be encoded in generated certificates. +
    + +
    Method
    +
    GET
    + +
    URL
    +
    `/pki/config/urls`
    + +
    Parameters
    +
    + None +
    + +
    Returns
    +
    + + ```javascript + { + "lease_id": "", + "renewable": false, + "lease_duration": 0, + "data": { + "issuing_certificates": [, ], + "crl_distribution_points": [, ], + "ocsp_servers": [, ], + }, + "auth": null + } + ``` + +
    +
    + +#### POST + +
    +
    Description
    +
    + Allows setting the issuing certificate endpoints, CRL distribution points, + and OCSP server endpoints that will be encoded into issued certificates. + You can update any of the values at any time without affecting the other + existing values. To remove the values, simply use a blank string as the + parameter. +
    + +
    Method
    +
    POST
    + +
    URL
    +
    `/pki/config/urls`
    + +
    Parameters
    +
    +
      +
    • + issuing_certificates + optional + The URL values for the Issuing Certificate field. +
    • +
    • + crl_distribution_points + optional + The URL values for the CRL Distribution Points field. +
    • +
    • + ocsp_servers + optional + The URL values for the OCSP Servers field. +
    • +
    +
    + +
    Returns
    +
    + A `204` response code. +
    +
    + ### /pki/crl(/pem) #### GET @@ -305,7 +668,6 @@ If you get stuck at any time, simply run `vault path-help pki` or with a subpath by administrators to cut the size of the CRL if it contains a number of certificates that have now expired, but has not been rotated due to no further certificates being revoked. -

    This is a root-protected endpoint.
    Method
    @@ -333,26 +695,28 @@ If you get stuck at any time, simply run `vault path-help pki` or with a subpath
    -### /pki/issue/ +### /pki/intermediate/generate #### POST
    Description
    - Generates a new set of credentials (private key and - certificate) based on the named role. The issuing CA - certificate is returned as well, so that only the root CA - need be in a client's trust store. -

    *The private key is _not_ stored. - If you do not save the private key, you will need to - request a new certificate.* + Generates a new private key and a CSR for signing. If using Vault as a + root, and for many other CAs, the various parameters on the final + certificate are set at signing time and may or may not honor the parameters + set here. _This will overwrite any previously existing CA private key._ If + the path ends with `exported`, the private key will be returned in the + response; if it is `internal` the private key will not be returned and + *cannot be retrieved later*.

    This is mostly meant as a helper + function, and not all possible parameters that can be set in a CSR are + supported.
    Method
    POST
    URL
    -
    `/pki/issue/`
    +
    `/pki/intermediate/generate/[exported|internal]`
    Parameters
    @@ -360,30 +724,144 @@ If you get stuck at any time, simply run `vault path-help pki` or with a subpath
  • common_name required - The requested CN for the certificate. If the CN is allowed - by role policy, it will be issued. + The requested CN for the certificate.
  • alt_names optional - Requested Subject Alternative Names, in a comma-delimited - list. If any requested names do not match role policy, - the entire request will be denied. + Requested Subject Alternative Names, in a comma-delimited list. These + can be host names or email addresses; they will be parsed into their + respective fields.
  • ip_sans optional - Requested IP Subject Alternative Names, in a comma-delimited - list. Only valid if the role allows IP SANs (which is the - default). + Requested IP Subject Alternative Names, in a comma-delimited list. +
  • +
  • + format + optional + Format for returned data. Can be `pem` or `der`; defaults to `pem`. If + `der`, the output is base64 encoded. +
  • +
  • + key_type + optional + Desired key type; must be `rsa` or `ec`. Defaults to `rsa`. +
  • +
  • + key_bits + optional + The number of bits to use. Defaults to `2048`. Must be changed to a + valid value if the `key_type` is `ec`. +
  • + +
    + +
    Returns
    +
    + + ```javascript + { + "lease_id": "", + "renewable": false, + "lease_duration": 21600, + "data": { + "csr": "-----BEGIN CERTIFICATE REQUEST-----\nMIIDzDCCAragAwIBAgIUOd0ukLcjH43TfTHFG9qE0FtlMVgwCwYJKoZIhvcNAQEL\n...\numkqeYeO30g1uYvDuWLXVA==\n-----END CERTIFICATE REQUEST-----\n", + }, + "auth": null + } + ``` + +
    +
    + +### /pki/intermediate/set-signed +#### POST + +
    +
    Description
    +
    + Allows submitting the signed CA certificate corresponding to a private key generated via `/pki/intermediate/generate`. The certificate should be submitted in PEM format; see the documentation for `/pki/config/ca` for some hints on submitting. +
    + +
    Method
    +
    POST
    + +
    URL
    +
    `/pki/intermediate/set-signed`
    + +
    Parameters
    +
    +
      +
    • + certificate + required + The certificate in PEM format. +
    • +
    +
    + +
    Returns
    +
    + A `204` response code. +
    +
    + +### /pki/issue/ +#### POST + +
    +
    Description
    +
    + Generates a new set of credentials (private key and certificate) based on + the role named in the endpoint. The issuing CA certificate is returned as + well, so that only the root CA need be in a client's trust store.

    *The private key is _not_ stored. If you do not save the private + key, you will need to request a new certificate.* +
    + +
    Method
    +
    POST
    + +
    URL
    +
    `/pki/issue/`
    + +
    Parameters
    +
    +
      +
    • + common_name + required + The requested CN for the certificate. If the CN is allowed by role + policy, it will be issued. +
    • +
    • + alt_names + optional + Requested Subject Alternative Names, in a comma-delimited list. These + can be host names or email addresses; they will be parsed into their + respective fields. If any requested names do not match role policy, the + entire request will be denied. +
    • +
    • + ip_sans + optional + Requested IP Subject Alternative Names, in a comma-delimited list. Only + valid if the role allows IP SANs (which is the default).
    • ttl optional - Requested Time To Live. Cannot be greater than the role's - `max_ttl` value. If not provided, the role's `ttl` - value will be used. Note that the role values default - to system values if not explicitly set. + Requested Time To Live. Cannot be greater than the role's `max_ttl` + value. If not provided, the role's `ttl` value will be used. Note that + the role values default to system values if not explicitly set. +
    • +
    • + format + optional + Format for returned data. Can be `pem` or `der`; defaults to `pem`. If + `der`, the output is base64 encoded.
    @@ -402,7 +880,7 @@ If you get stuck at any time, simply run `vault path-help pki` or with a subpath "private_key": "-----BEGIN RSA PRIVATE KEY-----\nMIIEowIBAAKCAQEAnVHfwoKsUG1GDVyWB1AFroaKl2ImMBO8EnvGLRrmobIkQvh+\n...\nQN351pgTphi6nlCkGPzkDuwvtxSxiCWXQcaxrHAL7MiJpPzkIBq1\n-----END RSA PRIVATE KEY-----\n", "serial": "39:dd:2e:90:b7:23:1f:8d:d3:7d:31:c5:1b:da:84:d0:5b:65:31:58" }, - "auth": null + "auth": null } ``` @@ -419,7 +897,6 @@ If you get stuck at any time, simply run `vault path-help pki` or with a subpath alternative option to the standard method of revoking using Vault lease IDs. A successful revocation will rotate the CRL. -

    This is a root-protected endpoint.
    Method
    @@ -459,14 +936,12 @@ If you get stuck at any time, simply run `vault path-help pki` or with a subpath
    Description
    - Creates or updates the role definition. Note that - the `allowed_base_domain`, `allow_token_displayname`, - `allow_subdomains`, and `allow_any_name` attributes - are additive; between them nearly and across multiple - roles nearly any issuing policy can be accommodated. - `server_flag`, `client_flag`, and `code_signing_flag` - are additive as well. If a client requests a - certificate that is not allowed by the CN policy in + Creates or updates the role definition. Note that the + `allowed_domains`, `allow_subdomains`, and + `allow_any_name` attributes are additive; between them nearly and across + multiple roles nearly any issuing policy can be accommodated. + `server_flag`, `client_flag`, and `code_signing_flag` are additive as well. + If a client requests a certificate that is not allowed by the CN policy in the role, the request is denied.
    @@ -474,7 +949,7 @@ If you get stuck at any time, simply run `vault path-help pki` or with a subpath
    POST
    URL
    -
    `/pki/roles/`
    +
    `/pki/roles/`
    Parameters
    @@ -482,87 +957,91 @@ If you get stuck at any time, simply run `vault path-help pki` or with a subpath
  • ttl optional - The Time To Live value provided as a string duration - with time suffix. Hour is the largest suffix. - If not set, uses the system default value or the - value of `max_ttl`, whichever is shorter. + The Time To Live value provided as a string duration with time suffix. + Hour is the largest suffix. If not set, uses the system default value + or the value of `max_ttl`, whichever is shorter.
  • max_ttl optional - The maximum Time To Live provided as a string duration - with time suffix. Hour is the largest suffix. If not set, - defaults to the system maximum lease TTL. + The maximum Time To Live provided as a string duration with time + suffix. Hour is the largest suffix. If not set, defaults to the system + maximum lease TTL.
  • allow_localhost optional - If set, clients can request certificates for `localhost` - as one of the requested common names. This is useful - for testing and to allow clients on a single host to - talk securely. - Defaults to true. + If set, clients can request certificates for `localhost` as one of the + requested common names. This is useful for testing and to allow clients + on a single host to talk securely. Defaults to true.
  • - allowed_base_domain + allowed_domains optional - If set, clients can request certificates for subdomains - directly off of this base domain. _This includes the - wildcard subdomain._ For instance, a base_domain of - `example.com` allows clients to request certificates for - `foo.example.com` and `*.example.com`. To allow further - levels of subdomains, enable the `allow_subdomains` option. - There is no default. + Designates the domains of the role, provided as a comma-separated list. + This is used with the `allow_bare_domains` and `allow_subdomains` + options. There is no default.
  • - allow_token_displayname + allow_bare_domains optional - If set, clients can request certificates matching - the value of Display Name from the requesting token. - Remember, this stacks with the other CN options, - including `allowed_base_domain`. Defaults to `false`. + If set, clients can request certificates matching the value of the + actual domains themselves; e.g. if a configured domain set with + `allowed_domains` is `example.com`, this allows clients to actually + request a certificate containing the name `example.com` as one of the + DNS values on the final certificate. In some scenarios, this can be + considered a security risk. Defaults to false.
  • allow_subdomains optional - If set, clients can request certificates with CNs that - are subdomains of the CNs allowed by the other role - options. _This includes wildcard subdomains._ This is - redundant when using the `allow_any_name` option. - Defaults to `false`. + If set, clients can request certificates with CNs that are subdomains + of the CNs allowed by the other role options. _This includes wildcard + subdomains._ For example, an `allowed_domains` value of + `example.com` with this option set to true will allow `foo.example.com` + and `bar.example.com` as well as `*.example.com`. This is redundant + when using the `allow_any_name` option. Defaults to `false`.
  • allow_any_name optional - If set, clients can request any CN. Useful in some - circumstances, but make sure you understand whether it - is appropriate for your installation before enabling it. - Defaults to `false`. + If set, clients can request any CN. Useful in some circumstances, but + make sure you understand whether it is appropriate for your + installation before enabling it. Defaults to `false`. +
  • +
  • + enforce_hostnames + optional + If set, only valid host names are allowed for CNs, DNS SANs, and the + host part of email addresses. Defaults to `true`.
  • allow_ip_sans optional - If set, clients can request IP Subject Alternative - Names. Unlike CNs, no authorization checking is - performed except to verify that the given values - are valid IP addresses. Defaults to `true`. + If set, clients can request IP Subject Alternative Names. No + authorization checking is performed except to verify that the given + values are valid IP addresses. Defaults to `true`.
  • server_flag optional - If set, certificates are flagged for server use. - Defaults to `true`. + If set, certificates are flagged for server use. Defaults to `true`.
  • client_flag optional - If set, certificates are flagged for client use. - Defaults to `true`. + If set, certificates are flagged for client use. Defaults to `true`.
  • code_signing_flag optional - If set, certificates are flagged for code signing - use. Defaults to `false`. + If set, certificates are flagged for code signing use. Defaults to + `false`. +
  • +
  • + email_protection_flag + optional + If set, certificates are flagged for email protection use. Defaults to + `false`.
  • key_type @@ -579,6 +1058,12 @@ If you get stuck at any time, simply run `vault path-help pki` or with a subpath `ec` keys. See https://golang.org/pkg/crypto/elliptic/#Curve for an overview of allowed bit lengths for `ec`.
  • +
  • + use_csr_common_name + optional + If set, when used with the CSR signing endpoint, the common name in the + CSR will be used instead of taken from the JSON data. This does `not` + include any requested SANs in the CSR. Defaults to `false`.
  • @@ -600,7 +1085,7 @@ If you get stuck at any time, simply run `vault path-help pki` or with a subpath
    GET
    URL
    -
    `/pki/roles/`
    +
    `/pki/roles/`
    Parameters
    @@ -617,8 +1102,7 @@ If you get stuck at any time, simply run `vault path-help pki` or with a subpath "allow_ip_sans": true, "allow_localhost": true, "allow_subdomains": false, - "allow_token_displayname": false, - "allowed_base_domain": "example.com", + "allowed_domains": "example.com,foobar.com", "client_flag": true, "code_signing_flag": false, "key_bits": 2048, @@ -633,7 +1117,6 @@ If you get stuck at any time, simply run `vault path-help pki` or with a subpath
    - #### DELETE
    @@ -647,7 +1130,7 @@ If you get stuck at any time, simply run `vault path-help pki` or with a subpath
    DELETE
    URL
    -
    `/pki/roles/`
    +
    `/pki/roles/`
    Parameters
    @@ -659,3 +1142,347 @@ If you get stuck at any time, simply run `vault path-help pki` or with a subpath A `204` response code.
    + +### /pki/root/generate +#### POST + +
    +
    Description
    +
    + Generates a new self-signed CA certificate and private key. _This will + overwrite any previously-existing private key and certificate._ If the path + ends with `exported`, the private key will be returned in the response; if + it is `internal` the private key will not be returned and *cannot be + retrieved later*. Distribution points use the values set via `config/urls`. +

    As with other issued certificates, Vault will automatically + revoke the generated root at the end of its lease period; the CA + certificate will sign its own CRL. +
    + +
    Method
    +
    POST
    + +
    URL
    +
    `/pki/root/generate/[exported|internal]`
    + +
    Parameters
    +
    +
      +
    • + common_name + required + The requested CN for the certificate. +
    • +
    • + alt_names + optional + Requested Subject Alternative Names, in a comma-delimited list. These + can be host names or email addresses; they will be parsed into their + respective fields. +
    • +
    • + ip_sans + optional + Requested IP Subject Alternative Names, in a comma-delimited list. +
    • +
    • + ttl + optional + Requested Time To Live (after which the certificate will be expired). + This cannot be larger than the mount max (or, if not set, the system + max). +
    • +
    • + format + optional + Format for returned data. Can be `pem` or `der`; defaults to `pem`. If + `der`, the output is base64 encoded. +
    • +
    • + key_type + optional + Desired key type; must be `rsa` or `ec`. Defaults to `rsa`. +
    • +
    • + key_bits + optional + The number of bits to use. Defaults to `2048`. Must be changed to a + valid value if the `key_type` is `ec`. +
    • +
    • + max_path_length + optional + If set, the maximum path length to encode in the generated certificate. + Defaults to `-1`, which means no limit. unless the signing certificate + has a maximum path length set, in which case the path length is set to + one less than that of the signing certificate. A limit of `0` means a + literal path length of zero. +
    • +
    +
    + +
    Returns
    +
    + + ```javascript + { + "lease_id": "pki/root/generate/internal/aa959dd4-467e-e5ff-642b-371add518b40", + "lease_duration": 315359999, + "renewable": false, + "data": { + "certificate": "-----BEGIN CERTIFICATE-----\nMIIDzDCCAragAwIBAgIUOd0ukLcjH43TfTHFG9qE0FtlMVgwCwYJKoZIhvcNAQEL\n...\numkqeYeO30g1uYvDuWLXVA==\n-----END CERTIFICATE-----\n", + "issuing_ca": "-----BEGIN CERTIFICATE-----\nMIIDzDCCAragAwIBAgIUOd0ukLcjH43TfTHFG9qE0FtlMVgwCwYJKoZIhvcNAQEL\n...\numkqeYeO30g1uYvDuWLXVA==\n-----END CERTIFICATE-----\n", + "serial": "39:dd:2e:90:b7:23:1f:8d:d3:7d:31:c5:1b:da:84:d0:5b:65:31:58" + }, + "auth": null + } + ``` + +
    +
    + +### /pki/root/sign-intermediate +#### POST + +
    +
    Description
    +
    + Uses the configured CA certificate to issue a certificate with appropriate + values for acting as an intermediate CA. Distribution points use the values + set via `config/urls`. Values set in the CSR are ignored unless + `use_csr_values` is set to true, in which case the values from the CSR are + used verbatim. +
    + +
    Method
    +
    POST
    + +
    URL
    +
    `/pki/root/sign-intermediate`
    + +
    Parameters
    +
    +
      +
    • +
    • + csr + required + The PEM-encoded CSR. +
    • + common_name + required + The requested CN for the certificate. + +
    • + alt_names + optional + Requested Subject Alternative Names, in a comma-delimited list. These + can be host names or email addresses; they will be parsed into their + respective fields. +
    • +
    • + ip_sans + optional + Requested IP Subject Alternative Names, in a comma-delimited list. +
    • +
    • + ttl + optional + Requested Time To Live (after which the certificate will be expired). + This cannot be larger than the mount max (or, if not set, the system + max). +
    • +
    • + format + optional + Format for returned data. Can be `pem` or `der`; defaults to `pem`. If + `der`, the output is base64 encoded. +
    • +
    • + max_path_length + optional + If set, the maximum path length to encode in the generated certificate. + Defaults to `-1`, which means no limit. unless the signing certificate + has a maximum path length set, in which case the path length is set to + one less than that of the signing certificate. A limit of `0` means a + literal path length of zero. +
    • +
    • + use_csr_values + optional + If set to `true`, then: 1) Subject information, including names and + alternate names, will be preserved from the CSR rather than using the + values provided in the other parameters to this path; 2) Any key usages + (for instance, non-repudiation) requested in the CSR will be added to + the basic set of key usages used for CA certs signed by this path; 3) + Extensions requested in the CSR will be copied into the issued + certificate. +
    • +
    +
    + +
    Returns
    +
    + + ```javascript + { + "lease_id": "pki/root/sign-intermediate/bc23e3c6-8dcd-48c6-f3af-dd2db7f815c2", + "renewable": false, + "lease_duration": 21600, + "data": { + "certificate": "-----BEGIN CERTIFICATE-----\nMIIDzDCCAragAwIBAgIUOd0ukLcjH43TfTHFG9qE0FtlMVgwCwYJKoZIhvcNAQEL\n...\numkqeYeO30g1uYvDuWLXVA==\n-----END CERTIFICATE-----\n", + "issuing_ca": "-----BEGIN CERTIFICATE-----\nMIIDUTCCAjmgAwIBAgIJAKM+z4MSfw2mMA0GCSqGSIb3DQEBCwUAMBsxGTAXBgNV\n...\nG/7g4koczXLoUM3OQXd5Aq2cs4SS1vODrYmgbioFsQ3eDHd1fg==\n-----END CERTIFICATE-----\n", + "serial": "39:dd:2e:90:b7:23:1f:8d:d3:7d:31:c5:1b:da:84:d0:5b:65:31:58" + }, + "auth": null + } + ``` + +
    +
    + +### /pki/sign/ +#### POST + +
    +
    Description
    +
    + Signs a new certificate based upon the provided CSR and the supplied + parameters, subject to the restrictions contained in the role named in the + endpoint. The issuing CA certificate is returned as well, so that only the + root CA need be in a client's trust store. +
    + +
    Method
    +
    POST
    + +
    URL
    +
    `/pki/sign/`
    + +
    Parameters
    +
    +
      +
    • + csr + required + The PEM-encoded CSR. +
    • +
    • + common_name + required + The requested CN for the certificate. If the CN is allowed by role + policy, it will be issued. +
    • +
    • + alt_names + optional + Requested Subject Alternative Names, in a comma-delimited list. These + can be host names or email addresses; they will be parsed into their + respective fields. If any requested names do not match role policy, the + entire request will be denied. +
    • +
    • + ip_sans + optional + Requested IP Subject Alternative Names, in a comma-delimited list. Only + valid if the role allows IP SANs (which is the default). +
    • +
    • + ttl + optional + Requested Time To Live. Cannot be greater than the role's `max_ttl` + value. If not provided, the role's `ttl` value will be used. Note that + the role values default to system values if not explicitly set. +
    • +
    • + format + optional + Format for returned data. Can be `pem` or `der`; defaults to `pem`. If + `der`, the output is base64 encoded. +
    • +
    +
    + +
    Returns
    +
    + + ```javascript + { + "lease_id": "pki/sign/test/7ad6cfa5-f04f-c62a-d477-f33210475d05", + "renewable": false, + "lease_duration": 21600, + "data": { + "certificate": "-----BEGIN CERTIFICATE-----\nMIIDzDCCAragAwIBAgIUOd0ukLcjH43TfTHFG9qE0FtlMVgwCwYJKoZIhvcNAQEL\n...\numkqeYeO30g1uYvDuWLXVA==\n-----END CERTIFICATE-----\n", + "issuing_ca": "-----BEGIN CERTIFICATE-----\nMIIDUTCCAjmgAwIBAgIJAKM+z4MSfw2mMA0GCSqGSIb3DQEBCwUAMBsxGTAXBgNV\n...\nG/7g4koczXLoUM3OQXd5Aq2cs4SS1vODrYmgbioFsQ3eDHd1fg==\n-----END CERTIFICATE-----\n", + "serial": "39:dd:2e:90:b7:23:1f:8d:d3:7d:31:c5:1b:da:84:d0:5b:65:31:58" + }, + "auth": null + } + ``` + +
    +
    + +### /pki/sign-verbatim +#### POST + +
    +
    Description
    +
    + Signs a new certificate based upon the provided CSR. Values are taken + verbatim from the CSR; the _only_ restriction is that this endpoint will + refuse to issue an intermediate CA certificate (see the + `/pki/root/sign-intermediate` endpoint for that functionality.) _This is a + potentially dangerous endpoint and only highly trusted users should + have access._ +
    + +
    Method
    +
    POST
    + +
    URL
    +
    `/pki/sign-verbatim`
    + +
    Parameters
    +
    +
      +
    • + csr + required + The PEM-encoded CSR. +
    • +
    • + ttl + optional + Requested Time To Live. Cannot be greater than the mount's `max_ttl` + value. If not provided, the mount's `ttl` value will be used, which + defaults to system values if not explicitly set. +
    • +
    • + format + optional + Format for returned data. Can be `pem` or `der`; defaults to `pem`. If + `der`, the output is base64 encoded. +
    • +
    +
    + +
    Returns
    +
    + + ```javascript + { + "lease_id": "pki/sign-verbatim/7ad6cfa5-f04f-c62a-d477-f33210475d05", + "renewable": false, + "lease_duration": 21600, + "data": { + "certificate": "-----BEGIN CERTIFICATE-----\nMIIDzDCCAragAwIBAgIUOd0ukLcjH43TfTHFG9qE0FtlMVgwCwYJKoZIhvcNAQEL\n...\numkqeYeO30g1uYvDuWLXVA==\n-----END CERTIFICATE-----\n", + "issuing_ca": "-----BEGIN CERTIFICATE-----\nMIIDUTCCAjmgAwIBAgIJAKM+z4MSfw2mMA0GCSqGSIb3DQEBCwUAMBsxGTAXBgNV\n...\nG/7g4koczXLoUM3OQXd5Aq2cs4SS1vODrYmgbioFsQ3eDHd1fg==\n-----END CERTIFICATE-----\n", + "serial": "39:dd:2e:90:b7:23:1f:8d:d3:7d:31:c5:1b:da:84:d0:5b:65:31:58" + }, + "auth": null + } + ``` + +
    +
    diff --git a/website/source/intro/vs/kms.html.md b/website/source/intro/vs/kms.html.md index be3c4b15c..6318d2f59 100644 --- a/website/source/intro/vs/kms.html.md +++ b/website/source/intro/vs/kms.html.md @@ -21,7 +21,7 @@ In contrast, Vault provides a comprehensive secret management solution. The [`transit` backend](/docs/secrets/transit/index.html) provides similar capabilities as the KMS service, allowing for encryption keys to be stored and cryptographic operations to be performed. However, Vault goes -much futher than just key management. +much further than just key management. The flexible secret backends allow Vault to handle any type of secret data, including database credentials, API keys, PKI keys, and encryption keys. diff --git a/website/source/layouts/svg/_svg-by-hashicorp.erb b/website/source/layouts/svg/_svg-by-hashicorp.erb index d89929590..607d16b1e 100644 --- a/website/source/layouts/svg/_svg-by-hashicorp.erb +++ b/website/source/layouts/svg/_svg-by-hashicorp.erb @@ -1,18 +1,17 @@ - - + - - - - - - - - - + + + + + + + + + + + + + - -