def create_client(http=None): credentials = oauth2client.GoogleCredentials.get_application_default() if credentials.create_scoped_required(): credentials = credentials.create_scoped(CRM_SCOPES) if not http: http = httplib2.Http() credentials.authorize(http) return discovery.build(CRM_SERVICE_NAME, CRM_VERSION, http=http)
Organization_id = str(YOUR-ORG_NUMERIC_ID) proj_prefix = "your-proj-prefix-" # must be lower case! proj_id = proj_prefix+"-"+str(random_with_N_digits(6)) #************************
def List_projects(org_id): crm = create_client() project_filter = 'parent.type:organization parent.id:%s' % org_id print(project_filter) projects = crm.projects().list(filter=project_filter).execute() #while projects is not None: print(projects)
def create_project(proj_id): crm = create_client() print "org id in function is :\n" print(organization_id) new_project = crm.projects().create( body={ 'project_id': proj_id, 'name': proj_id, 'parent': { 'type': 'organization', 'id': organization_id } }).execute()
0 件のコメント :
コメントを投稿