Beispiel #1
0
 def purge(
         self,
         *,
         key: handlers.HandlerId,
         body: bodies.Body,
         patch: patches.Patch,
 ) -> None:
     safe_key = key.replace('/', '.')
     full_key = f'{self.prefix}/{safe_key}' if self.prefix else safe_key
     if full_key in body.metadata.annotations or full_key in patch.meta.annotations:
         patch.meta.annotations[full_key] = None
Beispiel #2
0
 def fetch(
         self,
         *,
         key: handlers.HandlerId,
         body: bodies.Body,
 ) -> Optional[ProgressRecord]:
     safe_key = key.replace('/', '.')
     full_key = f'{self.prefix}/{safe_key}' if self.prefix else safe_key
     value = body.metadata.annotations.get(full_key, None)
     content = json.loads(value) if value is not None else None
     return cast(Optional[ProgressRecord], content)
Beispiel #3
0
 def store(
         self,
         *,
         key: handlers.HandlerId,
         record: ProgressRecord,
         body: bodies.Body,
         patch: patches.Patch,
 ) -> None:
     safe_key = key.replace('/', '.')
     full_key = f'{self.prefix}/{safe_key}' if self.prefix else safe_key
     clean_data = {key: val for key, val in record.items() if self.verbose or val is not None}
     patch.meta.annotations[full_key] = json.dumps(clean_data)