Closed
Description
Component
No response
Infrahub SDK version
1.7.1
Current Behavior
In our SDK, we have some functions
@property
def attribute_names(self) -> list[str]:
return [item.name for item in self.attributes]
@property
def relationship_names(self) -> list[str]:
return [item.name for item in self.relationships]
@property
def mandatory_input_names(self) -> list[str]:
return self.mandatory_attribute_names + self.mandatory_relationship_names
@property
def mandatory_attribute_names(self) -> list[str]:
return [item.name for item in self.attributes if not item.optional and item.default_value is None]
@property
def mandatory_relationship_names(self) -> list[str]:
return [item.name for item in self.relationships if not item.optional]
Those verified if a given attribute is optional and if there is a default_value, but not if the attribute is read_only.
Expected Behavior
I would expect the read_only attribute to not be return as part of the "mandatory_input_names"
Steps to Reproduce
Using the demo-schema and demo-data
Run the script below :
from infrahub_sdk import InfrahubClient, Config
client = InfrahubClient(address="http://localhost:8000", config=Config(api_token="06438eb2-8019-4776-878c-0941b1f1d1ec",timeout=240,default_branch="main"),)
schema = await client.schema.get(kind="InfraDevice")
schema.mandatory_input_names
you should see
['computed_description', 'type', 'name', 'site']
With computed_description
being a computed_attribute, mandatory based on a jinja2
AttributeSchemaAPI(id='18219d74-9f39-653e-2db1-c512aa060fe0', state='present', name='computed_description', kind='Text', label='Computed Description', description='Combine various attributes to provide a human frendly description of this device.', default_value=None, unique=False, branch='aware', optional=False, choices=None, enum=None, max_length=None, min_length=None, regex=None, order_weight=3000, inherited=False, read_only=True, allow_override='any'),
Additional Information
No response