aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/google.golang.org/api/gensupport/params.go
diff options
context:
space:
mode:
authorNathan Dench <ndenc2@gmail.com>2019-05-24 15:16:44 +1000
committerNathan Dench <ndenc2@gmail.com>2019-05-24 15:16:44 +1000
commit107c1cdb09c575aa2f61d97f48d8587eb6bada4c (patch)
treeca7d008643efc555c388baeaf1d986e0b6b3e28c /vendor/google.golang.org/api/gensupport/params.go
parent844b5a68d8af4791755b8f0ad293cc99f5959183 (diff)
downloadterraform-provider-statuscake-107c1cdb09c575aa2f61d97f48d8587eb6bada4c.tar.gz
terraform-provider-statuscake-107c1cdb09c575aa2f61d97f48d8587eb6bada4c.tar.zst
terraform-provider-statuscake-107c1cdb09c575aa2f61d97f48d8587eb6bada4c.zip
Upgrade to 0.12
Diffstat (limited to 'vendor/google.golang.org/api/gensupport/params.go')
-rw-r--r--vendor/google.golang.org/api/gensupport/params.go51
1 files changed, 51 insertions, 0 deletions
diff --git a/vendor/google.golang.org/api/gensupport/params.go b/vendor/google.golang.org/api/gensupport/params.go
new file mode 100644
index 0000000..0e878a4
--- /dev/null
+++ b/vendor/google.golang.org/api/gensupport/params.go
@@ -0,0 +1,51 @@
1// Copyright 2015 The Go Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5package gensupport
6
7import (
8 "net/url"
9
10 "google.golang.org/api/googleapi"
11)
12
13// URLParams is a simplified replacement for url.Values
14// that safely builds up URL parameters for encoding.
15type URLParams map[string][]string
16
17// Get returns the first value for the given key, or "".
18func (u URLParams) Get(key string) string {
19 vs := u[key]
20 if len(vs) == 0 {
21 return ""
22 }
23 return vs[0]
24}
25
26// Set sets the key to value.
27// It replaces any existing values.
28func (u URLParams) Set(key, value string) {
29 u[key] = []string{value}
30}
31
32// SetMulti sets the key to an array of values.
33// It replaces any existing values.
34// Note that values must not be modified after calling SetMulti
35// so the caller is responsible for making a copy if necessary.
36func (u URLParams) SetMulti(key string, values []string) {
37 u[key] = values
38}
39
40// Encode encodes the values into ``URL encoded'' form
41// ("bar=baz&foo=quux") sorted by key.
42func (u URLParams) Encode() string {
43 return url.Values(u).Encode()
44}
45
46// SetOptions sets the URL params and any additional call options.
47func SetOptions(u URLParams, opts ...googleapi.CallOption) {
48 for _, o := range opts {
49 u.Set(o.Get())
50 }
51}