aria.ops.definition.credential_type
1# Copyright 2022 VMware, Inc. 2# SPDX-License-Identifier: Apache-2.0 3from abc import ABC 4from collections import OrderedDict 5from typing import Optional 6from typing import Union 7 8from aria.ops.definition.assertions import validate_key 9from aria.ops.definition.exceptions import DuplicateKeyException 10 11 12class CredentialParameter(ABC): 13 def __init__( 14 self, 15 key: str, 16 label: Optional[str] = None, 17 required: bool = True, 18 display_order: int = 0, 19 ): 20 """ 21 :param key: Used to identify the parameter. 22 :param label: Label that is displayed in the VMware Aria Operations UI. Defaults to the key. 23 :param required: True if user is required to provide this parameter. Defaults to True. 24 :param display_order: Determines the order parameters will be displayed in the UI. 25 """ 26 self.key = validate_key(key, "Credential parameter") 27 self.label = label 28 if label is None: 29 self.label = key 30 self.required = required 31 self.display_order = display_order 32 33 def to_json(self) -> dict: 34 return { 35 "key": self.key, 36 "label": self.label, 37 "required": self.required, 38 "password": False, 39 "enum": False, 40 "display_order": self.display_order, 41 } 42 43 44class CredentialIntParameter(CredentialParameter): 45 """ 46 :param key: Used to identify the parameter. 47 :param label: Label that is displayed in the VMware Aria Operations UI. Defaults to the key. 48 :param required: True if user is required to provide this parameter. Defaults to True. 49 :param display_order: Determines the order parameters will be displayed in the UI. 50 """ 51 52 def __init__( 53 self, 54 key: str, 55 label: Optional[str] = None, 56 required: bool = True, 57 display_order: int = 0, 58 ): 59 super().__init__(key, label, required, display_order) 60 61 def to_json(self) -> dict: 62 return super().to_json() | { 63 "type": "integer", 64 } 65 66 67class CredentialStringParameter(CredentialParameter): 68 def __init__( 69 self, 70 key: str, 71 label: Optional[str] = None, 72 required: bool = True, 73 display_order: int = 0, 74 ): 75 """ 76 :param key: Used to identify the parameter. 77 :param label: Label that is displayed in the VMware Aria Operations UI. Defaults to the key. 78 :param required: True if user is required to provide this parameter. Defaults to True. 79 :param display_order: Determines the order parameters will be displayed in the UI. 80 """ 81 super().__init__(key, label, required, display_order) 82 83 def to_json(self) -> dict: 84 return super().to_json() | { 85 "type": "string", 86 } 87 88 89class CredentialPasswordParameter(CredentialParameter): 90 def __init__( 91 self, 92 key: str, 93 label: Optional[str] = None, 94 required: bool = True, 95 display_order: int = 0, 96 ): 97 """ 98 :param key: Used to identify the parameter. 99 :param label: Label that is displayed in the VMware Aria Operations UI. Defaults to the key. 100 :param required: True if user is required to provide this parameter. Defaults to True. 101 :param display_order: Determines the order parameters will be displayed in the UI. 102 """ 103 super().__init__(key, label, required, display_order) 104 105 def to_json(self) -> dict: 106 return super().to_json() | { 107 "type": "string", 108 "password": True, 109 } 110 111 112class CredentialEnumParameter(CredentialParameter): 113 """ 114 :param key: Used to identify the parameter. 115 :param values: An array containing all enum values. If 'default' is specified and not part of this array, it 116 will be added as an additional enum value. Enum values are not localizable. 117 :param label: Label that is displayed in the VMware Aria Operations UI. Defaults to the key. 118 :param default: The default value of the enum. 119 :param required: True if user is required to provide this parameter. Defaults to True. 120 :param display_order: Determines the order parameters will be displayed in the UI. 121 """ 122 123 def __init__( 124 self, 125 key: str, 126 values: list[Union[str, tuple[str, str]]], 127 label: Optional[str] = None, 128 default: Optional[str] = None, 129 required: bool = True, 130 display_order: int = 0, 131 ): 132 super().__init__(key, label, required, display_order) 133 self.values = values 134 self.default = default 135 136 if ( 137 default not in [v[0] if isinstance(v, tuple) else v for v in self.values] 138 and default is not None 139 ): 140 self.values.append((default, default)) 141 142 def to_json(self) -> dict: 143 return super().to_json() | { 144 "type": "string", 145 "default": self.default, 146 "enum": True, 147 "enum_values": [ 148 { 149 "key": str(value[0]) if isinstance(value, tuple) else value, 150 "label": str(value[1]) if isinstance(value, tuple) else value, 151 "display_order": display_order, 152 } 153 for display_order, value in enumerate(self.values) 154 ], 155 } 156 157 158class CredentialType: 159 def __init__(self, key: str, label: Optional[str] = None): 160 self.key = validate_key(key, "Credential type") 161 self.label = label 162 if label is None: 163 self.label = key 164 self.credential_parameters: dict = OrderedDict() 165 166 def define_string_parameter( 167 self, key: str, label: Optional[str] = None, required: bool = True 168 ) -> CredentialStringParameter: 169 """ 170 Create a new string credential parameter and apply it to this credential definition. 171 :param key: Used to identify the parameter. 172 :param label: Label that is displayed in the VMware Aria Operations UI. Defaults to the key. 173 :param required: True if user is required to provide this parameter. Defaults to True. 174 :return The created string parameter definition. 175 """ 176 field = CredentialStringParameter(key, label, required) 177 self.add_parameter(field) 178 return field 179 180 def define_int_parameter( 181 self, key: str, label: Optional[str] = None, required: bool = True 182 ) -> CredentialIntParameter: 183 """ 184 Create a new int credential parameter and apply it to this credential definition. 185 :param key: Used to identify the parameter. 186 :param label: Label that is displayed in the VMware Aria Operations UI. Defaults to the key. 187 :param required: True if user is required to provide this parameter. Defaults to True. 188 :return The created int parameter definition. 189 """ 190 field = CredentialIntParameter(key, label, required) 191 self.add_parameter(field) 192 return field 193 194 def define_password_parameter( 195 self, key: str, label: Optional[str] = None, required: bool = True 196 ) -> CredentialPasswordParameter: 197 """ 198 Create a new password credential parameter and apply it to this credential definition. 199 :param key: Used to identify the parameter. 200 :param label: Label that is displayed in the VMware Aria Operations UI. Defaults to the key. 201 :param required: True if user is required to provide this parameter. Defaults to True. 202 :return The created password parameter definition. 203 """ 204 field = CredentialPasswordParameter(key, label, required) 205 self.add_parameter(field) 206 return field 207 208 def define_enum_parameter( 209 self, 210 key: str, 211 values: list[Union[str, tuple[str, str]]], 212 label: Optional[str] = None, 213 default: Optional[str] = None, 214 required: bool = True, 215 ) -> CredentialEnumParameter: 216 """ 217 Create a new enum credential parameter and apply it to this credential definition. 218 :param key: Used to identify the parameter. 219 :param values: An array containing all enum values. If 'default' is specified and not part of this array, it 220 will be added as an additional enum value. Enum values are not localizable. 221 :param label: Label that is displayed in the VMware Aria Operations UI. Defaults to the key. 222 :param default: The default value of the enum. 223 :param required: True if user is required to provide this parameter. Defaults to True. 224 :return The created enum parameter definition. 225 """ 226 field = CredentialEnumParameter(key, values, label, default, required) 227 self.add_parameter(field) 228 return field 229 230 def add_parameters(self, credential_parameters: list[CredentialParameter]) -> None: 231 """ 232 :param credential_parameters: A list of parameters to add to the credential 233 :return None 234 """ 235 for credential_parameter in credential_parameters: 236 self.add_parameter(credential_parameter) 237 238 def add_parameter(self, credential_parameter: CredentialParameter) -> None: 239 """ 240 :param credential_parameter: The parameter to add to the credential 241 :return None 242 """ 243 key = credential_parameter.key 244 if key in self.credential_parameters: 245 raise DuplicateKeyException( 246 f"Credential field with key {key} already exists in adapter definition." 247 ) 248 credential_parameter.display_order = len(self.credential_parameters) 249 self.credential_parameters[key] = credential_parameter 250 251 def to_json(self) -> dict: 252 return { 253 "key": self.key, 254 "label": self.label, 255 "fields": [ 256 field.to_json() for field in self.credential_parameters.values() 257 ], 258 }
class
CredentialParameter(abc.ABC):
13class CredentialParameter(ABC): 14 def __init__( 15 self, 16 key: str, 17 label: Optional[str] = None, 18 required: bool = True, 19 display_order: int = 0, 20 ): 21 """ 22 :param key: Used to identify the parameter. 23 :param label: Label that is displayed in the VMware Aria Operations UI. Defaults to the key. 24 :param required: True if user is required to provide this parameter. Defaults to True. 25 :param display_order: Determines the order parameters will be displayed in the UI. 26 """ 27 self.key = validate_key(key, "Credential parameter") 28 self.label = label 29 if label is None: 30 self.label = key 31 self.required = required 32 self.display_order = display_order 33 34 def to_json(self) -> dict: 35 return { 36 "key": self.key, 37 "label": self.label, 38 "required": self.required, 39 "password": False, 40 "enum": False, 41 "display_order": self.display_order, 42 }
Helper class that provides a standard way to create an ABC using inheritance.
CredentialParameter( key: str, label: Optional[str] = None, required: bool = True, display_order: int = 0)
14 def __init__( 15 self, 16 key: str, 17 label: Optional[str] = None, 18 required: bool = True, 19 display_order: int = 0, 20 ): 21 """ 22 :param key: Used to identify the parameter. 23 :param label: Label that is displayed in the VMware Aria Operations UI. Defaults to the key. 24 :param required: True if user is required to provide this parameter. Defaults to True. 25 :param display_order: Determines the order parameters will be displayed in the UI. 26 """ 27 self.key = validate_key(key, "Credential parameter") 28 self.label = label 29 if label is None: 30 self.label = key 31 self.required = required 32 self.display_order = display_order
Parameters
- key: Used to identify the parameter.
- label: Label that is displayed in the VMware Aria Operations UI. Defaults to the key.
- required: True if user is required to provide this parameter. Defaults to True.
- display_order: Determines the order parameters will be displayed in the UI.
45class CredentialIntParameter(CredentialParameter): 46 """ 47 :param key: Used to identify the parameter. 48 :param label: Label that is displayed in the VMware Aria Operations UI. Defaults to the key. 49 :param required: True if user is required to provide this parameter. Defaults to True. 50 :param display_order: Determines the order parameters will be displayed in the UI. 51 """ 52 53 def __init__( 54 self, 55 key: str, 56 label: Optional[str] = None, 57 required: bool = True, 58 display_order: int = 0, 59 ): 60 super().__init__(key, label, required, display_order) 61 62 def to_json(self) -> dict: 63 return super().to_json() | { 64 "type": "integer", 65 }
Parameters
- key: Used to identify the parameter.
- label: Label that is displayed in the VMware Aria Operations UI. Defaults to the key.
- required: True if user is required to provide this parameter. Defaults to True.
- display_order: Determines the order parameters will be displayed in the UI.
CredentialIntParameter( key: str, label: Optional[str] = None, required: bool = True, display_order: int = 0)
53 def __init__( 54 self, 55 key: str, 56 label: Optional[str] = None, 57 required: bool = True, 58 display_order: int = 0, 59 ): 60 super().__init__(key, label, required, display_order)
Parameters
- key: Used to identify the parameter.
- label: Label that is displayed in the VMware Aria Operations UI. Defaults to the key.
- required: True if user is required to provide this parameter. Defaults to True.
- display_order: Determines the order parameters will be displayed in the UI.
68class CredentialStringParameter(CredentialParameter): 69 def __init__( 70 self, 71 key: str, 72 label: Optional[str] = None, 73 required: bool = True, 74 display_order: int = 0, 75 ): 76 """ 77 :param key: Used to identify the parameter. 78 :param label: Label that is displayed in the VMware Aria Operations UI. Defaults to the key. 79 :param required: True if user is required to provide this parameter. Defaults to True. 80 :param display_order: Determines the order parameters will be displayed in the UI. 81 """ 82 super().__init__(key, label, required, display_order) 83 84 def to_json(self) -> dict: 85 return super().to_json() | { 86 "type": "string", 87 }
Helper class that provides a standard way to create an ABC using inheritance.
CredentialStringParameter( key: str, label: Optional[str] = None, required: bool = True, display_order: int = 0)
69 def __init__( 70 self, 71 key: str, 72 label: Optional[str] = None, 73 required: bool = True, 74 display_order: int = 0, 75 ): 76 """ 77 :param key: Used to identify the parameter. 78 :param label: Label that is displayed in the VMware Aria Operations UI. Defaults to the key. 79 :param required: True if user is required to provide this parameter. Defaults to True. 80 :param display_order: Determines the order parameters will be displayed in the UI. 81 """ 82 super().__init__(key, label, required, display_order)
Parameters
- key: Used to identify the parameter.
- label: Label that is displayed in the VMware Aria Operations UI. Defaults to the key.
- required: True if user is required to provide this parameter. Defaults to True.
- display_order: Determines the order parameters will be displayed in the UI.
90class CredentialPasswordParameter(CredentialParameter): 91 def __init__( 92 self, 93 key: str, 94 label: Optional[str] = None, 95 required: bool = True, 96 display_order: int = 0, 97 ): 98 """ 99 :param key: Used to identify the parameter. 100 :param label: Label that is displayed in the VMware Aria Operations UI. Defaults to the key. 101 :param required: True if user is required to provide this parameter. Defaults to True. 102 :param display_order: Determines the order parameters will be displayed in the UI. 103 """ 104 super().__init__(key, label, required, display_order) 105 106 def to_json(self) -> dict: 107 return super().to_json() | { 108 "type": "string", 109 "password": True, 110 }
Helper class that provides a standard way to create an ABC using inheritance.
CredentialPasswordParameter( key: str, label: Optional[str] = None, required: bool = True, display_order: int = 0)
91 def __init__( 92 self, 93 key: str, 94 label: Optional[str] = None, 95 required: bool = True, 96 display_order: int = 0, 97 ): 98 """ 99 :param key: Used to identify the parameter. 100 :param label: Label that is displayed in the VMware Aria Operations UI. Defaults to the key. 101 :param required: True if user is required to provide this parameter. Defaults to True. 102 :param display_order: Determines the order parameters will be displayed in the UI. 103 """ 104 super().__init__(key, label, required, display_order)
Parameters
- key: Used to identify the parameter.
- label: Label that is displayed in the VMware Aria Operations UI. Defaults to the key.
- required: True if user is required to provide this parameter. Defaults to True.
- display_order: Determines the order parameters will be displayed in the UI.
113class CredentialEnumParameter(CredentialParameter): 114 """ 115 :param key: Used to identify the parameter. 116 :param values: An array containing all enum values. If 'default' is specified and not part of this array, it 117 will be added as an additional enum value. Enum values are not localizable. 118 :param label: Label that is displayed in the VMware Aria Operations UI. Defaults to the key. 119 :param default: The default value of the enum. 120 :param required: True if user is required to provide this parameter. Defaults to True. 121 :param display_order: Determines the order parameters will be displayed in the UI. 122 """ 123 124 def __init__( 125 self, 126 key: str, 127 values: list[Union[str, tuple[str, str]]], 128 label: Optional[str] = None, 129 default: Optional[str] = None, 130 required: bool = True, 131 display_order: int = 0, 132 ): 133 super().__init__(key, label, required, display_order) 134 self.values = values 135 self.default = default 136 137 if ( 138 default not in [v[0] if isinstance(v, tuple) else v for v in self.values] 139 and default is not None 140 ): 141 self.values.append((default, default)) 142 143 def to_json(self) -> dict: 144 return super().to_json() | { 145 "type": "string", 146 "default": self.default, 147 "enum": True, 148 "enum_values": [ 149 { 150 "key": str(value[0]) if isinstance(value, tuple) else value, 151 "label": str(value[1]) if isinstance(value, tuple) else value, 152 "display_order": display_order, 153 } 154 for display_order, value in enumerate(self.values) 155 ], 156 }
Parameters
- key: Used to identify the parameter.
- values: An array containing all enum values. If 'default' is specified and not part of this array, it will be added as an additional enum value. Enum values are not localizable.
- label: Label that is displayed in the VMware Aria Operations UI. Defaults to the key.
- default: The default value of the enum.
- required: True if user is required to provide this parameter. Defaults to True.
- display_order: Determines the order parameters will be displayed in the UI.
CredentialEnumParameter( key: str, values: list[typing.Union[str, tuple[str, str]]], label: Optional[str] = None, default: Optional[str] = None, required: bool = True, display_order: int = 0)
124 def __init__( 125 self, 126 key: str, 127 values: list[Union[str, tuple[str, str]]], 128 label: Optional[str] = None, 129 default: Optional[str] = None, 130 required: bool = True, 131 display_order: int = 0, 132 ): 133 super().__init__(key, label, required, display_order) 134 self.values = values 135 self.default = default 136 137 if ( 138 default not in [v[0] if isinstance(v, tuple) else v for v in self.values] 139 and default is not None 140 ): 141 self.values.append((default, default))
Parameters
- key: Used to identify the parameter.
- label: Label that is displayed in the VMware Aria Operations UI. Defaults to the key.
- required: True if user is required to provide this parameter. Defaults to True.
- display_order: Determines the order parameters will be displayed in the UI.
def
to_json(self) -> dict:
143 def to_json(self) -> dict: 144 return super().to_json() | { 145 "type": "string", 146 "default": self.default, 147 "enum": True, 148 "enum_values": [ 149 { 150 "key": str(value[0]) if isinstance(value, tuple) else value, 151 "label": str(value[1]) if isinstance(value, tuple) else value, 152 "display_order": display_order, 153 } 154 for display_order, value in enumerate(self.values) 155 ], 156 }
class
CredentialType:
159class CredentialType: 160 def __init__(self, key: str, label: Optional[str] = None): 161 self.key = validate_key(key, "Credential type") 162 self.label = label 163 if label is None: 164 self.label = key 165 self.credential_parameters: dict = OrderedDict() 166 167 def define_string_parameter( 168 self, key: str, label: Optional[str] = None, required: bool = True 169 ) -> CredentialStringParameter: 170 """ 171 Create a new string credential parameter and apply it to this credential definition. 172 :param key: Used to identify the parameter. 173 :param label: Label that is displayed in the VMware Aria Operations UI. Defaults to the key. 174 :param required: True if user is required to provide this parameter. Defaults to True. 175 :return The created string parameter definition. 176 """ 177 field = CredentialStringParameter(key, label, required) 178 self.add_parameter(field) 179 return field 180 181 def define_int_parameter( 182 self, key: str, label: Optional[str] = None, required: bool = True 183 ) -> CredentialIntParameter: 184 """ 185 Create a new int credential parameter and apply it to this credential definition. 186 :param key: Used to identify the parameter. 187 :param label: Label that is displayed in the VMware Aria Operations UI. Defaults to the key. 188 :param required: True if user is required to provide this parameter. Defaults to True. 189 :return The created int parameter definition. 190 """ 191 field = CredentialIntParameter(key, label, required) 192 self.add_parameter(field) 193 return field 194 195 def define_password_parameter( 196 self, key: str, label: Optional[str] = None, required: bool = True 197 ) -> CredentialPasswordParameter: 198 """ 199 Create a new password credential parameter and apply it to this credential definition. 200 :param key: Used to identify the parameter. 201 :param label: Label that is displayed in the VMware Aria Operations UI. Defaults to the key. 202 :param required: True if user is required to provide this parameter. Defaults to True. 203 :return The created password parameter definition. 204 """ 205 field = CredentialPasswordParameter(key, label, required) 206 self.add_parameter(field) 207 return field 208 209 def define_enum_parameter( 210 self, 211 key: str, 212 values: list[Union[str, tuple[str, str]]], 213 label: Optional[str] = None, 214 default: Optional[str] = None, 215 required: bool = True, 216 ) -> CredentialEnumParameter: 217 """ 218 Create a new enum credential parameter and apply it to this credential definition. 219 :param key: Used to identify the parameter. 220 :param values: An array containing all enum values. If 'default' is specified and not part of this array, it 221 will be added as an additional enum value. Enum values are not localizable. 222 :param label: Label that is displayed in the VMware Aria Operations UI. Defaults to the key. 223 :param default: The default value of the enum. 224 :param required: True if user is required to provide this parameter. Defaults to True. 225 :return The created enum parameter definition. 226 """ 227 field = CredentialEnumParameter(key, values, label, default, required) 228 self.add_parameter(field) 229 return field 230 231 def add_parameters(self, credential_parameters: list[CredentialParameter]) -> None: 232 """ 233 :param credential_parameters: A list of parameters to add to the credential 234 :return None 235 """ 236 for credential_parameter in credential_parameters: 237 self.add_parameter(credential_parameter) 238 239 def add_parameter(self, credential_parameter: CredentialParameter) -> None: 240 """ 241 :param credential_parameter: The parameter to add to the credential 242 :return None 243 """ 244 key = credential_parameter.key 245 if key in self.credential_parameters: 246 raise DuplicateKeyException( 247 f"Credential field with key {key} already exists in adapter definition." 248 ) 249 credential_parameter.display_order = len(self.credential_parameters) 250 self.credential_parameters[key] = credential_parameter 251 252 def to_json(self) -> dict: 253 return { 254 "key": self.key, 255 "label": self.label, 256 "fields": [ 257 field.to_json() for field in self.credential_parameters.values() 258 ], 259 }
def
define_string_parameter( self, key: str, label: Optional[str] = None, required: bool = True) -> aria.ops.definition.credential_type.CredentialStringParameter:
167 def define_string_parameter( 168 self, key: str, label: Optional[str] = None, required: bool = True 169 ) -> CredentialStringParameter: 170 """ 171 Create a new string credential parameter and apply it to this credential definition. 172 :param key: Used to identify the parameter. 173 :param label: Label that is displayed in the VMware Aria Operations UI. Defaults to the key. 174 :param required: True if user is required to provide this parameter. Defaults to True. 175 :return The created string parameter definition. 176 """ 177 field = CredentialStringParameter(key, label, required) 178 self.add_parameter(field) 179 return field
Create a new string credential parameter and apply it to this credential definition.
Parameters
- key: Used to identify the parameter.
- label: Label that is displayed in the VMware Aria Operations UI. Defaults to the key.
- required: True if user is required to provide this parameter. Defaults to True. :return The created string parameter definition.
def
define_int_parameter( self, key: str, label: Optional[str] = None, required: bool = True) -> aria.ops.definition.credential_type.CredentialIntParameter:
181 def define_int_parameter( 182 self, key: str, label: Optional[str] = None, required: bool = True 183 ) -> CredentialIntParameter: 184 """ 185 Create a new int credential parameter and apply it to this credential definition. 186 :param key: Used to identify the parameter. 187 :param label: Label that is displayed in the VMware Aria Operations UI. Defaults to the key. 188 :param required: True if user is required to provide this parameter. Defaults to True. 189 :return The created int parameter definition. 190 """ 191 field = CredentialIntParameter(key, label, required) 192 self.add_parameter(field) 193 return field
Create a new int credential parameter and apply it to this credential definition.
Parameters
- key: Used to identify the parameter.
- label: Label that is displayed in the VMware Aria Operations UI. Defaults to the key.
- required: True if user is required to provide this parameter. Defaults to True. :return The created int parameter definition.
def
define_password_parameter( self, key: str, label: Optional[str] = None, required: bool = True) -> aria.ops.definition.credential_type.CredentialPasswordParameter:
195 def define_password_parameter( 196 self, key: str, label: Optional[str] = None, required: bool = True 197 ) -> CredentialPasswordParameter: 198 """ 199 Create a new password credential parameter and apply it to this credential definition. 200 :param key: Used to identify the parameter. 201 :param label: Label that is displayed in the VMware Aria Operations UI. Defaults to the key. 202 :param required: True if user is required to provide this parameter. Defaults to True. 203 :return The created password parameter definition. 204 """ 205 field = CredentialPasswordParameter(key, label, required) 206 self.add_parameter(field) 207 return field
Create a new password credential parameter and apply it to this credential definition.
Parameters
- key: Used to identify the parameter.
- label: Label that is displayed in the VMware Aria Operations UI. Defaults to the key.
- required: True if user is required to provide this parameter. Defaults to True. :return The created password parameter definition.
def
define_enum_parameter( self, key: str, values: list[typing.Union[str, tuple[str, str]]], label: Optional[str] = None, default: Optional[str] = None, required: bool = True) -> aria.ops.definition.credential_type.CredentialEnumParameter:
209 def define_enum_parameter( 210 self, 211 key: str, 212 values: list[Union[str, tuple[str, str]]], 213 label: Optional[str] = None, 214 default: Optional[str] = None, 215 required: bool = True, 216 ) -> CredentialEnumParameter: 217 """ 218 Create a new enum credential parameter and apply it to this credential definition. 219 :param key: Used to identify the parameter. 220 :param values: An array containing all enum values. If 'default' is specified and not part of this array, it 221 will be added as an additional enum value. Enum values are not localizable. 222 :param label: Label that is displayed in the VMware Aria Operations UI. Defaults to the key. 223 :param default: The default value of the enum. 224 :param required: True if user is required to provide this parameter. Defaults to True. 225 :return The created enum parameter definition. 226 """ 227 field = CredentialEnumParameter(key, values, label, default, required) 228 self.add_parameter(field) 229 return field
Create a new enum credential parameter and apply it to this credential definition.
Parameters
- key: Used to identify the parameter.
- values: An array containing all enum values. If 'default' is specified and not part of this array, it will be added as an additional enum value. Enum values are not localizable.
- label: Label that is displayed in the VMware Aria Operations UI. Defaults to the key.
- default: The default value of the enum.
- required: True if user is required to provide this parameter. Defaults to True. :return The created enum parameter definition.
def
add_parameters( self, credential_parameters: list[aria.ops.definition.credential_type.CredentialParameter]) -> None:
231 def add_parameters(self, credential_parameters: list[CredentialParameter]) -> None: 232 """ 233 :param credential_parameters: A list of parameters to add to the credential 234 :return None 235 """ 236 for credential_parameter in credential_parameters: 237 self.add_parameter(credential_parameter)
Parameters
- credential_parameters: A list of parameters to add to the credential :return None
def
add_parameter( self, credential_parameter: aria.ops.definition.credential_type.CredentialParameter) -> None:
239 def add_parameter(self, credential_parameter: CredentialParameter) -> None: 240 """ 241 :param credential_parameter: The parameter to add to the credential 242 :return None 243 """ 244 key = credential_parameter.key 245 if key in self.credential_parameters: 246 raise DuplicateKeyException( 247 f"Credential field with key {key} already exists in adapter definition." 248 ) 249 credential_parameter.display_order = len(self.credential_parameters) 250 self.credential_parameters[key] = credential_parameter
Parameters
- credential_parameter: The parameter to add to the credential :return None