You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

297 lines
9.3 KiB

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