(self, runner_type_api, name_or_id, requester_user)
| 69 | ) |
| 70 | |
| 71 | def put(self, runner_type_api, name_or_id, requester_user): |
| 72 | # Note: We only allow "enabled" attribute of the runner to be changed |
| 73 | runner_type_db = self._get_by_name_or_id(name_or_id=name_or_id) |
| 74 | |
| 75 | permission_type = PermissionType.RUNNER_MODIFY |
| 76 | rbac_utils = get_rbac_backend().get_utils_class() |
| 77 | rbac_utils.assert_user_has_resource_db_permission( |
| 78 | user_db=requester_user, |
| 79 | resource_db=runner_type_db, |
| 80 | permission_type=permission_type, |
| 81 | ) |
| 82 | |
| 83 | old_runner_type_db = runner_type_db |
| 84 | LOG.debug( |
| 85 | "PUT /runnertypes/ lookup with id=%s found object: %s", |
| 86 | name_or_id, |
| 87 | runner_type_db, |
| 88 | ) |
| 89 | |
| 90 | try: |
| 91 | if runner_type_api.id and runner_type_api.id != name_or_id: |
| 92 | LOG.warning( |
| 93 | "Discarding mismatched id=%s found in payload and using uri_id=%s.", |
| 94 | runner_type_api.id, |
| 95 | name_or_id, |
| 96 | ) |
| 97 | |
| 98 | runner_type_db.enabled = runner_type_api.enabled |
| 99 | runner_type_db = RunnerType.add_or_update(runner_type_db) |
| 100 | except (ValidationError, ValueError) as e: |
| 101 | LOG.exception("Validation failed for runner type data=%s", runner_type_api) |
| 102 | abort(http_client.BAD_REQUEST, six.text_type(e)) |
| 103 | return |
| 104 | |
| 105 | extra = { |
| 106 | "old_runner_type_db": old_runner_type_db, |
| 107 | "new_runner_type_db": runner_type_db, |
| 108 | } |
| 109 | LOG.audit( |
| 110 | "Runner Type updated. RunnerType.id=%s." % (runner_type_db.id), extra=extra |
| 111 | ) |
| 112 | runner_type_api = RunnerTypeAPI.from_model(runner_type_db) |
| 113 | return runner_type_api |
| 114 | |
| 115 | |
| 116 | runner_types_controller = RunnerTypesController() |
nothing calls this directly
no test coverage detected