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.
 
 
 

149 lines
4.6 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. // Oneline: First sentence. Second sentence. Description is long enough
  109. // to be wrapped.
  110. Oneline string `json:"oneline,omitempty"`
  111. // Twoline: First sentence.
  112. // Second sentence. Description is long enough to be wrapped.
  113. Twoline string `json:"twoline,omitempty"`
  114. // ForceSendFields is a list of field names (e.g. "Oneline") to
  115. // unconditionally include in API requests. By default, fields with
  116. // empty values are omitted from API requests. However, any non-pointer,
  117. // non-interface field appearing in ForceSendFields will be sent to the
  118. // server regardless of whether the field is empty or not. This may be
  119. // used to include empty fields in Patch requests.
  120. ForceSendFields []string `json:"-"`
  121. // NullFields is a list of field names (e.g. "Oneline") to include in
  122. // API requests with the JSON null value. By default, fields with empty
  123. // values are omitted from API requests. However, any field with an
  124. // empty value appearing in NullFields will be sent to the server as
  125. // null. It is an error if a field in this list has a non-empty value.
  126. // This may be used to include null fields in Patch requests.
  127. NullFields []string `json:"-"`
  128. }
  129. func (s *Thing) MarshalJSON() ([]byte, error) {
  130. type NoMethod Thing
  131. raw := NoMethod(*s)
  132. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  133. }