...

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

Documentation: google.golang.org/api/admin/datatransfer/v1

     1  // Copyright 2024 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 admin provides access to the Admin SDK API.
     8  //
     9  // For product documentation, see: https://developers.google.com/admin-sdk/
    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/admin/datatransfer/v1"
    27  //	...
    28  //	ctx := context.Background()
    29  //	adminService, err := admin.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  // By default, all available scopes (see "Constants") are used to authenticate.
    38  // To restrict scopes, use [google.golang.org/api/option.WithScopes]:
    39  //
    40  //	adminService, err := admin.NewService(ctx, option.WithScopes(admin.AdminDatatransferReadonlyScope))
    41  //
    42  // To use an API key for authentication (note: some APIs do not support API
    43  // keys), use [google.golang.org/api/option.WithAPIKey]:
    44  //
    45  //	adminService, err := admin.NewService(ctx, option.WithAPIKey("AIza..."))
    46  //
    47  // To use an OAuth token (e.g., a user token obtained via a three-legged OAuth
    48  // flow, use [google.golang.org/api/option.WithTokenSource]:
    49  //
    50  //	config := &oauth2.Config{...}
    51  //	// ...
    52  //	token, err := config.Exchange(ctx, ...)
    53  //	adminService, err := admin.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token)))
    54  //
    55  // See [google.golang.org/api/option.ClientOption] for details on options.
    56  package admin // import "google.golang.org/api/admin/datatransfer/v1"
    57  
    58  import (
    59  	"bytes"
    60  	"context"
    61  	"encoding/json"
    62  	"errors"
    63  	"fmt"
    64  	"io"
    65  	"net/http"
    66  	"net/url"
    67  	"strconv"
    68  	"strings"
    69  
    70  	googleapi "google.golang.org/api/googleapi"
    71  	internal "google.golang.org/api/internal"
    72  	gensupport "google.golang.org/api/internal/gensupport"
    73  	option "google.golang.org/api/option"
    74  	internaloption "google.golang.org/api/option/internaloption"
    75  	htransport "google.golang.org/api/transport/http"
    76  )
    77  
    78  // Always reference these packages, just in case the auto-generated code
    79  // below doesn't.
    80  var _ = bytes.NewBuffer
    81  var _ = strconv.Itoa
    82  var _ = fmt.Sprintf
    83  var _ = json.NewDecoder
    84  var _ = io.Copy
    85  var _ = url.Parse
    86  var _ = gensupport.MarshalJSON
    87  var _ = googleapi.Version
    88  var _ = errors.New
    89  var _ = strings.Replace
    90  var _ = context.Canceled
    91  var _ = internaloption.WithDefaultEndpoint
    92  var _ = internal.Version
    93  
    94  const apiId = "admin:datatransfer_v1"
    95  const apiName = "admin"
    96  const apiVersion = "datatransfer_v1"
    97  const basePath = "https://admin.googleapis.com/"
    98  const basePathTemplate = "https://admin.UNIVERSE_DOMAIN/"
    99  const mtlsBasePath = "https://admin.mtls.googleapis.com/"
   100  
   101  // OAuth2 scopes used by this API.
   102  const (
   103  	// View and manage data transfers between users in your organization
   104  	AdminDatatransferScope = "https://www.googleapis.com/auth/admin.datatransfer"
   105  
   106  	// View data transfers between users in your organization
   107  	AdminDatatransferReadonlyScope = "https://www.googleapis.com/auth/admin.datatransfer.readonly"
   108  )
   109  
   110  // NewService creates a new Service.
   111  func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
   112  	scopesOption := internaloption.WithDefaultScopes(
   113  		"https://www.googleapis.com/auth/admin.datatransfer",
   114  		"https://www.googleapis.com/auth/admin.datatransfer.readonly",
   115  	)
   116  	// NOTE: prepend, so we don't override user-specified scopes.
   117  	opts = append([]option.ClientOption{scopesOption}, opts...)
   118  	opts = append(opts, internaloption.WithDefaultEndpoint(basePath))
   119  	opts = append(opts, internaloption.WithDefaultEndpointTemplate(basePathTemplate))
   120  	opts = append(opts, internaloption.WithDefaultMTLSEndpoint(mtlsBasePath))
   121  	opts = append(opts, internaloption.EnableNewAuthLibrary())
   122  	client, endpoint, err := htransport.NewClient(ctx, opts...)
   123  	if err != nil {
   124  		return nil, err
   125  	}
   126  	s, err := New(client)
   127  	if err != nil {
   128  		return nil, err
   129  	}
   130  	if endpoint != "" {
   131  		s.BasePath = endpoint
   132  	}
   133  	return s, nil
   134  }
   135  
   136  // New creates a new Service. It uses the provided http.Client for requests.
   137  //
   138  // Deprecated: please use NewService instead.
   139  // To provide a custom HTTP client, use option.WithHTTPClient.
   140  // If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead.
   141  func New(client *http.Client) (*Service, error) {
   142  	if client == nil {
   143  		return nil, errors.New("client is nil")
   144  	}
   145  	s := &Service{client: client, BasePath: basePath}
   146  	s.Applications = NewApplicationsService(s)
   147  	s.Transfers = NewTransfersService(s)
   148  	return s, nil
   149  }
   150  
   151  type Service struct {
   152  	client    *http.Client
   153  	BasePath  string // API endpoint base URL
   154  	UserAgent string // optional additional User-Agent fragment
   155  
   156  	Applications *ApplicationsService
   157  
   158  	Transfers *TransfersService
   159  }
   160  
   161  func (s *Service) userAgent() string {
   162  	if s.UserAgent == "" {
   163  		return googleapi.UserAgent
   164  	}
   165  	return googleapi.UserAgent + " " + s.UserAgent
   166  }
   167  
   168  func NewApplicationsService(s *Service) *ApplicationsService {
   169  	rs := &ApplicationsService{s: s}
   170  	return rs
   171  }
   172  
   173  type ApplicationsService struct {
   174  	s *Service
   175  }
   176  
   177  func NewTransfersService(s *Service) *TransfersService {
   178  	rs := &TransfersService{s: s}
   179  	return rs
   180  }
   181  
   182  type TransfersService struct {
   183  	s *Service
   184  }
   185  
   186  // Application: Application resources represent applications installed on the
   187  // domain that support transferring ownership of user data.
   188  type Application struct {
   189  	// Etag: Etag of the resource.
   190  	Etag string `json:"etag,omitempty"`
   191  	// Id: The application's ID. Retrievable by using the `applications.list()`
   192  	// (/admin-sdk/data-transfer/reference/rest/v1/applications/list) method.
   193  	Id int64 `json:"id,omitempty,string"`
   194  	// Kind: Identifies the resource as a DataTransfer Application Resource.
   195  	Kind string `json:"kind,omitempty"`
   196  	// Name: The application's name.
   197  	Name string `json:"name,omitempty"`
   198  	// TransferParams: The list of all possible transfer parameters for this
   199  	// application. These parameters select which categories of the user's data to
   200  	// transfer.
   201  	TransferParams []*ApplicationTransferParam `json:"transferParams,omitempty"`
   202  
   203  	// ServerResponse contains the HTTP response code and headers from the server.
   204  	googleapi.ServerResponse `json:"-"`
   205  	// ForceSendFields is a list of field names (e.g. "Etag") to unconditionally
   206  	// include in API requests. By default, fields with empty or default values are
   207  	// omitted from API requests. See
   208  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   209  	// details.
   210  	ForceSendFields []string `json:"-"`
   211  	// NullFields is a list of field names (e.g. "Etag") to include in API requests
   212  	// with the JSON null value. By default, fields with empty values are omitted
   213  	// from API requests. See
   214  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   215  	NullFields []string `json:"-"`
   216  }
   217  
   218  func (s *Application) MarshalJSON() ([]byte, error) {
   219  	type NoMethod Application
   220  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   221  }
   222  
   223  // ApplicationDataTransfer: Template to map fields of ApplicationDataTransfer
   224  // resource.
   225  type ApplicationDataTransfer struct {
   226  	// ApplicationId: The application's ID.
   227  	ApplicationId int64 `json:"applicationId,omitempty,string"`
   228  	// ApplicationTransferParams: The transfer parameters for the application.
   229  	// These parameters are used to select the data which will get transferred in
   230  	// context of this application. For more information about the specific values
   231  	// available for each application, see the Transfer parameters
   232  	// (/admin-sdk/data-transfer/v1/parameters) reference.
   233  	ApplicationTransferParams []*ApplicationTransferParam `json:"applicationTransferParams,omitempty"`
   234  	// ApplicationTransferStatus: Read-only. Current status of transfer for this
   235  	// application.
   236  	ApplicationTransferStatus string `json:"applicationTransferStatus,omitempty"`
   237  	// ForceSendFields is a list of field names (e.g. "ApplicationId") to
   238  	// unconditionally include in API requests. By default, fields with empty or
   239  	// default values are omitted from API requests. See
   240  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   241  	// details.
   242  	ForceSendFields []string `json:"-"`
   243  	// NullFields is a list of field names (e.g. "ApplicationId") to include in API
   244  	// requests with the JSON null value. By default, fields with empty values are
   245  	// omitted from API requests. See
   246  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   247  	NullFields []string `json:"-"`
   248  }
   249  
   250  func (s *ApplicationDataTransfer) MarshalJSON() ([]byte, error) {
   251  	type NoMethod ApplicationDataTransfer
   252  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   253  }
   254  
   255  // ApplicationTransferParam: Template for application transfer parameters.
   256  type ApplicationTransferParam struct {
   257  	// Key: The type of the transfer parameter, such as `PRIVACY_LEVEL`.
   258  	Key string `json:"key,omitempty"`
   259  	// Value: The value of the transfer parameter, such as `PRIVATE` or `SHARED`.
   260  	Value []string `json:"value,omitempty"`
   261  	// ForceSendFields is a list of field names (e.g. "Key") to unconditionally
   262  	// include in API requests. By default, fields with empty or default values are
   263  	// omitted from API requests. See
   264  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   265  	// details.
   266  	ForceSendFields []string `json:"-"`
   267  	// NullFields is a list of field names (e.g. "Key") to include in API requests
   268  	// with the JSON null value. By default, fields with empty values are omitted
   269  	// from API requests. See
   270  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   271  	NullFields []string `json:"-"`
   272  }
   273  
   274  func (s *ApplicationTransferParam) MarshalJSON() ([]byte, error) {
   275  	type NoMethod ApplicationTransferParam
   276  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   277  }
   278  
   279  // ApplicationsListResponse: Template for a collection of Applications.
   280  type ApplicationsListResponse struct {
   281  	// Applications: The list of applications that support data transfer and are
   282  	// also installed for the customer.
   283  	Applications []*Application `json:"applications,omitempty"`
   284  	// Etag: ETag of the resource.
   285  	Etag string `json:"etag,omitempty"`
   286  	// Kind: Identifies the resource as a collection of Applications.
   287  	Kind string `json:"kind,omitempty"`
   288  	// NextPageToken: Token to specify the next page in the list.
   289  	NextPageToken string `json:"nextPageToken,omitempty"`
   290  
   291  	// ServerResponse contains the HTTP response code and headers from the server.
   292  	googleapi.ServerResponse `json:"-"`
   293  	// ForceSendFields is a list of field names (e.g. "Applications") to
   294  	// unconditionally include in API requests. By default, fields with empty or
   295  	// default values are omitted from API requests. See
   296  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   297  	// details.
   298  	ForceSendFields []string `json:"-"`
   299  	// NullFields is a list of field names (e.g. "Applications") to include in API
   300  	// requests with the JSON null value. By default, fields with empty values are
   301  	// omitted from API requests. See
   302  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   303  	NullFields []string `json:"-"`
   304  }
   305  
   306  func (s *ApplicationsListResponse) MarshalJSON() ([]byte, error) {
   307  	type NoMethod ApplicationsListResponse
   308  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   309  }
   310  
   311  // DataTransfer: A Transfer resource represents the transfer of the ownership
   312  // of user data between users.
   313  type DataTransfer struct {
   314  	// ApplicationDataTransfers: The list of per-application data transfer
   315  	// resources. It contains details of the applications associated with this
   316  	// transfer resource, and also specifies the applications for which data
   317  	// transfer has to be done at the time of the transfer resource creation.
   318  	ApplicationDataTransfers []*ApplicationDataTransfer `json:"applicationDataTransfers,omitempty"`
   319  	// Etag: ETag of the resource.
   320  	Etag string `json:"etag,omitempty"`
   321  	// Id: Read-only. The transfer's ID.
   322  	Id string `json:"id,omitempty"`
   323  	// Kind: Identifies the resource as a DataTransfer request.
   324  	Kind string `json:"kind,omitempty"`
   325  	// NewOwnerUserId: ID of the user to whom the data is being transferred.
   326  	NewOwnerUserId string `json:"newOwnerUserId,omitempty"`
   327  	// OldOwnerUserId: ID of the user whose data is being transferred.
   328  	OldOwnerUserId string `json:"oldOwnerUserId,omitempty"`
   329  	// OverallTransferStatusCode: Read-only. Overall transfer status.
   330  	OverallTransferStatusCode string `json:"overallTransferStatusCode,omitempty"`
   331  	// RequestTime: Read-only. The time at which the data transfer was requested.
   332  	RequestTime string `json:"requestTime,omitempty"`
   333  
   334  	// ServerResponse contains the HTTP response code and headers from the server.
   335  	googleapi.ServerResponse `json:"-"`
   336  	// ForceSendFields is a list of field names (e.g. "ApplicationDataTransfers")
   337  	// to unconditionally include in API requests. By default, fields with empty or
   338  	// default values are omitted from API requests. See
   339  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   340  	// details.
   341  	ForceSendFields []string `json:"-"`
   342  	// NullFields is a list of field names (e.g. "ApplicationDataTransfers") to
   343  	// include in API requests with the JSON null value. By default, fields with
   344  	// empty values are omitted from API requests. See
   345  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   346  	NullFields []string `json:"-"`
   347  }
   348  
   349  func (s *DataTransfer) MarshalJSON() ([]byte, error) {
   350  	type NoMethod DataTransfer
   351  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   352  }
   353  
   354  // DataTransfersListResponse: Template for a collection of DataTransfer
   355  // resources.
   356  type DataTransfersListResponse struct {
   357  	// DataTransfers: List of data transfer requests.
   358  	DataTransfers []*DataTransfer `json:"dataTransfers,omitempty"`
   359  	// Etag: ETag of the resource.
   360  	Etag string `json:"etag,omitempty"`
   361  	// Kind: Identifies the resource as a collection of data transfer requests.
   362  	Kind string `json:"kind,omitempty"`
   363  	// NextPageToken: Token to specify the next page in the list.
   364  	NextPageToken string `json:"nextPageToken,omitempty"`
   365  
   366  	// ServerResponse contains the HTTP response code and headers from the server.
   367  	googleapi.ServerResponse `json:"-"`
   368  	// ForceSendFields is a list of field names (e.g. "DataTransfers") to
   369  	// unconditionally include in API requests. By default, fields with empty or
   370  	// default values are omitted from API requests. See
   371  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   372  	// details.
   373  	ForceSendFields []string `json:"-"`
   374  	// NullFields is a list of field names (e.g. "DataTransfers") to include in API
   375  	// requests with the JSON null value. By default, fields with empty values are
   376  	// omitted from API requests. See
   377  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   378  	NullFields []string `json:"-"`
   379  }
   380  
   381  func (s *DataTransfersListResponse) MarshalJSON() ([]byte, error) {
   382  	type NoMethod DataTransfersListResponse
   383  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   384  }
   385  
   386  type ApplicationsGetCall struct {
   387  	s             *Service
   388  	applicationId int64
   389  	urlParams_    gensupport.URLParams
   390  	ifNoneMatch_  string
   391  	ctx_          context.Context
   392  	header_       http.Header
   393  }
   394  
   395  // Get: Retrieves information about an application for the given application
   396  // ID.
   397  //
   398  // - applicationId: ID of the application resource to be retrieved.
   399  func (r *ApplicationsService) Get(applicationId int64) *ApplicationsGetCall {
   400  	c := &ApplicationsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   401  	c.applicationId = applicationId
   402  	return c
   403  }
   404  
   405  // Fields allows partial responses to be retrieved. See
   406  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   407  // details.
   408  func (c *ApplicationsGetCall) Fields(s ...googleapi.Field) *ApplicationsGetCall {
   409  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   410  	return c
   411  }
   412  
   413  // IfNoneMatch sets an optional parameter which makes the operation fail if the
   414  // object's ETag matches the given value. This is useful for getting updates
   415  // only after the object has changed since the last request.
   416  func (c *ApplicationsGetCall) IfNoneMatch(entityTag string) *ApplicationsGetCall {
   417  	c.ifNoneMatch_ = entityTag
   418  	return c
   419  }
   420  
   421  // Context sets the context to be used in this call's Do method.
   422  func (c *ApplicationsGetCall) Context(ctx context.Context) *ApplicationsGetCall {
   423  	c.ctx_ = ctx
   424  	return c
   425  }
   426  
   427  // Header returns a http.Header that can be modified by the caller to add
   428  // headers to the request.
   429  func (c *ApplicationsGetCall) Header() http.Header {
   430  	if c.header_ == nil {
   431  		c.header_ = make(http.Header)
   432  	}
   433  	return c.header_
   434  }
   435  
   436  func (c *ApplicationsGetCall) doRequest(alt string) (*http.Response, error) {
   437  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
   438  	if c.ifNoneMatch_ != "" {
   439  		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
   440  	}
   441  	var body io.Reader = nil
   442  	c.urlParams_.Set("alt", alt)
   443  	c.urlParams_.Set("prettyPrint", "false")
   444  	urls := googleapi.ResolveRelative(c.s.BasePath, "admin/datatransfer/v1/applications/{applicationId}")
   445  	urls += "?" + c.urlParams_.Encode()
   446  	req, err := http.NewRequest("GET", urls, body)
   447  	if err != nil {
   448  		return nil, err
   449  	}
   450  	req.Header = reqHeaders
   451  	googleapi.Expand(req.URL, map[string]string{
   452  		"applicationId": strconv.FormatInt(c.applicationId, 10),
   453  	})
   454  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   455  }
   456  
   457  // Do executes the "datatransfer.applications.get" call.
   458  // Any non-2xx status code is an error. Response headers are in either
   459  // *Application.ServerResponse.Header or (if a response was returned at all) in
   460  // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
   461  // whether the returned error was because http.StatusNotModified was returned.
   462  func (c *ApplicationsGetCall) Do(opts ...googleapi.CallOption) (*Application, error) {
   463  	gensupport.SetOptions(c.urlParams_, opts...)
   464  	res, err := c.doRequest("json")
   465  	if res != nil && res.StatusCode == http.StatusNotModified {
   466  		if res.Body != nil {
   467  			res.Body.Close()
   468  		}
   469  		return nil, gensupport.WrapError(&googleapi.Error{
   470  			Code:   res.StatusCode,
   471  			Header: res.Header,
   472  		})
   473  	}
   474  	if err != nil {
   475  		return nil, err
   476  	}
   477  	defer googleapi.CloseBody(res)
   478  	if err := googleapi.CheckResponse(res); err != nil {
   479  		return nil, gensupport.WrapError(err)
   480  	}
   481  	ret := &Application{
   482  		ServerResponse: googleapi.ServerResponse{
   483  			Header:         res.Header,
   484  			HTTPStatusCode: res.StatusCode,
   485  		},
   486  	}
   487  	target := &ret
   488  	if err := gensupport.DecodeResponse(target, res); err != nil {
   489  		return nil, err
   490  	}
   491  	return ret, nil
   492  }
   493  
   494  type ApplicationsListCall struct {
   495  	s            *Service
   496  	urlParams_   gensupport.URLParams
   497  	ifNoneMatch_ string
   498  	ctx_         context.Context
   499  	header_      http.Header
   500  }
   501  
   502  // List: Lists the applications available for data transfer for a customer.
   503  func (r *ApplicationsService) List() *ApplicationsListCall {
   504  	c := &ApplicationsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   505  	return c
   506  }
   507  
   508  // CustomerId sets the optional parameter "customerId": Immutable ID of the
   509  // Google Workspace account.
   510  func (c *ApplicationsListCall) CustomerId(customerId string) *ApplicationsListCall {
   511  	c.urlParams_.Set("customerId", customerId)
   512  	return c
   513  }
   514  
   515  // MaxResults sets the optional parameter "maxResults": Maximum number of
   516  // results to return. Default is 100.
   517  func (c *ApplicationsListCall) MaxResults(maxResults int64) *ApplicationsListCall {
   518  	c.urlParams_.Set("maxResults", fmt.Sprint(maxResults))
   519  	return c
   520  }
   521  
   522  // PageToken sets the optional parameter "pageToken": Token to specify next
   523  // page in the list.
   524  func (c *ApplicationsListCall) PageToken(pageToken string) *ApplicationsListCall {
   525  	c.urlParams_.Set("pageToken", pageToken)
   526  	return c
   527  }
   528  
   529  // Fields allows partial responses to be retrieved. See
   530  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   531  // details.
   532  func (c *ApplicationsListCall) Fields(s ...googleapi.Field) *ApplicationsListCall {
   533  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   534  	return c
   535  }
   536  
   537  // IfNoneMatch sets an optional parameter which makes the operation fail if the
   538  // object's ETag matches the given value. This is useful for getting updates
   539  // only after the object has changed since the last request.
   540  func (c *ApplicationsListCall) IfNoneMatch(entityTag string) *ApplicationsListCall {
   541  	c.ifNoneMatch_ = entityTag
   542  	return c
   543  }
   544  
   545  // Context sets the context to be used in this call's Do method.
   546  func (c *ApplicationsListCall) Context(ctx context.Context) *ApplicationsListCall {
   547  	c.ctx_ = ctx
   548  	return c
   549  }
   550  
   551  // Header returns a http.Header that can be modified by the caller to add
   552  // headers to the request.
   553  func (c *ApplicationsListCall) Header() http.Header {
   554  	if c.header_ == nil {
   555  		c.header_ = make(http.Header)
   556  	}
   557  	return c.header_
   558  }
   559  
   560  func (c *ApplicationsListCall) doRequest(alt string) (*http.Response, error) {
   561  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
   562  	if c.ifNoneMatch_ != "" {
   563  		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
   564  	}
   565  	var body io.Reader = nil
   566  	c.urlParams_.Set("alt", alt)
   567  	c.urlParams_.Set("prettyPrint", "false")
   568  	urls := googleapi.ResolveRelative(c.s.BasePath, "admin/datatransfer/v1/applications")
   569  	urls += "?" + c.urlParams_.Encode()
   570  	req, err := http.NewRequest("GET", urls, body)
   571  	if err != nil {
   572  		return nil, err
   573  	}
   574  	req.Header = reqHeaders
   575  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   576  }
   577  
   578  // Do executes the "datatransfer.applications.list" call.
   579  // Any non-2xx status code is an error. Response headers are in either
   580  // *ApplicationsListResponse.ServerResponse.Header or (if a response was
   581  // returned at all) in error.(*googleapi.Error).Header. Use
   582  // googleapi.IsNotModified to check whether the returned error was because
   583  // http.StatusNotModified was returned.
   584  func (c *ApplicationsListCall) Do(opts ...googleapi.CallOption) (*ApplicationsListResponse, error) {
   585  	gensupport.SetOptions(c.urlParams_, opts...)
   586  	res, err := c.doRequest("json")
   587  	if res != nil && res.StatusCode == http.StatusNotModified {
   588  		if res.Body != nil {
   589  			res.Body.Close()
   590  		}
   591  		return nil, gensupport.WrapError(&googleapi.Error{
   592  			Code:   res.StatusCode,
   593  			Header: res.Header,
   594  		})
   595  	}
   596  	if err != nil {
   597  		return nil, err
   598  	}
   599  	defer googleapi.CloseBody(res)
   600  	if err := googleapi.CheckResponse(res); err != nil {
   601  		return nil, gensupport.WrapError(err)
   602  	}
   603  	ret := &ApplicationsListResponse{
   604  		ServerResponse: googleapi.ServerResponse{
   605  			Header:         res.Header,
   606  			HTTPStatusCode: res.StatusCode,
   607  		},
   608  	}
   609  	target := &ret
   610  	if err := gensupport.DecodeResponse(target, res); err != nil {
   611  		return nil, err
   612  	}
   613  	return ret, nil
   614  }
   615  
   616  // Pages invokes f for each page of results.
   617  // A non-nil error returned from f will halt the iteration.
   618  // The provided context supersedes any context provided to the Context method.
   619  func (c *ApplicationsListCall) Pages(ctx context.Context, f func(*ApplicationsListResponse) error) error {
   620  	c.ctx_ = ctx
   621  	defer c.PageToken(c.urlParams_.Get("pageToken"))
   622  	for {
   623  		x, err := c.Do()
   624  		if err != nil {
   625  			return err
   626  		}
   627  		if err := f(x); err != nil {
   628  			return err
   629  		}
   630  		if x.NextPageToken == "" {
   631  			return nil
   632  		}
   633  		c.PageToken(x.NextPageToken)
   634  	}
   635  }
   636  
   637  type TransfersGetCall struct {
   638  	s              *Service
   639  	dataTransferId string
   640  	urlParams_     gensupport.URLParams
   641  	ifNoneMatch_   string
   642  	ctx_           context.Context
   643  	header_        http.Header
   644  }
   645  
   646  // Get: Retrieves a data transfer request by its resource ID.
   647  //
   648  //   - dataTransferId: ID of the resource to be retrieved. This is returned in
   649  //     the response from the insert method.
   650  func (r *TransfersService) Get(dataTransferId string) *TransfersGetCall {
   651  	c := &TransfersGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   652  	c.dataTransferId = dataTransferId
   653  	return c
   654  }
   655  
   656  // Fields allows partial responses to be retrieved. See
   657  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   658  // details.
   659  func (c *TransfersGetCall) Fields(s ...googleapi.Field) *TransfersGetCall {
   660  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   661  	return c
   662  }
   663  
   664  // IfNoneMatch sets an optional parameter which makes the operation fail if the
   665  // object's ETag matches the given value. This is useful for getting updates
   666  // only after the object has changed since the last request.
   667  func (c *TransfersGetCall) IfNoneMatch(entityTag string) *TransfersGetCall {
   668  	c.ifNoneMatch_ = entityTag
   669  	return c
   670  }
   671  
   672  // Context sets the context to be used in this call's Do method.
   673  func (c *TransfersGetCall) Context(ctx context.Context) *TransfersGetCall {
   674  	c.ctx_ = ctx
   675  	return c
   676  }
   677  
   678  // Header returns a http.Header that can be modified by the caller to add
   679  // headers to the request.
   680  func (c *TransfersGetCall) Header() http.Header {
   681  	if c.header_ == nil {
   682  		c.header_ = make(http.Header)
   683  	}
   684  	return c.header_
   685  }
   686  
   687  func (c *TransfersGetCall) doRequest(alt string) (*http.Response, error) {
   688  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
   689  	if c.ifNoneMatch_ != "" {
   690  		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
   691  	}
   692  	var body io.Reader = nil
   693  	c.urlParams_.Set("alt", alt)
   694  	c.urlParams_.Set("prettyPrint", "false")
   695  	urls := googleapi.ResolveRelative(c.s.BasePath, "admin/datatransfer/v1/transfers/{dataTransferId}")
   696  	urls += "?" + c.urlParams_.Encode()
   697  	req, err := http.NewRequest("GET", urls, body)
   698  	if err != nil {
   699  		return nil, err
   700  	}
   701  	req.Header = reqHeaders
   702  	googleapi.Expand(req.URL, map[string]string{
   703  		"dataTransferId": c.dataTransferId,
   704  	})
   705  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   706  }
   707  
   708  // Do executes the "datatransfer.transfers.get" call.
   709  // Any non-2xx status code is an error. Response headers are in either
   710  // *DataTransfer.ServerResponse.Header or (if a response was returned at all)
   711  // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
   712  // whether the returned error was because http.StatusNotModified was returned.
   713  func (c *TransfersGetCall) Do(opts ...googleapi.CallOption) (*DataTransfer, error) {
   714  	gensupport.SetOptions(c.urlParams_, opts...)
   715  	res, err := c.doRequest("json")
   716  	if res != nil && res.StatusCode == http.StatusNotModified {
   717  		if res.Body != nil {
   718  			res.Body.Close()
   719  		}
   720  		return nil, gensupport.WrapError(&googleapi.Error{
   721  			Code:   res.StatusCode,
   722  			Header: res.Header,
   723  		})
   724  	}
   725  	if err != nil {
   726  		return nil, err
   727  	}
   728  	defer googleapi.CloseBody(res)
   729  	if err := googleapi.CheckResponse(res); err != nil {
   730  		return nil, gensupport.WrapError(err)
   731  	}
   732  	ret := &DataTransfer{
   733  		ServerResponse: googleapi.ServerResponse{
   734  			Header:         res.Header,
   735  			HTTPStatusCode: res.StatusCode,
   736  		},
   737  	}
   738  	target := &ret
   739  	if err := gensupport.DecodeResponse(target, res); err != nil {
   740  		return nil, err
   741  	}
   742  	return ret, nil
   743  }
   744  
   745  type TransfersInsertCall struct {
   746  	s            *Service
   747  	datatransfer *DataTransfer
   748  	urlParams_   gensupport.URLParams
   749  	ctx_         context.Context
   750  	header_      http.Header
   751  }
   752  
   753  // Insert: Inserts a data transfer request. See the Transfer parameters
   754  // (/admin-sdk/data-transfer/v1/parameters) reference for specific application
   755  // requirements.
   756  func (r *TransfersService) Insert(datatransfer *DataTransfer) *TransfersInsertCall {
   757  	c := &TransfersInsertCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   758  	c.datatransfer = datatransfer
   759  	return c
   760  }
   761  
   762  // Fields allows partial responses to be retrieved. See
   763  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   764  // details.
   765  func (c *TransfersInsertCall) Fields(s ...googleapi.Field) *TransfersInsertCall {
   766  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   767  	return c
   768  }
   769  
   770  // Context sets the context to be used in this call's Do method.
   771  func (c *TransfersInsertCall) Context(ctx context.Context) *TransfersInsertCall {
   772  	c.ctx_ = ctx
   773  	return c
   774  }
   775  
   776  // Header returns a http.Header that can be modified by the caller to add
   777  // headers to the request.
   778  func (c *TransfersInsertCall) Header() http.Header {
   779  	if c.header_ == nil {
   780  		c.header_ = make(http.Header)
   781  	}
   782  	return c.header_
   783  }
   784  
   785  func (c *TransfersInsertCall) doRequest(alt string) (*http.Response, error) {
   786  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
   787  	var body io.Reader = nil
   788  	body, err := googleapi.WithoutDataWrapper.JSONReader(c.datatransfer)
   789  	if err != nil {
   790  		return nil, err
   791  	}
   792  	c.urlParams_.Set("alt", alt)
   793  	c.urlParams_.Set("prettyPrint", "false")
   794  	urls := googleapi.ResolveRelative(c.s.BasePath, "admin/datatransfer/v1/transfers")
   795  	urls += "?" + c.urlParams_.Encode()
   796  	req, err := http.NewRequest("POST", urls, body)
   797  	if err != nil {
   798  		return nil, err
   799  	}
   800  	req.Header = reqHeaders
   801  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   802  }
   803  
   804  // Do executes the "datatransfer.transfers.insert" call.
   805  // Any non-2xx status code is an error. Response headers are in either
   806  // *DataTransfer.ServerResponse.Header or (if a response was returned at all)
   807  // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
   808  // whether the returned error was because http.StatusNotModified was returned.
   809  func (c *TransfersInsertCall) Do(opts ...googleapi.CallOption) (*DataTransfer, error) {
   810  	gensupport.SetOptions(c.urlParams_, opts...)
   811  	res, err := c.doRequest("json")
   812  	if res != nil && res.StatusCode == http.StatusNotModified {
   813  		if res.Body != nil {
   814  			res.Body.Close()
   815  		}
   816  		return nil, gensupport.WrapError(&googleapi.Error{
   817  			Code:   res.StatusCode,
   818  			Header: res.Header,
   819  		})
   820  	}
   821  	if err != nil {
   822  		return nil, err
   823  	}
   824  	defer googleapi.CloseBody(res)
   825  	if err := googleapi.CheckResponse(res); err != nil {
   826  		return nil, gensupport.WrapError(err)
   827  	}
   828  	ret := &DataTransfer{
   829  		ServerResponse: googleapi.ServerResponse{
   830  			Header:         res.Header,
   831  			HTTPStatusCode: res.StatusCode,
   832  		},
   833  	}
   834  	target := &ret
   835  	if err := gensupport.DecodeResponse(target, res); err != nil {
   836  		return nil, err
   837  	}
   838  	return ret, nil
   839  }
   840  
   841  type TransfersListCall struct {
   842  	s            *Service
   843  	urlParams_   gensupport.URLParams
   844  	ifNoneMatch_ string
   845  	ctx_         context.Context
   846  	header_      http.Header
   847  }
   848  
   849  // List: Lists the transfers for a customer by source user, destination user,
   850  // or status.
   851  func (r *TransfersService) List() *TransfersListCall {
   852  	c := &TransfersListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   853  	return c
   854  }
   855  
   856  // CustomerId sets the optional parameter "customerId": Immutable ID of the
   857  // Google Workspace account.
   858  func (c *TransfersListCall) CustomerId(customerId string) *TransfersListCall {
   859  	c.urlParams_.Set("customerId", customerId)
   860  	return c
   861  }
   862  
   863  // MaxResults sets the optional parameter "maxResults": Maximum number of
   864  // results to return. Default is 100.
   865  func (c *TransfersListCall) MaxResults(maxResults int64) *TransfersListCall {
   866  	c.urlParams_.Set("maxResults", fmt.Sprint(maxResults))
   867  	return c
   868  }
   869  
   870  // NewOwnerUserId sets the optional parameter "newOwnerUserId": Destination
   871  // user's profile ID.
   872  func (c *TransfersListCall) NewOwnerUserId(newOwnerUserId string) *TransfersListCall {
   873  	c.urlParams_.Set("newOwnerUserId", newOwnerUserId)
   874  	return c
   875  }
   876  
   877  // OldOwnerUserId sets the optional parameter "oldOwnerUserId": Source user's
   878  // profile ID.
   879  func (c *TransfersListCall) OldOwnerUserId(oldOwnerUserId string) *TransfersListCall {
   880  	c.urlParams_.Set("oldOwnerUserId", oldOwnerUserId)
   881  	return c
   882  }
   883  
   884  // PageToken sets the optional parameter "pageToken": Token to specify the next
   885  // page in the list.
   886  func (c *TransfersListCall) PageToken(pageToken string) *TransfersListCall {
   887  	c.urlParams_.Set("pageToken", pageToken)
   888  	return c
   889  }
   890  
   891  // Status sets the optional parameter "status": Status of the transfer.
   892  func (c *TransfersListCall) Status(status string) *TransfersListCall {
   893  	c.urlParams_.Set("status", status)
   894  	return c
   895  }
   896  
   897  // Fields allows partial responses to be retrieved. See
   898  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   899  // details.
   900  func (c *TransfersListCall) Fields(s ...googleapi.Field) *TransfersListCall {
   901  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   902  	return c
   903  }
   904  
   905  // IfNoneMatch sets an optional parameter which makes the operation fail if the
   906  // object's ETag matches the given value. This is useful for getting updates
   907  // only after the object has changed since the last request.
   908  func (c *TransfersListCall) IfNoneMatch(entityTag string) *TransfersListCall {
   909  	c.ifNoneMatch_ = entityTag
   910  	return c
   911  }
   912  
   913  // Context sets the context to be used in this call's Do method.
   914  func (c *TransfersListCall) Context(ctx context.Context) *TransfersListCall {
   915  	c.ctx_ = ctx
   916  	return c
   917  }
   918  
   919  // Header returns a http.Header that can be modified by the caller to add
   920  // headers to the request.
   921  func (c *TransfersListCall) Header() http.Header {
   922  	if c.header_ == nil {
   923  		c.header_ = make(http.Header)
   924  	}
   925  	return c.header_
   926  }
   927  
   928  func (c *TransfersListCall) doRequest(alt string) (*http.Response, error) {
   929  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
   930  	if c.ifNoneMatch_ != "" {
   931  		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
   932  	}
   933  	var body io.Reader = nil
   934  	c.urlParams_.Set("alt", alt)
   935  	c.urlParams_.Set("prettyPrint", "false")
   936  	urls := googleapi.ResolveRelative(c.s.BasePath, "admin/datatransfer/v1/transfers")
   937  	urls += "?" + c.urlParams_.Encode()
   938  	req, err := http.NewRequest("GET", urls, body)
   939  	if err != nil {
   940  		return nil, err
   941  	}
   942  	req.Header = reqHeaders
   943  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   944  }
   945  
   946  // Do executes the "datatransfer.transfers.list" call.
   947  // Any non-2xx status code is an error. Response headers are in either
   948  // *DataTransfersListResponse.ServerResponse.Header or (if a response was
   949  // returned at all) in error.(*googleapi.Error).Header. Use
   950  // googleapi.IsNotModified to check whether the returned error was because
   951  // http.StatusNotModified was returned.
   952  func (c *TransfersListCall) Do(opts ...googleapi.CallOption) (*DataTransfersListResponse, error) {
   953  	gensupport.SetOptions(c.urlParams_, opts...)
   954  	res, err := c.doRequest("json")
   955  	if res != nil && res.StatusCode == http.StatusNotModified {
   956  		if res.Body != nil {
   957  			res.Body.Close()
   958  		}
   959  		return nil, gensupport.WrapError(&googleapi.Error{
   960  			Code:   res.StatusCode,
   961  			Header: res.Header,
   962  		})
   963  	}
   964  	if err != nil {
   965  		return nil, err
   966  	}
   967  	defer googleapi.CloseBody(res)
   968  	if err := googleapi.CheckResponse(res); err != nil {
   969  		return nil, gensupport.WrapError(err)
   970  	}
   971  	ret := &DataTransfersListResponse{
   972  		ServerResponse: googleapi.ServerResponse{
   973  			Header:         res.Header,
   974  			HTTPStatusCode: res.StatusCode,
   975  		},
   976  	}
   977  	target := &ret
   978  	if err := gensupport.DecodeResponse(target, res); err != nil {
   979  		return nil, err
   980  	}
   981  	return ret, nil
   982  }
   983  
   984  // Pages invokes f for each page of results.
   985  // A non-nil error returned from f will halt the iteration.
   986  // The provided context supersedes any context provided to the Context method.
   987  func (c *TransfersListCall) Pages(ctx context.Context, f func(*DataTransfersListResponse) error) error {
   988  	c.ctx_ = ctx
   989  	defer c.PageToken(c.urlParams_.Get("pageToken"))
   990  	for {
   991  		x, err := c.Do()
   992  		if err != nil {
   993  			return err
   994  		}
   995  		if err := f(x); err != nil {
   996  			return err
   997  		}
   998  		if x.NextPageToken == "" {
   999  			return nil
  1000  		}
  1001  		c.PageToken(x.NextPageToken)
  1002  	}
  1003  }
  1004  

View as plain text