mirror of
https://github.com/GAM-team/GAM.git
synced 2026-07-03 12:21:35 +00:00
Updates for CRM v3 changes (#1400)
This commit is contained in:
@@ -849,6 +849,8 @@ An argument containing instances of ~~xxx~~ has xxx replaced by the value of fie
|
|||||||
Example: gam csv Users.csv gam update user "~primaryEmail" address type work unstructured "~~Street~~, ~~City~~, ~~State~~ ~~ZIP~~"
|
Example: gam csv Users.csv gam update user "~primaryEmail" address type work unstructured "~~Street~~, ~~City~~, ~~State~~ ~~ZIP~~"
|
||||||
Each user (~primaryEmail, e.g. foo@bar.com) would have their work address updated
|
Each user (~primaryEmail, e.g. foo@bar.com) would have their work address updated
|
||||||
|
|
||||||
|
gam create gcpfolder <String>
|
||||||
|
|
||||||
gam create project [<EmailAddress>] [<ProjectID>]
|
gam create project [<EmailAddress>] [<ProjectID>]
|
||||||
gam create project [admin <EmailAddress>] [project <ProjectID>] [parent <String>]
|
gam create project [admin <EmailAddress>] [project <ProjectID>] [parent <String>]
|
||||||
gam use project [<EmailAddress>] [<ProjectID>]
|
gam use project [<EmailAddress>] [<ProjectID>]
|
||||||
|
|||||||
@@ -7517,22 +7517,15 @@ def _getLoginHintProjectId(createCmd):
|
|||||||
f'Invalid Project ID: {projectId}, expected <{PROJECTID_FORMAT_REQUIRED}>'
|
f'Invalid Project ID: {projectId}, expected <{PROJECTID_FORMAT_REQUIRED}>'
|
||||||
)
|
)
|
||||||
crm, httpObj = getCRMService(login_hint)
|
crm, httpObj = getCRMService(login_hint)
|
||||||
if parent and not parent.startswith(
|
if parent and not parent.startswith('organizations/') and not parent.startswith('folders/'):
|
||||||
'organizations/') and not parent.startswith('folders/'):
|
|
||||||
parent = convertGCPFolderNameToID(parent, crm)
|
parent = convertGCPFolderNameToID(parent, crm)
|
||||||
if parent:
|
|
||||||
parent_type, parent_id = parent.split('/')
|
|
||||||
if parent_type[-1] == 's':
|
|
||||||
parent_type = parent_type[:
|
|
||||||
-1] # folders > folder, organizations > organization
|
|
||||||
parent = {'type': parent_type, 'id': parent_id}
|
|
||||||
projects = _getProjects(crm, f'id:{projectId}')
|
projects = _getProjects(crm, f'id:{projectId}')
|
||||||
if not createCmd:
|
if not createCmd:
|
||||||
if not projects:
|
if not projects:
|
||||||
controlflow.system_error_exit(
|
controlflow.system_error_exit(
|
||||||
2,
|
2,
|
||||||
f'User: {login_hint}, Project ID: {projectId}, Does not exist')
|
f'User: {login_hint}, Project ID: {projectId}, Does not exist')
|
||||||
if projects[0]['lifecycleState'] != 'ACTIVE':
|
if projects[0]['state'] != 'ACTIVE':
|
||||||
controlflow.system_error_exit(
|
controlflow.system_error_exit(
|
||||||
2, f'User: {login_hint}, Project ID: {projectId}, Not active')
|
2, f'User: {login_hint}, Project ID: {projectId}, Not active')
|
||||||
else:
|
else:
|
||||||
@@ -7563,17 +7556,14 @@ def convertGCPFolderNameToID(parent, crm):
|
|||||||
|
|
||||||
|
|
||||||
def createGCPFolder():
|
def createGCPFolder():
|
||||||
|
displayName = sys.argv[3]
|
||||||
login_hint = _getValidateLoginHint()
|
login_hint = _getValidateLoginHint()
|
||||||
login_domain = login_hint.split('@')[-1]
|
login_domain = login_hint.split('@')[-1]
|
||||||
crm, _ = getCRMService(login_hint)
|
crm, _ = getCRMService(login_hint)
|
||||||
organization = getGCPOrg(crm, login_domain)
|
organization = getGCPOrg(crm, login_domain)
|
||||||
gapi.call(crm.folders(),
|
result = gapi.call(crm.folders(), 'create',
|
||||||
'create',
|
body={'parent': organization, 'displayName': displayName})
|
||||||
body={
|
print(f'User: {login_hint}, Folder: {displayName}, GCP Folder Name: {result["name"]}, Created')
|
||||||
'parent': organization,
|
|
||||||
'name': sys.argv[3],
|
|
||||||
'displayName': sys.argv[3]
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
def _getLoginHintProjects(printShowCmd):
|
def _getLoginHintProjects(printShowCmd):
|
||||||
@@ -8069,8 +8059,9 @@ def doPrintShowProjects(csvFormat):
|
|||||||
csvRows = []
|
csvRows = []
|
||||||
todrive = False
|
todrive = False
|
||||||
titles = [
|
titles = [
|
||||||
'User', 'projectId', 'projectNumber', 'name', 'createTime',
|
'User', 'projectId', 'name', 'displayName',
|
||||||
'lifecycleState'
|
'createTime', 'updateTime', 'deleteTime',
|
||||||
|
'state'
|
||||||
]
|
]
|
||||||
while i < len(sys.argv):
|
while i < len(sys.argv):
|
||||||
myarg = sys.argv[i].lower()
|
myarg = sys.argv[i].lower()
|
||||||
@@ -8087,19 +8078,19 @@ def doPrintShowProjects(csvFormat):
|
|||||||
for project in projects:
|
for project in projects:
|
||||||
i += 1
|
i += 1
|
||||||
print(f' Project: {project["projectId"]}{currentCount(i, count)}')
|
print(f' Project: {project["projectId"]}{currentCount(i, count)}')
|
||||||
print(f' projectNumber: {project["projectNumber"]}')
|
|
||||||
print(f' name: {project["name"]}')
|
print(f' name: {project["name"]}')
|
||||||
print(f' createTime: {project["createTime"]}')
|
print(f' displayName: {project["displayName"]}')
|
||||||
print(f' lifecycleState: {project["lifecycleState"]}')
|
for field in ['createTime', 'updateTime', 'deleteTime']:
|
||||||
|
if field in project:
|
||||||
|
print(f' {field}: {project[field]}')
|
||||||
|
print(f' state: {project["state"]}')
|
||||||
jcount = len(project.get('labels', []))
|
jcount = len(project.get('labels', []))
|
||||||
if jcount > 0:
|
if jcount > 0:
|
||||||
print(' labels:')
|
print(' labels:')
|
||||||
for k, v in list(project['labels'].items()):
|
for k, v in list(project['labels'].items()):
|
||||||
print(f' {k}: {v}')
|
print(f' {k}: {v}')
|
||||||
if 'parent' in project:
|
if 'parent' in project:
|
||||||
print(' parent:')
|
print(f' parent: {project["parent"]}')
|
||||||
print(f' type: {project["parent"]["type"]}')
|
|
||||||
print(f' id: {project["parent"]["id"]}')
|
|
||||||
else:
|
else:
|
||||||
for project in projects:
|
for project in projects:
|
||||||
display.add_row_titles_to_csv_file(
|
display.add_row_titles_to_csv_file(
|
||||||
|
|||||||
Reference in New Issue
Block a user