class BulkTagInput(graphene.InputObjectType): """Input object for bulkTag. Args: id (str): ID of target to add. resource_type (EntityType): Entity type the tag is to be attached to. resource_ids (List[str], optional): IDs of the resources the tag is to be attached to. If resource_filter is given, this argument is not used. resource_filter (FilterString, optional) – Filter term to select resources the tag is to be attached to. If this argument is given, resource_ids is not used """ tag_id = graphene.UUID(name='id', required=True, description='ID of target to add.') resource_type = EntityType( required=True, description="Entity type the tag is to be attached to.") resource_ids = graphene.List( graphene.String, description=("IDs of the resources the tag is to be attached to."), ) resource_filter = FilterString(description=( "Filter term to select resources the tag is to be attached to."))
class CreateTagInput(graphene.InputObjectType): """Input object for createTag. Args: name (str): Name of the tag. A full tag name consisting of namespace and predicate e.g. foo:bar. resource_type (EntityType): Entity type the tag is to be attached to. resource_ids (List[str], optional): IDs of the resources the tag is to be attached to. value (str, optional): Value associated with the tag. comment (str, optional): Comment for the tag. active (bool, optional): Whether the tag should be active. """ name = graphene.String( required=True, description=("Name of the tag. A full tag name consisting" "of namespace and predicate e.g. foo:bar."), ) resource_type = EntityType( required=True, description="Entity type the tag is to be attached to.") resource_ids = graphene.List( graphene.String, description=( "IDs of the resources the tag is to be attached to." "Only one of resource_filter or resource_ids can be provided."), ) value = graphene.String(description="Value associated with the tag.") comment = graphene.String(description="Comment for the tag.") active = graphene.Boolean(description="Whether the tag should be active.")
def mutate(_root, info, input_object): gmp = get_gmp(info) if input_object.resource_filter is not None: gmp.modify_tag( str(input_object.tag_id), resource_filter=input_object.resource_filter.filter_string, resource_type=EntityType.get(input_object.resource_type), resource_action='add', ) else: gmp.modify_tag( str(input_object.tag_id), resource_ids=input_object.resource_ids, resource_type=EntityType.get(input_object.resource_type), resource_action='add', ) return RemoveTag(ok=True)
def mutate(_root, info, input_object): gmp = get_gmp(info) gmp.modify_tag( str(input_object.tag_id), resource_ids=input_object.resource_ids, resource_type=EntityType.get(input_object.resource_type), resource_action='add', ) return AddTag(ok=True)
def mutate(_root, info, input_object): gmp = get_gmp(info) resp = gmp.create_tag( input_object.name, EntityType.get(input_object.resource_type), resource_ids=input_object.resource_ids, value=input_object.value, comment=input_object.comment, active=input_object.active, ) return CreateTag(tag_id=resp.get('id'))
class ModifyTagInput(graphene.InputObjectType): """Input object for modifyTag. Args: id (str): ID of target to modify. name (str, optional): Name of the tag. A full tag name consisting of namespace and predicate e.g. foo:bar. resource_type (EntityType, optional): Entity type the tag is to be attached to. resource_ids (List[str], optional): IDs of the resources the tag is to be attached to. resource_action (ResourceAction, optional): Whether to add or remove resources instead of overwriting. One of ADD, SET or REMOVE. value (str, optional): Value associated with the tag. comment (str, optional): Comment for the tag. active (bool, optional): Whether the tag should be active. """ tag_id = graphene.UUID( name='id', required=True, description='ID of target to modify.' ) name = graphene.String( description=( "Name of the tag. A full tag name consisting" "of namespace and predicate e.g. foo:bar." ) ) resource_type = EntityType( description="Entity type the tag is to be attached to." ) resource_ids = graphene.List( graphene.String, description=("IDs of the resources the tag is to be attached to."), ) resource_action = ResourceAction( description=( "Whether to add or remove " "resources instead of overwriting. One of ADD, " "SET or REMOVE." ) ) value = graphene.String(description="Value associated with the tag.") comment = graphene.String(description="Comment for the tag.") active = graphene.Boolean(description="Whether the tag should be active.")
def mutate(_root, info, input_object): gmp = get_gmp(info) if input_object.resource_type is not None: resource_type = EntityType.get(input_object.resource_type) else: resource_type = None gmp.modify_tag( str(input_object.tag_id), name=input_object.name, comment=input_object.comment, value=input_object.value, active=input_object.active, resource_action=input_object.resource_action, resource_type=resource_type, resource_ids=input_object.resource_ids, ) return ModifyTag(ok=True)
class AddTagInput(graphene.InputObjectType): """Input object for addTag. Args: id (str): ID of target to add. resource_type (EntityType): Entity type the tag is to be added to. resource_ids (List[str]): IDs of the resources the tag is to be added to. """ tag_id = graphene.UUID(name='id', required=True, description='ID of target to add.') resource_type = EntityType( required=True, description="Entity type the tag is to be added to.") resource_ids = graphene.List( graphene.String, required=True, description=("IDs of the resources the tag is to be added to."), )