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.
 
 
 

165 line
4.8 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 x provides access to the X.
  6. //
  7. // For product documentation, see: https://cloud.google.com/appengine/docs/admin-api/
  8. //
  9. // Creating a client
  10. //
  11. // Usage example:
  12. //
  13. // import "google.golang.org/api/x/v1"
  14. // ...
  15. // ctx := context.Background()
  16. // xService, err := x.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. // xService, err := x.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. // xService, err := x.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token)))
  34. //
  35. // See https://godoc.org/google.golang.org/api/option/ for details on options.
  36. package x // import "google.golang.org/api/x/v1"
  37. import (
  38. "bytes"
  39. "context"
  40. "encoding/json"
  41. "errors"
  42. "fmt"
  43. "io"
  44. "net/http"
  45. "net/url"
  46. "strconv"
  47. "strings"
  48. gensupport "google.golang.org/api/gensupport"
  49. googleapi "google.golang.org/api/googleapi"
  50. option "google.golang.org/api/option"
  51. htransport "google.golang.org/api/transport/http"
  52. )
  53. // Always reference these packages, just in case the auto-generated code
  54. // below doesn't.
  55. var _ = bytes.NewBuffer
  56. var _ = strconv.Itoa
  57. var _ = fmt.Sprintf
  58. var _ = json.NewDecoder
  59. var _ = io.Copy
  60. var _ = url.Parse
  61. var _ = gensupport.MarshalJSON
  62. var _ = googleapi.Version
  63. var _ = errors.New
  64. var _ = strings.Replace
  65. var _ = context.Canceled
  66. const apiId = "X:v1"
  67. const apiName = "X"
  68. const apiVersion = "v1"
  69. const basePath = "https://appengine.googleapis.com/"
  70. // NewService creates a new Service.
  71. func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
  72. client, endpoint, err := htransport.NewClient(ctx, opts...)
  73. if err != nil {
  74. return nil, err
  75. }
  76. s, err := New(client)
  77. if err != nil {
  78. return nil, err
  79. }
  80. if endpoint != "" {
  81. s.BasePath = endpoint
  82. }
  83. return s, nil
  84. }
  85. // New creates a new Service. It uses the provided http.Client for requests.
  86. //
  87. // Deprecated: please use NewService instead.
  88. // To provide a custom HTTP client, use option.WithHTTPClient.
  89. // If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead.
  90. func New(client *http.Client) (*Service, error) {
  91. if client == nil {
  92. return nil, errors.New("client is nil")
  93. }
  94. s := &Service{client: client, BasePath: basePath}
  95. return s, nil
  96. }
  97. type Service struct {
  98. client *http.Client
  99. BasePath string // API endpoint base URL
  100. UserAgent string // optional additional User-Agent fragment
  101. }
  102. func (s *Service) userAgent() string {
  103. if s.UserAgent == "" {
  104. return googleapi.UserAgent
  105. }
  106. return googleapi.UserAgent + " " + s.UserAgent
  107. }
  108. // Utilization: CPU utilization policy.
  109. type Utilization struct {
  110. Average float64 `json:"average,omitempty"`
  111. Count int64 `json:"count,omitempty"`
  112. Target float64 `json:"target,omitempty"`
  113. // ForceSendFields is a list of field names (e.g. "Average") to
  114. // unconditionally include in API requests. By default, fields with
  115. // empty values are omitted from API requests. However, any non-pointer,
  116. // non-interface field appearing in ForceSendFields will be sent to the
  117. // server regardless of whether the field is empty or not. This may be
  118. // used to include empty fields in Patch requests.
  119. ForceSendFields []string `json:"-"`
  120. // NullFields is a list of field names (e.g. "Average") to include in
  121. // API requests with the JSON null value. By default, fields with empty
  122. // values are omitted from API requests. However, any field with an
  123. // empty value appearing in NullFields will be sent to the server as
  124. // null. It is an error if a field in this list has a non-empty value.
  125. // This may be used to include null fields in Patch requests.
  126. NullFields []string `json:"-"`
  127. }
  128. func (s *Utilization) MarshalJSON() ([]byte, error) {
  129. type NoMethod Utilization
  130. raw := NoMethod(*s)
  131. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  132. }
  133. func (s *Utilization) UnmarshalJSON(data []byte) error {
  134. type NoMethod Utilization
  135. var s1 struct {
  136. Average gensupport.JSONFloat64 `json:"average"`
  137. Target gensupport.JSONFloat64 `json:"target"`
  138. *NoMethod
  139. }
  140. s1.NoMethod = (*NoMethod)(s)
  141. if err := json.Unmarshal(data, &s1); err != nil {
  142. return err
  143. }
  144. s.Average = float64(s1.Average)
  145. s.Target = float64(s1.Target)
  146. return nil
  147. }