Glue: batch_get_crawlers (#5896)

This commit is contained in:
Przemysław Dąbek 2023-02-02 13:44:53 +01:00 committed by GitHub
parent 75059fd4cf
commit 985bf4f5a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 0 deletions

View File

@ -738,6 +738,13 @@ class GlueBackend(BaseBackend):
)
return errors_output
def batch_get_crawlers(self, crawler_names):
crawlers = []
for crawler in self.get_crawlers():
if crawler.as_dict()["Name"] in crawler_names:
crawlers.append(crawler.as_dict())
return crawlers
class FakeDatabase(BaseModel):
def __init__(self, database_name, database_input):

View File

@ -498,3 +498,16 @@ class GlueResponse(BaseResponse):
description = self._get_param("Description")
schema = self.glue_backend.update_schema(schema_id, compatibility, description)
return json.dumps(schema)
def batch_get_crawlers(self):
crawler_names = self._get_param("CrawlerNames")
crawlers = self.glue_backend.batch_get_crawlers(crawler_names)
crawlers_not_found = list(
set(crawler_names) - set(map(lambda crawler: crawler["Name"], crawlers))
)
return json.dumps(
{
"Crawlers": crawlers,
"CrawlersNotFound": crawlers_not_found,
}
)

View File

@ -401,3 +401,16 @@ def test_untag_glue_crawler():
resp = client.get_tags(ResourceArn=resource_arn)
resp.should.have.key("Tags").equals({"key1": "value1", "key3": "value3"})
@mock_glue
def test_batch_get_crawlers():
client = create_glue_client()
crawler_name = create_test_crawler(client)
response = client.batch_get_crawlers(
CrawlerNames=[crawler_name, "crawler-not-found"]
)
response["Crawlers"].should.have.length_of(1)
response["CrawlersNotFound"].should.have.length_of(1)