...

Text file src/google.golang.org/api/google-api-go-generator/testdata/http-body.want

Documentation: google.golang.org/api/google-api-go-generator/testdata

     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 healthcare provides access to the Cloud Healthcare API.
     8//
     9// For product documentation, see: https://cloud.google.com/healthcare
    10//
    11// # Library status
    12//
    13// These client libraries are officially supported by Google. However, this
    14// library is considered complete and is in maintenance mode. This means
    15// that we will address critical bugs and security issues but will not add
    16// any new features.
    17//
    18// When possible, we recommend using our newer
    19// [Cloud Client Libraries for Go](https://pkg.go.dev/cloud.google.com/go)
    20// that are still actively being worked and iterated on.
    21//
    22// # Creating a client
    23//
    24// Usage example:
    25//
    26//	import "google.golang.org/api/healthcare/v1beta1"
    27//	...
    28//	ctx := context.Background()
    29//	healthcareService, err := healthcare.NewService(ctx)
    30//
    31// In this example, Google Application Default Credentials are used for
    32// authentication. For information on how to create and obtain Application
    33// Default Credentials, see https://developers.google.com/identity/protocols/application-default-credentials.
    34//
    35// # Other authentication options
    36//
    37// To use an API key for authentication (note: some APIs do not support API
    38// keys), use [google.golang.org/api/option.WithAPIKey]:
    39//
    40//	healthcareService, err := healthcare.NewService(ctx, option.WithAPIKey("AIza..."))
    41//
    42// To use an OAuth token (e.g., a user token obtained via a three-legged OAuth
    43// flow, use [google.golang.org/api/option.WithTokenSource]:
    44//
    45//	config := &oauth2.Config{...}
    46//	// ...
    47//	token, err := config.Exchange(ctx, ...)
    48//	healthcareService, err := healthcare.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token)))
    49//
    50// See [google.golang.org/api/option.ClientOption] for details on options.
    51package healthcare // import "google.golang.org/api/healthcare/v1beta1"
    52
    53import (
    54	"bytes"
    55	"context"
    56	"encoding/json"
    57	"errors"
    58	"fmt"
    59	"io"
    60	"net/http"
    61	"net/url"
    62	"strconv"
    63	"strings"
    64
    65	googleapi "google.golang.org/api/googleapi"
    66	internal "google.golang.org/api/internal"
    67	gensupport "google.golang.org/api/internal/gensupport"
    68	option "google.golang.org/api/option"
    69	internaloption "google.golang.org/api/option/internaloption"
    70	htransport "google.golang.org/api/transport/http"
    71)
    72
    73// Always reference these packages, just in case the auto-generated code
    74// below doesn't.
    75var _ = bytes.NewBuffer
    76var _ = strconv.Itoa
    77var _ = fmt.Sprintf
    78var _ = json.NewDecoder
    79var _ = io.Copy
    80var _ = url.Parse
    81var _ = gensupport.MarshalJSON
    82var _ = googleapi.Version
    83var _ = errors.New
    84var _ = strings.Replace
    85var _ = context.Canceled
    86var _ = internaloption.WithDefaultEndpoint
    87var _ = internal.Version
    88
    89const apiId = "healthcare:v1beta1"
    90const apiName = "healthcare"
    91const apiVersion = "v1beta1"
    92const basePath = "https://healthcare.googleapis.com/"
    93const basePathTemplate = "https://healthcare.UNIVERSE_DOMAIN/"
    94const mtlsBasePath = "https://healthcare.mtls.googleapis.com/"
    95
    96// OAuth2 scopes used by this API.
    97const (
    98	// View and manage your data across Google Cloud Platform services
    99	CloudPlatformScope = "https://www.googleapis.com/auth/cloud-platform"
   100)
   101
   102// NewService creates a new Service.
   103func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
   104	scopesOption := internaloption.WithDefaultScopes(
   105		"https://www.googleapis.com/auth/cloud-platform",
   106	)
   107	// NOTE: prepend, so we don't override user-specified scopes.
   108	opts = append([]option.ClientOption{scopesOption}, opts...)
   109	opts = append(opts, internaloption.WithDefaultEndpoint(basePath))
   110	opts = append(opts, internaloption.WithDefaultEndpointTemplate(basePathTemplate))
   111	opts = append(opts, internaloption.WithDefaultMTLSEndpoint(mtlsBasePath))
   112	opts = append(opts, internaloption.EnableNewAuthLibrary())
   113	client, endpoint, err := htransport.NewClient(ctx, opts...)
   114	if err != nil {
   115		return nil, err
   116	}
   117	s, err := New(client)
   118	if err != nil {
   119		return nil, err
   120	}
   121	if endpoint != "" {
   122		s.BasePath = endpoint
   123	}
   124	return s, nil
   125}
   126
   127// New creates a new Service. It uses the provided http.Client for requests.
   128//
   129// Deprecated: please use NewService instead.
   130// To provide a custom HTTP client, use option.WithHTTPClient.
   131// If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead.
   132func New(client *http.Client) (*Service, error) {
   133	if client == nil {
   134		return nil, errors.New("client is nil")
   135	}
   136	s := &Service{client: client, BasePath: basePath}
   137	s.Projects = NewProjectsService(s)
   138	return s, nil
   139}
   140
   141type Service struct {
   142	client    *http.Client
   143	BasePath  string // API endpoint base URL
   144	UserAgent string // optional additional User-Agent fragment
   145
   146	Projects *ProjectsService
   147}
   148
   149func (s *Service) userAgent() string {
   150	if s.UserAgent == "" {
   151		return googleapi.UserAgent
   152	}
   153	return googleapi.UserAgent + " " + s.UserAgent
   154}
   155
   156func NewProjectsService(s *Service) *ProjectsService {
   157	rs := &ProjectsService{s: s}
   158	rs.Locations = NewProjectsLocationsService(s)
   159	return rs
   160}
   161
   162type ProjectsService struct {
   163	s *Service
   164
   165	Locations *ProjectsLocationsService
   166}
   167
   168func NewProjectsLocationsService(s *Service) *ProjectsLocationsService {
   169	rs := &ProjectsLocationsService{s: s}
   170	rs.Datasets = NewProjectsLocationsDatasetsService(s)
   171	return rs
   172}
   173
   174type ProjectsLocationsService struct {
   175	s *Service
   176
   177	Datasets *ProjectsLocationsDatasetsService
   178}
   179
   180func NewProjectsLocationsDatasetsService(s *Service) *ProjectsLocationsDatasetsService {
   181	rs := &ProjectsLocationsDatasetsService{s: s}
   182	rs.FhirStores = NewProjectsLocationsDatasetsFhirStoresService(s)
   183	return rs
   184}
   185
   186type ProjectsLocationsDatasetsService struct {
   187	s *Service
   188
   189	FhirStores *ProjectsLocationsDatasetsFhirStoresService
   190}
   191
   192func NewProjectsLocationsDatasetsFhirStoresService(s *Service) *ProjectsLocationsDatasetsFhirStoresService {
   193	rs := &ProjectsLocationsDatasetsFhirStoresService{s: s}
   194	rs.Fhir = NewProjectsLocationsDatasetsFhirStoresFhirService(s)
   195	return rs
   196}
   197
   198type ProjectsLocationsDatasetsFhirStoresService struct {
   199	s *Service
   200
   201	Fhir *ProjectsLocationsDatasetsFhirStoresFhirService
   202}
   203
   204func NewProjectsLocationsDatasetsFhirStoresFhirService(s *Service) *ProjectsLocationsDatasetsFhirStoresFhirService {
   205	rs := &ProjectsLocationsDatasetsFhirStoresFhirService{s: s}
   206	return rs
   207}
   208
   209type ProjectsLocationsDatasetsFhirStoresFhirService struct {
   210	s *Service
   211}
   212
   213// HttpBody: Message that represents an arbitrary HTTP body. It should only be
   214// used for
   215// payload formats that can't be represented as JSON, such as raw binary or
   216// an HTML page.
   217//
   218// This message can be used both in streaming and non-streaming API methods
   219// in
   220// the request as well as the response.
   221//
   222// It can be used as a top-level request field, which is convenient if
   223// one
   224// wants to extract parameters from either the URL or HTTP template into
   225// the
   226// request fields and also want access to the raw HTTP body.
   227//
   228// Example:
   229//
   230//	message GetResourceRequest {
   231//	  // A unique request id.
   232//	  string request_id = 1;
   233//
   234//	  // The raw HTTP body is bound to this field.
   235//	  google.api.HttpBody http_body = 2;
   236//	}
   237//
   238//	service ResourceService {
   239//	  rpc GetResource(GetResourceRequest) returns (google.api.HttpBody);
   240//	  rpc UpdateResource(google.api.HttpBody) returns
   241//
   242// (google.protobuf.Empty);
   243//
   244//	}
   245//
   246// Example with streaming methods:
   247//
   248//	service CaldavService {
   249//	  rpc GetCalendar(stream google.api.HttpBody)
   250//	    returns (stream google.api.HttpBody);
   251//	  rpc UpdateCalendar(stream google.api.HttpBody)
   252//	    returns (stream google.api.HttpBody);
   253//	}
   254//
   255// Use of this type only changes how the request and response bodies
   256// are
   257// handled, all other features will continue to work unchanged.
   258type HttpBody struct {
   259	// ContentType: The HTTP Content-Type header value specifying the content type
   260	// of the body.
   261	ContentType string `json:"contentType,omitempty"`
   262	// Data: The HTTP request/response body as raw binary.
   263	Data string `json:"data,omitempty"`
   264	// Extensions: Application specific response metadata. Must be set in the first
   265	// response
   266	// for streaming APIs.
   267	Extensions []googleapi.RawMessage `json:"extensions,omitempty"`
   268
   269	// ServerResponse contains the HTTP response code and headers from the server.
   270	googleapi.ServerResponse `json:"-"`
   271	// ForceSendFields is a list of field names (e.g. "ContentType") to
   272	// unconditionally include in API requests. By default, fields with empty or
   273	// default values are omitted from API requests. See
   274	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   275	// details.
   276	ForceSendFields []string `json:"-"`
   277	// NullFields is a list of field names (e.g. "ContentType") to include in API
   278	// requests with the JSON null value. By default, fields with empty values are
   279	// omitted from API requests. See
   280	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   281	NullFields []string `json:"-"`
   282}
   283
   284func (s *HttpBody) MarshalJSON() ([]byte, error) {
   285	type NoMethod HttpBody
   286	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   287}
   288
   289type ProjectsLocationsDatasetsFhirStoresFhirCreateResourceCall struct {
   290	s          *Service
   291	parent     string
   292	type_      string
   293	body_      io.Reader
   294	urlParams_ gensupport.URLParams
   295	ctx_       context.Context
   296	header_    http.Header
   297}
   298
   299// CreateResource: Creates a FHIR resource.
   300//
   301// - parent: The name of the FHIR store this resource belongs to.
   302// - type: The type of the resource to create.
   303func (r *ProjectsLocationsDatasetsFhirStoresFhirService) CreateResource(parent string, type_ string, body_ io.Reader) *ProjectsLocationsDatasetsFhirStoresFhirCreateResourceCall {
   304	c := &ProjectsLocationsDatasetsFhirStoresFhirCreateResourceCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   305	c.parent = parent
   306	c.type_ = type_
   307	c.body_ = body_
   308	return c
   309}
   310
   311// Fields allows partial responses to be retrieved. See
   312// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   313// details.
   314func (c *ProjectsLocationsDatasetsFhirStoresFhirCreateResourceCall) Fields(s ...googleapi.Field) *ProjectsLocationsDatasetsFhirStoresFhirCreateResourceCall {
   315	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   316	return c
   317}
   318
   319// Context sets the context to be used in this call's Do method.
   320func (c *ProjectsLocationsDatasetsFhirStoresFhirCreateResourceCall) Context(ctx context.Context) *ProjectsLocationsDatasetsFhirStoresFhirCreateResourceCall {
   321	c.ctx_ = ctx
   322	return c
   323}
   324
   325// Header returns a http.Header that can be modified by the caller to add
   326// headers to the request.
   327func (c *ProjectsLocationsDatasetsFhirStoresFhirCreateResourceCall) Header() http.Header {
   328	if c.header_ == nil {
   329		c.header_ = make(http.Header)
   330	}
   331	return c.header_
   332}
   333
   334func (c *ProjectsLocationsDatasetsFhirStoresFhirCreateResourceCall) doRequest(alt string) (*http.Response, error) {
   335	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
   336	var body io.Reader = nil
   337	body = c.body_
   338	urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta1/{+parent}/fhir/{+type}")
   339	urls += "?" + c.urlParams_.Encode()
   340	req, err := http.NewRequest("POST", urls, body)
   341	if err != nil {
   342		return nil, err
   343	}
   344	req.Header = reqHeaders
   345	googleapi.Expand(req.URL, map[string]string{
   346		"parent": c.parent,
   347		"type":   c.type_,
   348	})
   349	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   350}
   351
   352// Do executes the "healthcare.projects.locations.datasets.fhirStores.fhir.createResource" call.
   353func (c *ProjectsLocationsDatasetsFhirStoresFhirCreateResourceCall) Do(opts ...googleapi.CallOption) (*http.Response, error) {
   354	gensupport.SetOptions(c.urlParams_, opts...)
   355	return c.doRequest("")
   356}
   357
   358type ProjectsLocationsDatasetsFhirStoresFhirReadCall struct {
   359	s            *Service
   360	name         string
   361	urlParams_   gensupport.URLParams
   362	ifNoneMatch_ string
   363	ctx_         context.Context
   364	header_      http.Header
   365}
   366
   367// Read: Gets the contents of a FHIR resource.
   368//
   369// Implements the FHIR standard read
   370// interaction
   371// (http://hl7.org/implement/standards/fhir/STU3/http.html#read).
   372//
   373// Also supports the FHIR standard conditional read
   374// interaction
   375// (http://hl7.org/implement/standards/fhir/STU3/http.html#cread)
   376// specified by supplying an `If-Modified-Since` header with a date/time
   377// value
   378// or an `If-None-Match` header with an ETag value.
   379//
   380// On success, the response body will contain a JSON-encoded representation
   381// of the resource.
   382// Errors generated by the FHIR store will contain a
   383// JSON-encoded
   384// `OperationOutcome` resource describing the reason for the error. If
   385// the
   386// request cannot be mapped to a valid API method on a FHIR store, a
   387// generic
   388// GCP error might be returned instead.
   389//
   390// - name: The name of the resource to retrieve.
   391func (r *ProjectsLocationsDatasetsFhirStoresFhirService) Read(name string) *ProjectsLocationsDatasetsFhirStoresFhirReadCall {
   392	c := &ProjectsLocationsDatasetsFhirStoresFhirReadCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   393	c.name = name
   394	return c
   395}
   396
   397// Fields allows partial responses to be retrieved. See
   398// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   399// details.
   400func (c *ProjectsLocationsDatasetsFhirStoresFhirReadCall) Fields(s ...googleapi.Field) *ProjectsLocationsDatasetsFhirStoresFhirReadCall {
   401	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   402	return c
   403}
   404
   405// IfNoneMatch sets an optional parameter which makes the operation fail if the
   406// object's ETag matches the given value. This is useful for getting updates
   407// only after the object has changed since the last request.
   408func (c *ProjectsLocationsDatasetsFhirStoresFhirReadCall) IfNoneMatch(entityTag string) *ProjectsLocationsDatasetsFhirStoresFhirReadCall {
   409	c.ifNoneMatch_ = entityTag
   410	return c
   411}
   412
   413// Context sets the context to be used in this call's Do method.
   414func (c *ProjectsLocationsDatasetsFhirStoresFhirReadCall) Context(ctx context.Context) *ProjectsLocationsDatasetsFhirStoresFhirReadCall {
   415	c.ctx_ = ctx
   416	return c
   417}
   418
   419// Header returns a http.Header that can be modified by the caller to add
   420// headers to the request.
   421func (c *ProjectsLocationsDatasetsFhirStoresFhirReadCall) Header() http.Header {
   422	if c.header_ == nil {
   423		c.header_ = make(http.Header)
   424	}
   425	return c.header_
   426}
   427
   428func (c *ProjectsLocationsDatasetsFhirStoresFhirReadCall) doRequest(alt string) (*http.Response, error) {
   429	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
   430	if c.ifNoneMatch_ != "" {
   431		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
   432	}
   433	var body io.Reader = nil
   434	c.urlParams_.Set("alt", alt)
   435	c.urlParams_.Set("prettyPrint", "false")
   436	urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta1/{+name}")
   437	urls += "?" + c.urlParams_.Encode()
   438	req, err := http.NewRequest("GET", urls, body)
   439	if err != nil {
   440		return nil, err
   441	}
   442	req.Header = reqHeaders
   443	googleapi.Expand(req.URL, map[string]string{
   444		"name": c.name,
   445	})
   446	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   447}
   448
   449// Do executes the "healthcare.projects.locations.datasets.fhirStores.fhir.read" call.
   450func (c *ProjectsLocationsDatasetsFhirStoresFhirReadCall) Do(opts ...googleapi.CallOption) (*http.Response, error) {
   451	gensupport.SetOptions(c.urlParams_, opts...)
   452	return c.doRequest("")
   453}

View as plain text