| 
									
										
										
										
											2018-11-27 19:17:41 +08:00
										 |  |  | # -*- coding: utf-8 -*- | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import time | 
					
						
							|  |  |  | import re | 
					
						
							|  |  |  | import base | 
					
						
							| 
									
										
										
										
											2023-02-24 10:56:28 +08:00
										 |  |  | import v2_swagger_client | 
					
						
							|  |  |  | from v2_swagger_client.rest import ApiException | 
					
						
							| 
									
										
										
										
											2018-11-27 19:17:41 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | class System(base.Base): | 
					
						
							|  |  |  |     def get_gc_history(self, expect_status_code = 200, expect_response_body = None, **kwargs): | 
					
						
							|  |  |  |         client = self._get_client(**kwargs) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         try: | 
					
						
							|  |  |  |             data, status_code, _ = client.system_gc_get_with_http_info() | 
					
						
							|  |  |  |         except ApiException as e: | 
					
						
							|  |  |  |             if e.status == expect_status_code: | 
					
						
							|  |  |  |                 if expect_response_body is not None and e.body.strip() != expect_response_body.strip(): | 
					
						
							|  |  |  |                     raise Exception(r"Get configuration response body is not as expected {} actual status is {}.".format(expect_response_body.strip(), e.body.strip())) | 
					
						
							|  |  |  |                 else: | 
					
						
							|  |  |  |                     return e.reason, e.body | 
					
						
							|  |  |  |             else: | 
					
						
							|  |  |  |                 raise Exception(r"Get configuration result is not as expected {} actual status is {}.".format(expect_status_code, e.status)) | 
					
						
							|  |  |  |         base._assert_status_code(expect_status_code, status_code) | 
					
						
							|  |  |  |         return data | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def get_gc_status_by_id(self, job_id, expect_status_code = 200, expect_response_body = None, **kwargs): | 
					
						
							|  |  |  |         client = self._get_client(**kwargs) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         try: | 
					
						
							|  |  |  |             data, status_code, _ = client.system_gc_id_get_with_http_info(job_id) | 
					
						
							|  |  |  |         except ApiException as e: | 
					
						
							|  |  |  |             if e.status == expect_status_code: | 
					
						
							|  |  |  |                 if expect_response_body is not None and e.body.strip() != expect_response_body.strip(): | 
					
						
							|  |  |  |                     raise Exception(r"Get configuration response body is not as expected {} actual status is {}.".format(expect_response_body.strip(), e.body.strip())) | 
					
						
							|  |  |  |                 else: | 
					
						
							|  |  |  |                     return e.reason, e.body | 
					
						
							|  |  |  |             else: | 
					
						
							|  |  |  |                 raise Exception(r"Get configuration result is not as expected {} actual status is {}.".format(expect_status_code, e.status)) | 
					
						
							|  |  |  |         base._assert_status_code(expect_status_code, status_code) | 
					
						
							|  |  |  |         return data | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def get_gc_log_by_id(self, job_id, expect_status_code = 200, expect_response_body = None, **kwargs): | 
					
						
							|  |  |  |         client = self._get_client(**kwargs) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         try: | 
					
						
							|  |  |  |             data, status_code, _ = client.system_gc_id_log_get_with_http_info(job_id) | 
					
						
							|  |  |  |         except ApiException as e: | 
					
						
							|  |  |  |             if e.status == expect_status_code: | 
					
						
							|  |  |  |                 if expect_response_body is not None and e.body.strip() != expect_response_body.strip(): | 
					
						
							|  |  |  |                     raise Exception(r"Get configuration response body is not as expected {} actual status is {}.".format(expect_response_body.strip(), e.body.strip())) | 
					
						
							|  |  |  |                 else: | 
					
						
							|  |  |  |                     return e.reason, e.body | 
					
						
							|  |  |  |             else: | 
					
						
							|  |  |  |                 raise Exception(r"Get configuration result is not as expected {} actual status is {}.".format(expect_status_code, e.status)) | 
					
						
							|  |  |  |         base._assert_status_code(expect_status_code, status_code) | 
					
						
							|  |  |  |         return data | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def get_gc_schedule(self, expect_status_code = 200, expect_response_body = None, **kwargs): | 
					
						
							|  |  |  |         client = self._get_client(**kwargs) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         try: | 
					
						
							|  |  |  |             data, status_code, _ = client.system_gc_schedule_get_with_http_info() | 
					
						
							|  |  |  |         except ApiException as e: | 
					
						
							|  |  |  |             if e.status == expect_status_code: | 
					
						
							|  |  |  |                 if expect_response_body is not None and e.body.strip() != expect_response_body.strip(): | 
					
						
							|  |  |  |                     raise Exception(r"Get configuration response body is not as expected {} actual status is {}.".format(expect_response_body.strip(), e.body.strip())) | 
					
						
							|  |  |  |                 else: | 
					
						
							|  |  |  |                     return e.reason, e.body | 
					
						
							|  |  |  |             else: | 
					
						
							|  |  |  |                 raise Exception(r"Get configuration result is not as expected {} actual status is {}.".format(expect_status_code, e.status)) | 
					
						
							|  |  |  |         base._assert_status_code(expect_status_code, status_code) | 
					
						
							|  |  |  |         return data | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-22 10:34:03 +08:00
										 |  |  |     def set_cve_allowlist(self, expires_at=None, expected_status_code=200, *cve_ids, **kwargs): | 
					
						
							| 
									
										
										
										
											2019-08-13 14:02:00 +08:00
										 |  |  |         client = self._get_client(**kwargs) | 
					
						
							| 
									
										
										
										
											2023-02-24 10:56:28 +08:00
										 |  |  |         cve_list = [v2_swagger_client.CVEAllowlistItem(cve_id=c) for c in cve_ids] | 
					
						
							|  |  |  |         allowlist = v2_swagger_client.CVEAllowlist(expires_at=expires_at, items=cve_list) | 
					
						
							| 
									
										
										
										
											2019-08-13 14:02:00 +08:00
										 |  |  |         try: | 
					
						
							| 
									
										
										
										
											2020-06-22 10:34:03 +08:00
										 |  |  |             r = client.system_cve_allowlist_put_with_http_info(allowlist=allowlist, _preload_content=False) | 
					
						
							| 
									
										
										
										
											2019-08-13 14:02:00 +08:00
										 |  |  |         except Exception as e: | 
					
						
							|  |  |  |             base._assert_status_code(expected_status_code, e.status) | 
					
						
							|  |  |  |         else: | 
					
						
							| 
									
										
										
										
											2020-08-17 14:51:18 +08:00
										 |  |  |             base._assert_status_code(expected_status_code, r.status) | 
					
						
							| 
									
										
										
										
											2019-08-13 14:02:00 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-22 10:34:03 +08:00
										 |  |  |     def get_cve_allowlist(self, **kwargs): | 
					
						
							| 
									
										
										
										
											2019-08-13 14:02:00 +08:00
										 |  |  |         client = self._get_client(**kwargs) | 
					
						
							| 
									
										
										
										
											2020-06-22 10:34:03 +08:00
										 |  |  |         return client.system_cve_allowlist_get() | 
					
						
							| 
									
										
										
										
											2019-09-11 13:34:23 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     def get_project_quota(self, reference, reference_id, **kwargs): | 
					
						
							|  |  |  |         params={} | 
					
						
							|  |  |  |         params['reference'] = reference | 
					
						
							|  |  |  |         params['reference_id'] = reference_id | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-25 16:19:55 +08:00
										 |  |  |         client = self._get_client(api_type='quota', **kwargs) | 
					
						
							|  |  |  |         data, status_code, _ = client.list_quotas_with_http_info(**params) | 
					
						
							| 
									
										
										
										
											2019-09-11 13:34:23 +08:00
										 |  |  |         base._assert_status_code(200, status_code) | 
					
						
							| 
									
										
										
										
											2020-06-22 10:34:03 +08:00
										 |  |  |         return data |