pulp_glue.common.context¶
PluginRequirement
¶
PluginRequirement(
name: str,
min: t.Optional[str] = None,
max: t.Optional[str] = None,
feature: t.Optional[str] = None,
inverted: bool = False,
specifier: t.Optional[
t.Union[str, SpecifierSet]
] = None,
)
A class to represent a Pulp plugin with a set of versions.
This can be used in conjunction with has_plugin(s)
, needs_plugin(s)
and CAPABILITIES
.
The parameters min
and max
are deprecated.
Parameters: |
|
---|
Source code in pulp-glue/pulp_glue/common/context.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
|
PulpException
¶
Bases: Exception
The base exception pulp-glue
will emit on expected error paths.
PulpHTTPError
¶
PulpHTTPError(msg: str, status_code: int)
Bases: PulpException
Exception to indicate HTTP error responses.
Source code in pulp-glue/pulp_glue/common/context.py
111 112 113 |
|
PulpNoWait
¶
Bases: Exception
Exception to indicate that a task continues running in the background.
PulpContext
¶
PulpContext(
api_root: str,
api_kwargs: t.Dict[str, t.Any],
background_tasks: bool,
timeout: t.Union[int, datetime.timedelta],
domain: str = "default",
format: t.Optional[str] = None,
)
Abstract class for the global PulpContext object. It is an abstraction layer for api access and output handling.
Parameters: |
|
---|
Source code in pulp-glue/pulp_glue/common/context.py
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 |
|
api
property
¶
api: OpenAPI
The lazy evaluated OpenAPI
object contained in this context.
This is only needed for low level interactions with the openapi spec.
All calls to the API should be performed via call
.
echo
¶
echo(
message: str, nl: bool = True, err: bool = False
) -> None
Abstract function that will be called to emit warnings and task progress.
Warning
This function needs to be implemented.
Source code in pulp-glue/pulp_glue/common/context.py
242 243 244 245 246 247 248 249 |
|
prompt
¶
prompt(text: str, hide_input: bool = False) -> str
Abstract function that will be called to ask for a password interactively.
Note
If a password is provided non-interactively, this function need not be implemented.
Source code in pulp-glue/pulp_glue/common/context.py
251 252 253 254 255 256 257 258 |
|
call
¶
call(
operation_id: str,
non_blocking: bool = False,
parameters: t.Optional[t.Dict[str, t.Any]] = None,
body: t.Optional[EntityDefinition] = None,
validate_body: bool = True,
) -> t.Any
Perform an API call for operation_id. Wait for triggered tasks to finish if not background. Returns the operation result, or the finished task.
Parameters: |
|
---|
Returns: |
|
---|
Raises: |
|
---|
Source code in pulp-glue/pulp_glue/common/context.py
339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 |
|
wait_for_task
¶
wait_for_task(
task: EntityDefinition, expect_cancel: bool = False
) -> t.Any
Wait for a task to finish and return the finished task object.
Parameters: |
|
---|
Raises: |
|
---|
Source code in pulp-glue/pulp_glue/common/context.py
438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 |
|
wait_for_task_group
¶
wait_for_task_group(task_group: EntityDefinition) -> t.Any
Wait for a task group to finish and return the finished task object.
Parameters: |
|
---|
Raises: |
|
---|
Source code in pulp-glue/pulp_glue/common/context.py
488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 |
|
PulpEntityContext
¶
PulpEntityContext(
pulp_ctx: PulpContext,
pulp_href: t.Optional[str] = None,
entity: t.Optional[EntityDefinition] = None,
)
Base class for entity specific contexts. This class provides the basic CRUD commands and ties its instances to the global PulpContext for api access. Mostly specification is achieved by defining / extending the class attributes below.
Parameters: |
|
---|
Source code in pulp-glue/pulp_glue/common/context.py
672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 |
|
NULLABLES
class-attribute
¶
NULLABLES: Set[str] = set()
Set of fields that can be cleared by sending 'null'.
NEEDS_PLUGINS
class-attribute
¶
NEEDS_PLUGINS: List[PluginRequirement] = []
List of plugin requirements to operate such an entity on the server.
CAPABILITIES
class-attribute
¶
CAPABILITIES: Dict[str, List[PluginRequirement]] = {}
List of capabilities this entity provides.
Subclasses can specify version dependent capabilities here
Example
CAPABILITIES = {
"feature1": [
PluginRequirement("file"),
PluginRequirement("core", specifier=">=3.7.0")
]
}
HREF_PATTERN
instance-attribute
¶
HREF_PATTERN: str
Regular expression with capture groups for 'plugin' and 'resource_type' to match URIs.
scope
property
¶
scope: Dict[str, Any]
Extra scope used in parameters for create and list calls.
Subclasses for nested entities can define the parameters for there parent scope here.
entity
property
writable
¶
entity: EntityDefinition
Entity property that will perform a lazy lookup once it is accessed.
You can specify lookup parameters by assigning a dictionary to it,
or assign an href to the pulp_href
property.
To reset to having no attached entity you can assign None
.
Assigning to it will reset the lazy lookup behaviour.
pulp_href
property
writable
¶
pulp_href: str
Property to represent the href of the attached entity. Assigning to it will reset the lazy lookup behaviour.
tangible
property
¶
tangible: bool
Indicate whether an entity is available or specified by search parameters.
call
¶
call(
operation: str,
non_blocking: bool = False,
parameters: t.Optional[t.Dict[str, t.Any]] = None,
body: t.Optional[EntityDefinition] = None,
validate_body: bool = True,
) -> t.Any
Perform an API call for operation. Wait for triggered tasks to finish if not background. Returns the operation result, or the finished task.
Parameters: |
|
---|
Returns: |
|
---|
Raises: |
|
---|
Source code in pulp-glue/pulp_glue/common/context.py
692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 |
|
preprocess_entity
¶
preprocess_entity(
body: EntityDefinition, partial: bool = False
) -> EntityDefinition
Filter to prepare the body for a create or update call.
This function can be subclassed by specific Entity contexts to fix data depending on plugin versions.
Parameters: |
|
---|
Returns: |
|
---|
Source code in pulp-glue/pulp_glue/common/context.py
751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 |
|
list
¶
list(
limit: int, offset: int, parameters: t.Dict[str, t.Any]
) -> t.List[t.Any]
List entities by the type of this context.
Parameters: |
|
---|
Returns: |
|
---|
Source code in pulp-glue/pulp_glue/common/context.py
767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 |
|
find
¶
find(**kwargs: t.Any) -> t.Any
Find an entity based on search parameters.
Note: It is preferred to use the entity
property instead of calling find
directly.
Parameters: |
|
---|
Returns: |
|
---|
Raises: |
|
---|
Source code in pulp-glue/pulp_glue/common/context.py
803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 |
|
show
¶
show(href: t.Optional[str] = None) -> t.Any
Retrieve and return the full record of an entity from the server.
Parameters: |
|
---|
Returns: |
|
---|
Raises: |
|
---|
Source code in pulp-glue/pulp_glue/common/context.py
837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 |
|
create
¶
create(
body: EntityDefinition,
parameters: t.Optional[t.Mapping[str, t.Any]] = None,
non_blocking: bool = False,
) -> t.Any
Create an entity.
Parameters: |
|
---|
Returns: |
|
---|
Source code in pulp-glue/pulp_glue/common/context.py
853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 |
|
update
¶
update(
href: t.Optional[str] = None,
body: t.Optional[EntityDefinition] = None,
parameters: t.Optional[t.Mapping[str, t.Any]] = None,
non_blocking: bool = False,
) -> t.Any
Update the entity.
Parameters: |
|
---|
Returns: |
|
---|
Source code in pulp-glue/pulp_glue/common/context.py
890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 |
|
delete
¶
delete(
href: t.Optional[str] = None, non_blocking: bool = False
) -> t.Any
Delete the entity.
Parameters: |
|
---|
Returns: |
|
---|
Source code in pulp-glue/pulp_glue/common/context.py
929 930 931 932 933 934 935 936 937 938 939 940 941 942 |
|
set_label
¶
set_label(
key: str, value: str, non_blocking: bool = False
) -> t.Any
Set a label.
Parameters: |
|
---|
Source code in pulp-glue/pulp_glue/common/context.py
944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 |
|
unset_label
¶
unset_label(key: str, non_blocking: bool = False) -> t.Any
Unset a label.
Parameters: |
|
---|
Source code in pulp-glue/pulp_glue/common/context.py
969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 |
|
show_label
¶
show_label(key: str) -> t.Optional[str]
Show value of a label.
Parameters: |
|
---|
Returns: |
|
---|
Raises: |
|
---|
Source code in pulp-glue/pulp_glue/common/context.py
994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 |
|
capable
¶
capable(capability: str) -> bool
Report on a capability based on the presence of all needed server plugins.
Parameters: |
|
---|
Returns: |
|
---|
Source code in pulp-glue/pulp_glue/common/context.py
1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 |
|
needs_capability
¶
needs_capability(capability: str) -> None
Translates a capability in calls to needs_plugin
via CAPABILITIES
.
Parameters: |
|
---|
Source code in pulp-glue/pulp_glue/common/context.py
1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 |
|
PulpRemoteContext
¶
PulpRemoteContext(
pulp_ctx: PulpContext,
pulp_href: t.Optional[str] = None,
entity: t.Optional[EntityDefinition] = None,
)
Bases: PulpEntityContext
Base class for remote contexts.
Source code in pulp-glue/pulp_glue/common/context.py
672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 |
|
PulpPublicationContext
¶
PulpPublicationContext(
pulp_ctx: PulpContext,
pulp_href: t.Optional[str] = None,
entity: t.Optional[EntityDefinition] = None,
)
Bases: PulpEntityContext
Base class for publication contexts.
Source code in pulp-glue/pulp_glue/common/context.py
672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 |
|
PulpDistributionContext
¶
PulpDistributionContext(
pulp_ctx: PulpContext,
pulp_href: t.Optional[str] = None,
entity: t.Optional[EntityDefinition] = None,
)
Bases: PulpEntityContext
Base class for distribution contexts.
Source code in pulp-glue/pulp_glue/common/context.py
672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 |
|
PulpRepositoryVersionContext
¶
PulpRepositoryVersionContext(
pulp_ctx: PulpContext,
repository_ctx: PulpRepositoryContext,
pulp_href: t.Optional[str] = None,
)
Bases: PulpEntityContext
Base class for repository version contexts.
Parameters: |
|
---|
Source code in pulp-glue/pulp_glue/common/context.py
1156 1157 1158 1159 1160 1161 1162 1163 |
|
repair
¶
repair(href: t.Optional[str] = None) -> t.Any
Trigger a repair task for this repository version.
Parameters: |
|
---|
Returns: |
|
---|
Source code in pulp-glue/pulp_glue/common/context.py
1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 |
|
PulpRepositoryContext
¶
PulpRepositoryContext(
pulp_ctx: PulpContext,
pulp_href: t.Optional[str] = None,
entity: t.Optional[EntityDefinition] = None,
)
Bases: PulpEntityContext
Base class for repository contexts.
Source code in pulp-glue/pulp_glue/common/context.py
672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 |
|
get_version_context
¶
get_version_context(
number: t.Optional[int] = None,
) -> PulpRepositoryVersionContext
Return a repository version context of the proper type scoped for this repository.
Parameters: |
|
---|
Returns: |
|
---|
Source code in pulp-glue/pulp_glue/common/context.py
1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 |
|
sync
¶
sync(
href: t.Optional[str] = None,
body: t.Optional[EntityDefinition] = None,
) -> t.Any
Trigger a sync task for this repository.
Parameters: |
|
---|
Returns: |
|
---|
Source code in pulp-glue/pulp_glue/common/context.py
1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 |
|
modify
¶
modify(
href: t.Optional[str] = None,
add_content: t.Optional[t.List[str]] = None,
remove_content: t.Optional[t.List[str]] = None,
base_version: t.Optional[str] = None,
) -> t.Any
Add to or remove content from this repository.
Parameters: |
|
---|
Returns: |
|
---|
Source code in pulp-glue/pulp_glue/common/context.py
1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 |
|
PulpGenericRepositoryContext
¶
PulpGenericRepositoryContext(
pulp_ctx: PulpContext,
pulp_href: t.Optional[str] = None,
entity: t.Optional[EntityDefinition] = None,
)
Bases: PulpRepositoryContext
Generic repository context class to separate specific general functionality.
Source code in pulp-glue/pulp_glue/common/context.py
672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 |
|
reclaim
¶
reclaim(
repo_hrefs: t.List[t.Union[str, PulpRepositoryContext]],
repo_versions_keeplist: t.Optional[
t.List[t.Union[str, PulpRepositoryVersionContext]]
] = None,
) -> t.Any
Reclaim disk space for a list of repositories.
Parameters: |
|
---|
Returns: |
|
---|
Source code in pulp-glue/pulp_glue/common/context.py
1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 |
|
PulpContentContext
¶
PulpContentContext(
pulp_ctx: PulpContext,
pulp_href: t.Optional[str] = None,
entity: t.Optional[EntityDefinition] = None,
)
Bases: PulpEntityContext
Base class for content contexts.
Source code in pulp-glue/pulp_glue/common/context.py
672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 |
|
upload
¶
upload(
file: t.IO[bytes],
chunk_size: int,
repository: t.Optional[PulpRepositoryContext],
**kwargs: t.Any
) -> t.Any
Create a content unit by uploading a file.
Parameters: |
|
---|
Returns: |
|
---|
Source code in pulp-glue/pulp_glue/common/context.py
1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 |
|
PulpACSContext
¶
PulpACSContext(
pulp_ctx: PulpContext,
pulp_href: t.Optional[str] = None,
entity: t.Optional[EntityDefinition] = None,
)
Bases: PulpEntityContext
Base class for ACS contexts.
Source code in pulp-glue/pulp_glue/common/context.py
672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 |
|
PulpContentGuardContext
¶
PulpContentGuardContext(
pulp_ctx: PulpContext,
pulp_href: t.Optional[str] = None,
entity: t.Optional[EntityDefinition] = None,
)
Bases: PulpEntityContext
Base class for content guard contexts.
Source code in pulp-glue/pulp_glue/common/context.py
672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 |
|
api_quirk
¶
api_quirk(
req: PluginRequirement,
) -> t.Callable[[t.Callable[[OpenAPI], None]], None]
A function decorator to allow manipulating API specs based on the availability of plugins.
Parameters: |
|
---|
Examples:
@api_quirk(PluginRequirement("catdog", specifier="<1.5.2"))
def patch_barking_filter_type(api: OpenAPI) -> None:
# fixup api.api_spec here
Source code in pulp-glue/pulp_glue/common/context.py
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
|