Skip to content

brandkit

brandkit

DomoInstanceConfig Brand Kit Management

This module provides a unified interface for managing brand kit configurations in Domo, including custom color palettes and active palette settings.

BrandKit_InstantiationError

BrandKit_InstantiationError(
    auth: DomoAuth, message: str, cls=None
)

Bases: ClassError

Exception raised when brand kit instantiation fails.

Source code in src/crew_dcs/classes/DomoInstanceConfig/brandkit.py
37
38
39
40
41
42
def __init__(self, auth: DomoAuth, message: str, cls=None):
    super().__init__(
        domo_instance=auth.domo_instance,
        message=message,
        cls=cls or self.__class__,
    )

ColorPalette dataclass

ColorPalette(
    name: str = "Custom Color Palette",
    palette_id: str | None = None,
    settings: ColorPaletteSettings = ColorPaletteSettings(),
    color_ranges: list[ColorRange] = list(),
    color_rules: list[ColorRule] = list(),
    selector: list[list[list[int]]] = list(),
    gradients: list[Gradient] = list(),
    line_colors: list[list[int]] = list(),
    pop_colors: list[list[int]] = list(),
    pop_var_line_colors: list[list[int]] = list(),
    pop_var_colors: list[list[int]] = list(),
    pop_line_colors: list[list[int]] = list(),
    name_color_map: dict[str, list[int]] = dict(),
)

Bases: DomoBase

Complete color palette composition with all components.

Attributes:

Name Type Description
name str

Palette name

palette_id str | None

Unique identifier (populated after creation)

settings ColorPaletteSettings

Color palette settings

color_ranges list[ColorRange]

List of color ranges

color_rules list[ColorRule]

List of color rules

selector list[list[list[int]]]

Selector configuration

gradients list[Gradient]

List of gradient configurations

line_colors list[list[int]]

Line color references

pop_colors list[list[int]]

Period-over-period colors

pop_var_line_colors list[list[int]]

PoP variance line colors

pop_var_colors list[list[int]]

PoP variance colors

pop_line_colors list[list[int]]

PoP line colors

name_color_map dict[str, list[int]]

Named color mappings for specific chart elements

from_dict classmethod

from_dict(
    obj: dict[str, Any], name: str = "Custom Color Palette"
) -> ColorPalette

Create ColorPalette from dictionary.

Parameters:

Name Type Description Default
obj dict[str, Any]

Dictionary containing palette configuration

required
name str

Palette name

'Custom Color Palette'

Returns:

Type Description
ColorPalette

ColorPalette instance

Source code in src/crew_dcs/classes/DomoInstanceConfig/brandkit.py
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
@classmethod
def from_dict(
    cls, obj: dict[str, Any], name: str = "Custom Color Palette"
) -> "ColorPalette":
    """Create ColorPalette from dictionary.

    Args:
        obj: Dictionary containing palette configuration
        name: Palette name

    Returns:
        ColorPalette instance
    """
    return cls(
        name=name,
        palette_id=obj.get("id"),
        settings=ColorPaletteSettings.from_dict(obj.get("settings", {})),
        color_ranges=[
            ColorRange.from_dict(cr) for cr in obj.get("colorRanges", [])
        ],
        color_rules=[
            ColorRule.from_dict(rule) for rule in obj.get("colorRules", [])
        ],
        selector=obj.get("selector", []),
        gradients=[Gradient.from_dict(g) for g in obj.get("gradients", [])],
        line_colors=obj.get("lineColors", []),
        pop_colors=obj.get("popColors", []),
        pop_var_line_colors=obj.get("popVarLineColors", []),
        pop_var_colors=obj.get("popVarColors", []),
        pop_line_colors=obj.get("popLineColors", []),
        name_color_map=obj.get("nameColorMap", {}),
    )

to_dict

to_dict() -> dict[str, Any]

Convert to dictionary for API payload.

Source code in src/crew_dcs/classes/DomoInstanceConfig/brandkit.py
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
def to_dict(self) -> dict[str, Any]:
    """Convert to dictionary for API payload."""
    return {
        "settings": self.settings.to_dict(),
        "colorRanges": [cr.to_dict() for cr in self.color_ranges],
        "colorRules": [rule.to_dict() for rule in self.color_rules],
        "selector": self.selector,
        "gradients": [g.to_dict() for g in self.gradients],
        "lineColors": self.line_colors,
        "popColors": self.pop_colors,
        "popVarLineColors": self.pop_var_line_colors,
        "popVarColors": self.pop_var_colors,
        "popLineColors": self.pop_line_colors,
        "nameColorMap": self.name_color_map,
    }

ColorPaletteSettings dataclass

ColorPaletteSettings(
    selection_method_pop: str = "manual",
    color_mode: str = "oklab",
    selection_method: str = "manual",
    pairing_options: dict[str, Any] = (
        lambda: {"colorCount": 2}
    )(),
    pairing_options_pop: dict[str, Any] = (
        lambda: {"colorCount": 3}
    )(),
    lightness_range: list[int] = (lambda: [30, 95])(),
)

Bases: DomoBase

Settings for color palette generation and behavior.

Attributes:

Name Type Description
selection_method_pop str

Selection method for period-over-period colors

color_mode str

Color interpolation mode (e.g., "oklab")

selection_method str

Primary color selection method

pairing_options dict[str, Any]

Options for color pairing

pairing_options_pop dict[str, Any]

PoP pairing options

lightness_range list[int]

Range for lightness values [min, max]

from_dict classmethod

from_dict(obj: dict[str, Any]) -> ColorPaletteSettings

Create ColorPaletteSettings from dictionary.

Source code in src/crew_dcs/classes/DomoInstanceConfig/brandkit.py
198
199
200
201
202
203
204
205
206
207
208
@classmethod
def from_dict(cls, obj: dict[str, Any]) -> "ColorPaletteSettings":
    """Create ColorPaletteSettings from dictionary."""
    return cls(
        selection_method_pop=obj.get("selectionMethodPoP", "manual"),
        color_mode=obj.get("colorMode", "oklab"),
        selection_method=obj.get("selectionMethod", "manual"),
        pairing_options=obj.get("pairingOptions", {"colorCount": 2}),
        pairing_options_pop=obj.get("pairingOptionsPoP", {"colorCount": 3}),
        lightness_range=obj.get("lightnessRange", [30, 95]),
    )

to_dict

to_dict() -> dict[str, Any]

Convert to dictionary for API payload.

Source code in src/crew_dcs/classes/DomoInstanceConfig/brandkit.py
187
188
189
190
191
192
193
194
195
196
def to_dict(self) -> dict[str, Any]:
    """Convert to dictionary for API payload."""
    return {
        "selectionMethodPoP": self.selection_method_pop,
        "colorMode": self.color_mode,
        "selectionMethod": self.selection_method,
        "pairingOptions": self.pairing_options,
        "pairingOptionsPoP": self.pairing_options_pop,
        "lightnessRange": self.lightness_range,
    }

ColorRange dataclass

ColorRange(
    name: str,
    values: list[str] = list(),
    key_colors: list[KeyColor] = list(),
)

Bases: DomoBase

Represents a color range in the palette.

Attributes:

Name Type Description
name str

Name of the color range (e.g., "AcmeBlue-0")

values list[str]

List of hex color values

key_colors list[KeyColor]

List of key colors defining the range

from_dict classmethod

from_dict(obj: dict[str, Any]) -> ColorRange

Create ColorRange from dictionary.

Source code in src/crew_dcs/classes/DomoInstanceConfig/brandkit.py
107
108
109
110
111
112
113
114
@classmethod
def from_dict(cls, obj: dict[str, Any]) -> "ColorRange":
    """Create ColorRange from dictionary."""
    return cls(
        name=obj.get("name", ""),
        values=obj.get("values", []),
        key_colors=[KeyColor.from_dict(kc) for kc in obj.get("keyColors", [])],
    )

to_dict

to_dict() -> dict[str, Any]

Convert to dictionary for API payload.

Source code in src/crew_dcs/classes/DomoInstanceConfig/brandkit.py
 99
100
101
102
103
104
105
def to_dict(self) -> dict[str, Any]:
    """Convert to dictionary for API payload."""
    return {
        "name": self.name,
        "values": self.values,
        "keyColors": [kc.to_dict() for kc in self.key_colors],
    }

ColorRule dataclass

ColorRule(
    min: int, max: int, values: list[list[int]] = list()
)

Bases: DomoBase

Represents a color rule defining which colors to use for specific counts.

Attributes:

Name Type Description
min int

Minimum number of colors

max int

Maximum number of colors

values list[list[int]]

List of color references as [range_index, color_index] pairs

from_dict classmethod

from_dict(obj: dict[str, Any]) -> ColorRule

Create ColorRule from dictionary.

Source code in src/crew_dcs/classes/DomoInstanceConfig/brandkit.py
135
136
137
138
139
140
@classmethod
def from_dict(cls, obj: dict[str, Any]) -> "ColorRule":
    """Create ColorRule from dictionary."""
    return cls(
        min=obj.get("min", 0), max=obj.get("max", 0), values=obj.get("values", [])
    )

to_dict

to_dict() -> dict[str, Any]

Convert to dictionary for API payload.

Source code in src/crew_dcs/classes/DomoInstanceConfig/brandkit.py
131
132
133
def to_dict(self) -> dict[str, Any]:
    """Convert to dictionary for API payload."""
    return {"min": self.min, "max": self.max, "values": self.values}

DomoBrandKit dataclass

DomoBrandKit(
    auth: DomoAuth,
    active_palette_id: str | None = None,
    active_palette_type: str = "CUSTOMER",
    palettes: dict[str, ColorPalette] = dict(),
)

Bases: DomoBase

Manages brand kit configurations in Domo.

This class provides methods to create, retrieve, and manage custom color palettes and set active palettes for the instance.

Note: Unlike most Domo entities, brand kit represents instance-level configuration and palette management.

Attributes:

Name Type Description
auth DomoAuth

Authentication object for API requests

active_palette_id str | None

ID of the currently active palette

active_palette_type str

Type of active palette (e.g., "CUSTOMER")

palettes dict[str, ColorPalette]

Cache of retrieved color palettes

display_url property

display_url: str

Return the URL to the brand kit configuration page in Domo.

clear_cache

clear_cache()

Clear the palette cache.

Source code in src/crew_dcs/classes/DomoInstanceConfig/brandkit.py
564
565
566
def clear_cache(self):
    """Clear the palette cache."""
    self.palettes.clear()

create_color_palette async

create_color_palette(
    palette: ColorPalette,
    debug_api: bool = False,
    session: AsyncClient | None = None,
    return_raw: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
) -> ColorPalette | dict[str, Any]

Create a custom color palette.

Parameters:

Name Type Description Default
palette ColorPalette

ColorPalette object with complete configuration

required
debug_api bool

Enable debug output

False
session AsyncClient | None

Optional httpx session

None
return_raw bool

Return raw response without processing

False
context RouteContext | None

Optional RouteContext for API call configuration

None

Returns:

Type Description
ColorPalette | dict[str, Any]

ColorPalette instance with populated palette_id, or raw response if return_raw=True

Raises:

Type Description
BrandKit_CRUD_Error

If palette creation fails

Calls route

Source code in src/crew_dcs/classes/DomoInstanceConfig/brandkit.py
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
async def create_color_palette(
    self,
    palette: ColorPalette,
    debug_api: bool = False,
    session: httpx.AsyncClient | None = None,
    return_raw: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
) -> ColorPalette | dict[str, Any]:
    """Create a custom color palette.

    Args:
        palette: ColorPalette object with complete configuration
        debug_api: Enable debug output
        session: Optional httpx session
        return_raw: Return raw response without processing
        context: Optional RouteContext for API call configuration

    Returns:
        ColorPalette instance with populated palette_id, or raw response if return_raw=True

    Raises:
        BrandKit_CRUD_Error: If palette creation fails
    """
    base_context = RouteContext.build_context(
        session=session,
        debug_api=debug_api,
        parent_class=self.__class__.__name__,
        **context_kwargs,
    )
    context = RouteContext.build_context(context=context or base_context)

    res = await brandkit_routes.create_color_palette(
        auth=self.auth,
        name=palette.name,
        palette_config=palette.to_dict(),
        context=context,
        return_raw=return_raw,
    )

    if return_raw:
        return res

    # Update palette with returned ID
    palette.palette_id = res.response.get("id")

    # Cache the palette
    if palette.palette_id:
        self.palettes[palette.palette_id] = palette

    return palette

get async

get(
    page_size: int = 50,
    debug_api: bool = False,
    session: AsyncClient | None = None,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
) -> DomoBrandKit

Fill in the instance's color palettes.

Replaces palettes with the palettes the instance currently holds, keyed by palette ID, paging through list_color_palettes until a short page. active_palette_id is left as is: crew-dcs has no route that reads the active palette. The route is assumed to return a bare list (unverified against a live instance; the Postman register lists a different path, /chartColorPalettes/all, that no route covers).

Parameters:

Name Type Description Default
page_size int

Palettes requested per call

50
debug_api bool

Enable debug output

False
session AsyncClient | None

Optional httpx session

None
context RouteContext | None

Optional RouteContext for API call configuration

None

Returns:

Type Description
DomoBrandKit

This DomoBrandKit, with palettes refreshed.

Raises:

Type Description
BrandKit_GET_Error

If palette listing fails or returns a non-list body

Calls route

Source code in src/crew_dcs/classes/DomoInstanceConfig/brandkit.py
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
async def get(
    self,
    page_size: int = 50,
    debug_api: bool = False,
    session: httpx.AsyncClient | None = None,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
) -> "DomoBrandKit":
    """Fill in the instance's color palettes.

    Replaces ``palettes`` with the palettes the instance currently holds, keyed
    by palette ID, paging through ``list_color_palettes`` until a short page.
    ``active_palette_id`` is left as is: crew-dcs has no route that reads the
    active palette. The route is assumed to return a bare list (unverified
    against a live instance; the Postman register lists a different path,
    ``/chartColorPalettes/all``, that no route covers).

    Args:
        page_size: Palettes requested per call
        debug_api: Enable debug output
        session: Optional httpx session
        context: Optional RouteContext for API call configuration

    Returns:
        This DomoBrandKit, with ``palettes`` refreshed.

    Raises:
        BrandKit_GET_Error: If palette listing fails or returns a non-list body
    """
    base_context = RouteContext.build_context(
        session=session,
        debug_api=debug_api,
        parent_class=self.__class__.__name__,
        **context_kwargs,
    )
    context = RouteContext.build_context(context=context or base_context)

    palettes: dict[str, ColorPalette] = {}
    offset = 0
    while True:
        res = await brandkit_routes.list_color_palettes(
            auth=self.auth,
            limit=page_size,
            offset=offset,
            context=context,
        )
        if not isinstance(res.response, list):
            raise brandkit_routes.BrandKit_GET_Error(
                res=res,
                message=(
                    "Expected a list of color palettes, got "
                    f"{type(res.response).__name__}"
                ),
            )
        for obj in res.response:
            palettes[obj["id"]] = ColorPalette.from_dict(
                obj, name=obj.get("name", "Palette")
            )
        if len(res.response) < page_size:
            break
        offset += page_size

    self.palettes = palettes

    return self

get_palette_by_id async

get_palette_by_id(
    palette_id: str,
    use_cache: bool = True,
    debug_api: bool = False,
    session: AsyncClient | None = None,
    return_raw: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
) -> ColorPalette | dict[str, Any]

Get a color palette by ID.

Parameters:

Name Type Description Default
palette_id str

Unique identifier for the palette

required
use_cache bool

Check cache before making API call

True
debug_api bool

Enable debug output

False
session AsyncClient | None

Optional httpx session

None
return_raw bool

Return raw response without processing

False
context RouteContext | None

Optional RouteContext for API call configuration

None

Returns:

Type Description
ColorPalette | dict[str, Any]

ColorPalette instance or raw response if return_raw=True

Raises:

Type Description
BrandKit_GET_Error

If palette retrieval fails

Calls route

Source code in src/crew_dcs/classes/DomoInstanceConfig/brandkit.py
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
async def get_palette_by_id(
    self,
    palette_id: str,
    use_cache: bool = True,
    debug_api: bool = False,
    session: httpx.AsyncClient | None = None,
    return_raw: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
) -> ColorPalette | dict[str, Any]:
    """Get a color palette by ID.

    Args:
        palette_id: Unique identifier for the palette
        use_cache: Check cache before making API call
        debug_api: Enable debug output
        session: Optional httpx session
        return_raw: Return raw response without processing
        context: Optional RouteContext for API call configuration

    Returns:
        ColorPalette instance or raw response if return_raw=True

    Raises:
        BrandKit_GET_Error: If palette retrieval fails
    """
    # Check cache first
    if use_cache and palette_id in self.palettes:
        return self.palettes[palette_id]

    base_context = RouteContext.build_context(
        session=session,
        debug_api=debug_api,
        parent_class=self.__class__.__name__,
        **context_kwargs,
    )
    context = RouteContext.build_context(context=context or base_context)

    res = await brandkit_routes.get_color_palette_by_id(
        auth=self.auth,
        palette_id=palette_id,
        context=context,
        return_raw=return_raw,
    )

    if return_raw:
        return res

    # Parse palette from response
    palette = ColorPalette.from_dict(
        res.response, name=res.response.get("name", "Retrieved Palette")
    )

    # Cache the palette
    self.palettes[palette_id] = palette

    return palette

set_active_palette async

set_active_palette(
    palette_id: str | None = None,
    palette: ColorPalette | None = None,
    palette_type: str = "CUSTOMER",
    debug_api: bool = False,
    session: AsyncClient | None = None,
    return_raw: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
) -> dict[str, Any]

Set a color palette as the active default for the instance.

Parameters:

Name Type Description Default
palette_id str | None

ID of palette to set as active (provide either this or palette)

None
palette ColorPalette | None

ColorPalette object (will use its palette_id)

None
palette_type str

Type of palette (default: "CUSTOMER")

'CUSTOMER'
debug_api bool

Enable debug output

False
session AsyncClient | None

Optional httpx session

None
return_raw bool

Return raw response without processing

False
context RouteContext | None

Optional RouteContext for API call configuration

None

Returns:

Type Description
dict[str, Any]

Response indicating success/failure

Raises:

Type Description
ValueError

If neither palette_id nor palette is provided

BrandKit_CRUD_Error

If setting active palette fails

Calls route

Source code in src/crew_dcs/classes/DomoInstanceConfig/brandkit.py
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
async def set_active_palette(
    self,
    palette_id: str | None = None,
    palette: ColorPalette | None = None,
    palette_type: str = "CUSTOMER",
    debug_api: bool = False,
    session: httpx.AsyncClient | None = None,
    return_raw: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
) -> dict[str, Any]:
    """Set a color palette as the active default for the instance.

    Args:
        palette_id: ID of palette to set as active (provide either this or palette)
        palette: ColorPalette object (will use its palette_id)
        palette_type: Type of palette (default: "CUSTOMER")
        debug_api: Enable debug output
        session: Optional httpx session
        return_raw: Return raw response without processing
        context: Optional RouteContext for API call configuration

    Returns:
        Response indicating success/failure

    Raises:
        ValueError: If neither palette_id nor palette is provided
        BrandKit_CRUD_Error: If setting active palette fails
    """
    base_context = RouteContext.build_context(
        session=session,
        debug_api=debug_api,
        parent_class=self.__class__.__name__,
        **context_kwargs,
    )
    context = RouteContext.build_context(context=context or base_context)

    # Determine palette_id from arguments
    if palette:
        if not palette.palette_id:
            raise ValueError("Palette must have a palette_id")
        palette_id = palette.palette_id
    elif not palette_id:
        raise ValueError("Must provide either palette_id or palette")

    res = await brandkit_routes.set_active_color_palette(
        auth=self.auth,
        palette_id=palette_id,
        palette_type=palette_type,
        context=context,
        return_raw=return_raw,
    )

    if return_raw:
        return res

    # Update local state
    self.active_palette_id = palette_id
    self.active_palette_type = palette_type

    return res

Gradient dataclass

Gradient(col_count: int, values: list[list[int]] = list())

Bases: DomoBase

Represents a gradient configuration.

Attributes:

Name Type Description
col_count int

Number of colors in the gradient

values list[list[int]]

List of color references as [range_index, color_index] pairs

from_dict classmethod

from_dict(obj: dict[str, Any]) -> Gradient

Create Gradient from dictionary.

Source code in src/crew_dcs/classes/DomoInstanceConfig/brandkit.py
159
160
161
162
@classmethod
def from_dict(cls, obj: dict[str, Any]) -> "Gradient":
    """Create Gradient from dictionary."""
    return cls(col_count=obj.get("colCount", 0), values=obj.get("values", []))

to_dict

to_dict() -> dict[str, Any]

Convert to dictionary for API payload.

Source code in src/crew_dcs/classes/DomoInstanceConfig/brandkit.py
155
156
157
def to_dict(self) -> dict[str, Any]:
    """Convert to dictionary for API payload."""
    return {"colCount": self.col_count, "values": self.values}

KeyColor dataclass

KeyColor(
    color: str,
    step_value: int | None = None,
    locked: bool = False,
    base: bool = False,
    index: int = 0,
)

Bases: DomoBase

Represents a key color in a color range.

Attributes:

Name Type Description
color str

Hex color code (e.g., "#E7F3FB")

step_value int | None

Step value for the color (e.g., 50, 500)

locked bool

Whether the color is locked

base bool

Whether this is a base color

index int

Index in the color range

from_dict classmethod

from_dict(obj: dict[str, Any]) -> KeyColor

Create KeyColor from dictionary.

Source code in src/crew_dcs/classes/DomoInstanceConfig/brandkit.py
73
74
75
76
77
78
79
80
81
82
@classmethod
def from_dict(cls, obj: dict[str, Any]) -> "KeyColor":
    """Create KeyColor from dictionary."""
    return cls(
        color=obj.get("color", ""),
        step_value=obj.get("stepValue"),
        locked=obj.get("locked", "false").lower() == "true",
        base=obj.get("base", "false").lower() == "true",
        index=obj.get("index", 0),
    )

to_dict

to_dict() -> dict[str, Any]

Convert to dictionary for API payload.

Source code in src/crew_dcs/classes/DomoInstanceConfig/brandkit.py
63
64
65
66
67
68
69
70
71
def to_dict(self) -> dict[str, Any]:
    """Convert to dictionary for API payload."""
    return {
        "color": self.color,
        "stepValue": self.step_value,
        "locked": str(self.locked).lower(),
        "base": str(self.base).lower(),
        "index": self.index,
    }