(self, resource, *args, **kwargs)
| 224 | display_attributes = ["name", "value", "scope", "expire_timestamp"] |
| 225 | |
| 226 | def __init__(self, resource, *args, **kwargs): |
| 227 | super(KeyValuePairSetCommand, self).__init__( |
| 228 | resource, |
| 229 | "set", |
| 230 | "Set an existing %s." % resource.get_display_name().lower(), |
| 231 | *args, |
| 232 | **kwargs, |
| 233 | ) |
| 234 | |
| 235 | # --encrypt and --encrypted options are mutually exclusive. |
| 236 | # --encrypt implies provided value is plain text and should be encrypted whereas |
| 237 | # --encrypted implies value is already encrypted and should be treated as-is. |
| 238 | encryption_group = self.parser.add_mutually_exclusive_group() |
| 239 | encryption_group.add_argument( |
| 240 | "-e", |
| 241 | "--encrypt", |
| 242 | dest="secret", |
| 243 | action="store_true", |
| 244 | help="Encrypt value before saving.", |
| 245 | ) |
| 246 | encryption_group.add_argument( |
| 247 | "--encrypted", |
| 248 | dest="encrypted", |
| 249 | action="store_true", |
| 250 | help=( |
| 251 | "Value provided is already encrypted with the " |
| 252 | "instance crypto key and should be stored as-is." |
| 253 | ), |
| 254 | ) |
| 255 | |
| 256 | self.parser.add_argument( |
| 257 | "name", metavar="name", help="Name of the key value pair." |
| 258 | ) |
| 259 | self.parser.add_argument("value", help="Value paired with the key.", nargs="?") |
| 260 | self.parser.add_argument( |
| 261 | "-l", |
| 262 | "--ttl", |
| 263 | dest="ttl", |
| 264 | type=int, |
| 265 | default=None, |
| 266 | help="TTL (in seconds) for this value.", |
| 267 | ) |
| 268 | self.parser.add_argument( |
| 269 | "-s", |
| 270 | "--scope", |
| 271 | dest="scope", |
| 272 | default=DEFAULT_CUD_SCOPE, |
| 273 | help="Specify the scope under which you want " + "to place the item.", |
| 274 | ) |
| 275 | self.parser.add_argument( |
| 276 | "-u", |
| 277 | "--user", |
| 278 | dest="user", |
| 279 | default=None, |
| 280 | help="User for user scoped items (admin only).", |
| 281 | ) |
| 282 | |
| 283 | @resource.add_auth_token_to_kwargs_from_cli |
nothing calls this directly
no test coverage detected