API (Rest Framework)¶
Bases: ImportStartActionMixin, BaseImportJobViewSet
Base API viewset for ImportJob model.
Based on resource_class it will generate an endpoint which will allow to start an import to model which was specified in resource_class. On success this endpoint we return an instance of import.
Endpoints
- list - to get list of all import jobs
- details(retrieve) - to get status of import job
- start - create import job and start parsing data from attached file
- confirm - confirm import after parsing process is finished
- cancel - stop importing/parsing process and cancel this import job
Source code in import_export_extensions/api/views/import_job.py
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | |
get_queryset()
¶
Filter import jobs by resource used in viewset.
Source code in import_export_extensions/api/views/import_job.py
132 133 134 135 136 137 138 139 140 141 142 143 | |
Bases: ExportStartActionMixin, BaseExportJobViewSet
Base API viewset for ExportJob model.
Based on resource_class it will generate an endpoint which will allow to start an export of model which was specified in resource_class. This endpoint will support filtration based on FilterSet class specified in resource. On success this endpoint we return an instance of export, to get status of job, just use detail(retrieve) endpoint.
Source code in import_export_extensions/api/views/export_job.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | |
get_queryset()
¶
Filter export jobs by resource used in viewset.
Source code in import_export_extensions/api/views/export_job.py
105 106 107 108 109 110 111 112 113 114 115 116 | |
Bases: LimitQuerySetToCurrentUserMixin, ImportJobViewSet
Viewset for providing import feature to users.
Source code in import_export_extensions/api/views/import_job.py
146 147 148 149 150 | |
Bases: LimitQuerySetToCurrentUserMixin, ExportJobViewSet
Viewset for providing export feature to users.
Source code in import_export_extensions/api/views/export_job.py
119 120 121 122 123 | |
Bases: ListModelMixin, RetrieveModelMixin, GenericViewSet
Base viewset for managing import jobs.
Source code in import_export_extensions/api/views/import_job.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 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 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | |
__init_subclass__()
¶
Dynamically create an cancel api endpoints.
Need to do this to enable action and correct open-api spec generated by drf_spectacular.
Source code in import_export_extensions/api/views/import_job.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | |
cancel(*args, **kwargs)
¶
Cancel import job that is in progress.
Source code in import_export_extensions/api/views/import_job.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 | |
confirm(*args, **kwargs)
¶
Confirm import job that has parsed status.
Source code in import_export_extensions/api/views/import_job.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 | |
Bases: ListModelMixin, RetrieveModelMixin, GenericViewSet
Base viewset for managing export jobs.
Source code in import_export_extensions/api/views/export_job.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | |
__init_subclass__()
¶
Dynamically create an cancel api endpoints.
Need to do this to enable action and correct open-api spec generated by drf_spectacular.
Source code in import_export_extensions/api/views/export_job.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | |
cancel(*args, **kwargs)
¶
Cancel export job that is in progress.
Source code in import_export_extensions/api/views/export_job.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 | |
Bases: LimitQuerySetToCurrentUserMixin, BaseImportJobViewSet
Viewset for providing export job management to users.
Source code in import_export_extensions/api/views/import_job.py
153 154 155 156 157 | |
Bases: LimitQuerySetToCurrentUserMixin, BaseExportJobViewSet
Viewset for providing export job management to users.
Source code in import_export_extensions/api/views/export_job.py
126 127 128 129 130 | |
Make queryset to return only current user jobs.
Source code in import_export_extensions/api/mixins/common.py
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | |
get_queryset()
¶
Return user's jobs.
Source code in import_export_extensions/api/mixins/common.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | |
Mixin which adds start import action.
Source code in import_export_extensions/api/mixins/import_mixins.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 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 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | |
__init_subclass__()
¶
Set up start_import_action as action of viewset.
Source code in import_export_extensions/api/mixins/import_mixins.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | |
get_import_create_serializer_class()
¶
Get serializer which will be used to start import job.
Source code in import_export_extensions/api/mixins/import_mixins.py
91 92 93 94 95 | |
get_import_detail_serializer_class()
¶
Get serializer which will be used show details of import job.
Source code in import_export_extensions/api/mixins/import_mixins.py
85 86 87 88 89 | |
get_import_resource_kwargs()
¶
Provide extra arguments to resource class.
Source code in import_export_extensions/api/mixins/import_mixins.py
97 98 99 | |
get_queryset()
¶
Return import model queryset on import action.
For better openapi support and consistency.
Source code in import_export_extensions/api/mixins/import_mixins.py
75 76 77 78 79 80 81 82 83 | |
get_serializer(*args, **kwargs)
¶
Provide resource kwargs to serializer class.
Source code in import_export_extensions/api/mixins/import_mixins.py
101 102 103 104 105 106 107 108 | |
start_import(request)
¶
Validate request data and start ImportJob.
Source code in import_export_extensions/api/mixins/import_mixins.py
110 111 112 113 114 115 116 117 118 119 120 121 122 | |
Mixin which adds start export action.
Source code in import_export_extensions/api/mixins/export_mixins.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 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 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 | |
__init_subclass__()
¶
Set up start_export_action as action of viewset.
Source code in import_export_extensions/api/mixins/export_mixins.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | |
get_export_create_serializer_class()
¶
Get serializer which will be used to start export job.
Source code in import_export_extensions/api/mixins/export_mixins.py
189 190 191 192 193 194 195 | |
get_export_detail_serializer_class()
¶
Get serializer which will be used show details of export job.
Source code in import_export_extensions/api/mixins/export_mixins.py
183 184 185 186 187 | |
get_export_resource_kwargs()
¶
Provide extra arguments to resource class.
Source code in import_export_extensions/api/mixins/export_mixins.py
197 198 199 | |
get_queryset()
¶
Return export model queryset on export action.
For better openapi support and consistency.
Source code in import_export_extensions/api/mixins/export_mixins.py
173 174 175 176 177 178 179 180 181 | |
get_serializer(*args, **kwargs)
¶
Provide resource kwargs to serializer class.
Source code in import_export_extensions/api/mixins/export_mixins.py
201 202 203 204 205 206 207 208 | |
set_export_action(action_name, action_attr, action_kwargs)
classmethod
¶
Set up export action with proper attrs.
Source code in import_export_extensions/api/mixins/export_mixins.py
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | |
set_up_export_action_api_specs(action_name, action_view)
classmethod
¶
Correct specs of drf-spectacular if it is installed.
Source code in import_export_extensions/api/mixins/export_mixins.py
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | |
start_export(request)
¶
Validate request data and start ExportJob.
Source code in import_export_extensions/api/mixins/export_mixins.py
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 | |
Bases: Serializer
Base Serializer to start export job.
It used to set up base workflow of ExportJob creation via API.
Source code in import_export_extensions/api/serializers/export_job.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 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 90 91 92 93 94 95 96 97 98 | |
__init__(*args, ordering=None, filter_kwargs=None, resource_kwargs=None, **kwargs)
¶
Set ordering, filter kwargs and current user.
Source code in import_export_extensions/api/serializers/export_job.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | |
create(validated_data)
¶
Create export job.
Source code in import_export_extensions/api/serializers/export_job.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | |
update(instance, validated_data)
¶
Empty method to pass linters checks.
Source code in import_export_extensions/api/serializers/export_job.py
97 98 | |
validate(attrs)
¶
Check that ordering and filter kwargs are valid.
Source code in import_export_extensions/api/serializers/export_job.py
68 69 70 71 72 73 74 75 76 | |
Bases: Serializer
Base Serializer to start import job.
It used to set up base workflow of ImportJob creation via API.
Source code in import_export_extensions/api/serializers/import_job.py
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | |
__init__(*args, resource_kwargs=None, **kwargs)
¶
Set filter kwargs and current user.
Source code in import_export_extensions/api/serializers/import_job.py
98 99 100 101 102 103 104 105 106 107 108 | |
create(validated_data)
¶
Create import job.
Source code in import_export_extensions/api/serializers/import_job.py
110 111 112 113 114 115 116 117 118 119 120 121 122 | |
update(instance, validated_data)
¶
Empty method to pass linters checks.
Source code in import_export_extensions/api/serializers/import_job.py
124 125 | |
Bases: ModelSerializer
Serializer to show information about export job.
Source code in import_export_extensions/api/serializers/export_job.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | |
Bases: ModelSerializer
Serializer to show information about import job.
Source code in import_export_extensions/api/serializers/import_job.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | |
Bases: Serializer
Serializer to show progress of job.
Source code in import_export_extensions/api/serializers/progress.py
11 12 13 14 | |
Bases: Serializer
Serializer to show progress info, like how much is done.
Source code in import_export_extensions/api/serializers/progress.py
4 5 6 7 8 | |