25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

271 lines
8.0 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 additionalprops provides access to the Example API.
  6. //
  7. // Creating a client
  8. //
  9. // Usage example:
  10. //
  11. // import "google.golang.org/api/additionalprops/v1"
  12. // ...
  13. // ctx := context.Background()
  14. // additionalpropsService, err := additionalprops.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. // additionalpropsService, err := additionalprops.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. // additionalpropsService, err := additionalprops.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 additionalprops // import "google.golang.org/api/additionalprops/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 = "additionalprops:v1"
  65. const apiName = "additionalprops"
  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. s.Atlas = NewAtlasService(s)
  94. return s, nil
  95. }
  96. type Service struct {
  97. client *http.Client
  98. BasePath string // API endpoint base URL
  99. UserAgent string // optional additional User-Agent fragment
  100. Atlas *AtlasService
  101. }
  102. func (s *Service) userAgent() string {
  103. if s.UserAgent == "" {
  104. return googleapi.UserAgent
  105. }
  106. return googleapi.UserAgent + " " + s.UserAgent
  107. }
  108. func NewAtlasService(s *Service) *AtlasService {
  109. rs := &AtlasService{s: s}
  110. return rs
  111. }
  112. type AtlasService struct {
  113. s *Service
  114. }
  115. type Property struct {
  116. }
  117. // TimeseriesDescriptor: The descriptions of a time series.
  118. type TimeseriesDescriptor struct {
  119. // Labels: The set of key-value pairs that describe this time series,
  120. // including target-specific labels and metric-specific labels.
  121. Labels map[string]string `json:"labels,omitempty"`
  122. // Metric: The name of the metric.
  123. Metric string `json:"metric,omitempty"`
  124. // Project: The project ID to which this time series belongs.
  125. Project string `json:"project,omitempty"`
  126. // Tags: A map of additional information.
  127. Tags map[string][]Property `json:"tags,omitempty"`
  128. // ForceSendFields is a list of field names (e.g. "Labels") to
  129. // unconditionally include in API requests. By default, fields with
  130. // empty values are omitted from API requests. However, any non-pointer,
  131. // non-interface field appearing in ForceSendFields will be sent to the
  132. // server regardless of whether the field is empty or not. This may be
  133. // used to include empty fields in Patch requests.
  134. ForceSendFields []string `json:"-"`
  135. // NullFields is a list of field names (e.g. "Labels") to include in API
  136. // requests with the JSON null value. By default, fields with empty
  137. // values are omitted from API requests. However, any field with an
  138. // empty value appearing in NullFields will be sent to the server as
  139. // null. It is an error if a field in this list has a non-empty value.
  140. // This may be used to include null fields in Patch requests.
  141. NullFields []string `json:"-"`
  142. }
  143. func (s *TimeseriesDescriptor) MarshalJSON() ([]byte, error) {
  144. type NoMethod TimeseriesDescriptor
  145. raw := NoMethod(*s)
  146. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  147. }
  148. // method id "mapofstrings.getMap":
  149. type AtlasGetMapCall struct {
  150. s *Service
  151. urlParams_ gensupport.URLParams
  152. ifNoneMatch_ string
  153. ctx_ context.Context
  154. header_ http.Header
  155. }
  156. // GetMap: Get a map.
  157. func (r *AtlasService) GetMap() *AtlasGetMapCall {
  158. c := &AtlasGetMapCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  159. return c
  160. }
  161. // Fields allows partial responses to be retrieved. See
  162. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  163. // for more information.
  164. func (c *AtlasGetMapCall) Fields(s ...googleapi.Field) *AtlasGetMapCall {
  165. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  166. return c
  167. }
  168. // IfNoneMatch sets the optional parameter which makes the operation
  169. // fail if the object's ETag matches the given value. This is useful for
  170. // getting updates only after the object has changed since the last
  171. // request. Use googleapi.IsNotModified to check whether the response
  172. // error from Do is the result of In-None-Match.
  173. func (c *AtlasGetMapCall) IfNoneMatch(entityTag string) *AtlasGetMapCall {
  174. c.ifNoneMatch_ = entityTag
  175. return c
  176. }
  177. // Context sets the context to be used in this call's Do method. Any
  178. // pending HTTP request will be aborted if the provided context is
  179. // canceled.
  180. func (c *AtlasGetMapCall) Context(ctx context.Context) *AtlasGetMapCall {
  181. c.ctx_ = ctx
  182. return c
  183. }
  184. // Header returns an http.Header that can be modified by the caller to
  185. // add HTTP headers to the request.
  186. func (c *AtlasGetMapCall) Header() http.Header {
  187. if c.header_ == nil {
  188. c.header_ = make(http.Header)
  189. }
  190. return c.header_
  191. }
  192. func (c *AtlasGetMapCall) doRequest(alt string) (*http.Response, error) {
  193. reqHeaders := make(http.Header)
  194. for k, v := range c.header_ {
  195. reqHeaders[k] = v
  196. }
  197. reqHeaders.Set("User-Agent", c.s.userAgent())
  198. if c.ifNoneMatch_ != "" {
  199. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  200. }
  201. var body io.Reader = nil
  202. c.urlParams_.Set("alt", alt)
  203. c.urlParams_.Set("prettyPrint", "false")
  204. urls := googleapi.ResolveRelative(c.s.BasePath, "map")
  205. urls += "?" + c.urlParams_.Encode()
  206. req, err := http.NewRequest("GET", urls, body)
  207. if err != nil {
  208. return nil, err
  209. }
  210. req.Header = reqHeaders
  211. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  212. }
  213. // Do executes the "mapofstrings.getMap" call.
  214. func (c *AtlasGetMapCall) Do(opts ...googleapi.CallOption) (map[string]string, error) {
  215. gensupport.SetOptions(c.urlParams_, opts...)
  216. res, err := c.doRequest("json")
  217. if err != nil {
  218. return nil, err
  219. }
  220. defer googleapi.CloseBody(res)
  221. if err := googleapi.CheckResponse(res); err != nil {
  222. return nil, err
  223. }
  224. var ret map[string]string
  225. target := &ret
  226. if err := gensupport.DecodeResponse(target, res); err != nil {
  227. return nil, err
  228. }
  229. return ret, nil
  230. // {
  231. // "description": "Get a map.",
  232. // "httpMethod": "GET",
  233. // "id": "mapofstrings.getMap",
  234. // "path": "map",
  235. // "response": {
  236. // "$ref": "GetMapResponse"
  237. // }
  238. // }
  239. }