Repository: getmoto/moto
Pull request #5891 (2023-02-01 11:48:59)

MotoServer - deprecate server-argument
Part of a cleanup to simplify the server-logic. The command `moto_server ec2` can be used if you only want to serve EC2 requests on this MotoServer, but I'm not aware of any benefits of this. Running just `moto_server` does the same thing.

This feature was removed from the documentation in https://github.com/getmoto/moto/pull/3728

If someone is using this construct, and is able to show a use-case that I'm not seeing, we can always undo this.



Patch:
diff --git a/moto/glue/models.py b/moto/glue/models.py
index 26cfbbc0e..6b27c85df 100644
--- a/moto/glue/models.py
+++ b/moto/glue/models.py
@@ -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):
diff --git a/moto/glue/responses.py b/moto/glue/responses.py
index 486e0bee7..361848a3b 100644
--- a/moto/glue/responses.py
+++ b/moto/glue/responses.py
@@ -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,
+            }
+        )
diff --git a/moto/server.py b/moto/server.py
index 8d1570505..b451943a1 100644
--- a/moto/server.py
+++ b/moto/server.py
@@ -2,6 +2,8 @@ import argparse
 import os
 import signal
 import sys
+import warnings
+
 from werkzeug.serving import run_simple
 
 from moto.moto_server.werkzeug_app import (
@@ -70,6 +72,11 @@ def main(argv=None):
     except Exception:
         pass  # ignore "ValueError: signal only works in main thread"
 
+    if args.service:
+        warnings.warn(
+            f"The service-argument ({args.service}) is considered deprecated, and will be deprecated in a future release. Please let us know if you have any questions: https://github.com/getmoto/moto/issues"
+        )
+
     # Wrap the main application
     main_app = DomainDispatcherApplication(create_backend_app, service=args.service)
     main_app.debug = True


Test patch:
diff --git a/tests/test_glue/test_glue.py b/tests/test_glue/test_glue.py
index 5e3fcbfce..507b7affc 100644
--- a/tests/test_glue/test_glue.py
+++ b/tests/test_glue/test_glue.py
@@ -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)