# Resources - [API documentation](#api-documentation) - [Definitions](#definitions) - [Special quoting](#special-quoting) - [Manage buildings](#manage-buildings) - [Display buildings](#display-buildings) - [Manage features](#manage-features) - [Display features](#display-features) - [Manage resources](#manage-resources) - [Display resources](#display-resources) - [Display resource counts](#display-resource-counts) - [Manage resource calendar ACLs](#manage-resource-calendar-acls) - [Display resource calendar ACLs](#display-resource-calendar-acls) ## API documentation * https://support.google.com/a/answer/1033925 * https://support.google.com/a/answer/7540850 * https://developers.google.com/admin-sdk/directory/reference/rest/v1/resources.calendars * https://developers.google.com/admin-sdk/directory/reference/rest/v1/resources.buildings * https://developers.google.com/admin-sdk/directory/reference/rest/v1/resources.features * https://developers.google.com/my-business/reference/rest/v4/PostalAddress As resource calendar ids can contain spaces, some care must be used when entering `` and ``. Suppose you have an resource calendar `Foo Bar`. To get information about it you enter the command: `gam info resource "Foo Bar"` The shell strips the `"` leaving a single argument `Foo Bar`; gam correctly processes the argument. Suppose you enter the command: `gam info resources "Foo Bar"` The shell strips the `"` leaving a single argument `Foo Bar`; gam splits the argument on space leaving two items and then tries to process `Foo` and `Bar`, not what you want. You must enter: `gam info resources "'Foo Bar'"` The shell strips the `"` leaving a single argument `'Foo Bar'`; gam splits the argument on space while honoring the `'` leaving one item `Foo Bar` and correctly processes the item. In general, when you're accessing a single resource calendar, use the `resource` option to minimize quoting issues. ## Definitions See [Collections of Items](Collections-of-Items) ``` ::= (.)+ ::= @ ::= editor|freebusy|freebusyreader|owner|reader|writer ::= |user:|group:|domain:)|domain|default ::= "(,)*" ::= | | | ::= |id: ::= ::= "''(,'')*" ::= ::= "(,)*" ::= | | See: https://github.com/taers232c/GAMADV-XTD3/wiki/Collections-of-Items ::= address| buildingid| buildingname| coordinates| description| floors| floornames| id| name ::= "(,)*" ::= (address|addresslines )| (city|locality )| (country|regioncode )| (description )| (floors )| (id )| (language|languageCode )| (latitude )| (longitude )| (name ) (state|administrativearea )| (sublocality )| (zipcode|postalcode ) ::= (addfeatures )| (buildingid )| (capacity )| (category other|room|conference_room|category_unknown|unknown)| (description )| (features )| (floor )| (floorsection )| (name )| (removefeatures )| (type )| (uservisibledescription ) ::= acls| buildingid| calendar| capacity| category| description| email| featureinstances| features| floor| floorsection| generatedresourcename| id| name| resourcecategory| resourcedescription| resourceemail| resourceid| resourcename| resourcetype| type| uservisibledescription ::= "(,)*" ``` ## Special quoting When entering `` with `s`containing spaces, enclose the list in `"` and the names containing spaces in `'`. ``` features "CameraSet" features "'Laptop Cart'" features "CameraSet,'Laptop Cart'" ``` ## Manage buildings When creating a building, at a minimum you must enter `address|addresslines` and `country|regioncode`. * Enter a single-line address as `address "123 Main Street"` * Enter a multi-line address as `addresslines "123 Main Street\nAnytown, US"` For `country|regioncode` see: http://www.unicode.org/cldr/charts/30/supplemental/territory_information.html ``` gam create|add building * gam update building * gam delete building ``` ## Display buildings ``` gam info building [formatjson] gam show buildings [allfields|*|(fields )] [formatjson] ``` By default, Gam displays the information as an indented list of keys and values. * `formatjson` - Display the fields in JSON format. ``` gam print buildings [todrive *] [allfields|*|(fields )] [delimiter ] [formatjson [quotechar ]] ``` By default, Gam displays the information as columns of fields; the following option causes the output to be in JSON format, * `formatjson` - Display the fields in JSON format. 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. ## Manage features ``` gam create|add feature name gam update feature name gam delete feature ``` ## Display features ``` gam show features gam print features [todrive *] ``` ## Manage resources These commands operate on a single resource. ``` gam create|add resource * gam update resource * gam delete resource ``` These commands operate on multiple resources. ``` gam update resources * gam delete resources ``` When updating a resource, use the following options to manage the features. * `features ` - Replace the current set of features with a list of features * `addfeatures ` - Add a list of features to the current set of features * `removefeatures ` - Remove a list features from the current set of features ## Display resources ``` gam info resource [acls] [noselfowner] [calendar] [formatjson] gam info resources [acls] [noselfowner] [calendar] [formatjson] gam show resources [allfields|*|(fields )] [query ] [acls] [noselfowner] [calendar] [convertcrnl] [formatjson] ``` Optional data may be displayed for the resource: * `acls` - Display the resource calendar ACLs * `calendar` - Display the resource calendar settings Option `noselfowner` suppresses the display of ACLs that reference the calendar itself as its owner. By default, Gam displays the information as an indented list of keys and values. * `formatjson` - Display the fields in JSON format. ``` gam print resources [todrive *] [allfields|*|(fields )] [query ] [acls] [noselfowner] [calendar] [convertcrnl] [formatjson [quotechar ]] ``` Optional data may be displayed for the resource: * `acls` - Display the resource calendar ACLs * `calendar` - Display the resource calendar settings Option `noselfowner` suppresses the display of ACLs that reference the calendar itself as its owner. Some text fields may contain carriage returns or line feeds, displaying fields containing these characters will make processing the CSV file with a script hard; this option converts those characters to a text form. The default value is `csv_output_convert_cr_nl` from `gam.cfg` * `convertcrnl` - Convert carriage return to \r and line feed to \n By default, Gam displays the information as columns of fields; the following option causes the output to be in JSON format, * `formatjson` - Display the fields in JSON format. 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. ### Example Print all resources and their owners. ``` gam config csv_output_row_filter "role:regex:owner" redirect csv Resource.csv print resources acls ``` ## Display resource counts Display the number of mobile devices. ``` gam print resources [query ] showitemcountonly ``` Example ``` $ gam print resources showitemcountonly Getting all Resource Calendars, may take some time on a large Google Workspace Account... Got 32 Resource Calendars: Back 50 - Video Cameras Class Set 32 ``` The `Getting` and `Got` messages are written to stderr, the count is writtem to stdout. To retrieve the count with `showitemcountonly`: ``` Linux/MacOS count=$(gam print resources showitemcountonly) Windows PowerShell count = & gam print resources showitemcountonly ``` ## Manage resource calendar ACLs These commands operate on a single resource calendar. ``` gam resource add acls|calendaracls gam resource update acls|calendaracls gam resource delete acls|calendaracls [] ``` These commands operate on multiple resource calendars. ``` gam resources add acls|calendaracls gam resources update acls|calendaracls gam resources delete acls|calendaracls [] ``` ## Display resource calendar ACLs ``` gam resource info acls|calendaracls [formatjson] gam resources info acls|calendaracls [formatjson] gam resources show acls|calendaracls [noselfowner] [formatjson] ``` Option `noselfowner` suppresses the display of ACLs that reference the calendar itself as its owner. By default, Gam displays the information as an indented list of keys and values. * `formatjson` - Display the fields in JSON format. ``` gam resources print acls|calendaracls [todrive *] [noselfowner] (addcsvdata )* [formatjson [quotechar ]] ``` Option `noselfowner` suppresses the display of ACLs that reference the calendar itself as its owner. Add additional columns of data from the command line to the output * `addcsvdata ` By default, Gam displays the information as columns of fields; the following option causes the output to be in JSON format, * `formatjson` - Display the fields in JSON format. 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.