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
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
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
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
def DescribeSourceReqHook(ref, args, req): """Generate organization name from organization id.""" del ref req.parent = GetOrganization(args) return req
def ListNotificationReqHook(ref, args, req): """Generate an organization id if only given numbers.""" del ref req.parent = GetOrganization(args) return req
def GetProjectAssetReqHook(ref, args, req): """Generate organization name from organization id.""" del ref req.parent = GetOrganization(args) req.filter = _GetNameOrResourceFilter(args) return req