otupy.profiles.ctxd.args.Args
- class Args(*args, **kwargs)
Bases:
ArgsCTXD Args
This class extends the Args defined in the Language Specification. The extension mechanism is described in the [Developing extensions](https://github.com/mattereppe/otupy/blob/main/docs/developingextensions.md#developing-extensions) Section of the main documentation.
- Parameters:
name_only – Set to True to get only service name, False (default) to get full details.
cached – Set to True to speed up the answer by returning cached results, False (default) to update services before returning the response.
Methods
D.clear() -> None.
D.copy() -> a shallow copy of D
Builds instance from dictionary
Create a new dictionary with keys from iterable and values set to value.
Return the value for key if key is in the dictionary, else default.
D.items() -> a set-like object providing a view on D's items
D.keys() -> a set-like object providing a view on D's keys
Make this class recursive
D.pop(k[,d]) -> v, remove specified key and return the corresponding value.
Remove and return a (key, value) pair as a 2-tuple.
Insert key with a value of default if key is not in the dictionary.
Converts to dictionary
D.update([E, ]**F) -> None.
Check whether field names are valid
D.values() -> an object providing a view on D's values
Attributes
Allowed arguments
nsidRegistered extensions
- __init__(*args, **kwargs)
Create and validate objects
Store the map and convert the fields to appropriate types, whenever possible. It accepts both plain dictionaries (as first arguments) and keyword arguments (last elements) and automatically merges them. Keyword arguments take precedence over non-keyword arguments.
- Parameters:
args – One or more dictionaries or maps used to initialize this object.
kwargs – keyword arguments used to initialize this object.
- clear() None. Remove all items from D.
- copy() a shallow copy of D
- fieldtypes: dict = {'cached': <class 'bool'>, 'duration': <class 'otupy.types.data.duration.Duration'>, 'name_only': <class 'bool'>, 'response_requested': <aenum 'ResponseType'>, 'start_time': <class 'otupy.types.data.datetime.DateTime'>, 'stop_time': <class 'otupy.types.data.datetime.DateTime'>}
Allowed arguments
This is a list of allowed keys and corresponding argument types (classes). The keys and types are set according to the Language Specification. This argument defines the syntax for the base Map that builds the Args type. There is (currently) no controls on input data; this argument is only used to instantiate the Args object from an OpenC2 Message.
- classmethod fromdict(dic, e)
Builds instance from dictionary
It is used during deserialization to create an otupy instance from the text message. It takes an
Encoderinstance that is used to recursively build instances of the inner objects (theEncoderprovides standard methods to create instances of base objects like strings, integers, boolean).- Parameters:
dic – The intermediary dictionary representation from which the object is built.
e – The
Encoderthat is being used.
- Returns:
An instance of this class initialized from the dictionary values.
- classmethod fromkeys(iterable, value=None, /)
Create a new dictionary with keys from iterable and values set to value.
- get(key, default=None, /)
Return the value for key if key is in the dictionary, else default.
- items() a set-like object providing a view on D's items
- keys() a set-like object providing a view on D's keys
- static make_recursive(cls)
Make this class recursive
This method can be used as a decorator to make a Map-derived class recurive, namely to hold objects of the same type in fieldtypes. To use this function, just declare the field that must be of the same type as the class as typing.Self, and use the @make_recursive decorator at declaration time.
- Param:
No arguments must be specified when using this method as a decorator.
- Returns:
A new instance of the class, where all types in fieldtypes marked as typing.Self are replaced with the class instance.
- pop(k[, d]) v, remove specified key and return the corresponding value.
If the key is not found, return the default if given; otherwise, raise a KeyError.
- popitem()
Remove and return a (key, value) pair as a 2-tuple.
Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty.
- register = {'slpf': <class 'otupy.profiles.slpf.args.Args'>, 'x-ctxd': <class 'otupy.profiles.ctxd.args.Args'>}
Registered extensions
Classes that implement a Data Type defined in the Language Specification will use this field to register extensions defined by external Profiles. Classes that define extensions within Profiles shall register themselves according to the specific documentation of the base type class, but shall not modify this field.
- setdefault(key, default=None, /)
Insert key with a value of default if key is not in the dictionary.
Return the value for key if key is in the dictionary, else default.
- todict(e)
Converts to dictionary
It is used to convert this object to an intermediary representation during serialization. It takes an
Encoderargument that is used to recursively serialize inner data and structures (theEncoderprovides standard methods for converting base types to dictionaries)..- Parameters:
e – The
Encoderthat is being used.- Returns:
A dictionary compliants to the Language Specification’s serialization rules.
- update([E, ]**F) None. Update D from dict/iterable E and F.
If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
- validate_fields(min_num=1)
Check whether field names are valid
Check if supplied field names are compliant with the fieldtypes list. Only check the name and number of fields, but does not perform any type checking.
- Parameters:
min_num – Check that at list min_num fields are supplied (usually, at least 1 field must be supplied to create a valid object). Default to 1.
- Returns:
True if validity check is passed, raise a ValueError exception otherwise.
- values() an object providing a view on D's values