# Users - Keep - [API documentation](#api-documentation) - [Notes](#notes) - [Definitions](#definitions) - [Add Note](#add-note) - [Delete Note](#delete-note) - [Display Notes](#display-notes) - [Download Note Attachments](#download-note-attachments) - [Manage Notes permissions](#manage-notes-permissions) - [Add Permissions](#add-permissions) - [Delete Permissions](#delete-permissions) - [Examples](#examples) ## API documentation * https://developers.google.com/keep/api/reference/rest ## Notes To use these commands you must add the 'Keep API' to your project and update your service account authorization. ``` gam update project gam user user@domain.com check serviceaccount ``` ## Definitions * [``](Collections-of-Users) * [Command data from Google Docs/Sheets/Storage](Command-Data-From-Google-Docs-Sheets-Storage) ``` ::= ::= ::= https://storage.cloud.google.com//| https://storage.googleapis.com//| gs:///| / ::= ||( ) ::= (json [charset ] ) | (json file [charset ]) | ::= ((text )| (textfile [charset ])| (gdoc )| (gcsdoc )| ) ::= notes/ ::= "(, ::= | | | | See: https://github.com/taers232c/GAMADV-XTD3/wiki/Collections-of-Items ::= attachments| body| createtime| name| permissions| title| trashed| trashtime| updatetime ::= "(,)*" ::= ::= ::= (parentid )| (parentname )| (anyownerparentname )| (teamdriveparentid )| (teamdriveparent )| (teamdriveparentid teamdriveparentname )| (teamdriveparent teamdriveparentname ) ``` Keep notes have an ID that is referred to by Google as its `name`; this is the value you will use wherever `` is required. ## Add Note ``` gam create note [title ] [missingtextvalue ] [copyacls [copyowneraswriter]] [compact|formatjson|nodetails] ``` `` is the note text, there are four ways to specify it: * `message|textmessage|htmlmessage ` - Use `` as the note text * `file|htmlfile [charset ]` - Read the note text from `` * `gdoc|ghtml ` - Read the note text from `` * `gcsdoc|gcshtml ` - Read the note text from the Google Cloud Storage file `` Use the `` option to specify the title, text and list options. Use the `missingtextvalue ` option to have GAM supply a value for JSON `list` and `text` items that are missing text fields. This option must appear before the `` option. If not specified and a text field is missing, you'll get the following error: `Request contains an invalid argument.` The `title ` option takes precedence over the JSON title. If you specify options `json` and `copyacls`, the note is created and any ACLs from the json data are added to the note. If you also specify `copyowneraswriter`, the original note owner is added as a writer to the created note. By default, Gam displays the created note as an indented list of keys and values; the note text is displayed as individual lines. * `compact` - Display the note text with escaped carriage returns as \r and newlines as \n * `formatjson` - Display the note in JSON format * `nodetails` - Display the note name only ## Delete Note ``` gam delete note ``` ## Display Notes Display selected notes ``` gam info note [fields ] [compact|formatjson] ``` By default, Gam displays the information as an indented list of keys and values; the note text is displayed as individual lines. * `compact` - Display the note text with escaped carriage returns as \r and newlines as \n * `formatjson` - Display the note in JSON format Display all notes ``` gam show notes [fields ] [filter ] [role owner|writwer] [compact|formatjson] ``` By default, GAM displays all non-trashed notes: * `filter trashed` - Display notes in the trash * `role owner|writer` - Display notes where the user has the specified role By default, Gam displays the information as an indented list of keys and values; the note text is displayed as individual lines. * `compact` - Display the note text with escaped carriage returns as \r and newlines as \n * `formatjson` - Display the note in JSON format ``` gam print notes [todrive *] [fields ] [filter ] [role owner|writwer] [formatjson [quotechar ]] ``` By default, GAM displays all non-trashed notes: * `filter trashed` - Display notes in the trash * `role owner|writer` - Display notes where the user has the specified role By default, when writing CSV files, Gam uses a quote character of double quote `"`. The quote character is used to enclose columns that contain the quote character itself, the column delimiter (comma by default) and new-line characters. Any quote characters within the column are doubled. When using the `formatjson` option, double quotes are used extensively in the data resulting in hard to read/process output. The `quotechar ` option allows you to choose an alternate quote character, single quote for instance, that makes for readable/processable output. `quotechar` defaults to `gam.cfg/csv_output_quote_char`. When uploading CSV files to Google, double quote `"` should be used. ## Download Note Attachments ``` gam get noteattachments [targetfolder ] [targetname ] [overwrite []] [] ``` By default, when getting an attachment, it is downloaded to the directory specified in `gam.cfg/drive_dir`. * `targetfolder ` - Specify an alternate location for the downloaded file. By default, when getting an attachment, the local name is the same as the Note title or `attachment` if the Note doesn't have a title.. * `targetname ` - Specify an alternate name for the downloaded file. The strings `#email#`, `#user#` and `#username#` will be replaced by the the user's full emailaddress or just the name portion in `targetfolder ` and `targetname `. The final attachment local file name will have `-.` appended to the base name: * `` - The index of the attachment * `` - An extension based on the MIME type; `gif, jpg, png, webp` By default, when getting an attachment, an existing local file will not be overwritten; a numeric prefix is added to the filename. * `overwrite` - Overwite an existing file * `overwrite true` - Overwite an existing file * `overwrite false` - Do not overwite an existing file; add a numeric prefix and create a new file If `` is specified, the dowloaded attachments will be uploaded to Google Drive. ## Manage Notes permissions * The owner of a note can not have it's role changed. * The owner of a note can not be deleted. * A new owner can not be added to a note. ### Add permissions ``` gam create noteacl (user|group )+ [nodetails] ``` By default, Gam displays the user, note name, number of created permissions and the permission details * `nodetails` - Do not display the permission details ### Delete permissions ``` gam delete noteacl (user|group )+ ``` Use the `user and `group`` options to specify email addresses. Use the `json` option to specify permissions. ``` {"permissions": [{"email": "user@domain.com", "name": "notes/abc123xyz/permissions/def456uvw", "role": "WRITER", "user": {"email": "user@domain.com"}}]} ``` ## Examples ### Copy notes and permissions from one user to another. ``` gam redirect csv ./notes.csv user user1@domain.com print notes formatjson quotechar "'" gam csv ./notes.csv quotechar "'" gam user user2@domain.com create note json "~JSON" copyacls ``` ### Delete all permissions for a note ``` gam redirect stdout ./notes.json user user@domain.com info note notes/abc123xyz permissions formatjson gam user user@domain.com delete notesacl notes/abc123xyz json file notes.json ``` ### Delete all of a user's trashed notes. ``` gam redirect csv ./notes.csv user user@domain.com print notes fields name filter trashed gam user user@domain.com delete notes csvfile notes.csv:name ```