Skip to content

Commit

Permalink
AppSync: add visibility options (getmoto#8188)
Browse files Browse the repository at this point in the history
  • Loading branch information
zkarpinski authored Oct 2, 2024
1 parent 5117905 commit 3fcadd5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions moto/appsync/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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,
}


Expand All @@ -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,
Expand All @@ -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(
Expand Down
2 changes: 2 additions & 0 deletions moto/appsync/responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions tests/test_appsync/test_appsync.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -41,6 +42,7 @@ def test_create_graphql_api_advanced():
"cloudWatchLogsRoleArn": "arn:aws:cloudwatch:role",
},
xrayEnabled=True,
visibility="PRIVATE",
)

assert "graphqlApi" in resp
Expand All @@ -61,6 +63,7 @@ def test_create_graphql_api_advanced():
"fieldLogLevel": "ERROR",
}
assert api["xrayEnabled"] is True
assert api["visibility"] == "PRIVATE"


@mock_aws
Expand All @@ -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
Expand Down

0 comments on commit 3fcadd5

Please sign in to comment.