Repository: getmoto/moto
Pull request #6831 (2023-09-18 22:55:07)

Bump docker/setup-qemu-action from 2 to 3
[//]: # (dependabot-start)
⚠️  **Dependabot is rebasing this PR** ⚠️ 

Rebasing might not happen immediately, so don't worry if this takes some time.

Note: if you make any changes to this PR yourself, they will take precedence over the rebase.

---

[//]: # (dependabot-end)

Bumps [docker/setup-qemu-action](https://github.com/docker/setup-qemu-action) from 2 to 3.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/docker/setup-qemu-action/releases">docker/setup-qemu-action's releases</a>.</em></p>
<blockquote>
<h2>v3.0.0</h2>
<ul>
<li>Node 20 as default runtime (requires <a href="https://github.com/actions/runner/releases/tag/v2.308.0">Actions Runner v2.308.0</a> or later) by <a href="https://github.com/crazy-max"><code>@​crazy-max</code></a> in <a href="https://redirect.github.com/docker/setup-qemu-action/pull/102">docker/setup-qemu-action#102</a></li>
<li>Bump <code>@​actions/core</code> from 1.10.0 to 1.10.1 in <a href="https://redirect.github.com/docker/setup-qemu-action/pull/103">docker/setup-qemu-action#103</a></li>
<li>Bump semver from 6.3.0 to 6.3.1 in <a href="https://redirect.github.com/docker/setup-qemu-action/pull/89">docker/setup-qemu-action#89</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a href="https://github.com/docker/setup-qemu-action/compare/v2.2.0...v3.0.0">https://github.com/docker/setup-qemu-action/compare/v2.2.0...v3.0.0</a></p>
<h2>v2.2.0</h2>
<ul>
<li>Trim off spaces in <code>platforms</code> input by <a href="https://github.com/Chocobo1"><code>@​Chocobo1</code></a> in <a href="https://redirect.github.com/docker/setup-qemu-action/pull/64">docker/setup-qemu-action#64</a></li>
<li>Switch to actions-toolkit implementation by <a href="https://github.com/crazy-max"><code>@​crazy-max</code></a> in <a href="https://redirect.github.com/docker/setup-qemu-action/pull/70">docker/setup-qemu-action#70</a> <a href="https://redirect.github.com/docker/setup-qemu-action/pull/80">docker/setup-qemu-action#80</a> <a href="https://redirect.github.com/docker/setup-qemu-action/pull/83">docker/setup-qemu-action#83</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a href="https://github.com/docker/setup-qemu-action/compare/v2.1.0...v2.2.0">https://github.com/docker/setup-qemu-action/compare/v2.1.0...v2.2.0</a></p>
<h2>v2.1.0</h2>
<ul>
<li>Use context for inputs by <a href="https://github.com/crazy-max"><code>@​crazy-max</code></a> (<a href="https://redirect.github.com/docker/setup-qemu-action/issues/62">#62</a>)</li>
<li>Use built-in <code>getExecOutput</code> by <a href="https://github.com/crazy-max"><code>@​crazy-max</code></a> (<a href="https://redirect.github.com/docker/setup-qemu-action/issues/61">#61</a>)</li>
<li>Remove workaround for <code>setOutput</code> by <a href="https://github.com/crazy-max"><code>@​crazy-max</code></a> (<a href="https://redirect.github.com/docker/setup-qemu-action/issues/63">#63</a>)</li>
<li>Bump <code>@​actions/core</code> from 1.6.0 to 1.10.0 (<a href="https://redirect.github.com/docker/setup-qemu-action/issues/54">#54</a> <a href="https://redirect.github.com/docker/setup-qemu-action/issues/58">#58</a> <a href="https://redirect.github.com/docker/setup-qemu-action/issues/59">#59</a>)</li>
</ul>
<p><strong>Full Changelog</strong>: <a href="https://github.com/docker/setup-qemu-action/compare/v2.0.0...v2.1.0">https://github.com/docker/setup-qemu-action/compare/v2.0.0...v2.1.0</a></p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/docker/setup-qemu-action/commit/68827325e0b33c7199eb31dd4e31fbe9023e06e3"><code>6882732</code></a> Merge pull request <a href="https://redirect.github.com/docker/setup-qemu-action/issues/103">#103</a> from docker/dependabot/npm_and_yarn/actions/core-1.10.1</li>
<li><a href="https://github.com/docker/setup-qemu-action/commit/183f4af5043c24c5dcd58e6e9868b7df0a201a17"><code>183f4af</code></a> chore: update generated content</li>
<li><a href="https://github.com/docker/setup-qemu-action/commit/f17493529ee8f8b9fd58ed31aa1e9816c8345eb8"><code>f174935</code></a> build(deps): bump <code>@​actions/core</code> from 1.10.0 to 1.10.1</li>
<li><a href="https://github.com/docker/setup-qemu-action/commit/2e423eb50075d10a6af463e39e267d4057cc07bb"><code>2e423eb</code></a> Merge pull request <a href="https://redirect.github.com/docker/setup-qemu-action/issues/89">#89</a> from docker/dependabot/npm_and_yarn/semver-6.3.1</li>
<li><a href="https://github.com/docker/setup-qemu-action/commit/ecc406afa7d79acce0ed8a04bb5eb086136fd000"><code>ecc406a</code></a> Bump semver from 6.3.0 to 6.3.1</li>
<li><a href="https://github.com/docker/setup-qemu-action/commit/12dec5e201ab2f6dbea47c28f4a138590189069a"><code>12dec5e</code></a> Merge pull request <a href="https://redirect.github.com/docker/setup-qemu-action/issues/102">#102</a> from crazy-max/update-node20</li>
<li><a href="https://github.com/docker/setup-qemu-action/commit/c29b31213096fed2f8b8b36e66385d52653bf332"><code>c29b312</code></a> chore: node 20 as default runtime</li>
<li><a href="https://github.com/docker/setup-qemu-action/commit/34ae628c8f4fb0d5c8921b9a0ffa9dcf66120c07"><code>34ae628</code></a> chore: update generated content</li>
<li><a href="https://github.com/docker/setup-qemu-action/commit/1f3d2e1ac09548bbfb7d44b1809ac66e3d551ea4"><code>1f3d2e1</code></a> chore: fix author in package.json</li>
<li><a href="https://github.com/docker/setup-qemu-action/commit/277dbe8c9c1990b42dc38cb1f35a593889a31a62"><code>277dbe8</code></a> vendor: bump <code>@​docker/actions-toolkit</code> from 0.3.0 to 0.12.0</li>
<li>Additional commits viewable in <a href="https://github.com/docker/setup-qemu-action/compare/v2...v3">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=docker/setup-qemu-action&package-manager=github_actions&previous-version=2&new-version=3)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)


</details>

codecov[bot]: ## [Codecov](https://app.codecov.io/gh/getmoto/moto/pull/6831?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getmoto) Report
> Merging [#6831](https://app.codecov.io/gh/getmoto/moto/pull/6831?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getmoto) (569862b) into [master](https://app.codecov.io/gh/getmoto/moto/commit/643cf7c55e7889746eaae08da1c14ba13bf7ed38?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getmoto) (643cf7c) will **increase** coverage by `0.00%`.
> The diff coverage is `n/a`.

```diff
@@           Coverage Diff           @@
##           master    #6831   +/-   ##
=======================================
  Coverage   96.20%   96.20%           
=======================================
  Files         816      816           
  Lines       80042    80042           
=======================================
+ Hits        77002    77004    +2     
+ Misses       3040     3038    -2     
```

| [Flag](https://app.codecov.io/gh/getmoto/moto/pull/6831/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getmoto) | Coverage Δ | |
|---|---|---|
| [servertests](https://app.codecov.io/gh/getmoto/moto/pull/6831/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getmoto) | `37.01% <ø> (ø)` | |
| [unittests](https://app.codecov.io/gh/getmoto/moto/pull/6831/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getmoto) | `96.14% <ø> (+<0.01%)` | :arrow_up: |

Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getmoto#carryforward-flags-in-the-pull-request-comment) to find out more.

[see 1 file with indirect coverage changes](https://app.codecov.io/gh/getmoto/moto/pull/6831/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getmoto)



Patch:
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 5954fa91f..a35650baf 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -116,9 +116,9 @@ jobs:
       # Required to get the correct Digest
       # See https://github.com/docker/build-push-action/issues/461
       - name: Set up QEMU
-        uses: docker/setup-qemu-action@v2
+        uses: docker/setup-qemu-action@v3
       - name: Set up Docker Buildx
-        uses: docker/setup-buildx-action@v2
+        uses: docker/setup-buildx-action@v3
       - name: Login to DockerHub
         uses: docker/login-action@v2
         with:
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 203a1bc67..b9464aa0f 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -67,9 +67,9 @@ jobs:
     # Required to get the correct Digest
     # See https://github.com/docker/build-push-action/issues/461
     - name: Set up QEMU
-      uses: docker/setup-qemu-action@v2
+      uses: docker/setup-qemu-action@v3
     - name: Set up Docker Buildx
-      uses: docker/setup-buildx-action@v2
+      uses: docker/setup-buildx-action@v3
     - name: Login to DockerHub
       uses: docker/login-action@v2
       with:
diff --git a/docs/docs/services/opensearch.rst b/docs/docs/services/opensearch.rst
index a6728af5d..c7196e50d 100644
--- a/docs/docs/services/opensearch.rst
+++ b/docs/docs/services/opensearch.rst
@@ -61,7 +61,7 @@ opensearch
 - [ ] get_package_version_history
 - [ ] get_upgrade_history
 - [ ] get_upgrade_status
-- [ ] list_domain_names
+- [x] list_domain_names
 - [ ] list_domains_for_package
 - [ ] list_instance_type_details
 - [ ] list_packages_for_domain
diff --git a/moto/es/urls.py b/moto/es/urls.py
index 9c8322d6b..b26bfd9ca 100644
--- a/moto/es/urls.py
+++ b/moto/es/urls.py
@@ -10,6 +10,7 @@ url_paths = {
     "{0}/2015-01-01/domain$": ElasticsearchServiceResponse.list_domains,
     "{0}/2015-01-01/es/domain$": ElasticsearchServiceResponse.domains,
     "{0}/2015-01-01/es/domain/(?P<domainname>[^/]+)": ElasticsearchServiceResponse.domain,
+    "{0}/2021-01-01/domain$": OpenSearchServiceResponse.dispatch,
     "{0}/2021-01-01/opensearch/compatibleVersions": OpenSearchServiceResponse.dispatch,
     "{0}/2021-01-01/opensearch/domain": OpenSearchServiceResponse.dispatch,
     "{0}/2021-01-01/opensearch/domain/(?P<domainname>[^/]+)": OpenSearchServiceResponse.dispatch,
diff --git a/moto/opensearch/exceptions.py b/moto/opensearch/exceptions.py
index e0c3a9a33..b5b3f9fe9 100644
--- a/moto/opensearch/exceptions.py
+++ b/moto/opensearch/exceptions.py
@@ -5,3 +5,10 @@ from moto.core.exceptions import JsonRESTError
 class ResourceNotFoundException(JsonRESTError):
     def __init__(self, name: str):
         super().__init__("ResourceNotFoundException", f"Domain not found: {name}")
+
+
+class EngineTypeNotFoundException(JsonRESTError):
+    def __init__(self, domain_name: str):
+        super().__init__(
+            "EngineTypeNotFoundException", f"Engine Type not found: {domain_name}"
+        )
diff --git a/moto/opensearch/models.py b/moto/opensearch/models.py
index 4ef254e49..d2b724021 100644
--- a/moto/opensearch/models.py
+++ b/moto/opensearch/models.py
@@ -2,9 +2,9 @@ from typing import Any, Dict, List, Optional
 
 from moto.core import BaseBackend, BackendDict, BaseModel
 from moto.utilities.tagging_service import TaggingService
-from .data import compatible_versions
-from .exceptions import ResourceNotFoundException
 
+from .data import compatible_versions
+from .exceptions import ResourceNotFoundException, EngineTypeNotFoundException
 
 default_cluster_config = {
     "InstanceType": "t3.small.search",
@@ -327,5 +327,27 @@ class OpenSearchServiceBackend(BaseBackend):
     def remove_tags(self, arn: str, tag_keys: List[str]) -> None:
         self.tagger.untag_resource_using_names(arn, tag_keys)
 
+    def list_domain_names(self, engine_type: str) -> List[Dict[str, str]]:
+        domains = []
+        for domain in self.domains.values():
+            if engine_type:
+                if engine_type in domain.engine_version:
+                    domains.append(
+                        {
+                            "DomainName": domain.domain_name,
+                            "EngineType": engine_type.split("_")[0],
+                        }
+                    )
+                else:
+                    raise EngineTypeNotFoundException(domain.domain_name)
+            else:
+                domains.append(
+                    {
+                        "DomainName": domain.domain_name,
+                        "EngineType": domain.engine_version.split("_")[0],
+                    }
+                )
+        return domains
+
 
 opensearch_backends = BackendDict(OpenSearchServiceBackend, "opensearch")
diff --git a/moto/opensearch/responses.py b/moto/opensearch/responses.py
index 2d189ffac..2d3bbf088 100644
--- a/moto/opensearch/responses.py
+++ b/moto/opensearch/responses.py
@@ -2,6 +2,7 @@
 import json
 
 from moto.core.responses import BaseResponse
+
 from .models import opensearch_backends, OpenSearchServiceBackend
 
 
@@ -138,3 +139,10 @@ class OpenSearchServiceResponse(BaseResponse):
         tag_keys = self._get_param("TagKeys")
         self.opensearch_backend.remove_tags(arn, tag_keys)
         return "{}"
+
+    def list_domain_names(self) -> str:
+        engine_type = self._get_param("engineType")
+        domain_names = self.opensearch_backend.list_domain_names(
+            engine_type=engine_type,
+        )
+        return json.dumps(dict(DomainNames=domain_names))


Test patch:
diff --git a/tests/test_opensearch/test_opensearch.py b/tests/test_opensearch/test_opensearch.py
index 38609040c..380e018bd 100644
--- a/tests/test_opensearch/test_opensearch.py
+++ b/tests/test_opensearch/test_opensearch.py
@@ -1,9 +1,10 @@
 import boto3
 import pytest
-
 from botocore.exceptions import ClientError
+
 from moto import mock_opensearch
 
+
 # See our Development Tips on writing tests for hints on how to write good tests:
 # http://docs.getmoto.org/en/latest/docs/contributing/development_tips/tests.html
 
@@ -139,3 +140,67 @@ def test_update_domain_config():
             "CustomEndpointEnabled": False,
         }
     }
+
+
+@mock_opensearch
+def test_list_domain_names():
+    client = boto3.client("opensearch", region_name="ap-southeast-1")
+
+    test_domain_names_list_exist = False
+
+    opensearch_domain_name = "testdn"
+    opensearch_engine_version = "OpenSearch_1.0"
+    client.create_domain(
+        DomainName=opensearch_domain_name, EngineVersion=opensearch_engine_version
+    )
+
+    resp = client.list_domain_names()
+    domain_names = resp["DomainNames"]
+
+    for domain_name in domain_names:
+        if domain_name["DomainName"] == opensearch_domain_name:
+            test_domain_names_list_exist = True
+
+    assert resp["ResponseMetadata"]["HTTPStatusCode"] == 200
+    assert test_domain_names_list_exist
+
+
+@mock_opensearch
+def test_list_filtered_domain_names():
+    client = boto3.client("opensearch", region_name="ap-southeast-1")
+
+    test_domain_names_list_exist = False
+
+    opensearch_domain_name = "testdn"
+    opensearch_engine_version = "OpenSearch_1.0"
+    client.create_domain(
+        DomainName=opensearch_domain_name, EngineVersion=opensearch_engine_version
+    )
+
+    resp = client.list_domain_names(EngineType="OpenSearch")
+    domain_names = resp["DomainNames"]
+
+    for domain_name in domain_names:
+        if domain_name["DomainName"] == opensearch_domain_name:
+            if domain_name["EngineType"] == opensearch_engine_version.split("_")[0]:
+                test_domain_names_list_exist = True
+
+    assert resp["ResponseMetadata"]["HTTPStatusCode"] == 200
+    assert test_domain_names_list_exist
+
+
+@mock_opensearch
+def test_list_unknown_domain_names_engine_type():
+    client = boto3.client("opensearch", region_name="ap-southeast-1")
+
+    opensearch_domain_name = "testdn"
+    opensearch_engine_version = "OpenSearch_1.0"
+    client.create_domain(
+        DomainName=opensearch_domain_name, EngineVersion=opensearch_engine_version
+    )
+
+    with pytest.raises(ClientError) as exc:
+        client.list_domain_names(EngineType="unknown")
+    err = exc.value.response["Error"]
+    assert err["Code"] == "EngineTypeNotFoundException"
+    assert err["Message"] == "Engine Type not found: testdn"