...

Source file src/google.golang.org/api/corp_spatialanalytics/v1/corp_spatialanalytics-gen.go

Documentation: google.golang.org/api/corp_spatialanalytics/v1

     1  // Copyright 2021 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 corp_spatialanalytics provides access to the .
     8  //
     9  // # Creating a client
    10  //
    11  // Usage example:
    12  //
    13  //	import "google.golang.org/api/corp_spatialanalytics/v1"
    14  //	...
    15  //	ctx := context.Background()
    16  //	corp_spatialanalyticsService, err := corp_spatialanalytics.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  //	corp_spatialanalyticsService, err := corp_spatialanalytics.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  //	corp_spatialanalyticsService, err := corp_spatialanalytics.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 corp_spatialanalytics // import "google.golang.org/api/corp_spatialanalytics/v1"
    37  
    38  import (
    39  	"bytes"
    40  	"context"
    41  	"encoding/json"
    42  	"errors"
    43  	"fmt"
    44  	"io"
    45  	"net/http"
    46  	"net/url"
    47  	"strconv"
    48  	"strings"
    49  
    50  	googleapi "google.golang.org/api/googleapi"
    51  	gensupport "google.golang.org/api/internal/gensupport"
    52  	option "google.golang.org/api/option"
    53  	internaloption "google.golang.org/api/option/internaloption"
    54  	htransport "google.golang.org/api/transport/http"
    55  )
    56  
    57  // Always reference these packages, just in case the auto-generated code
    58  // below doesn't.
    59  var _ = bytes.NewBuffer
    60  var _ = strconv.Itoa
    61  var _ = fmt.Sprintf
    62  var _ = json.NewDecoder
    63  var _ = io.Copy
    64  var _ = url.Parse
    65  var _ = gensupport.MarshalJSON
    66  var _ = googleapi.Version
    67  var _ = errors.New
    68  var _ = strings.Replace
    69  var _ = context.Canceled
    70  var _ = internaloption.WithDefaultEndpoint
    71  
    72  const apiId = ""
    73  const apiName = ""
    74  const apiVersion = ""
    75  const basePath = "https://www.googleapis.com/discovery/v1/apis"
    76  
    77  // NewService creates a new Service.
    78  func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
    79  	opts = append(opts, internaloption.WithDefaultEndpoint(basePath))
    80  	client, endpoint, err := htransport.NewClient(ctx, opts...)
    81  	if err != nil {
    82  		return nil, err
    83  	}
    84  	s, err := New(client)
    85  	if err != nil {
    86  		return nil, err
    87  	}
    88  	if endpoint != "" {
    89  		s.BasePath = endpoint
    90  	}
    91  	return s, nil
    92  }
    93  
    94  // New creates a new Service. It uses the provided http.Client for requests.
    95  //
    96  // Deprecated: please use NewService instead.
    97  // To provide a custom HTTP client, use option.WithHTTPClient.
    98  // If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead.
    99  func New(client *http.Client) (*Service, error) {
   100  	if client == nil {
   101  		return nil, errors.New("client is nil")
   102  	}
   103  	s := &Service{client: client, BasePath: basePath}
   104  	return s, nil
   105  }
   106  
   107  type Service struct {
   108  	client    *http.Client
   109  	BasePath  string // API endpoint base URL
   110  	UserAgent string // optional additional User-Agent fragment
   111  }
   112  
   113  func (s *Service) userAgent() string {
   114  	if s.UserAgent == "" {
   115  		return googleapi.UserAgent
   116  	}
   117  	return googleapi.UserAgent + " " + s.UserAgent
   118  }
   119  

View as plain text