diff --git a/moto/appsync/models.py b/moto/appsync/models.py index c2dd460a9fc0..d5a9e39c6e43 100644 --- a/moto/appsync/models.py +++ b/moto/appsync/models.py @@ -193,6 +193,7 @@ def __init__( user_pool_config: str, open_id_connect_config: str, lambda_authorizer_config: str, + visibility: str, ): self.region = region self.name = name @@ -204,6 +205,7 @@ def __init__( self.open_id_connect_config = open_id_connect_config self.user_pool_config = user_pool_config self.xray_enabled = xray_enabled + self.visibility = visibility or "GLOBAL" # Default to Global if not provided self.arn = f"arn:{get_partition(self.region)}:appsync:{self.region}:{account_id}:apis/{self.api_id}" self.graphql_schema: Optional[GraphqlSchema] = None @@ -318,6 +320,7 @@ def to_json(self) -> Dict[str, Any]: "openIDConnectConfig": self.open_id_connect_config, "userPoolConfig": self.user_pool_config, "xrayEnabled": self.xray_enabled, + "visibility": self.visibility, } @@ -340,6 +343,7 @@ def create_graphql_api( xray_enabled: str, lambda_authorizer_config: str, tags: Dict[str, str], + visibility: str, ) -> GraphqlAPI: graphql_api = GraphqlAPI( account_id=self.account_id, @@ -352,6 +356,7 @@ def create_graphql_api( user_pool_config=user_pool_config, open_id_connect_config=open_id_connect_config, lambda_authorizer_config=lambda_authorizer_config, + visibility=visibility, ) self.graphql_apis[graphql_api.api_id] = graphql_api self.tagger.tag_resource( diff --git a/moto/appsync/responses.py b/moto/appsync/responses.py index c2096000e705..962511bad9be 100644 --- a/moto/appsync/responses.py +++ b/moto/appsync/responses.py @@ -32,6 +32,7 @@ def create_graphql_api(self) -> str: ) xray_enabled = params.get("xrayEnabled", False) lambda_authorizer_config = params.get("lambdaAuthorizerConfig") + visibility = params.get("visibility") graphql_api = self.appsync_backend.create_graphql_api( name=name, log_config=log_config, @@ -42,6 +43,7 @@ def create_graphql_api(self) -> str: xray_enabled=xray_enabled, lambda_authorizer_config=lambda_authorizer_config, tags=tags, + visibility=visibility, ) response = graphql_api.to_json() response["tags"] = self.appsync_backend.list_tags_for_resource(graphql_api.arn) diff --git a/tests/test_appsync/test_appsync.py b/tests/test_appsync/test_appsync.py index 5f43b7a01430..7c752c5620a0 100644 --- a/tests/test_appsync/test_appsync.py +++ b/tests/test_appsync/test_appsync.py @@ -27,6 +27,7 @@ def test_create_graphql_api(): assert api["xrayEnabled"] is False assert "additionalAuthenticationProviders" not in api assert "logConfig" not in api + assert api["visibility"] == "GLOBAL" @mock_aws @@ -41,6 +42,7 @@ def test_create_graphql_api_advanced(): "cloudWatchLogsRoleArn": "arn:aws:cloudwatch:role", }, xrayEnabled=True, + visibility="PRIVATE", ) assert "graphqlApi" in resp @@ -61,6 +63,7 @@ def test_create_graphql_api_advanced(): "fieldLogLevel": "ERROR", } assert api["xrayEnabled"] is True + assert api["visibility"] == "PRIVATE" @mock_aws @@ -77,6 +80,7 @@ def test_get_graphql_api(): assert api["name"] == "api1" assert "apiId" in api assert api["authenticationType"] == "API_KEY" + assert api["visibility"] == "GLOBAL" @mock_aws