We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Support Secrets Manager list-secrets
Implement support for `aws secretsmanager list-secrets`

Note: this API call is paginated.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `moto/secretsmanager/responses.py`
Content:
```
1 from __future__ import unicode_literals
2 
3 from moto.core.responses import BaseResponse
4 
5 from .models import secretsmanager_backends
6 
7 
8 class SecretsManagerResponse(BaseResponse):
9 
10     def get_secret_value(self):
11         secret_id = self._get_param('SecretId')
12         version_id = self._get_param('VersionId')
13         version_stage = self._get_param('VersionStage')
14         return secretsmanager_backends[self.region].get_secret_value(
15             secret_id=secret_id,
16             version_id=version_id,
17             version_stage=version_stage)
18 
19     def create_secret(self):
20         name = self._get_param('Name')
21         secret_string = self._get_param('SecretString')
22         tags = self._get_param('Tags', if_none=[])
23         return secretsmanager_backends[self.region].create_secret(
24             name=name,
25             secret_string=secret_string,
26             tags=tags
27         )
28 
29     def get_random_password(self):
30         password_length = self._get_param('PasswordLength', if_none=32)
31         exclude_characters = self._get_param('ExcludeCharacters', if_none='')
32         exclude_numbers = self._get_param('ExcludeNumbers', if_none=False)
33         exclude_punctuation = self._get_param('ExcludePunctuation', if_none=False)
34         exclude_uppercase = self._get_param('ExcludeUppercase', if_none=False)
35         exclude_lowercase = self._get_param('ExcludeLowercase', if_none=False)
36         include_space = self._get_param('IncludeSpace', if_none=False)
37         require_each_included_type = self._get_param(
38             'RequireEachIncludedType', if_none=True)
39         return secretsmanager_backends[self.region].get_random_password(
40             password_length=password_length,
41             exclude_characters=exclude_characters,
42             exclude_numbers=exclude_numbers,
43             exclude_punctuation=exclude_punctuation,
44             exclude_uppercase=exclude_uppercase,
45             exclude_lowercase=exclude_lowercase,
46             include_space=include_space,
47             require_each_included_type=require_each_included_type
48         )
49 
50     def describe_secret(self):
51         secret_id = self._get_param('SecretId')
52         return secretsmanager_backends[self.region].describe_secret(
53             secret_id=secret_id
54         )
55 
56     def rotate_secret(self):
57         client_request_token = self._get_param('ClientRequestToken')
58         rotation_lambda_arn = self._get_param('RotationLambdaARN')
59         rotation_rules = self._get_param('RotationRules')
60         secret_id = self._get_param('SecretId')
61         return secretsmanager_backends[self.region].rotate_secret(
62             secret_id=secret_id,
63             client_request_token=client_request_token,
64             rotation_lambda_arn=rotation_lambda_arn,
65             rotation_rules=rotation_rules
66         )
67
```

Path: `moto/secretsmanager/models.py`
Content:
```
1 from __future__ import unicode_literals
2 
3 import time
4 import json
5 import uuid
6 
7 import boto3
8 
9 from moto.core import BaseBackend, BaseModel
10 from .exceptions import (
11     ResourceNotFoundException,
12     InvalidParameterException,
13     ClientError
14 )
15 from .utils import random_password, secret_arn
16 
17 
18 class SecretsManager(BaseModel):
19 
20     def __init__(self, region_name, **kwargs):
21         self.region = region_name
22 
23 
24 class SecretsManagerBackend(BaseBackend):
25 
26     def __init__(self, region_name=None, **kwargs):
27         super(SecretsManagerBackend, self).__init__()
28         self.region = region_name
29         self.secrets = {}
30 
31     def reset(self):
32         region_name = self.region
33         self.__dict__ = {}
34         self.__init__(region_name)
35 
36     def _is_valid_identifier(self, identifier):
37         return identifier in self.secrets
38 
39     def get_secret_value(self, secret_id, version_id, version_stage):
40 
41         if not self._is_valid_identifier(secret_id):
42             raise ResourceNotFoundException()
43 
44         secret = self.secrets[secret_id]
45 
46         response = json.dumps({
47             "ARN": secret_arn(self.region, secret['secret_id']),
48             "Name": secret['name'],
49             "VersionId": secret['version_id'],
50             "SecretString": secret['secret_string'],
51             "VersionStages": [
52                 "AWSCURRENT",
53             ],
54             "CreatedDate": secret['createdate']
55         })
56 
57         return response
58 
59     def create_secret(self, name, secret_string, tags, **kwargs):
60 
61         generated_version_id = str(uuid.uuid4())
62 
63         secret = {
64             'secret_string': secret_string,
65             'secret_id': name,
66             'name': name,
67             'createdate': int(time.time()),
68             'rotation_enabled': False,
69             'rotation_lambda_arn': '',
70             'auto_rotate_after_days': 0,
71             'version_id': generated_version_id,
72             'tags': tags
73         }
74 
75         self.secrets[name] = secret
76 
77         response = json.dumps({
78             "ARN": secret_arn(self.region, name),
79             "Name": name,
80             "VersionId": generated_version_id,
81         })
82 
83         return response
84 
85     def describe_secret(self, secret_id):
86         if not self._is_valid_identifier(secret_id):
87             raise ResourceNotFoundException
88 
89         secret = self.secrets[secret_id]
90 
91         response = json.dumps({
92             "ARN": secret_arn(self.region, secret['secret_id']),
93             "Name": secret['name'],
94             "Description": "",
95             "KmsKeyId": "",
96             "RotationEnabled": secret['rotation_enabled'],
97             "RotationLambdaARN": secret['rotation_lambda_arn'],
98             "RotationRules": {
99                 "AutomaticallyAfterDays": secret['auto_rotate_after_days']
100             },
101             "LastRotatedDate": None,
102             "LastChangedDate": None,
103             "LastAccessedDate": None,
104             "DeletedDate": None,
105             "Tags": secret['tags']
106         })
107 
108         return response
109 
110     def rotate_secret(self, secret_id, client_request_token=None,
111                       rotation_lambda_arn=None, rotation_rules=None):
112 
113         rotation_days = 'AutomaticallyAfterDays'
114 
115         if not self._is_valid_identifier(secret_id):
116             raise ResourceNotFoundException
117 
118         if client_request_token:
119             token_length = len(client_request_token)
120             if token_length < 32 or token_length > 64:
121                 msg = (
122                     'ClientRequestToken '
123                     'must be 32-64 characters long.'
124                 )
125                 raise InvalidParameterException(msg)
126 
127         if rotation_lambda_arn:
128             if len(rotation_lambda_arn) > 2048:
129                 msg = (
130                     'RotationLambdaARN '
131                     'must <= 2048 characters long.'
132                 )
133                 raise InvalidParameterException(msg)
134 
135         if rotation_rules:
136             if rotation_days in rotation_rules:
137                 rotation_period = rotation_rules[rotation_days]
138                 if rotation_period < 1 or rotation_period > 1000:
139                     msg = (
140                         'RotationRules.AutomaticallyAfterDays '
141                         'must be within 1-1000.'
142                     )
143                     raise InvalidParameterException(msg)
144 
145         secret = self.secrets[secret_id]
146 
147         secret['version_id'] = client_request_token or ''
148         secret['rotation_lambda_arn'] = rotation_lambda_arn or ''
149         if rotation_rules:
150             secret['auto_rotate_after_days'] = rotation_rules.get(rotation_days, 0)
151         if secret['auto_rotate_after_days'] > 0:
152             secret['rotation_enabled'] = True
153 
154         response = json.dumps({
155             "ARN": secret_arn(self.region, secret['secret_id']),
156             "Name": secret['name'],
157             "VersionId": secret['version_id']
158         })
159 
160         return response
161 
162     def get_random_password(self, password_length,
163                             exclude_characters, exclude_numbers,
164                             exclude_punctuation, exclude_uppercase,
165                             exclude_lowercase, include_space,
166                             require_each_included_type):
167         # password size must have value less than or equal to 4096
168         if password_length > 4096:
169             raise ClientError(
170                 "ClientError: An error occurred (ValidationException) \
171                 when calling the GetRandomPassword operation: 1 validation error detected: Value '{}' at 'passwordLength' \
172                 failed to satisfy constraint: Member must have value less than or equal to 4096".format(password_length))
173         if password_length < 4:
174             raise InvalidParameterException(
175                 "InvalidParameterException: An error occurred (InvalidParameterException) \
176                 when calling the GetRandomPassword operation: Password length is too short based on the required types.")
177 
178         response = json.dumps({
179             "RandomPassword": random_password(password_length,
180                                               exclude_characters,
181                                               exclude_numbers,
182                                               exclude_punctuation,
183                                               exclude_uppercase,
184                                               exclude_lowercase,
185                                               include_space,
186                                               require_each_included_type)
187         })
188 
189         return response
190 
191 
192 available_regions = (
193     boto3.session.Session().get_available_regions("secretsmanager")
194 )
195 secretsmanager_backends = {region: SecretsManagerBackend(region_name=region)
196                            for region in available_regions}
197
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/moto/secretsmanager/models.py b/moto/secretsmanager/models.py
--- a/moto/secretsmanager/models.py
+++ b/moto/secretsmanager/models.py
@@ -188,6 +188,31 @@
 
         return response
 
+    def list_secrets(self, max_results, next_token):
+        # TODO implement pagination and limits
+
+        secret_list = [{
+            "ARN": secret_arn(self.region, secret['secret_id']),
+            "DeletedDate": None,
+            "Description": "",
+            "KmsKeyId": "",
+            "LastAccessedDate": None,
+            "LastChangedDate": None,
+            "LastRotatedDate": None,
+            "Name": secret['name'],
+            "RotationEnabled": secret['rotation_enabled'],
+            "RotationLambdaARN": secret['rotation_lambda_arn'],
+            "RotationRules": {
+                "AutomaticallyAfterDays": secret['auto_rotate_after_days']
+            },
+            "SecretVersionsToStages": {
+                secret['version_id']: ["AWSCURRENT"]
+            },
+            "Tags": secret['tags']
+        } for secret in self.secrets.values()]
+
+        return secret_list, None
+
 
 available_regions = (
     boto3.session.Session().get_available_regions("secretsmanager")
diff --git a/moto/secretsmanager/responses.py b/moto/secretsmanager/responses.py
--- a/moto/secretsmanager/responses.py
+++ b/moto/secretsmanager/responses.py
@@ -4,6 +4,8 @@
 
 from .models import secretsmanager_backends
 
+import json
+
 
 class SecretsManagerResponse(BaseResponse):
 
@@ -64,3 +66,12 @@
             rotation_lambda_arn=rotation_lambda_arn,
             rotation_rules=rotation_rules
         )
+
+    def list_secrets(self):
+        max_results = self._get_int_param("MaxResults")
+        next_token = self._get_param("NextToken")
+        secret_list, next_token = secretsmanager_backends[self.region].list_secrets(
+            max_results=max_results,
+            next_token=next_token,
+        )
+        return json.dumps(dict(SecretList=secret_list, NextToken=next_token))

{"golden_diff": "diff --git a/moto/secretsmanager/models.py b/moto/secretsmanager/models.py\n--- a/moto/secretsmanager/models.py\n+++ b/moto/secretsmanager/models.py\n@@ -188,6 +188,31 @@\n \n         return response\n \n+    def list_secrets(self, max_results, next_token):\n+        # TODO implement pagination and limits\n+\n+        secret_list = [{\n+            \"ARN\": secret_arn(self.region, secret['secret_id']),\n+            \"DeletedDate\": None,\n+            \"Description\": \"\",\n+            \"KmsKeyId\": \"\",\n+            \"LastAccessedDate\": None,\n+            \"LastChangedDate\": None,\n+            \"LastRotatedDate\": None,\n+            \"Name\": secret['name'],\n+            \"RotationEnabled\": secret['rotation_enabled'],\n+            \"RotationLambdaARN\": secret['rotation_lambda_arn'],\n+            \"RotationRules\": {\n+                \"AutomaticallyAfterDays\": secret['auto_rotate_after_days']\n+            },\n+            \"SecretVersionsToStages\": {\n+                secret['version_id']: [\"AWSCURRENT\"]\n+            },\n+            \"Tags\": secret['tags']\n+        } for secret in self.secrets.values()]\n+\n+        return secret_list, None\n+\n \n available_regions = (\n     boto3.session.Session().get_available_regions(\"secretsmanager\")\ndiff --git a/moto/secretsmanager/responses.py b/moto/secretsmanager/responses.py\n--- a/moto/secretsmanager/responses.py\n+++ b/moto/secretsmanager/responses.py\n@@ -4,6 +4,8 @@\n \n from .models import secretsmanager_backends\n \n+import json\n+\n \n class SecretsManagerResponse(BaseResponse):\n \n@@ -64,3 +66,12 @@\n             rotation_lambda_arn=rotation_lambda_arn,\n             rotation_rules=rotation_rules\n         )\n+\n+    def list_secrets(self):\n+        max_results = self._get_int_param(\"MaxResults\")\n+        next_token = self._get_param(\"NextToken\")\n+        secret_list, next_token = secretsmanager_backends[self.region].list_secrets(\n+            max_results=max_results,\n+            next_token=next_token,\n+        )\n+        return json.dumps(dict(SecretList=secret_list, NextToken=next_token))\n", "issue": "Support Secrets Manager list-secrets\nImplement support for `aws secretsmanager list-secrets`\r\n\r\nNote: this API call is paginated.\n", "before_files": [{"content": "from __future__ import unicode_literals\n\nfrom moto.core.responses import BaseResponse\n\nfrom .models import secretsmanager_backends\n\n\nclass SecretsManagerResponse(BaseResponse):\n\n    def get_secret_value(self):\n        secret_id = self._get_param('SecretId')\n        version_id = self._get_param('VersionId')\n        version_stage = self._get_param('VersionStage')\n        return secretsmanager_backends[self.region].get_secret_value(\n            secret_id=secret_id,\n            version_id=version_id,\n            version_stage=version_stage)\n\n    def create_secret(self):\n        name = self._get_param('Name')\n        secret_string = self._get_param('SecretString')\n        tags = self._get_param('Tags', if_none=[])\n        return secretsmanager_backends[self.region].create_secret(\n            name=name,\n            secret_string=secret_string,\n            tags=tags\n        )\n\n    def get_random_password(self):\n        password_length = self._get_param('PasswordLength', if_none=32)\n        exclude_characters = self._get_param('ExcludeCharacters', if_none='')\n        exclude_numbers = self._get_param('ExcludeNumbers', if_none=False)\n        exclude_punctuation = self._get_param('ExcludePunctuation', if_none=False)\n        exclude_uppercase = self._get_param('ExcludeUppercase', if_none=False)\n        exclude_lowercase = self._get_param('ExcludeLowercase', if_none=False)\n        include_space = self._get_param('IncludeSpace', if_none=False)\n        require_each_included_type = self._get_param(\n            'RequireEachIncludedType', if_none=True)\n        return secretsmanager_backends[self.region].get_random_password(\n            password_length=password_length,\n            exclude_characters=exclude_characters,\n            exclude_numbers=exclude_numbers,\n            exclude_punctuation=exclude_punctuation,\n            exclude_uppercase=exclude_uppercase,\n            exclude_lowercase=exclude_lowercase,\n            include_space=include_space,\n            require_each_included_type=require_each_included_type\n        )\n\n    def describe_secret(self):\n        secret_id = self._get_param('SecretId')\n        return secretsmanager_backends[self.region].describe_secret(\n            secret_id=secret_id\n        )\n\n    def rotate_secret(self):\n        client_request_token = self._get_param('ClientRequestToken')\n        rotation_lambda_arn = self._get_param('RotationLambdaARN')\n        rotation_rules = self._get_param('RotationRules')\n        secret_id = self._get_param('SecretId')\n        return secretsmanager_backends[self.region].rotate_secret(\n            secret_id=secret_id,\n            client_request_token=client_request_token,\n            rotation_lambda_arn=rotation_lambda_arn,\n            rotation_rules=rotation_rules\n        )\n", "path": "moto/secretsmanager/responses.py"}, {"content": "from __future__ import unicode_literals\n\nimport time\nimport json\nimport uuid\n\nimport boto3\n\nfrom moto.core import BaseBackend, BaseModel\nfrom .exceptions import (\n    ResourceNotFoundException,\n    InvalidParameterException,\n    ClientError\n)\nfrom .utils import random_password, secret_arn\n\n\nclass SecretsManager(BaseModel):\n\n    def __init__(self, region_name, **kwargs):\n        self.region = region_name\n\n\nclass SecretsManagerBackend(BaseBackend):\n\n    def __init__(self, region_name=None, **kwargs):\n        super(SecretsManagerBackend, self).__init__()\n        self.region = region_name\n        self.secrets = {}\n\n    def reset(self):\n        region_name = self.region\n        self.__dict__ = {}\n        self.__init__(region_name)\n\n    def _is_valid_identifier(self, identifier):\n        return identifier in self.secrets\n\n    def get_secret_value(self, secret_id, version_id, version_stage):\n\n        if not self._is_valid_identifier(secret_id):\n            raise ResourceNotFoundException()\n\n        secret = self.secrets[secret_id]\n\n        response = json.dumps({\n            \"ARN\": secret_arn(self.region, secret['secret_id']),\n            \"Name\": secret['name'],\n            \"VersionId\": secret['version_id'],\n            \"SecretString\": secret['secret_string'],\n            \"VersionStages\": [\n                \"AWSCURRENT\",\n            ],\n            \"CreatedDate\": secret['createdate']\n        })\n\n        return response\n\n    def create_secret(self, name, secret_string, tags, **kwargs):\n\n        generated_version_id = str(uuid.uuid4())\n\n        secret = {\n            'secret_string': secret_string,\n            'secret_id': name,\n            'name': name,\n            'createdate': int(time.time()),\n            'rotation_enabled': False,\n            'rotation_lambda_arn': '',\n            'auto_rotate_after_days': 0,\n            'version_id': generated_version_id,\n            'tags': tags\n        }\n\n        self.secrets[name] = secret\n\n        response = json.dumps({\n            \"ARN\": secret_arn(self.region, name),\n            \"Name\": name,\n            \"VersionId\": generated_version_id,\n        })\n\n        return response\n\n    def describe_secret(self, secret_id):\n        if not self._is_valid_identifier(secret_id):\n            raise ResourceNotFoundException\n\n        secret = self.secrets[secret_id]\n\n        response = json.dumps({\n            \"ARN\": secret_arn(self.region, secret['secret_id']),\n            \"Name\": secret['name'],\n            \"Description\": \"\",\n            \"KmsKeyId\": \"\",\n            \"RotationEnabled\": secret['rotation_enabled'],\n            \"RotationLambdaARN\": secret['rotation_lambda_arn'],\n            \"RotationRules\": {\n                \"AutomaticallyAfterDays\": secret['auto_rotate_after_days']\n            },\n            \"LastRotatedDate\": None,\n            \"LastChangedDate\": None,\n            \"LastAccessedDate\": None,\n            \"DeletedDate\": None,\n            \"Tags\": secret['tags']\n        })\n\n        return response\n\n    def rotate_secret(self, secret_id, client_request_token=None,\n                      rotation_lambda_arn=None, rotation_rules=None):\n\n        rotation_days = 'AutomaticallyAfterDays'\n\n        if not self._is_valid_identifier(secret_id):\n            raise ResourceNotFoundException\n\n        if client_request_token:\n            token_length = len(client_request_token)\n            if token_length < 32 or token_length > 64:\n                msg = (\n                    'ClientRequestToken '\n                    'must be 32-64 characters long.'\n                )\n                raise InvalidParameterException(msg)\n\n        if rotation_lambda_arn:\n            if len(rotation_lambda_arn) > 2048:\n                msg = (\n                    'RotationLambdaARN '\n                    'must <= 2048 characters long.'\n                )\n                raise InvalidParameterException(msg)\n\n        if rotation_rules:\n            if rotation_days in rotation_rules:\n                rotation_period = rotation_rules[rotation_days]\n                if rotation_period < 1 or rotation_period > 1000:\n                    msg = (\n                        'RotationRules.AutomaticallyAfterDays '\n                        'must be within 1-1000.'\n                    )\n                    raise InvalidParameterException(msg)\n\n        secret = self.secrets[secret_id]\n\n        secret['version_id'] = client_request_token or ''\n        secret['rotation_lambda_arn'] = rotation_lambda_arn or ''\n        if rotation_rules:\n            secret['auto_rotate_after_days'] = rotation_rules.get(rotation_days, 0)\n        if secret['auto_rotate_after_days'] > 0:\n            secret['rotation_enabled'] = True\n\n        response = json.dumps({\n            \"ARN\": secret_arn(self.region, secret['secret_id']),\n            \"Name\": secret['name'],\n            \"VersionId\": secret['version_id']\n        })\n\n        return response\n\n    def get_random_password(self, password_length,\n                            exclude_characters, exclude_numbers,\n                            exclude_punctuation, exclude_uppercase,\n                            exclude_lowercase, include_space,\n                            require_each_included_type):\n        # password size must have value less than or equal to 4096\n        if password_length > 4096:\n            raise ClientError(\n                \"ClientError: An error occurred (ValidationException) \\\n                when calling the GetRandomPassword operation: 1 validation error detected: Value '{}' at 'passwordLength' \\\n                failed to satisfy constraint: Member must have value less than or equal to 4096\".format(password_length))\n        if password_length < 4:\n            raise InvalidParameterException(\n                \"InvalidParameterException: An error occurred (InvalidParameterException) \\\n                when calling the GetRandomPassword operation: Password length is too short based on the required types.\")\n\n        response = json.dumps({\n            \"RandomPassword\": random_password(password_length,\n                                              exclude_characters,\n                                              exclude_numbers,\n                                              exclude_punctuation,\n                                              exclude_uppercase,\n                                              exclude_lowercase,\n                                              include_space,\n                                              require_each_included_type)\n        })\n\n        return response\n\n\navailable_regions = (\n    boto3.session.Session().get_available_regions(\"secretsmanager\")\n)\nsecretsmanager_backends = {region: SecretsManagerBackend(region_name=region)\n                           for region in available_regions}\n", "path": "moto/secretsmanager/models.py"}], "after_files": [{"content": "from __future__ import unicode_literals\n\nfrom moto.core.responses import BaseResponse\n\nfrom .models import secretsmanager_backends\n\nimport json\n\n\nclass SecretsManagerResponse(BaseResponse):\n\n    def get_secret_value(self):\n        secret_id = self._get_param('SecretId')\n        version_id = self._get_param('VersionId')\n        version_stage = self._get_param('VersionStage')\n        return secretsmanager_backends[self.region].get_secret_value(\n            secret_id=secret_id,\n            version_id=version_id,\n            version_stage=version_stage)\n\n    def create_secret(self):\n        name = self._get_param('Name')\n        secret_string = self._get_param('SecretString')\n        tags = self._get_param('Tags', if_none=[])\n        return secretsmanager_backends[self.region].create_secret(\n            name=name,\n            secret_string=secret_string,\n            tags=tags\n        )\n\n    def get_random_password(self):\n        password_length = self._get_param('PasswordLength', if_none=32)\n        exclude_characters = self._get_param('ExcludeCharacters', if_none='')\n        exclude_numbers = self._get_param('ExcludeNumbers', if_none=False)\n        exclude_punctuation = self._get_param('ExcludePunctuation', if_none=False)\n        exclude_uppercase = self._get_param('ExcludeUppercase', if_none=False)\n        exclude_lowercase = self._get_param('ExcludeLowercase', if_none=False)\n        include_space = self._get_param('IncludeSpace', if_none=False)\n        require_each_included_type = self._get_param(\n            'RequireEachIncludedType', if_none=True)\n        return secretsmanager_backends[self.region].get_random_password(\n            password_length=password_length,\n            exclude_characters=exclude_characters,\n            exclude_numbers=exclude_numbers,\n            exclude_punctuation=exclude_punctuation,\n            exclude_uppercase=exclude_uppercase,\n            exclude_lowercase=exclude_lowercase,\n            include_space=include_space,\n            require_each_included_type=require_each_included_type\n        )\n\n    def describe_secret(self):\n        secret_id = self._get_param('SecretId')\n        return secretsmanager_backends[self.region].describe_secret(\n            secret_id=secret_id\n        )\n\n    def rotate_secret(self):\n        client_request_token = self._get_param('ClientRequestToken')\n        rotation_lambda_arn = self._get_param('RotationLambdaARN')\n        rotation_rules = self._get_param('RotationRules')\n        secret_id = self._get_param('SecretId')\n        return secretsmanager_backends[self.region].rotate_secret(\n            secret_id=secret_id,\n            client_request_token=client_request_token,\n            rotation_lambda_arn=rotation_lambda_arn,\n            rotation_rules=rotation_rules\n        )\n\n    def list_secrets(self):\n        max_results = self._get_int_param(\"MaxResults\")\n        next_token = self._get_param(\"NextToken\")\n        secret_list, next_token = secretsmanager_backends[self.region].list_secrets(\n            max_results=max_results,\n            next_token=next_token,\n        )\n        return json.dumps(dict(SecretList=secret_list, NextToken=next_token))\n", "path": "moto/secretsmanager/responses.py"}, {"content": "from __future__ import unicode_literals\n\nimport time\nimport json\nimport uuid\n\nimport boto3\n\nfrom moto.core import BaseBackend, BaseModel\nfrom .exceptions import (\n    ResourceNotFoundException,\n    InvalidParameterException,\n    ClientError\n)\nfrom .utils import random_password, secret_arn\n\n\nclass SecretsManager(BaseModel):\n\n    def __init__(self, region_name, **kwargs):\n        self.region = region_name\n\n\nclass SecretsManagerBackend(BaseBackend):\n\n    def __init__(self, region_name=None, **kwargs):\n        super(SecretsManagerBackend, self).__init__()\n        self.region = region_name\n        self.secrets = {}\n\n    def reset(self):\n        region_name = self.region\n        self.__dict__ = {}\n        self.__init__(region_name)\n\n    def _is_valid_identifier(self, identifier):\n        return identifier in self.secrets\n\n    def get_secret_value(self, secret_id, version_id, version_stage):\n\n        if not self._is_valid_identifier(secret_id):\n            raise ResourceNotFoundException()\n\n        secret = self.secrets[secret_id]\n\n        response = json.dumps({\n            \"ARN\": secret_arn(self.region, secret['secret_id']),\n            \"Name\": secret['name'],\n            \"VersionId\": secret['version_id'],\n            \"SecretString\": secret['secret_string'],\n            \"VersionStages\": [\n                \"AWSCURRENT\",\n            ],\n            \"CreatedDate\": secret['createdate']\n        })\n\n        return response\n\n    def create_secret(self, name, secret_string, tags, **kwargs):\n\n        generated_version_id = str(uuid.uuid4())\n\n        secret = {\n            'secret_string': secret_string,\n            'secret_id': name,\n            'name': name,\n            'createdate': int(time.time()),\n            'rotation_enabled': False,\n            'rotation_lambda_arn': '',\n            'auto_rotate_after_days': 0,\n            'version_id': generated_version_id,\n            'tags': tags\n        }\n\n        self.secrets[name] = secret\n\n        response = json.dumps({\n            \"ARN\": secret_arn(self.region, name),\n            \"Name\": name,\n            \"VersionId\": generated_version_id,\n        })\n\n        return response\n\n    def describe_secret(self, secret_id):\n        if not self._is_valid_identifier(secret_id):\n            raise ResourceNotFoundException\n\n        secret = self.secrets[secret_id]\n\n        response = json.dumps({\n            \"ARN\": secret_arn(self.region, secret['secret_id']),\n            \"Name\": secret['name'],\n            \"Description\": \"\",\n            \"KmsKeyId\": \"\",\n            \"RotationEnabled\": secret['rotation_enabled'],\n            \"RotationLambdaARN\": secret['rotation_lambda_arn'],\n            \"RotationRules\": {\n                \"AutomaticallyAfterDays\": secret['auto_rotate_after_days']\n            },\n            \"LastRotatedDate\": None,\n            \"LastChangedDate\": None,\n            \"LastAccessedDate\": None,\n            \"DeletedDate\": None,\n            \"Tags\": secret['tags']\n        })\n\n        return response\n\n    def rotate_secret(self, secret_id, client_request_token=None,\n                      rotation_lambda_arn=None, rotation_rules=None):\n\n        rotation_days = 'AutomaticallyAfterDays'\n\n        if not self._is_valid_identifier(secret_id):\n            raise ResourceNotFoundException\n\n        if client_request_token:\n            token_length = len(client_request_token)\n            if token_length < 32 or token_length > 64:\n                msg = (\n                    'ClientRequestToken '\n                    'must be 32-64 characters long.'\n                )\n                raise InvalidParameterException(msg)\n\n        if rotation_lambda_arn:\n            if len(rotation_lambda_arn) > 2048:\n                msg = (\n                    'RotationLambdaARN '\n                    'must <= 2048 characters long.'\n                )\n                raise InvalidParameterException(msg)\n\n        if rotation_rules:\n            if rotation_days in rotation_rules:\n                rotation_period = rotation_rules[rotation_days]\n                if rotation_period < 1 or rotation_period > 1000:\n                    msg = (\n                        'RotationRules.AutomaticallyAfterDays '\n                        'must be within 1-1000.'\n                    )\n                    raise InvalidParameterException(msg)\n\n        secret = self.secrets[secret_id]\n\n        secret['version_id'] = client_request_token or ''\n        secret['rotation_lambda_arn'] = rotation_lambda_arn or ''\n        if rotation_rules:\n            secret['auto_rotate_after_days'] = rotation_rules.get(rotation_days, 0)\n        if secret['auto_rotate_after_days'] > 0:\n            secret['rotation_enabled'] = True\n\n        response = json.dumps({\n            \"ARN\": secret_arn(self.region, secret['secret_id']),\n            \"Name\": secret['name'],\n            \"VersionId\": secret['version_id']\n        })\n\n        return response\n\n    def get_random_password(self, password_length,\n                            exclude_characters, exclude_numbers,\n                            exclude_punctuation, exclude_uppercase,\n                            exclude_lowercase, include_space,\n                            require_each_included_type):\n        # password size must have value less than or equal to 4096\n        if password_length > 4096:\n            raise ClientError(\n                \"ClientError: An error occurred (ValidationException) \\\n                when calling the GetRandomPassword operation: 1 validation error detected: Value '{}' at 'passwordLength' \\\n                failed to satisfy constraint: Member must have value less than or equal to 4096\".format(password_length))\n        if password_length < 4:\n            raise InvalidParameterException(\n                \"InvalidParameterException: An error occurred (InvalidParameterException) \\\n                when calling the GetRandomPassword operation: Password length is too short based on the required types.\")\n\n        response = json.dumps({\n            \"RandomPassword\": random_password(password_length,\n                                              exclude_characters,\n                                              exclude_numbers,\n                                              exclude_punctuation,\n                                              exclude_uppercase,\n                                              exclude_lowercase,\n                                              include_space,\n                                              require_each_included_type)\n        })\n\n        return response\n\n    def list_secrets(self, max_results, next_token):\n        # TODO implement pagination and limits\n\n        secret_list = [{\n            \"ARN\": secret_arn(self.region, secret['secret_id']),\n            \"DeletedDate\": None,\n            \"Description\": \"\",\n            \"KmsKeyId\": \"\",\n            \"LastAccessedDate\": None,\n            \"LastChangedDate\": None,\n            \"LastRotatedDate\": None,\n            \"Name\": secret['name'],\n            \"RotationEnabled\": secret['rotation_enabled'],\n            \"RotationLambdaARN\": secret['rotation_lambda_arn'],\n            \"RotationRules\": {\n                \"AutomaticallyAfterDays\": secret['auto_rotate_after_days']\n            },\n            \"SecretVersionsToStages\": {\n                secret['version_id']: [\"AWSCURRENT\"]\n            },\n            \"Tags\": secret['tags']\n        } for secret in self.secrets.values()]\n\n        return secret_list, None\n\n\navailable_regions = (\n    boto3.session.Session().get_available_regions(\"secretsmanager\")\n)\nsecretsmanager_backends = {region: SecretsManagerBackend(region_name=region)\n                           for region in available_regions}\n", "path": "moto/secretsmanager/models.py"}]}