def list_aliases( self, context: RequestContext, key_id: KeyIdType = None, limit: LimitType = None, marker: MarkerType = None, ) -> ListAliasesResponse: if key_id is None: return call_moto(context) response_aliases = PaginatedList() if kms_backends.get(context.region).keys.get(key_id) is None: raise NotFoundException(f"Unable to find key '{key_id}'") aliases_of_key = kms_backends.get( context.region).get_all_aliases().get(key_id) or [] for alias_name in aliases_of_key: response_aliases.append( AliasListEntry( AliasArn=kms_alias_arn(alias_name, region_name=context.region), AliasName=alias_name, TargetKeyId=key_id, )) page, nxt = response_aliases.get_page(lambda a: a["AliasName"], next_token=marker, page_size=limit) return ListAliasesResponse(Aliases=page, NextMarker=nxt, Truncated=nxt is not None)
def set_key_managed(key_id) -> None: """ Sets a KMS key to AWS managed :param key_id: ID of the KMS key """ region_name = aws_stack.get_region() backend = kms_backends.get(region_name) key_data = backend.keys.get(key_id) if key_data: key_data.key_manager = "AWS"
def _get_key_pairs(): region_name = aws_stack.get_region() backend = kms_backends.get(region_name) key_pairs = getattr(backend, ATTR_KEY_PAIRS, {}) setattr(backend, ATTR_KEY_PAIRS, key_pairs) return key_pairs