Updated gam <UserTypeEntity> create|update chatspace to support the new permissions settings

This commit is contained in:
Ross Scroggs
2024-09-23 17:11:48 -07:00
parent a6016825ff
commit 8ecbe67054
13 changed files with 136 additions and 9794 deletions

View File

@@ -10,6 +10,13 @@ Add the `-s` option to the end of the above commands to suppress creating the `g
See [Downloads-Installs](https://github.com/taers232c/GAMADV-XTD3/wiki/Downloads-Installs) for Windows or other options, including manual installation See [Downloads-Installs](https://github.com/taers232c/GAMADV-XTD3/wiki/Downloads-Installs) for Windows or other options, including manual installation
### 7.00.06
Updated `gam <UserTypeEntity> create|update chatspace` to support the new permissions settings
for Chat spaces that are in Developer Preview.
* See: https://developers.google.com/workspace/chat/api/reference/rest/v1/spaces#Space.FIELDS.predefined_permission_settings
### 7.00.05 ### 7.00.05
Fixed bug that caused an error when creating a calendar birthday event. Fixed bug that caused an error when creating a calendar birthday event.

View File

@@ -251,7 +251,7 @@ writes the credentials into the file oauth2.txt.
admin@server:/Users/admin$ rm -f /Users/admin/GAMConfig/oauth2.txt admin@server:/Users/admin$ rm -f /Users/admin/GAMConfig/oauth2.txt
admin@server:/Users/admin$ gam version admin@server:/Users/admin$ gam version
WARNING: Config File: /Users/admin/GAMConfig/gam.cfg, Section: DEFAULT, Item: oauth2_txt, Value: /Users/admin/GAMConfig/oauth2.txt, Not Found WARNING: Config File: /Users/admin/GAMConfig/gam.cfg, Section: DEFAULT, Item: oauth2_txt, Value: /Users/admin/GAMConfig/oauth2.txt, Not Found
GAMADV-XTD3 7.00.05 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource GAMADV-XTD3 7.00.06 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
Ross Scroggs <ross.scroggs@gmail.com> Ross Scroggs <ross.scroggs@gmail.com>
Python 3.12.6 64-bit final Python 3.12.6 64-bit final
MacOS Sonoma 14.5 x86_64 MacOS Sonoma 14.5 x86_64
@@ -923,7 +923,7 @@ writes the credentials into the file oauth2.txt.
C:\>del C:\GAMConfig\oauth2.txt C:\>del C:\GAMConfig\oauth2.txt
C:\>gam version C:\>gam version
WARNING: Config File: C:\GAMConfig\gam.cfg, Section: DEFAULT, Item: oauth2_txt, Value: C:\GAMConfig\oauth2.txt, Not Found WARNING: Config File: C:\GAMConfig\gam.cfg, Section: DEFAULT, Item: oauth2_txt, Value: C:\GAMConfig\oauth2.txt, Not Found
GAMADV-XTD3 7.00.05 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource GAMADV-XTD3 7.00.06 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
Ross Scroggs <ross.scroggs@gmail.com> Ross Scroggs <ross.scroggs@gmail.com>
Python 3.12.6 64-bit final Python 3.12.6 64-bit final
Windows-10-10.0.17134 AMD64 Windows-10-10.0.17134 AMD64

View File

@@ -19,7 +19,9 @@
* https://developers.google.com/workspace/chat/api/reference/rest/v1/spaces.messages/list * https://developers.google.com/workspace/chat/api/reference/rest/v1/spaces.messages/list
* https://developers.google.com/workspace/chat/api/reference/rest/v1/spaces.spaceEvents/list * https://developers.google.com/workspace/chat/api/reference/rest/v1/spaces.spaceEvents/list
* https://support.google.com/chat/answer/7655820 * https://support.google.com/chat/answer/7655820
* https://support.google.com/a/answer/13369245
* https://developers.google.com/workspace/chat/api/reference/rest/v1/spaces/search * https://developers.google.com/workspace/chat/api/reference/rest/v1/spaces/search
* https://developers.google.com/workspace/chat/api/reference/rest/v1/spaces#Space.FIELDS.predefined_permission_settings
## Introduction ## Introduction
These features were added in version 6.60.00. These features were added in version 6.60.00.
@@ -104,6 +106,7 @@ Google requires that you have a Chat Bot configured in order to use the Chat API
lastactivetime| lastactivetime|
membershipcount| membershipcount|
name| name|
permissionsettings|
singleuserbotdm| singleuserbotdm|
spacedetails| spacedetails|
spacehistorystate| spacehistorystate|
@@ -157,7 +160,7 @@ Google requires that you have a Chat Bot configured in order to use the Chat API
### Create a chat space ### Create a chat space
``` ```
gam <UserTypeEntity> create chatspace gam <UserTypeEntity> create chatspace
[type <ChatSpaceType>] [type <ChatSpaceType>] [announcement|collaboration]
[restricted|(audience <String>)] [restricted|(audience <String>)]
[externalusersallowed <Boolean>] [externalusersallowed <Boolean>]
[members <UserTypeEntity>] [members <UserTypeEntity>]
@@ -173,6 +176,7 @@ For `type space`, the following apply:
* `description <String>` - Optional * `description <String>` - Optional
* `guidelines <String>` - Optional * `guidelines <String>` - Optional
* `history <Boolean>` - Optional * `history <Boolean>` - Optional
* `announcement|collaboration` - Initial permission settings; default is `collaboration`; this is in Developer Preview
For `type groupchat`, the following apply: For `type groupchat`, the following apply:
* `members <UserTypeEntity>` - Required, must specify between 2 and 20 users * `members <UserTypeEntity>` - Required, must specify between 2 and 20 users
@@ -194,8 +198,6 @@ By default, Gam displays the information about the created chatspace as an inden
Use the `<ChatContent>` option to send an initial message to the created chatspace. Use the `<ChatContent>` option to send an initial message to the created chatspace.
The `restricted|audience` options are in Developer Preview and will not be generally available.
By default, details about the chatmessage are displayed. By default, details about the chatmessage are displayed.
* `returnidonly` - Display the chatmessage name only * `returnidonly` - Display the chatmessage name only
@@ -207,12 +209,29 @@ gam <UserTypeEntity> update chatspace <ChatSpace>
[type space] [type space]
[description <String>] [guidelines|rules <String>] [description <String>] [guidelines|rules <String>]
[history <Boolean>]) [history <Boolean>])
[managemembersandgroups managers|members]
[modifyspacedetails managers|members]
[togglehistory managers|members]
[useatmentionall managers|members]
[manageapps managers|members]
[managewebhooks managers|members]
[replymessages managers|members]
[formatjson] [formatjson]
``` ```
A groupchat space can be upgraded to a space by specifying `type space` and `displayname <String>`. A groupchat space can be upgraded to a space by specifying `type space` and `displayname <String>`.
The `restricted|audience` options can not be combined with options `displayname,type,description,guidelines,history`. The `restricted|audience` options can not be combined with options `displayname,type,description,guidelines,history`.
They are in Developer Preview and will not be generally available.
You can manage permissions for chat spaces with the following options that are available with Developer Preview.
[managemembersandgroups managers|members]
[modifyspacedetails managers|members]
[togglehistory managers|members]
[useatmentionall managers|members]
[manageapps managers|members]
[managewebhooks managers|members]
[postmessages managers|members]
[replymessages managers|members]
By default, Gam displays the information about the created chatspace as an indented list of keys and values. By default, Gam displays the information about the created chatspace as an indented list of keys and values.
* `formatjson` - Display the fields in JSON format. * `formatjson` - Display the fields in JSON format.
@@ -230,7 +249,6 @@ gam <UserItem> update chatspace asadmin <ChatSpace>
A groupchat space can be upgraded to a space by specifying `type space` and `displayname <String>`. A groupchat space can be upgraded to a space by specifying `type space` and `displayname <String>`.
The `restricted|audience` options can not be combined with options `displayname,type,description,guidelines,history`. The `restricted|audience` options can not be combined with options `displayname,type,description,guidelines,history`.
They are in Developer Preview and will not be generally available.
By default, Gam displays the information about the created chatspace as an indented list of keys and values. By default, Gam displays the information about the created chatspace as an indented list of keys and values.
* `formatjson` - Display the fields in JSON format. * `formatjson` - Display the fields in JSON format.

View File

@@ -3,7 +3,7 @@
Print the current version of Gam with details Print the current version of Gam with details
``` ```
gam version gam version
GAMADV-XTD3 7.00.05 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource GAMADV-XTD3 7.00.06 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
Ross Scroggs <ross.scroggs@gmail.com> Ross Scroggs <ross.scroggs@gmail.com>
Python 3.12.5 64-bit final Python 3.12.5 64-bit final
MacOS Sonoma 14.5 x86_64 MacOS Sonoma 14.5 x86_64
@@ -15,7 +15,7 @@ Time: 2023-06-02T21:10:00-07:00
Print the current version of Gam with details and time offset information Print the current version of Gam with details and time offset information
``` ```
gam version timeoffset gam version timeoffset
GAMADV-XTD3 7.00.05 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource GAMADV-XTD3 7.00.06 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
Ross Scroggs <ross.scroggs@gmail.com> Ross Scroggs <ross.scroggs@gmail.com>
Python 3.12.5 64-bit final Python 3.12.5 64-bit final
MacOS Sonoma 14.5 x86_64 MacOS Sonoma 14.5 x86_64
@@ -27,7 +27,7 @@ Your system time differs from www.googleapis.com by less than 1 second
Print the current version of Gam with extended details and SSL information Print the current version of Gam with extended details and SSL information
``` ```
gam version extended gam version extended
GAMADV-XTD3 7.00.05 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource GAMADV-XTD3 7.00.06 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
Ross Scroggs <ross.scroggs@gmail.com> Ross Scroggs <ross.scroggs@gmail.com>
Python 3.12.5 64-bit final Python 3.12.5 64-bit final
MacOS Sonoma 14.5 x86_64 MacOS Sonoma 14.5 x86_64
@@ -64,7 +64,7 @@ MacOS High Sierra 10.13.6 x86_64
Path: /Users/Admin/bin/gamadv-xtd3 Path: /Users/Admin/bin/gamadv-xtd3
Version Check: Version Check:
Current: 5.35.08 Current: 5.35.08
Latest: 7.00.05 Latest: 7.00.06
echo $? echo $?
1 1
``` ```
@@ -72,7 +72,7 @@ echo $?
Print the current version number without details Print the current version number without details
``` ```
gam version simple gam version simple
7.00.05 7.00.06
``` ```
In Linux/MacOS you can do: In Linux/MacOS you can do:
``` ```
@@ -82,7 +82,7 @@ echo $VER
Print the current version of Gam and address of this Wiki Print the current version of Gam and address of this Wiki
``` ```
gam help gam help
GAM 7.00.05 - https://github.com/taers232c/GAMADV-XTD3 GAM 7.00.06 - https://github.com/taers232c/GAMADV-XTD3
Ross Scroggs <ross.scroggs@gmail.com> Ross Scroggs <ross.scroggs@gmail.com>
Python 3.12.5 64-bit final Python 3.12.5 64-bit final
MacOS Sonoma 14.5 x86_64 MacOS Sonoma 14.5 x86_64

View File

@@ -2048,6 +2048,7 @@ gam setup chat
lastactivetime| lastactivetime|
membershipcount| membershipcount|
name| name|
permissionsettings|
singleuserbotdm| singleuserbotdm|
spacedetails| spacedetails|
spacehistorystate| spacehistorystate|
@@ -6093,7 +6094,7 @@ gam <UserTypeEntity> print focustime|outofoffice|workinglocation
<String> must contain only lowercase letters, numbers, and hyphens up to 56 characters in length. <String> must contain only lowercase letters, numbers, and hyphens up to 56 characters in length.
gam <UserTypeEntity> create chatspace gam <UserTypeEntity> create chatspace
[type <ChatSpaceType>] [type <ChatSpaceType>] [announcement|collaboration]
[restricted|(audience <String>)] [restricted|(audience <String>)]
[externalusersrallowed <Boolean>] [externalusersrallowed <Boolean>]
[members <UserTypeEntity>] [members <UserTypeEntity>]
@@ -6108,6 +6109,13 @@ gam <UserTypeEntity> update chatspace <ChatSpace>
[type space] [type space]
[description <String>] [guidelines|rules <String>] [description <String>] [guidelines|rules <String>]
[history <Boolean>]) [history <Boolean>])
[managemembersandgroups managers|members]
[modifyspacedetails managers|members]
[togglehistory managers|members]
[useatmentionall managers|members]
[manageapps managers|members]
[managewebhooks managers|members]
[replymessages managers|members]
[formatjson] [formatjson]
gam <UserTypeEntity> delete chatspace <ChatSpace> gam <UserTypeEntity> delete chatspace <ChatSpace>

View File

@@ -1,3 +1,10 @@
7.00.06
Updated `gam <UserTypeEntity> create|update chatspace` to support the new permissions settings
for Chat spaces that are in Developer Preview.
* See: https://developers.google.com/workspace/chat/api/reference/rest/v1/spaces#Space.FIELDS.predefined_permission_settings
7.00.05 7.00.05
Fixed bug that caused an error when creating a calendar birthday event. Fixed bug that caused an error when creating a calendar birthday event.

File diff suppressed because it is too large Load Diff

View File

@@ -25630,13 +25630,18 @@ CHAT_SPACE_TYPE_MAP = {
'directmessage': 'DIRECT_MESSAGE', 'directmessage': 'DIRECT_MESSAGE',
} }
CHAT_SPACE_PREDEFINED_PERMS_MAP = {
'announcement': 'ANNOUNCEMENT_SPACE',
'collaboration': 'COLLABORATION_SPACE',
}
CHAT_SPACE_MIN_MAX_MEMBERS = { CHAT_SPACE_MIN_MAX_MEMBERS = {
'SPACE': {'min': 0, 'max': 20}, 'SPACE': {'min': 0, 'max': 20},
'GROUP_CHAT': {'min': 2, 'max': 20}, 'GROUP_CHAT': {'min': 2, 'max': 20},
'DIRECT_MESSAGE': {'min': 1, 'max': 1}, 'DIRECT_MESSAGE': {'min': 1, 'max': 1},
} }
# gam <UserTypeEntity> create chatspace # gam <UserTypeEntity> create chatspace
# [type <ChatSpaceType>] # [type <ChatSpaceType>] [announcement|collaboration]
# [restricted|(audience <String>)] # [restricted|(audience <String>)]
# [externalusersallowed <Boolean>] # [externalusersallowed <Boolean>]
# [members <UserTypeEntity>] # [members <UserTypeEntity>]
@@ -25647,9 +25652,7 @@ CHAT_SPACE_MIN_MAX_MEMBERS = {
# [formatjson|returnidonly] # [formatjson|returnidonly]
def createChatSpace(users): def createChatSpace(users):
FJQC = FormatJSONQuoteChar() FJQC = FormatJSONQuoteChar()
body = {'space': {'spaceType': CHAT_SPACE_TYPE_MAP['space'], 'displayName': ''}, body = {'space': {'spaceType': CHAT_SPACE_TYPE_MAP['space'], 'displayName': ''}, 'requestId': str(uuid.uuid4())}
'requestId': str(uuid.uuid4()),
'memberships': []}
members = [] members = []
tbody = {} tbody = {}
returnIdOnly = False returnIdOnly = False
@@ -25658,6 +25661,8 @@ def createChatSpace(users):
myarg = getArgument() myarg = getArgument()
if getChatSpaceParameters(myarg, body['space'], CHAT_SPACE_TYPE_MAP, updateMask): if getChatSpaceParameters(myarg, body['space'], CHAT_SPACE_TYPE_MAP, updateMask):
pass pass
elif myarg in CHAT_SPACE_PREDEFINED_PERMS_MAP:
body['space']['predefinedPermissionSettings'] = CHAT_SPACE_PREDEFINED_PERMS_MAP[myarg]
elif myarg == 'externalusersallowed': elif myarg == 'externalusersallowed':
body['space']['externalUserAllowed'] = getBoolean() body['space']['externalUserAllowed'] = getBoolean()
elif myarg == 'members': elif myarg == 'members':
@@ -25678,6 +25683,8 @@ def createChatSpace(users):
CHAT_SPACE_MIN_MAX_MEMBERS[spaceType]['min'], CHAT_SPACE_MIN_MAX_MEMBERS[spaceType]['min'],
CHAT_SPACE_MIN_MAX_MEMBERS[spaceType]['max'])) CHAT_SPACE_MIN_MAX_MEMBERS[spaceType]['max']))
mtype = CHAT_MEMBER_TYPE_MAP['human'] mtype = CHAT_MEMBER_TYPE_MAP['human']
if members:
body['memberships'] = []
for member in members: for member in members:
name = normalizeEmailAddressOrUID(member) name = normalizeEmailAddressOrUID(member)
body['memberships'].append({'member': {'name': f'users/{name}', 'type': mtype}}) body['memberships'].append({'member': {'name': f'users/{name}', 'type': mtype}})
@@ -25686,9 +25693,11 @@ def createChatSpace(users):
missingArgumentExit('displayname') missingArgumentExit('displayname')
elif spaceType == 'GROUP_CHAT': elif spaceType == 'GROUP_CHAT':
body['space'].pop('displayName', None) body['space'].pop('displayName', None)
body['space'].pop('predefinedPermissionSettings', None)
else: # DIRECT_MESSAGE else: # DIRECT_MESSAGE
body['space'].pop('displayName', None) body['space'].pop('displayName', None)
body['space'].pop('spaceDetails', None) body['space'].pop('spaceDetails', None)
body['space'].pop('predefinedPermissionSettings', None)
body['space']['singleUserBotDm'] = False body['space']['singleUserBotDm'] = False
if tbody: if tbody:
trimChatMessageIfRequired(tbody) trimChatMessageIfRequired(tbody)
@@ -25737,12 +25746,34 @@ CHAT_UPDATE_SPACE_TYPE_MAP = {
'space': 'SPACE', 'space': 'SPACE',
} }
CHAT_SPACE_ROLE_PERMISSIONS_MAP = {
'managers': 'managersAllowed',
'members': 'membersAllowed',
}
CHAT_UPDATE_SPACE_PERMISSIONS_MAP = {
'managemembersandgroups': 'manageMembersAndGroups',
'modifyspacedetails': 'modifySpaceDetails',
'togglehistory': 'toggleHistory',
'useatmentionall': 'useAtMentionAll',
'manageapps': 'manageApps',
'managewebhooks': 'manageWebhooks',
'replymessages': 'replyMessages',
}
# gam <UserTypeEntity> update chatspace <ChatSpace> # gam <UserTypeEntity> update chatspace <ChatSpace>
# [restricted|(audience <String>)]| # [restricted|(audience <String>)]|
# ([displayname <String>] # ([displayname <String>]
# [type space] # [type space]
# [description <String>] [guidelines|rules <String>] # [description <String>] [guidelines|rules <String>]
# [history <Boolean>]) # [history <Boolean>])
# managemembersandgroups managers|members
# modifyspacedetails managers|members
# togglehistory managers|members
# useatmentionall managers|members
# manageapps managers|members
# managewebhooks managers|members
# replymessages managers|members
# [formatjson] # [formatjson]
def updateChatSpace(users): def updateChatSpace(users):
FJQC = FormatJSONQuoteChar() FJQC = FormatJSONQuoteChar()
@@ -25756,6 +25787,14 @@ def updateChatSpace(users):
name = getSpaceName(myarg) name = getSpaceName(myarg)
elif getChatSpaceParameters(myarg, body, CHAT_UPDATE_SPACE_TYPE_MAP, updateMask): elif getChatSpaceParameters(myarg, body, CHAT_UPDATE_SPACE_TYPE_MAP, updateMask):
pass pass
elif myarg in CHAT_UPDATE_SPACE_PERMISSIONS_MAP:
body.setdefault('permissionSettings', {})
permissionSetting = CHAT_UPDATE_SPACE_PERMISSIONS_MAP[myarg]
role = getChoice(CHAT_SPACE_ROLE_PERMISSIONS_MAP, mapChoice=True)
body['permissionSettings'][permissionSetting] = {'managersAllowed': True}
if role == 'membersAllowed':
body['permissionSettings'][permissionSetting].update({'membersAllowed': True})
updateMask.add(f'permissionSettings.{permissionSetting}')
else: else:
FJQC.GetFormatJSON(myarg) FJQC.GetFormatJSON(myarg)
if not name: if not name:
@@ -25823,6 +25862,7 @@ CHAT_SPACES_FIELDS_CHOICE_MAP = {
"lastactivetime": "lastActiveTime", "lastactivetime": "lastActiveTime",
"membershipcount": "membershipCount", "membershipcount": "membershipCount",
"name": "name", "name": "name",
"permissionsettings": "permissionSettings",
"singleuserbotdm": "singleUserBotDm", "singleuserbotdm": "singleUserBotDm",
"spacedetails": "spaceDetails", "spacedetails": "spaceDetails",
"spacehistorystate": "spaceHistoryState", "spacehistorystate": "spaceHistoryState",

File diff suppressed because it is too large Load Diff

View File

@@ -206,15 +206,15 @@ _INFO = {
ANALYTICS_ADMIN: {'name': 'Analytics Admin API', 'version': 'v1beta', 'v2discovery': True}, ANALYTICS_ADMIN: {'name': 'Analytics Admin API', 'version': 'v1beta', 'v2discovery': True},
CALENDAR: {'name': 'Calendar API', 'version': 'v3', 'v2discovery': True, 'mappedAPI': 'calendar-json'}, CALENDAR: {'name': 'Calendar API', 'version': 'v3', 'v2discovery': True, 'mappedAPI': 'calendar-json'},
CBCM: {'name': 'Chrome Browser Cloud Management API', 'version': 'v1.1beta1', 'v2discovery': True, 'localjson': True}, CBCM: {'name': 'Chrome Browser Cloud Management API', 'version': 'v1.1beta1', 'v2discovery': True, 'localjson': True},
CHAT: {'name': 'Chat API', 'version': 'v1', 'v2discovery': True, 'localjson': True}, CHAT: {'name': 'Chat API', 'version': 'v1', 'v2discovery': True},
CHAT_EVENTS: {'name': 'Chat API - Events', 'version': 'v1', 'v2discovery': True, 'localjson': True, 'mappedAPI': CHAT}, CHAT_EVENTS: {'name': 'Chat API - Events', 'version': 'v1', 'v2discovery': True, 'mappedAPI': CHAT},
CHAT_MEMBERSHIPS: {'name': 'Chat API - Memberships', 'version': 'v1', 'v2discovery': True, 'localjson': True, 'mappedAPI': CHAT}, CHAT_MEMBERSHIPS: {'name': 'Chat API - Memberships', 'version': 'v1', 'v2discovery': True, 'mappedAPI': CHAT},
CHAT_MEMBERSHIPS_ADMIN: {'name': 'Chat API - Memberships Admin', 'version': 'v1', 'v2discovery': True, 'localjson': True, 'mappedAPI': CHAT}, CHAT_MEMBERSHIPS_ADMIN: {'name': 'Chat API - Memberships Admin', 'version': 'v1', 'v2discovery': True, 'mappedAPI': CHAT},
CHAT_MESSAGES: {'name': 'Chat API - Messages', 'version': 'v1', 'v2discovery': True, 'localjson': True, 'mappedAPI': CHAT}, CHAT_MESSAGES: {'name': 'Chat API - Messages', 'version': 'v1', 'v2discovery': True, 'mappedAPI': CHAT},
CHAT_SPACES: {'name': 'Chat API - Spaces', 'version': 'v1', 'v2discovery': True, 'localjson': True, 'mappedAPI': CHAT}, CHAT_SPACES: {'name': 'Chat API - Spaces', 'version': 'v1', 'v2discovery': True, 'mappedAPI': CHAT},
CHAT_SPACES_ADMIN: {'name': 'Chat API - Spaces Admin', 'version': 'v1', 'v2discovery': True, 'localjson': True, 'mappedAPI': CHAT}, CHAT_SPACES_ADMIN: {'name': 'Chat API - Spaces Admin', 'version': 'v1', 'v2discovery': True, 'mappedAPI': CHAT},
CHAT_SPACES_DELETE: {'name': 'Chat API - Spaces Delete', 'version': 'v1', 'v2discovery': True, 'localjson': True, 'mappedAPI': CHAT}, CHAT_SPACES_DELETE: {'name': 'Chat API - Spaces Delete', 'version': 'v1', 'v2discovery': True, 'mappedAPI': CHAT},
CHAT_SPACES_DELETE_ADMIN: {'name': 'Chat API - Spaces Delete Admin', 'version': 'v1', 'v2discovery': True, 'localjson': True, 'mappedAPI': CHAT}, CHAT_SPACES_DELETE_ADMIN: {'name': 'Chat API - Spaces Delete Admin', 'version': 'v1', 'v2discovery': True, 'mappedAPI': CHAT},
CLASSROOM: {'name': 'Classroom API', 'version': 'v1', 'v2discovery': True}, CLASSROOM: {'name': 'Classroom API', 'version': 'v1', 'v2discovery': True},
CHROMEMANAGEMENT: {'name': 'Chrome Management API', 'version': 'v1', 'v2discovery': True}, CHROMEMANAGEMENT: {'name': 'Chrome Management API', 'version': 'v1', 'v2discovery': True},
CHROMEMANAGEMENT_APPDETAILS: {'name': 'Chrome Management API - AppDetails', 'version': 'v1', 'v2discovery': True, 'mappedAPI': CHROMEMANAGEMENT}, CHROMEMANAGEMENT_APPDETAILS: {'name': 'Chrome Management API - AppDetails', 'version': 'v1', 'v2discovery': True, 'mappedAPI': CHROMEMANAGEMENT},

View File

@@ -1170,9 +1170,11 @@ def createMethod(methodName, methodDesc, rootDesc, schema):
elif "response" not in methodDesc: elif "response" not in methodDesc:
model = RawModel() model = RawModel()
api_version = methodDesc.get("apiVersion", None)
headers = {} headers = {}
headers, params, query, body = model.request( headers, params, query, body = model.request(
headers, actual_path_params, actual_query_params, body_value headers, actual_path_params, actual_query_params, body_value, api_version
) )
expanded_url = uritemplate.expand(pathUrl, params) expanded_url = uritemplate.expand(pathUrl, params)

View File

@@ -27,10 +27,18 @@ import json
import logging import logging
import platform import platform
import urllib import urllib
import warnings
from googleapiclient import version as googleapiclient_version from googleapiclient import version as googleapiclient_version
from googleapiclient.errors import HttpError from googleapiclient.errors import HttpError
try:
from google.api_core.version_header import API_VERSION_METADATA_KEY
HAS_API_VERSION = True
except ImportError:
HAS_API_VERSION = False
_LIBRARY_VERSION = googleapiclient_version.__version__ _LIBRARY_VERSION = googleapiclient_version.__version__
_PY_VERSION = platform.python_version() _PY_VERSION = platform.python_version()
@@ -121,7 +129,7 @@ class BaseModel(Model):
LOGGER.info("query: %s", query) LOGGER.info("query: %s", query)
LOGGER.info("--request-end--") LOGGER.info("--request-end--")
def request(self, headers, path_params, query_params, body_value): def request(self, headers, path_params, query_params, body_value, api_version=None):
"""Updates outgoing requests with a serialized body. """Updates outgoing requests with a serialized body.
Args: Args:
@@ -130,6 +138,9 @@ class BaseModel(Model):
query_params: dict, parameters that appear in the query query_params: dict, parameters that appear in the query
body_value: object, the request body as a Python object, which must be body_value: object, the request body as a Python object, which must be
serializable by json. serializable by json.
api_version: str, The precise API version represented by this request,
which will result in an API Version header being sent along with the
HTTP request.
Returns: Returns:
A tuple of (headers, path_params, query, body) A tuple of (headers, path_params, query, body)
@@ -155,6 +166,15 @@ class BaseModel(Model):
_PY_VERSION, _PY_VERSION,
) )
if api_version and HAS_API_VERSION:
headers[API_VERSION_METADATA_KEY] = api_version
elif api_version:
warnings.warn(
"The `api_version` argument is ignored as a newer version of "
"`google-api-core` is required to use this feature."
"Please upgrade `google-api-core` to 2.19.0 or newer."
)
if body_value is not None: if body_value is not None:
headers["content-type"] = self.content_type headers["content-type"] = self.content_type
body_value = self.serialize(body_value) body_value = self.serialize(body_value)

View File

@@ -12,4 +12,4 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
__version__ = "2.124.0" __version__ = "2.146.0"