Create a new config for a pack. Handles requests: POST /configs/
(self, pack_config_content, pack_ref, requester_user, show_secrets=False)
| 111 | ) |
| 112 | |
| 113 | def put(self, pack_config_content, pack_ref, requester_user, show_secrets=False): |
| 114 | """ |
| 115 | Create a new config for a pack. |
| 116 | |
| 117 | Handles requests: |
| 118 | POST /configs/<pack_ref> |
| 119 | """ |
| 120 | |
| 121 | try: |
| 122 | config_api = ConfigAPI(pack=pack_ref, values=vars(pack_config_content)) |
| 123 | config_api.validate(validate_against_schema=True) |
| 124 | except jsonschema.ValidationError as e: |
| 125 | raise ValueValidationException(six.text_type(e)) |
| 126 | except ValueValidationException as e: |
| 127 | raise ValueValidationException(six.text_type(e)) |
| 128 | |
| 129 | self._dump_config_to_disk(config_api) |
| 130 | |
| 131 | config_db = ConfigsRegistrar.save_model(config_api) |
| 132 | |
| 133 | mask_secrets = self._get_mask_secrets(requester_user, show_secrets=show_secrets) |
| 134 | return ConfigAPI.from_model(config_db, mask_secrets=mask_secrets) |
| 135 | |
| 136 | def _dump_config_to_disk(self, config_api): |
| 137 | config_content = yaml.safe_dump(config_api.values, default_flow_style=False) |
nothing calls this directly
no test coverage detected