id#

State module for generating ids

idem_random.states.random.id.present(hub, ctx, name: str, length: int, resource_id: str = None, keepers: Dict[str, Any] = None, prefix: str = None) Dict[str, Any][source]#

This is a logical state and doesn’t interact with any cloud providers. This state can be used in conjunction with any other state to generate random id with the provided configurations. State’s configuration data is stored in esm. If for a given state, the configuration changes, a new random id is generated. If there are no configuration changes, then the old id is retained.

The generated id is alphanumeric, starting with a letter.

Parameters:
  • name (str) – An Idem name of the resource.

  • length (int) – The number of random characters to produce.

  • resource_id (str, Optional) – Unique random Id

  • keepers (dict, Optional) – A list of arbitrary map of values that, when changed, will trigger recreation of resource.

  • prefix (str, Optional) – Arbitrary string to prefix the output value with. This string is supplied as-is, meaning it is not guaranteed to be URL-safe or base64 encoded.

Request Syntax:

[random_id_state]:
  random.id.present:
    - name: 'string'
    - length: 'int'
    - keepers:
        'string': 'string'
    - prefix: 'string'
Returns:

Dict[str, Any]

Example:

random_passwd_state:
  random.id.present:
    - name: random_id
    - length: 2
    - keepers:
        name: random_id
    - prefix: random_prefix
idem_random.states.random.id.absent(hub, ctx, name: str) Dict[str, Any][source]#

This logical state is used to invalidate/delete the id.

Parameters:

name (str) – An Idem name of the resource.

Request Syntax:

[random_id_state]:
  random.id.absent:
    - name: 'string'
Returns:

Dict[str, Any]

Example:

random_state01011:
  random.id.absent:
    - name: rs01011