Example #1
0
def _MultiTenantProjectIds(project):
    setting_name = 'projects/{}/settings/cloudrun-multiTenancy'.format(project)

    messages = resourcesettings_service.ResourceSettingsMessages()

    get_request = messages.ResourcesettingsProjectsSettingsLookupEffectiveValueRequest(
        parent=setting_name)
    settings_service = resourcesettings_service.ProjectsSettingsService()
    service_value = settings_service.LookupEffectiveValue(get_request)
    return [
        _MulitTenantProjectId(project)
        for project in service_value.value.stringSetValue.values
    ]
Example #2
0
def GetServiceFromResourceType(resource_type):
    """Returns the service from the resource type input.

  Args:
    resource_type: A String object that contains the resource type
  """

    if resource_type == ORGANIZATION:
        service = settings_service.OrganizationsSettingsService()
    elif resource_type == FOLDER:
        service = settings_service.FoldersSettingsService()
    else:
        service = settings_service.ProjectsSettingsService()

    return service
def _MultiTenantProjectIds(project):
    setting_name = 'projects/{}/settings/cloudrun-multiTenancy'.format(project)

    messages = resourcesettings_service.ResourceSettingsMessages()

    get_request = messages.ResourcesettingsProjectsSettingsGetRequest(
        name=setting_name,
        view=messages.ResourcesettingsProjectsSettingsGetRequest.
        ViewValueValuesEnum.SETTING_VIEW_EFFECTIVE_VALUE)
    settings_service = resourcesettings_service.ProjectsSettingsService()
    service_value = settings_service.LookupEffectiveValue(get_request)
    return [
        _MulitTenantProjectId(project)
        for project in service_value.localValue.stringSetValue.values
    ]
Example #4
0
def GetServiceFromArgs(args):
    """Returns the service from the user-specified arguments.

  Args:
    args: argparse.Namespace, An object that contains the values for the
      arguments specified in the Args method.
  """

    if args.organization:
        service = settings_service.OrganizationsSettingsService()
    elif args.folder:
        service = settings_service.FoldersSettingsService()
    else:
        service = settings_service.ProjectsSettingsService()

    return service