From 7cc3b5a7c907b53e23b8e67785674fa8c31639ef Mon Sep 17 00:00:00 2001 From: dosas Date: Thu, 22 Aug 2024 13:58:17 +0200 Subject: [PATCH] Add AnsibleVariable to entities --- nailgun/entities.py | 41 +++++++++++++++++++++++++++++++++++++++++ tests/test_entities.py | 1 + 2 files changed, 42 insertions(+) diff --git a/nailgun/entities.py b/nailgun/entities.py index c49b51cf..56598f53 100644 --- a/nailgun/entities.py +++ b/nailgun/entities.py @@ -9146,6 +9146,47 @@ def sync(self, synchronous=True, timeout=None, **kwargs): return _handle_response(response, self._server_config, synchronous, timeout) +class AnsibleVariable( + Entity, + EntityCreateMixin, + EntityReadMixin, + EntityDeleteMixin, + EntitySearchMixin, + EntityUpdateMixin, +): + """A representation of a Ansible Variable entity.""" + + def __init__(self, server_config=None, **kwargs): + self._fields = { + 'variable': entity_fields.StringField(required=True), + 'ansible_role_id': entity_fields.IntegerField(required=True), + 'default_value': entity_fields.StringField(), + 'override_value_order': entity_fields.StringField(), + 'description': entity_fields.StringField(), + 'validator_type': entity_fields.ListField(), + 'validator_rule': entity_fields.StringField(), + 'variable_type': entity_fields.StringField( + default='string', + choices=( + 'string', + 'boolean', + 'integer', + 'real', + 'array', + 'hash', + 'yaml', + 'json', + ), + ), + 'merge_overrides': entity_fields.BooleanField(), + 'merge_default': entity_fields.BooleanField(), + 'avoid_duplicates': entity_fields.BooleanField(), + 'override': entity_fields.BooleanField(), + } + self._meta = {'api_path': 'ansible/api/ansible_variables'} + super().__init__(server_config=server_config, **kwargs) + + class TablePreferences( Entity, EntityCreateMixin, diff --git a/tests/test_entities.py b/tests/test_entities.py index 8cebd9c3..81048c2b 100644 --- a/tests/test_entities.py +++ b/tests/test_entities.py @@ -93,6 +93,7 @@ def test_init_succeeds(self): entities.ActivationKey, entities.AlternateContentSource, entities.AnsibleRoles, + entities.AnsibleVariable, entities.AnsiblePlaybooks, entities.Architecture, entities.ArfReport,