1// Copyright YEAR Google LLC.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5// Code generated file. DO NOT EDIT.
6
7// Package wrapnewlines provides access to the Example API.
8//
9// Creating a client
10//
11// Usage example:
12//
13//   import "google.golang.org/api/wrapnewlines/v1"
14//   ...
15//   ctx := context.Background()
16//   wrapnewlinesService, err := wrapnewlines.NewService(ctx)
17//
18// In this example, Google Application Default Credentials are used for authentication.
19//
20// For information on how to create and obtain Application Default Credentials, see https://developers.google.com/identity/protocols/application-default-credentials.
21//
22// Other authentication options
23//
24// To use an API key for authentication (note: some APIs do not support API keys), use option.WithAPIKey:
25//
26//   wrapnewlinesService, err := wrapnewlines.NewService(ctx, option.WithAPIKey("AIza..."))
27//
28// To use an OAuth token (e.g., a user token obtained via a three-legged OAuth flow), use option.WithTokenSource:
29//
30//   config := &oauth2.Config{...}
31//   // ...
32//   token, err := config.Exchange(ctx, ...)
33//   wrapnewlinesService, err := wrapnewlines.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token)))
34//
35// See https://godoc.org/google.golang.org/api/option/ for details on options.
36package wrapnewlines // import "google.golang.org/api/wrapnewlines/v1"
37
38import (
39	"bytes"
40	"context"
41	"encoding/json"
42	"errors"
43	"fmt"
44	"io"
45	"net/http"
46	"net/url"
47	"strconv"
48	"strings"
49
50	googleapi "google.golang.org/api/googleapi"
51	gensupport "google.golang.org/api/internal/gensupport"
52	option "google.golang.org/api/option"
53	internaloption "google.golang.org/api/option/internaloption"
54	htransport "google.golang.org/api/transport/http"
55)
56
57// Always reference these packages, just in case the auto-generated code
58// below doesn't.
59var _ = bytes.NewBuffer
60var _ = strconv.Itoa
61var _ = fmt.Sprintf
62var _ = json.NewDecoder
63var _ = io.Copy
64var _ = url.Parse
65var _ = gensupport.MarshalJSON
66var _ = googleapi.Version
67var _ = errors.New
68var _ = strings.Replace
69var _ = context.Canceled
70var _ = internaloption.WithDefaultEndpoint
71
72const apiId = "wrapnewlines:v1"
73const apiName = "wrapnewlines"
74const apiVersion = "v1"
75const basePath = "https://www.googleapis.com/discovery/v1/apis"
76
77// NewService creates a new Service.
78func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
79	opts = append(opts, internaloption.WithDefaultEndpoint(basePath))
80	client, endpoint, err := htransport.NewClient(ctx, opts...)
81	if err != nil {
82		return nil, err
83	}
84	s, err := New(client)
85	if err != nil {
86		return nil, err
87	}
88	if endpoint != "" {
89		s.BasePath = endpoint
90	}
91	return s, nil
92}
93
94// New creates a new Service. It uses the provided http.Client for requests.
95//
96// Deprecated: please use NewService instead.
97// To provide a custom HTTP client, use option.WithHTTPClient.
98// If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead.
99func New(client *http.Client) (*Service, error) {
100	if client == nil {
101		return nil, errors.New("client is nil")
102	}
103	s := &Service{client: client, BasePath: basePath}
104	return s, nil
105}
106
107type Service struct {
108	client    *http.Client
109	BasePath  string // API endpoint base URL
110	UserAgent string // optional additional User-Agent fragment
111}
112
113func (s *Service) userAgent() string {
114	if s.UserAgent == "" {
115		return googleapi.UserAgent
116	}
117	return googleapi.UserAgent + " " + s.UserAgent
118}
119
120// Thing: don't care
121type Thing struct {
122	// BoolEmptyDefaultA:
123	// Nonempty default: no
124	// Unfortunate default: no
125	BoolEmptyDefaultA bool `json:"bool_empty_default_a,omitempty"`
126
127	// BoolEmptyDefaultB:
128	// Nonempty default: no
129	// Unfortunate default: no
130	BoolEmptyDefaultB bool `json:"bool_empty_default_b,omitempty"`
131
132	// BoolNonemptyDefault:
133	// Nonempty default: yes
134	// Unfortunate default: yes
135	//
136	// Default: true
137	BoolNonemptyDefault *bool `json:"bool_nonempty_default,omitempty"`
138
139	// NumericEmptyDefaultA:
140	// Nonempty default: no
141	// Unfortunate default: no
142	NumericEmptyDefaultA int64 `json:"numeric_empty_default_a,omitempty,string"`
143
144	// NumericEmptyDefaultB:
145	// Nonempty default: no
146	// Unfortunate default: no
147	NumericEmptyDefaultB int64 `json:"numeric_empty_default_b,omitempty,string"`
148
149	// NumericEmptyDefaultC:
150	// Nonempty default: no
151	// Unfortunate default: no
152	NumericEmptyDefaultC int64 `json:"numeric_empty_default_c,omitempty,string"`
153
154	// NumericEmptyDefaultD:
155	// Nonempty default: no
156	// Unfortunate default: no
157	NumericEmptyDefaultD float64 `json:"numeric_empty_default_d,omitempty"`
158
159	// NumericEmptyDefaultE:
160	// Nonempty default: no
161	// Unfortunate default: no
162	NumericEmptyDefaultE float64 `json:"numeric_empty_default_e,omitempty"`
163
164	// NumericNonemptyDefaultA:
165	// Nonempty default: yes
166	// Unfortunate default: yes
167	// string encoded, so will not be represented as pointer.
168	//
169	// Default: 1
170	NumericNonemptyDefaultA *int64 `json:"numeric_nonempty_default_a,omitempty,string"`
171
172	// NumericNonemptyDefaultB:
173	// Nonempty default: yes
174	// Unfortunate default: yes
175	//
176	// Default: 0.001
177	NumericNonemptyDefaultB *float64 `json:"numeric_nonempty_default_b,omitempty"`
178
179	// StringEmptyDefaultDoesntAcceptEmpty:
180	// Nonempty default: no
181	// Accepts empty value: no
182	// Unfortunate default: no
183	StringEmptyDefaultDoesntAcceptEmpty string `json:"string_empty_default_doesnt_accept_empty,omitempty"`
184
185	// StringEmptyDefaultEnumAcceptsEmpty:
186	// Nonempty default: no
187	// Accepts empty value: yes (enum)
188	// Unfortunate default: no
189	//
190	// Possible values:
191	//   "" (default)
192	//   "value"
193	StringEmptyDefaultEnumAcceptsEmpty string `json:"string_empty_default_enum_accepts_empty,omitempty"`
194
195	// StringEmptyDefaultEnumDoesntAcceptEmpty:
196	// Nonempty default: no
197	// Accepts empty value: no (enum)
198	// Unfortunate default: no
199	//
200	// Possible values:
201	//   "value"
202	StringEmptyDefaultEnumDoesntAcceptEmpty string `json:"string_empty_default_enum_doesnt_accept_empty,omitempty"`
203
204	// StringEmptyDefaultPatternAcceptsEmpty:
205	// Nonempty default: no
206	// Accepts empty value: yes (pattern)
207	// Unfortunate default: no
208	StringEmptyDefaultPatternAcceptsEmpty string `json:"string_empty_default_pattern_accepts_empty,omitempty"`
209
210	// StringEmptyDefaultPatternDoesntAcceptEmpty:
211	// Nonempty default: no
212	// Accepts empty value: no (pattern)
213	// Unfortunate default: no
214	StringEmptyDefaultPatternDoesntAcceptEmpty string `json:"string_empty_default_pattern_doesnt_accept_empty,omitempty"`
215
216	// StringNonemptyDefaultDoesntAcceptEmpty:
217	// Nonempty default: yes
218	// Accepts empty value: no
219	// Unfortunate default: no
220	StringNonemptyDefaultDoesntAcceptEmpty string `json:"string_nonempty_default_doesnt_accept_empty,omitempty"`
221
222	// StringNonemptyDefaultEnumAcceptsEmpty:
223	// Nonempty default: yes
224	// Accepts empty value: yes (enum)
225	// Unfortunate default: yes
226	//
227	// Possible values:
228	//   ""
229	//   "nonempty" (default)
230	//   "aaa"
231	StringNonemptyDefaultEnumAcceptsEmpty *string `json:"string_nonempty_default_enum_accepts_empty,omitempty"`
232
233	// StringNonemptyDefaultEnumDoesntAcceptEmpty:
234	// Nonempty default: yes
235	// Accepts empty value: no (enum)
236	// Unfortunate default: no
237	//
238	// Possible values:
239	//   "nonempty" (default)
240	//   "aaa"
241	StringNonemptyDefaultEnumDoesntAcceptEmpty string `json:"string_nonempty_default_enum_doesnt_accept_empty,omitempty"`
242
243	// StringNonemptyDefaultPatternAcceptsEmpty:
244	// Nonempty default: yes
245	// Accepts empty value: yes (pattern)
246	// Unfortunate default: yes
247	//
248	// Default: nonempty
249	StringNonemptyDefaultPatternAcceptsEmpty *string `json:"string_nonempty_default_pattern_accepts_empty,omitempty"`
250
251	// StringNonemptyDefaultPatternDoesntAcceptEmpty:
252	// Nonempty default: yes
253	// Accepts empty value: no (pattern)
254	// Unfortunate default: no
255	StringNonemptyDefaultPatternDoesntAcceptEmpty string `json:"string_nonempty_default_pattern_doesnt_accept_empty,omitempty"`
256
257	// ForceSendFields is a list of field names (e.g. "BoolEmptyDefaultA")
258	// to unconditionally include in API requests. By default, fields with
259	// empty values are omitted from API requests. However, any non-pointer,
260	// non-interface field appearing in ForceSendFields will be sent to the
261	// server regardless of whether the field is empty or not. This may be
262	// used to include empty fields in Patch requests.
263	ForceSendFields []string `json:"-"`
264
265	// NullFields is a list of field names (e.g. "BoolEmptyDefaultA") to
266	// include in API requests with the JSON null value. By default, fields
267	// with empty values are omitted from API requests. However, any field
268	// with an empty value appearing in NullFields will be sent to the
269	// server as null. It is an error if a field in this list has a
270	// non-empty value. This may be used to include null fields in Patch
271	// requests.
272	NullFields []string `json:"-"`
273}
274
275func (s *Thing) MarshalJSON() ([]byte, error) {
276	type NoMethod Thing
277	raw := NoMethod(*s)
278	return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
279}
280
281func (s *Thing) UnmarshalJSON(data []byte) error {
282	type NoMethod Thing
283	var s1 struct {
284		NumericEmptyDefaultD    gensupport.JSONFloat64  `json:"numeric_empty_default_d"`
285		NumericEmptyDefaultE    gensupport.JSONFloat64  `json:"numeric_empty_default_e"`
286		NumericNonemptyDefaultB *gensupport.JSONFloat64 `json:"numeric_nonempty_default_b"`
287		*NoMethod
288	}
289	s1.NoMethod = (*NoMethod)(s)
290	if err := json.Unmarshal(data, &s1); err != nil {
291		return err
292	}
293	s.NumericEmptyDefaultD = float64(s1.NumericEmptyDefaultD)
294	s.NumericEmptyDefaultE = float64(s1.NumericEmptyDefaultE)
295	if s1.NumericNonemptyDefaultB != nil {
296		s.NumericNonemptyDefaultB = (*float64)(s1.NumericNonemptyDefaultB)
297	}
298	return nil
299}
300