// Copyright 2024 Google LLC. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Code generated file. DO NOT EDIT. // Package keep provides access to the Google Keep API. // // For product documentation, see: https://developers.google.com/keep/api // // # Library status // // These client libraries are officially supported by Google. However, this // library is considered complete and is in maintenance mode. This means // that we will address critical bugs and security issues but will not add // any new features. // // When possible, we recommend using our newer // [Cloud Client Libraries for Go](https://pkg.go.dev/cloud.google.com/go) // that are still actively being worked and iterated on. // // # Creating a client // // Usage example: // // import "google.golang.org/api/keep/v1" // ... // ctx := context.Background() // keepService, err := keep.NewService(ctx) // // In this example, Google Application Default Credentials are used for // authentication. For information on how to create and obtain Application // Default Credentials, see https://developers.google.com/identity/protocols/application-default-credentials. // // # Other authentication options // // By default, all available scopes (see "Constants") are used to authenticate. // To restrict scopes, use [google.golang.org/api/option.WithScopes]: // // keepService, err := keep.NewService(ctx, option.WithScopes(keep.KeepReadonlyScope)) // // To use an API key for authentication (note: some APIs do not support API // keys), use [google.golang.org/api/option.WithAPIKey]: // // keepService, err := keep.NewService(ctx, option.WithAPIKey("AIza...")) // // To use an OAuth token (e.g., a user token obtained via a three-legged OAuth // flow, use [google.golang.org/api/option.WithTokenSource]: // // config := &oauth2.Config{...} // // ... // token, err := config.Exchange(ctx, ...) // keepService, err := keep.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token))) // // See [google.golang.org/api/option.ClientOption] for details on options. package keep // import "google.golang.org/api/keep/v1" import ( "bytes" "context" "encoding/json" "errors" "fmt" "io" "net/http" "net/url" "strconv" "strings" googleapi "google.golang.org/api/googleapi" internal "google.golang.org/api/internal" gensupport "google.golang.org/api/internal/gensupport" option "google.golang.org/api/option" internaloption "google.golang.org/api/option/internaloption" htransport "google.golang.org/api/transport/http" ) // Always reference these packages, just in case the auto-generated code // below doesn't. var _ = bytes.NewBuffer var _ = strconv.Itoa var _ = fmt.Sprintf var _ = json.NewDecoder var _ = io.Copy var _ = url.Parse var _ = gensupport.MarshalJSON var _ = googleapi.Version var _ = errors.New var _ = strings.Replace var _ = context.Canceled var _ = internaloption.WithDefaultEndpoint var _ = internal.Version const apiId = "keep:v1" const apiName = "keep" const apiVersion = "v1" const basePath = "https://keep.googleapis.com/" const basePathTemplate = "https://keep.UNIVERSE_DOMAIN/" const mtlsBasePath = "https://keep.mtls.googleapis.com/" // OAuth2 scopes used by this API. const ( // See, edit, create and permanently delete all your Google Keep data KeepScope = "https://www.googleapis.com/auth/keep" // View all your Google Keep data KeepReadonlyScope = "https://www.googleapis.com/auth/keep.readonly" ) // NewService creates a new Service. func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) { scopesOption := internaloption.WithDefaultScopes( "https://www.googleapis.com/auth/keep", "https://www.googleapis.com/auth/keep.readonly", ) // NOTE: prepend, so we don't override user-specified scopes. opts = append([]option.ClientOption{scopesOption}, opts...) opts = append(opts, internaloption.WithDefaultEndpoint(basePath)) opts = append(opts, internaloption.WithDefaultEndpointTemplate(basePathTemplate)) opts = append(opts, internaloption.WithDefaultMTLSEndpoint(mtlsBasePath)) opts = append(opts, internaloption.EnableNewAuthLibrary()) client, endpoint, err := htransport.NewClient(ctx, opts...) if err != nil { return nil, err } s, err := New(client) if err != nil { return nil, err } if endpoint != "" { s.BasePath = endpoint } return s, nil } // New creates a new Service. It uses the provided http.Client for requests. // // Deprecated: please use NewService instead. // To provide a custom HTTP client, use option.WithHTTPClient. // If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead. func New(client *http.Client) (*Service, error) { if client == nil { return nil, errors.New("client is nil") } s := &Service{client: client, BasePath: basePath} s.Media = NewMediaService(s) s.Notes = NewNotesService(s) return s, nil } type Service struct { client *http.Client BasePath string // API endpoint base URL UserAgent string // optional additional User-Agent fragment Media *MediaService Notes *NotesService } func (s *Service) userAgent() string { if s.UserAgent == "" { return googleapi.UserAgent } return googleapi.UserAgent + " " + s.UserAgent } func NewMediaService(s *Service) *MediaService { rs := &MediaService{s: s} return rs } type MediaService struct { s *Service } func NewNotesService(s *Service) *NotesService { rs := &NotesService{s: s} rs.Permissions = NewNotesPermissionsService(s) return rs } type NotesService struct { s *Service Permissions *NotesPermissionsService } func NewNotesPermissionsService(s *Service) *NotesPermissionsService { rs := &NotesPermissionsService{s: s} return rs } type NotesPermissionsService struct { s *Service } // Attachment: An attachment to a note. type Attachment struct { // MimeType: The MIME types (IANA media types) in which the attachment is // available. MimeType []string `json:"mimeType,omitempty"` // Name: The resource name; Name string `json:"name,omitempty"` // ServerResponse contains the HTTP response code and headers from the server. googleapi.ServerResponse `json:"-"` // ForceSendFields is a list of field names (e.g. "MimeType") to // unconditionally include in API requests. By default, fields with empty or // default values are omitted from API requests. See // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more // details. ForceSendFields []string `json:"-"` // NullFields is a list of field names (e.g. "MimeType") to include in API // requests with the JSON null value. By default, fields with empty values are // omitted from API requests. See // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. NullFields []string `json:"-"` } func (s *Attachment) MarshalJSON() ([]byte, error) { type NoMethod Attachment return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) } // BatchCreatePermissionsRequest: The request to add one or more permissions on // the note. Currently, only the `WRITER` role may be specified. If adding a // permission fails, then the entire request fails and no changes are made. type BatchCreatePermissionsRequest struct { // Requests: The request message specifying the resources to create. Requests []*CreatePermissionRequest `json:"requests,omitempty"` // ForceSendFields is a list of field names (e.g. "Requests") to // unconditionally include in API requests. By default, fields with empty or // default values are omitted from API requests. See // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more // details. ForceSendFields []string `json:"-"` // NullFields is a list of field names (e.g. "Requests") to include in API // requests with the JSON null value. By default, fields with empty values are // omitted from API requests. See // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. NullFields []string `json:"-"` } func (s *BatchCreatePermissionsRequest) MarshalJSON() ([]byte, error) { type NoMethod BatchCreatePermissionsRequest return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) } // BatchCreatePermissionsResponse: The response for creating permissions on a // note. type BatchCreatePermissionsResponse struct { // Permissions: Permissions created. Permissions []*Permission `json:"permissions,omitempty"` // ServerResponse contains the HTTP response code and headers from the server. googleapi.ServerResponse `json:"-"` // ForceSendFields is a list of field names (e.g. "Permissions") to // unconditionally include in API requests. By default, fields with empty or // default values are omitted from API requests. See // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more // details. ForceSendFields []string `json:"-"` // NullFields is a list of field names (e.g. "Permissions") to include in API // requests with the JSON null value. By default, fields with empty values are // omitted from API requests. See // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. NullFields []string `json:"-"` } func (s *BatchCreatePermissionsResponse) MarshalJSON() ([]byte, error) { type NoMethod BatchCreatePermissionsResponse return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) } // BatchDeletePermissionsRequest: The request to remove one or more permissions // from a note. A permission with the `OWNER` role can't be removed. If // removing a permission fails, then the entire request fails and no changes // are made. Returns a 400 bad request error if a specified permission does not // exist on the note. type BatchDeletePermissionsRequest struct { // Names: Required. The names of the permissions to delete. Format: // `notes/{note}/permissions/{permission}` Names []string `json:"names,omitempty"` // ForceSendFields is a list of field names (e.g. "Names") to unconditionally // include in API requests. By default, fields with empty or default values are // omitted from API requests. See // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more // details. ForceSendFields []string `json:"-"` // NullFields is a list of field names (e.g. "Names") to include in API // requests with the JSON null value. By default, fields with empty values are // omitted from API requests. See // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. NullFields []string `json:"-"` } func (s *BatchDeletePermissionsRequest) MarshalJSON() ([]byte, error) { type NoMethod BatchDeletePermissionsRequest return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) } // CreatePermissionRequest: The request to add a single permission on the note. type CreatePermissionRequest struct { // Parent: Required. The parent note where this permission will be created. // Format: `notes/{note}` Parent string `json:"parent,omitempty"` // Permission: Required. The permission to create. One of Permission.email, // User.email or Group.email must be supplied. Permission *Permission `json:"permission,omitempty"` // ForceSendFields is a list of field names (e.g. "Parent") to unconditionally // include in API requests. By default, fields with empty or default values are // omitted from API requests. See // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more // details. ForceSendFields []string `json:"-"` // NullFields is a list of field names (e.g. "Parent") to include in API // requests with the JSON null value. By default, fields with empty values are // omitted from API requests. See // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. NullFields []string `json:"-"` } func (s *CreatePermissionRequest) MarshalJSON() ([]byte, error) { type NoMethod CreatePermissionRequest return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) } // Empty: A generic empty message that you can re-use to avoid defining // duplicated empty messages in your APIs. A typical example is to use it as // the request or the response type of an API method. For instance: service Foo // { rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); } type Empty struct { // ServerResponse contains the HTTP response code and headers from the server. googleapi.ServerResponse `json:"-"` } // Family: Describes a single Google Family. type Family struct { } // Group: Describes a single Group. type Group struct { // Email: The group email. Email string `json:"email,omitempty"` // ForceSendFields is a list of field names (e.g. "Email") to unconditionally // include in API requests. By default, fields with empty or default values are // omitted from API requests. See // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more // details. ForceSendFields []string `json:"-"` // NullFields is a list of field names (e.g. "Email") to include in API // requests with the JSON null value. By default, fields with empty values are // omitted from API requests. See // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. NullFields []string `json:"-"` } func (s *Group) MarshalJSON() ([]byte, error) { type NoMethod Group return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) } // ListContent: The list of items for a single list note. type ListContent struct { // ListItems: The items in the list. The number of items must be less than // 1,000. ListItems []*ListItem `json:"listItems,omitempty"` // ForceSendFields is a list of field names (e.g. "ListItems") to // unconditionally include in API requests. By default, fields with empty or // default values are omitted from API requests. See // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more // details. ForceSendFields []string `json:"-"` // NullFields is a list of field names (e.g. "ListItems") to include in API // requests with the JSON null value. By default, fields with empty values are // omitted from API requests. See // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. NullFields []string `json:"-"` } func (s *ListContent) MarshalJSON() ([]byte, error) { type NoMethod ListContent return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) } // ListItem: A single list item in a note's list. type ListItem struct { // Checked: Whether this item has been checked off or not. Checked bool `json:"checked,omitempty"` // ChildListItems: If set, list of list items nested under this list item. Only // one level of nesting is allowed. ChildListItems []*ListItem `json:"childListItems,omitempty"` // Text: The text of this item. Length must be less than 1,000 characters. Text *TextContent `json:"text,omitempty"` // ForceSendFields is a list of field names (e.g. "Checked") to unconditionally // include in API requests. By default, fields with empty or default values are // omitted from API requests. See // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more // details. ForceSendFields []string `json:"-"` // NullFields is a list of field names (e.g. "Checked") to include in API // requests with the JSON null value. By default, fields with empty values are // omitted from API requests. See // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. NullFields []string `json:"-"` } func (s *ListItem) MarshalJSON() ([]byte, error) { type NoMethod ListItem return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) } // ListNotesResponse: The response when listing a page of notes. type ListNotesResponse struct { // NextPageToken: Next page's `page_token` field. NextPageToken string `json:"nextPageToken,omitempty"` // Notes: A page of notes. Notes []*Note `json:"notes,omitempty"` // ServerResponse contains the HTTP response code and headers from the server. googleapi.ServerResponse `json:"-"` // ForceSendFields is a list of field names (e.g. "NextPageToken") to // unconditionally include in API requests. By default, fields with empty or // default values are omitted from API requests. See // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more // details. ForceSendFields []string `json:"-"` // NullFields is a list of field names (e.g. "NextPageToken") to include in API // requests with the JSON null value. By default, fields with empty values are // omitted from API requests. See // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. NullFields []string `json:"-"` } func (s *ListNotesResponse) MarshalJSON() ([]byte, error) { type NoMethod ListNotesResponse return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) } // Note: A single note. type Note struct { // Attachments: Output only. The attachments attached to this note. Attachments []*Attachment `json:"attachments,omitempty"` // Body: The body of the note. Body *Section `json:"body,omitempty"` // CreateTime: Output only. When this note was created. CreateTime string `json:"createTime,omitempty"` // Name: Output only. The resource name of this note. See general note on // identifiers in KeepService. Name string `json:"name,omitempty"` // Permissions: Output only. The list of permissions set on the note. Contains // at least one entry for the note owner. Permissions []*Permission `json:"permissions,omitempty"` // Title: The title of the note. Length must be less than 1,000 characters. Title string `json:"title,omitempty"` // TrashTime: Output only. When this note was trashed. If `trashed`, the note // is eventually deleted. If the note is not trashed, this field is not set // (and the trashed field is `false`). TrashTime string `json:"trashTime,omitempty"` // Trashed: Output only. `true` if this note has been trashed. If trashed, the // note is eventually deleted. Trashed bool `json:"trashed,omitempty"` // UpdateTime: Output only. When this note was last modified. UpdateTime string `json:"updateTime,omitempty"` // ServerResponse contains the HTTP response code and headers from the server. googleapi.ServerResponse `json:"-"` // ForceSendFields is a list of field names (e.g. "Attachments") to // unconditionally include in API requests. By default, fields with empty or // default values are omitted from API requests. See // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more // details. ForceSendFields []string `json:"-"` // NullFields is a list of field names (e.g. "Attachments") to include in API // requests with the JSON null value. By default, fields with empty values are // omitted from API requests. See // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. NullFields []string `json:"-"` } func (s *Note) MarshalJSON() ([]byte, error) { type NoMethod Note return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) } // Permission: A single permission on the note. Associates a `member` with a // `role`. type Permission struct { // Deleted: Output only. Whether this member has been deleted. If the member is // recovered, this value is set to false and the recovered member retains the // role on the note. Deleted bool `json:"deleted,omitempty"` // Email: The email associated with the member. If set on create, the `email` // field in the `User` or `Group` message must either be empty or match this // field. On read, may be unset if the member does not have an associated // email. Email string `json:"email,omitempty"` // Family: Output only. The Google Family to which this role applies. Family *Family `json:"family,omitempty"` // Group: Output only. The group to which this role applies. Group *Group `json:"group,omitempty"` // Name: Output only. The resource name. Name string `json:"name,omitempty"` // Role: The role granted by this permission. The role determines the // entity’s ability to read, write, and share notes. // // Possible values: // "ROLE_UNSPECIFIED" - An undefined role. // "OWNER" - A role granting full access. This role cannot be added or // removed. Defined by the creator of the note. // "WRITER" - A role granting the ability to contribute content and modify // note permissions. Role string `json:"role,omitempty"` // User: Output only. The user to whom this role applies. User *User `json:"user,omitempty"` // ForceSendFields is a list of field names (e.g. "Deleted") to unconditionally // include in API requests. By default, fields with empty or default values are // omitted from API requests. See // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more // details. ForceSendFields []string `json:"-"` // NullFields is a list of field names (e.g. "Deleted") to include in API // requests with the JSON null value. By default, fields with empty values are // omitted from API requests. See // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. NullFields []string `json:"-"` } func (s *Permission) MarshalJSON() ([]byte, error) { type NoMethod Permission return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) } // Section: The content of the note. type Section struct { // List: Used if this section's content is a list. List *ListContent `json:"list,omitempty"` // Text: Used if this section's content is a block of text. The length of the // text content must be less than 20,000 characters. Text *TextContent `json:"text,omitempty"` // ForceSendFields is a list of field names (e.g. "List") to unconditionally // include in API requests. By default, fields with empty or default values are // omitted from API requests. See // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more // details. ForceSendFields []string `json:"-"` // NullFields is a list of field names (e.g. "List") to include in API requests // with the JSON null value. By default, fields with empty values are omitted // from API requests. See // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. NullFields []string `json:"-"` } func (s *Section) MarshalJSON() ([]byte, error) { type NoMethod Section return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) } // TextContent: The block of text for a single text section or list item. type TextContent struct { // Text: The text of the note. The limits on this vary with the specific field // using this type. Text string `json:"text,omitempty"` // ForceSendFields is a list of field names (e.g. "Text") to unconditionally // include in API requests. By default, fields with empty or default values are // omitted from API requests. See // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more // details. ForceSendFields []string `json:"-"` // NullFields is a list of field names (e.g. "Text") to include in API requests // with the JSON null value. By default, fields with empty values are omitted // from API requests. See // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. NullFields []string `json:"-"` } func (s *TextContent) MarshalJSON() ([]byte, error) { type NoMethod TextContent return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) } // User: Describes a single user. type User struct { // Email: The user's email. Email string `json:"email,omitempty"` // ForceSendFields is a list of field names (e.g. "Email") to unconditionally // include in API requests. By default, fields with empty or default values are // omitted from API requests. See // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more // details. ForceSendFields []string `json:"-"` // NullFields is a list of field names (e.g. "Email") to include in API // requests with the JSON null value. By default, fields with empty values are // omitted from API requests. See // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. NullFields []string `json:"-"` } func (s *User) MarshalJSON() ([]byte, error) { type NoMethod User return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) } type MediaDownloadCall struct { s *Service name string urlParams_ gensupport.URLParams ifNoneMatch_ string ctx_ context.Context header_ http.Header } // Download: Gets an attachment. To download attachment media via REST requires // the alt=media query parameter. Returns a 400 bad request error if attachment // media is not available in the requested MIME type. // // - name: The name of the attachment. func (r *MediaService) Download(name string) *MediaDownloadCall { c := &MediaDownloadCall{s: r.s, urlParams_: make(gensupport.URLParams)} c.name = name return c } // MimeType sets the optional parameter "mimeType": The IANA MIME type format // requested. The requested MIME type must be one specified in the // attachment.mime_type. Required when downloading attachment media and ignored // otherwise. func (c *MediaDownloadCall) MimeType(mimeType string) *MediaDownloadCall { c.urlParams_.Set("mimeType", mimeType) return c } // Fields allows partial responses to be retrieved. See // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more // details. func (c *MediaDownloadCall) Fields(s ...googleapi.Field) *MediaDownloadCall { c.urlParams_.Set("fields", googleapi.CombineFields(s)) return c } // IfNoneMatch sets an optional parameter which makes the operation fail if the // object's ETag matches the given value. This is useful for getting updates // only after the object has changed since the last request. func (c *MediaDownloadCall) IfNoneMatch(entityTag string) *MediaDownloadCall { c.ifNoneMatch_ = entityTag return c } // Context sets the context to be used in this call's Do and Download methods. func (c *MediaDownloadCall) Context(ctx context.Context) *MediaDownloadCall { c.ctx_ = ctx return c } // Header returns a http.Header that can be modified by the caller to add // headers to the request. func (c *MediaDownloadCall) Header() http.Header { if c.header_ == nil { c.header_ = make(http.Header) } return c.header_ } func (c *MediaDownloadCall) doRequest(alt string) (*http.Response, error) { reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_) if c.ifNoneMatch_ != "" { reqHeaders.Set("If-None-Match", c.ifNoneMatch_) } var body io.Reader = nil c.urlParams_.Set("alt", alt) c.urlParams_.Set("prettyPrint", "false") urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}") urls += "?" + c.urlParams_.Encode() req, err := http.NewRequest("GET", urls, body) if err != nil { return nil, err } req.Header = reqHeaders googleapi.Expand(req.URL, map[string]string{ "name": c.name, }) return gensupport.SendRequest(c.ctx_, c.s.client, req) } // Download fetches the API endpoint's "media" value, instead of the normal // API response value. If the returned error is nil, the Response is guaranteed to // have a 2xx status code. Callers must close the Response.Body as usual. func (c *MediaDownloadCall) Download(opts ...googleapi.CallOption) (*http.Response, error) { gensupport.SetOptions(c.urlParams_, opts...) res, err := c.doRequest("media") if err != nil { return nil, err } if err := googleapi.CheckResponse(res); err != nil { res.Body.Close() return nil, gensupport.WrapError(err) } return res, nil } // Do executes the "keep.media.download" call. // Any non-2xx status code is an error. Response headers are in either // *Attachment.ServerResponse.Header or (if a response was returned at all) in // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check // whether the returned error was because http.StatusNotModified was returned. func (c *MediaDownloadCall) Do(opts ...googleapi.CallOption) (*Attachment, error) { gensupport.SetOptions(c.urlParams_, opts...) res, err := c.doRequest("json") if res != nil && res.StatusCode == http.StatusNotModified { if res.Body != nil { res.Body.Close() } return nil, gensupport.WrapError(&googleapi.Error{ Code: res.StatusCode, Header: res.Header, }) } if err != nil { return nil, err } defer googleapi.CloseBody(res) if err := googleapi.CheckResponse(res); err != nil { return nil, gensupport.WrapError(err) } ret := &Attachment{ ServerResponse: googleapi.ServerResponse{ Header: res.Header, HTTPStatusCode: res.StatusCode, }, } target := &ret if err := gensupport.DecodeResponse(target, res); err != nil { return nil, err } return ret, nil } type NotesCreateCall struct { s *Service note *Note urlParams_ gensupport.URLParams ctx_ context.Context header_ http.Header } // Create: Creates a new note. func (r *NotesService) Create(note *Note) *NotesCreateCall { c := &NotesCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)} c.note = note return c } // Fields allows partial responses to be retrieved. See // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more // details. func (c *NotesCreateCall) Fields(s ...googleapi.Field) *NotesCreateCall { c.urlParams_.Set("fields", googleapi.CombineFields(s)) return c } // Context sets the context to be used in this call's Do method. func (c *NotesCreateCall) Context(ctx context.Context) *NotesCreateCall { c.ctx_ = ctx return c } // Header returns a http.Header that can be modified by the caller to add // headers to the request. func (c *NotesCreateCall) Header() http.Header { if c.header_ == nil { c.header_ = make(http.Header) } return c.header_ } func (c *NotesCreateCall) doRequest(alt string) (*http.Response, error) { reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_) var body io.Reader = nil body, err := googleapi.WithoutDataWrapper.JSONReader(c.note) if err != nil { return nil, err } c.urlParams_.Set("alt", alt) c.urlParams_.Set("prettyPrint", "false") urls := googleapi.ResolveRelative(c.s.BasePath, "v1/notes") urls += "?" + c.urlParams_.Encode() req, err := http.NewRequest("POST", urls, body) if err != nil { return nil, err } req.Header = reqHeaders return gensupport.SendRequest(c.ctx_, c.s.client, req) } // Do executes the "keep.notes.create" call. // Any non-2xx status code is an error. Response headers are in either // *Note.ServerResponse.Header or (if a response was returned at all) in // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check // whether the returned error was because http.StatusNotModified was returned. func (c *NotesCreateCall) Do(opts ...googleapi.CallOption) (*Note, error) { gensupport.SetOptions(c.urlParams_, opts...) res, err := c.doRequest("json") if res != nil && res.StatusCode == http.StatusNotModified { if res.Body != nil { res.Body.Close() } return nil, gensupport.WrapError(&googleapi.Error{ Code: res.StatusCode, Header: res.Header, }) } if err != nil { return nil, err } defer googleapi.CloseBody(res) if err := googleapi.CheckResponse(res); err != nil { return nil, gensupport.WrapError(err) } ret := &Note{ ServerResponse: googleapi.ServerResponse{ Header: res.Header, HTTPStatusCode: res.StatusCode, }, } target := &ret if err := gensupport.DecodeResponse(target, res); err != nil { return nil, err } return ret, nil } type NotesDeleteCall struct { s *Service name string urlParams_ gensupport.URLParams ctx_ context.Context header_ http.Header } // Delete: Deletes a note. Caller must have the `OWNER` role on the note to // delete. Deleting a note removes the resource immediately and cannot be // undone. Any collaborators will lose access to the note. // // - name: Name of the note to delete. func (r *NotesService) Delete(name string) *NotesDeleteCall { c := &NotesDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)} c.name = name return c } // Fields allows partial responses to be retrieved. See // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more // details. func (c *NotesDeleteCall) Fields(s ...googleapi.Field) *NotesDeleteCall { c.urlParams_.Set("fields", googleapi.CombineFields(s)) return c } // Context sets the context to be used in this call's Do method. func (c *NotesDeleteCall) Context(ctx context.Context) *NotesDeleteCall { c.ctx_ = ctx return c } // Header returns a http.Header that can be modified by the caller to add // headers to the request. func (c *NotesDeleteCall) Header() http.Header { if c.header_ == nil { c.header_ = make(http.Header) } return c.header_ } func (c *NotesDeleteCall) doRequest(alt string) (*http.Response, error) { reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_) var body io.Reader = nil c.urlParams_.Set("alt", alt) c.urlParams_.Set("prettyPrint", "false") urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}") urls += "?" + c.urlParams_.Encode() req, err := http.NewRequest("DELETE", urls, body) if err != nil { return nil, err } req.Header = reqHeaders googleapi.Expand(req.URL, map[string]string{ "name": c.name, }) return gensupport.SendRequest(c.ctx_, c.s.client, req) } // Do executes the "keep.notes.delete" call. // Any non-2xx status code is an error. Response headers are in either // *Empty.ServerResponse.Header or (if a response was returned at all) in // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check // whether the returned error was because http.StatusNotModified was returned. func (c *NotesDeleteCall) Do(opts ...googleapi.CallOption) (*Empty, error) { gensupport.SetOptions(c.urlParams_, opts...) res, err := c.doRequest("json") if res != nil && res.StatusCode == http.StatusNotModified { if res.Body != nil { res.Body.Close() } return nil, gensupport.WrapError(&googleapi.Error{ Code: res.StatusCode, Header: res.Header, }) } if err != nil { return nil, err } defer googleapi.CloseBody(res) if err := googleapi.CheckResponse(res); err != nil { return nil, gensupport.WrapError(err) } ret := &Empty{ ServerResponse: googleapi.ServerResponse{ Header: res.Header, HTTPStatusCode: res.StatusCode, }, } target := &ret if err := gensupport.DecodeResponse(target, res); err != nil { return nil, err } return ret, nil } type NotesGetCall struct { s *Service name string urlParams_ gensupport.URLParams ifNoneMatch_ string ctx_ context.Context header_ http.Header } // Get: Gets a note. // // - name: Name of the resource. func (r *NotesService) Get(name string) *NotesGetCall { c := &NotesGetCall{s: r.s, urlParams_: make(gensupport.URLParams)} c.name = name return c } // Fields allows partial responses to be retrieved. See // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more // details. func (c *NotesGetCall) Fields(s ...googleapi.Field) *NotesGetCall { c.urlParams_.Set("fields", googleapi.CombineFields(s)) return c } // IfNoneMatch sets an optional parameter which makes the operation fail if the // object's ETag matches the given value. This is useful for getting updates // only after the object has changed since the last request. func (c *NotesGetCall) IfNoneMatch(entityTag string) *NotesGetCall { c.ifNoneMatch_ = entityTag return c } // Context sets the context to be used in this call's Do method. func (c *NotesGetCall) Context(ctx context.Context) *NotesGetCall { c.ctx_ = ctx return c } // Header returns a http.Header that can be modified by the caller to add // headers to the request. func (c *NotesGetCall) Header() http.Header { if c.header_ == nil { c.header_ = make(http.Header) } return c.header_ } func (c *NotesGetCall) doRequest(alt string) (*http.Response, error) { reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_) if c.ifNoneMatch_ != "" { reqHeaders.Set("If-None-Match", c.ifNoneMatch_) } var body io.Reader = nil c.urlParams_.Set("alt", alt) c.urlParams_.Set("prettyPrint", "false") urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}") urls += "?" + c.urlParams_.Encode() req, err := http.NewRequest("GET", urls, body) if err != nil { return nil, err } req.Header = reqHeaders googleapi.Expand(req.URL, map[string]string{ "name": c.name, }) return gensupport.SendRequest(c.ctx_, c.s.client, req) } // Do executes the "keep.notes.get" call. // Any non-2xx status code is an error. Response headers are in either // *Note.ServerResponse.Header or (if a response was returned at all) in // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check // whether the returned error was because http.StatusNotModified was returned. func (c *NotesGetCall) Do(opts ...googleapi.CallOption) (*Note, error) { gensupport.SetOptions(c.urlParams_, opts...) res, err := c.doRequest("json") if res != nil && res.StatusCode == http.StatusNotModified { if res.Body != nil { res.Body.Close() } return nil, gensupport.WrapError(&googleapi.Error{ Code: res.StatusCode, Header: res.Header, }) } if err != nil { return nil, err } defer googleapi.CloseBody(res) if err := googleapi.CheckResponse(res); err != nil { return nil, gensupport.WrapError(err) } ret := &Note{ ServerResponse: googleapi.ServerResponse{ Header: res.Header, HTTPStatusCode: res.StatusCode, }, } target := &ret if err := gensupport.DecodeResponse(target, res); err != nil { return nil, err } return ret, nil } type NotesListCall struct { s *Service urlParams_ gensupport.URLParams ifNoneMatch_ string ctx_ context.Context header_ http.Header } // List: Lists notes. Every list call returns a page of results with // `page_size` as the upper bound of returned items. A `page_size` of zero // allows the server to choose the upper bound. The ListNotesResponse contains // at most `page_size` entries. If there are more things left to list, it // provides a `next_page_token` value. (Page tokens are opaque values.) To get // the next page of results, copy the result's `next_page_token` into the next // request's `page_token`. Repeat until the `next_page_token` returned with a // page of results is empty. ListNotes return consistent results in the face of // concurrent changes, or signals that it cannot with an ABORTED error. func (r *NotesService) List() *NotesListCall { c := &NotesListCall{s: r.s, urlParams_: make(gensupport.URLParams)} return c } // Filter sets the optional parameter "filter": Filter for list results. If no // filter is supplied, the `trashed` filter is applied by default. Valid fields // to filter by are: `create_time`, `update_time`, `trash_time`, and `trashed`. // Filter syntax follows the Google AIP filtering spec (https://aip.dev/160). func (c *NotesListCall) Filter(filter string) *NotesListCall { c.urlParams_.Set("filter", filter) return c } // PageSize sets the optional parameter "pageSize": The maximum number of // results to return. func (c *NotesListCall) PageSize(pageSize int64) *NotesListCall { c.urlParams_.Set("pageSize", fmt.Sprint(pageSize)) return c } // PageToken sets the optional parameter "pageToken": The previous page's // `next_page_token` field. func (c *NotesListCall) PageToken(pageToken string) *NotesListCall { c.urlParams_.Set("pageToken", pageToken) return c } // Fields allows partial responses to be retrieved. See // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more // details. func (c *NotesListCall) Fields(s ...googleapi.Field) *NotesListCall { c.urlParams_.Set("fields", googleapi.CombineFields(s)) return c } // IfNoneMatch sets an optional parameter which makes the operation fail if the // object's ETag matches the given value. This is useful for getting updates // only after the object has changed since the last request. func (c *NotesListCall) IfNoneMatch(entityTag string) *NotesListCall { c.ifNoneMatch_ = entityTag return c } // Context sets the context to be used in this call's Do method. func (c *NotesListCall) Context(ctx context.Context) *NotesListCall { c.ctx_ = ctx return c } // Header returns a http.Header that can be modified by the caller to add // headers to the request. func (c *NotesListCall) Header() http.Header { if c.header_ == nil { c.header_ = make(http.Header) } return c.header_ } func (c *NotesListCall) doRequest(alt string) (*http.Response, error) { reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_) if c.ifNoneMatch_ != "" { reqHeaders.Set("If-None-Match", c.ifNoneMatch_) } var body io.Reader = nil c.urlParams_.Set("alt", alt) c.urlParams_.Set("prettyPrint", "false") urls := googleapi.ResolveRelative(c.s.BasePath, "v1/notes") urls += "?" + c.urlParams_.Encode() req, err := http.NewRequest("GET", urls, body) if err != nil { return nil, err } req.Header = reqHeaders return gensupport.SendRequest(c.ctx_, c.s.client, req) } // Do executes the "keep.notes.list" call. // Any non-2xx status code is an error. Response headers are in either // *ListNotesResponse.ServerResponse.Header or (if a response was returned at // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to // check whether the returned error was because http.StatusNotModified was // returned. func (c *NotesListCall) Do(opts ...googleapi.CallOption) (*ListNotesResponse, error) { gensupport.SetOptions(c.urlParams_, opts...) res, err := c.doRequest("json") if res != nil && res.StatusCode == http.StatusNotModified { if res.Body != nil { res.Body.Close() } return nil, gensupport.WrapError(&googleapi.Error{ Code: res.StatusCode, Header: res.Header, }) } if err != nil { return nil, err } defer googleapi.CloseBody(res) if err := googleapi.CheckResponse(res); err != nil { return nil, gensupport.WrapError(err) } ret := &ListNotesResponse{ ServerResponse: googleapi.ServerResponse{ Header: res.Header, HTTPStatusCode: res.StatusCode, }, } target := &ret if err := gensupport.DecodeResponse(target, res); err != nil { return nil, err } return ret, nil } // Pages invokes f for each page of results. // A non-nil error returned from f will halt the iteration. // The provided context supersedes any context provided to the Context method. func (c *NotesListCall) Pages(ctx context.Context, f func(*ListNotesResponse) error) error { c.ctx_ = ctx defer c.PageToken(c.urlParams_.Get("pageToken")) for { x, err := c.Do() if err != nil { return err } if err := f(x); err != nil { return err } if x.NextPageToken == "" { return nil } c.PageToken(x.NextPageToken) } } type NotesPermissionsBatchCreateCall struct { s *Service parent string batchcreatepermissionsrequest *BatchCreatePermissionsRequest urlParams_ gensupport.URLParams ctx_ context.Context header_ http.Header } // BatchCreate: Creates one or more permissions on the note. Only permissions // with the `WRITER` role may be created. If adding any permission fails, then // the entire request fails and no changes are made. // // - parent: The parent resource shared by all Permissions being created. // Format: `notes/{note}` If this is set, the parent field in the // CreatePermission messages must either be empty or match this field. func (r *NotesPermissionsService) BatchCreate(parent string, batchcreatepermissionsrequest *BatchCreatePermissionsRequest) *NotesPermissionsBatchCreateCall { c := &NotesPermissionsBatchCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)} c.parent = parent c.batchcreatepermissionsrequest = batchcreatepermissionsrequest return c } // Fields allows partial responses to be retrieved. See // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more // details. func (c *NotesPermissionsBatchCreateCall) Fields(s ...googleapi.Field) *NotesPermissionsBatchCreateCall { c.urlParams_.Set("fields", googleapi.CombineFields(s)) return c } // Context sets the context to be used in this call's Do method. func (c *NotesPermissionsBatchCreateCall) Context(ctx context.Context) *NotesPermissionsBatchCreateCall { c.ctx_ = ctx return c } // Header returns a http.Header that can be modified by the caller to add // headers to the request. func (c *NotesPermissionsBatchCreateCall) Header() http.Header { if c.header_ == nil { c.header_ = make(http.Header) } return c.header_ } func (c *NotesPermissionsBatchCreateCall) doRequest(alt string) (*http.Response, error) { reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_) var body io.Reader = nil body, err := googleapi.WithoutDataWrapper.JSONReader(c.batchcreatepermissionsrequest) if err != nil { return nil, err } c.urlParams_.Set("alt", alt) c.urlParams_.Set("prettyPrint", "false") urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+parent}/permissions:batchCreate") urls += "?" + c.urlParams_.Encode() req, err := http.NewRequest("POST", urls, body) if err != nil { return nil, err } req.Header = reqHeaders googleapi.Expand(req.URL, map[string]string{ "parent": c.parent, }) return gensupport.SendRequest(c.ctx_, c.s.client, req) } // Do executes the "keep.notes.permissions.batchCreate" call. // Any non-2xx status code is an error. Response headers are in either // *BatchCreatePermissionsResponse.ServerResponse.Header or (if a response was // returned at all) in error.(*googleapi.Error).Header. Use // googleapi.IsNotModified to check whether the returned error was because // http.StatusNotModified was returned. func (c *NotesPermissionsBatchCreateCall) Do(opts ...googleapi.CallOption) (*BatchCreatePermissionsResponse, error) { gensupport.SetOptions(c.urlParams_, opts...) res, err := c.doRequest("json") if res != nil && res.StatusCode == http.StatusNotModified { if res.Body != nil { res.Body.Close() } return nil, gensupport.WrapError(&googleapi.Error{ Code: res.StatusCode, Header: res.Header, }) } if err != nil { return nil, err } defer googleapi.CloseBody(res) if err := googleapi.CheckResponse(res); err != nil { return nil, gensupport.WrapError(err) } ret := &BatchCreatePermissionsResponse{ ServerResponse: googleapi.ServerResponse{ Header: res.Header, HTTPStatusCode: res.StatusCode, }, } target := &ret if err := gensupport.DecodeResponse(target, res); err != nil { return nil, err } return ret, nil } type NotesPermissionsBatchDeleteCall struct { s *Service parent string batchdeletepermissionsrequest *BatchDeletePermissionsRequest urlParams_ gensupport.URLParams ctx_ context.Context header_ http.Header } // BatchDelete: Deletes one or more permissions on the note. The specified // entities will immediately lose access. A permission with the `OWNER` role // can't be removed. If removing a permission fails, then the entire request // fails and no changes are made. Returns a 400 bad request error if a // specified permission does not exist on the note. // // - parent: The parent resource shared by all permissions being deleted. // Format: `notes/{note}` If this is set, the parent of all of the // permissions specified in the DeletePermissionRequest messages must match // this field. func (r *NotesPermissionsService) BatchDelete(parent string, batchdeletepermissionsrequest *BatchDeletePermissionsRequest) *NotesPermissionsBatchDeleteCall { c := &NotesPermissionsBatchDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)} c.parent = parent c.batchdeletepermissionsrequest = batchdeletepermissionsrequest return c } // Fields allows partial responses to be retrieved. See // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more // details. func (c *NotesPermissionsBatchDeleteCall) Fields(s ...googleapi.Field) *NotesPermissionsBatchDeleteCall { c.urlParams_.Set("fields", googleapi.CombineFields(s)) return c } // Context sets the context to be used in this call's Do method. func (c *NotesPermissionsBatchDeleteCall) Context(ctx context.Context) *NotesPermissionsBatchDeleteCall { c.ctx_ = ctx return c } // Header returns a http.Header that can be modified by the caller to add // headers to the request. func (c *NotesPermissionsBatchDeleteCall) Header() http.Header { if c.header_ == nil { c.header_ = make(http.Header) } return c.header_ } func (c *NotesPermissionsBatchDeleteCall) doRequest(alt string) (*http.Response, error) { reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_) var body io.Reader = nil body, err := googleapi.WithoutDataWrapper.JSONReader(c.batchdeletepermissionsrequest) if err != nil { return nil, err } c.urlParams_.Set("alt", alt) c.urlParams_.Set("prettyPrint", "false") urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+parent}/permissions:batchDelete") urls += "?" + c.urlParams_.Encode() req, err := http.NewRequest("POST", urls, body) if err != nil { return nil, err } req.Header = reqHeaders googleapi.Expand(req.URL, map[string]string{ "parent": c.parent, }) return gensupport.SendRequest(c.ctx_, c.s.client, req) } // Do executes the "keep.notes.permissions.batchDelete" call. // Any non-2xx status code is an error. Response headers are in either // *Empty.ServerResponse.Header or (if a response was returned at all) in // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check // whether the returned error was because http.StatusNotModified was returned. func (c *NotesPermissionsBatchDeleteCall) Do(opts ...googleapi.CallOption) (*Empty, error) { gensupport.SetOptions(c.urlParams_, opts...) res, err := c.doRequest("json") if res != nil && res.StatusCode == http.StatusNotModified { if res.Body != nil { res.Body.Close() } return nil, gensupport.WrapError(&googleapi.Error{ Code: res.StatusCode, Header: res.Header, }) } if err != nil { return nil, err } defer googleapi.CloseBody(res) if err := googleapi.CheckResponse(res); err != nil { return nil, gensupport.WrapError(err) } ret := &Empty{ ServerResponse: googleapi.ServerResponse{ Header: res.Header, HTTPStatusCode: res.StatusCode, }, } target := &ret if err := gensupport.DecodeResponse(target, res); err != nil { return nil, err } return ret, nil }