Attributes define the individual fields in your provider's schemas. Pyvider uses factory functions to create attributes with proper typing and validation.
🤖 AI-Generated Content
This documentation was generated with AI assistance and is still being audited. Some, or potentially a lot, of this information may be inaccurate. Learn more.
port=a_num(default=8080,description="Port number",validators=[lambdax:1<=x<=65535or"Port must be between 1 and 65535"])timeout=a_num(default=30.5,description="Timeout in seconds")
# List of stringstags=a_list(a_str(),default=[],description="Resource tags")# List of numbersports=a_list(a_num(),description="Allowed ports")# List of objectsrules=a_list(a_obj({"port":a_num(required=True),"protocol":a_str(required=True),}),description="Firewall rules")
# Map of stringslabels=a_map(a_str(),default={},description="Label key-value pairs")# Map of numbersquotas=a_map(a_num(),description="Resource quotas by type")
# Tuple with specific types for each elementcoordinates=a_tuple([a_num(),a_num()],# [latitude, longitude]description="Geographic coordinates")# Mixed typesmetadata=a_tuple([a_str(),a_num(),a_bool()],# [name, count, active]description="Resource metadata tuple")
api_key=a_str(required=True,sensitive=True,# Value will be maskeddescription="API key for authentication")credentials=a_obj({"username":a_str(required=True),"password":a_str(required=True,sensitive=True),},description="Login credentials")
frompyvider.schemaimporta_str,a_num# Single validatorport=a_num(validators=[lambdax:1<=x<=65535or"Port must be between 1 and 65535"])# Multiple validatorsusername=a_str(required=True,validators=[lambdax:len(x)>=3or"Username must be at least 3 characters",lambdax:x.isalnum()or"Username must be alphanumeric",lambdax:notx.startswith("_")or"Username cannot start with underscore",])# Validators for collectionstags=a_list(a_str(),validators=[lambdax:len(x)<=10or"Maximum 10 tags allowed",lambdax:all(len(tag)<=50fortaginx)or"Tag length must be <= 50 chars",])