Ejemplo n.º 1
0
def ListAssetsReqHook(ref, args, req):
    """Hook up filter such that the CSCC filter is used rather than gcloud."""
    del ref
    req.parent = GetOrganization(args)
    if req.fieldMask is not None:
        req.fieldMask = CleanUpUserInput(req.fieldMask)
    req.filter = args.filter
    args.filter = ""
    return req
Ejemplo n.º 2
0
def _GetAssetName(args):
  """Prepares asset relative path using organization and asset."""
  resource_pattern = re.compile("organizations/[0-9]+/assets/[0-9]+")
  id_pattern = re.compile("[0-9]+")
  assert resource_pattern.match(args.asset) or id_pattern.match(args.asset), (
      "Asset must match either organizations/[0-9]+/assets/[0-9]+ or [0-9]+.")
  if resource_pattern.match(args.asset):
    # Handle asset id as full resource name
    return args.asset
  return GetOrganization(args) + "/assets/" + args.asset
Ejemplo n.º 3
0
def _GetSourceName(args):
  """Returns relative resource name for a source."""
  resource_pattern = re.compile("organizations/[0-9]+/sources/[0-9-]+")
  id_pattern = re.compile("[0-9-]+")
  assert resource_pattern.match(args.source) or id_pattern.match(args.source), (
      "Source must match either organizations/[0-9]+/sources/[0-9-]+ "
      "or [0-9-]+.")
  if resource_pattern.match(args.source):
    # Handle full resource name
    return args.source
  return GetOrganization(args) + "/sources/" + args.source
Ejemplo n.º 4
0
def _GetNotificationConfigName(args):
  """Returns relative resource name for a notification config."""
  resource_pattern = re.compile(
      "organizations/[0-9]+/notificationConfigs/[a-zA-Z0-9-_]{1,128}$")
  id_pattern = re.compile("[a-zA-Z0-9-_]{1,128}$")
  if not resource_pattern.match(
      args.notificationConfigId) and not id_pattern.match(
          args.notificationConfigId):
    raise InvalidNotificationConfigError(
        "NotificationConfig must match either organizations/"
        "[0-9]+/notificationConfigs/[a-zA-Z0-9-_]{1,128})$ or "
        "[a-zA-Z0-9-_]{1,128}$.")
  if resource_pattern.match(args.notificationConfigId):
    # Handle config id as full resource name
    return args.notificationConfigId
  return GetOrganization(args) + "/notificationConfigs/" + args.notificationConfigId
Ejemplo n.º 5
0
def DescribeSourceReqHook(ref, args, req):
    """Generate organization name from organization id."""
    del ref
    req.parent = GetOrganization(args)
    return req
Ejemplo n.º 6
0
def ListNotificationReqHook(ref, args, req):
  """Generate an organization id if only given numbers."""
  del ref
  req.parent = GetOrganization(args)
  return req
Ejemplo n.º 7
0
def GetProjectAssetReqHook(ref, args, req):
    """Generate organization name from organization id."""
    del ref
    req.parent = GetOrganization(args)
    req.filter = _GetNameOrResourceFilter(args)
    return req