def store( self, *, body: bodies.Body, patch: patches.Patch, essence: bodies.BodyEssence, ) -> None: # Store as a single string instead of full dict -- to avoid merges and unexpected data. encoded: str = json.dumps(essence, separators=(',', ':')) # NB: no spaces dicts.ensure(patch, self.field, encoded)
def purge( self, *, key: ids.HandlerId, body: bodies.Body, patch: patches.Patch, ) -> None: absent = object() for full_key in self.make_keys(key, body=body): key_field = ['metadata', 'annotations', full_key] body_value = dicts.resolve(body, key_field, absent) patch_value = dicts.resolve(patch, key_field, absent) if body_value is not absent: dicts.ensure(patch, key_field, None) elif patch_value is not absent: dicts.remove(patch, key_field)
def store( self, *, key: ids.HandlerId, record: ProgressRecord, body: bodies.Body, patch: patches.Patch, ) -> None: decoded = { key: val for key, val in record.items() if self.verbose or val is not None } encoded = json.dumps(decoded, separators=(',', ':')) # NB: no spaces for full_key in self.make_keys(key, body=body): key_field = ['metadata', 'annotations', full_key] dicts.ensure(patch, key_field, encoded) self._store_marker(prefix=self.prefix, patch=patch, body=body)