Skip to content

tags

tags

a class based approach for interacting with Domo Datasets

DomoTags dataclass

DomoTags(parent: DomoEntity, tags: list[str] = list())

Bases: DomoSubEntity

class for interacting with dataset tags

add async

add(
    add_tags: list[str],
    debug_api: bool = False,
    session: AsyncClient | None = None,
    *,
    context: RouteContext | None = None,
    **context_kwargs
) -> list[str]

appends tags to the list of existing dataset_tags

Source code in src/crew_dcs/classes/subentity/tags.py
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
async def add(
    self,
    add_tags: list[str],
    debug_api: bool = False,
    session: httpx.AsyncClient | None = None,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
) -> list[str]:  # returns a list of tags
    """appends tags to the list of existing dataset_tags"""

    context = RouteContext.build_context(
        context=context,
        session=session,
        debug_api=debug_api,
        **context_kwargs,
    )

    await self.get(context=context)

    for tg in add_tags:
        if tg not in self.tags:
            self.tags.append(tg)

    return await self.update(
        context=context,
    )

get async

get(
    session: AsyncClient | None = None,
    debug_api: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs
) -> list[str]

gets the existing list of dataset_tags

Source code in src/crew_dcs/classes/subentity/tags.py
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
async def get(
    self,
    session: httpx.AsyncClient | None = None,
    debug_api: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
) -> list[str]:  # returns a list of tags
    """gets the existing list of dataset_tags"""

    context = RouteContext.build_context(
        context=context,
        session=session,
        debug_api=debug_api,
        **context_kwargs,
    )

    res = await dataset_routes.get_dataset_by_id(
        dataset_id=self.parent.id,
        auth=self.parent.auth,
        context=context,
    )

    if res.response.get("tags"):
        self.tags = json.loads(res.response.get("tags"))

    return self.tags

remove async

remove(
    remove_tags: list[str],
    debug_api: bool = False,
    session: AsyncClient | None = None,
    *,
    context: RouteContext | None = None,
    **context_kwargs
) -> list[str]

removes tags from the existing list of dataset_tags

Source code in src/crew_dcs/classes/subentity/tags.py
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
async def remove(
    self,
    remove_tags: list[str],
    debug_api: bool = False,
    session: httpx.AsyncClient | None = None,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
) -> list[str]:  # returns a list of tags
    """removes tags from the existing list of dataset_tags"""

    context = RouteContext.build_context(
        context=context,
        session=session,
        debug_api=debug_api,
        **context_kwargs,
    )

    await self.get(context=context)

    for tg in remove_tags:
        if tg in self.tags:
            self.tags.remove(tg)

    return await self.update(
        context=context,
    )

update async

update(
    debug_api: bool = False,
    session: AsyncClient | None = None,
    *,
    context: RouteContext | None = None,
    **context_kwargs
) -> list[str]

replaces all tags with a new list of dataset_tags

Source code in src/crew_dcs/classes/subentity/tags.py
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
async def update(
    self,
    debug_api: bool = False,
    session: httpx.AsyncClient | None = None,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
) -> list[str]:  # returns a list of tags
    """replaces all tags with a new list of dataset_tags"""

    context = RouteContext.build_context(
        context=context,
        session=session,
        debug_api=debug_api,
        **context_kwargs,
    )

    await dataset_routes.set_dataset_tags(
        auth=self.parent.auth,
        tag_ls=self.tags,
        dataset_id=self.parent.id,
        context=context,
    )

    await self.get(context=context)

    return self.tags

DomoTags_SetTagsError

DomoTags_SetTagsError(dataset_id, res, cls_instance)

Bases: ClassError

return if DatasetTags request is not successfull

Source code in src/crew_dcs/classes/subentity/tags.py
19
20
21
def __init__(self, dataset_id, res, cls_instance):
    message = f"failed to set tags on dataset - {dataset_id}"
    super().__init__(message=message, res=res, cls_instance=cls_instance)