> ## Documentation Index
> Fetch the complete documentation index at: https://docs.activeviam.com/llms.txt
> Use this file to discover all available pages before exploring further.

# atoti.Hierarchy.viewers

#### *property* Hierarchy.viewers *: [MutableSet](https://docs.python.org/3/library/collections.abc.html#collections.abc.MutableSet)\[[str](https://docs.python.org/3/library/stdtypes.html#str)]*

[`visible`](./atoti.Hierarchy.visible#atoti.Hierarchy.visible) is True if and only if at least one of the roles of the current user is included in this set.

### Example

* Without security:

  ```pycon theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
  >>> table = session.create_table(
  ...     "Example", data_types={"Product": "String"}
  ... )
  >>> cube = session.create_cube(table)
  >>> hierarchy = cube.hierarchies["Product"]
  ```

  Each hierarchy is visible by default:

  ```pycon theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
  >>> sorted(hierarchy.viewers)
  ['ROLE_ADMIN', 'ROLE_USER']
  >>> hierarchy.visible
  True
  ```

  Hiding the hierarchy from all users:

  ```pycon theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
  >>> hierarchy.viewers.clear()
  >>> hierarchy.viewers
  set()
  >>> hierarchy.visible
  False
  ```
* With security:

  ```pycon theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
  >>> session_config = tt.SessionConfig(security=tt.SecurityConfig())
  >>> secured_session = tt.Session.start(session_config)
  >>> table = secured_session.create_table(
  ...     "Example", data_types={"Product": "String"}
  ... )
  >>> cube = secured_session.create_cube(table)
  >>> hierarchy = cube.hierarchies["Product"]
  ```

  Each hierarchy is visible by default:

  ```pycon theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
  >>> sorted(hierarchy.viewers)
  ['ROLE_ADMIN', 'ROLE_USER']
  >>> hierarchy.visible
  True
  ```

  Setting up a non-admin user:

  ```pycon theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
  >>> authentication = tt.BasicAuthentication("John", "passwd")
  >>> secured_session.security.individual_roles[authentication.username] = {
  ...     "ROLE_USER"
  ... }
  >>> secured_session.security.basic_authentication.credentials[
  ...     authentication.username
  ... ] = authentication.password
  >>> john_session = tt.Session.connect(
  ...     secured_session.url, authentication=authentication
  ... )
  ```

  John has ROLE\_USER which is in [`viewers`](#atoti.Hierarchy.viewers) so the hierarchy is visible to him:

  ```pycon theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
  >>> hierarchy_seen_by_john = john_session.cubes["Example"].hierarchies[
  ...     "Product"
  ... ]
  >>> hierarchy_seen_by_john.visible
  True
  ```

  Making the hierarchy visible to admins only:

  ```pycon theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
  >>> hierarchy.viewers.discard("ROLE_USER")
  >>> "ROLE_USER" in hierarchy.viewers
  False
  >>> hierarchy.viewers
  {'ROLE_ADMIN'}
  >>> hierarchy.visible
  True
  >>> hierarchy_seen_by_john.visible
  False
  ```

  Hiding the hierarchy from all users:

  ```pycon theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
  >>> hierarchy.viewers.clear()
  >>> hierarchy.viewers
  set()
  >>> hierarchy.visible
  False
  >>> hierarchy_seen_by_john.visible
  False
  ```
