Add tagging support for Cognito identity pools (#4147)
This commit is contained in:
parent
3336539293
commit
8e61504482
@ -29,6 +29,8 @@ class CognitoIdentity(BaseModel):
|
||||
self.identity_pool_id = get_random_identity_id(region)
|
||||
self.creation_time = datetime.datetime.utcnow()
|
||||
|
||||
self.tags = kwargs.get("tags") or {}
|
||||
|
||||
def to_json(self):
|
||||
return json.dumps(
|
||||
{
|
||||
@ -68,7 +70,7 @@ class CognitoIdentityBackend(BaseBackend):
|
||||
"DeveloperProviderName": identity_pool.developer_provider_name,
|
||||
"IdentityPoolId": identity_pool.identity_pool_id,
|
||||
"IdentityPoolName": identity_pool.identity_pool_name,
|
||||
"IdentityPoolTags": {}, # TODO: add tags
|
||||
"IdentityPoolTags": identity_pool.tags,
|
||||
"OpenIdConnectProviderARNs": identity_pool.open_id_connect_provider_arns,
|
||||
"SamlProviderARNs": identity_pool.saml_provider_arns,
|
||||
"SupportedLoginProviders": identity_pool.supported_login_providers,
|
||||
@ -86,6 +88,7 @@ class CognitoIdentityBackend(BaseBackend):
|
||||
open_id_connect_provider_arns,
|
||||
cognito_identity_providers,
|
||||
saml_provider_arns,
|
||||
tags=None,
|
||||
):
|
||||
new_identity = CognitoIdentity(
|
||||
self.region,
|
||||
@ -96,6 +99,7 @@ class CognitoIdentityBackend(BaseBackend):
|
||||
open_id_connect_provider_arns=open_id_connect_provider_arns,
|
||||
cognito_identity_providers=cognito_identity_providers,
|
||||
saml_provider_arns=saml_provider_arns,
|
||||
tags=tags,
|
||||
)
|
||||
self.identity_pools[new_identity.identity_pool_id] = new_identity
|
||||
|
||||
@ -113,7 +117,7 @@ class CognitoIdentityBackend(BaseBackend):
|
||||
provider_arns,
|
||||
identity_providers,
|
||||
saml_providers,
|
||||
pool_tags,
|
||||
tags=None,
|
||||
):
|
||||
pool = self.identity_pools[identity_pool_id]
|
||||
pool.identity_pool_name = pool.identity_pool_name or identity_pool_name
|
||||
@ -129,6 +133,8 @@ class CognitoIdentityBackend(BaseBackend):
|
||||
pool.cognito_identity_providers = identity_providers
|
||||
if saml_providers is not None:
|
||||
pool.saml_provider_arns = saml_providers
|
||||
if tags:
|
||||
pool.tags = tags
|
||||
|
||||
response = pool.to_json()
|
||||
return response
|
||||
|
@ -16,6 +16,7 @@ class CognitoIdentityResponse(BaseResponse):
|
||||
open_id_connect_provider_arns = self._get_param("OpenIdConnectProviderARNs")
|
||||
cognito_identity_providers = self._get_param("CognitoIdentityProviders")
|
||||
saml_provider_arns = self._get_param("SamlProviderARNs")
|
||||
pool_tags = self._get_param("IdentityPoolTags")
|
||||
|
||||
return cognitoidentity_backends[self.region].create_identity_pool(
|
||||
identity_pool_name=identity_pool_name,
|
||||
@ -25,6 +26,7 @@ class CognitoIdentityResponse(BaseResponse):
|
||||
open_id_connect_provider_arns=open_id_connect_provider_arns,
|
||||
cognito_identity_providers=cognito_identity_providers,
|
||||
saml_provider_arns=saml_provider_arns,
|
||||
tags=pool_tags,
|
||||
)
|
||||
|
||||
def update_identity_pool(self):
|
||||
@ -34,10 +36,10 @@ class CognitoIdentityResponse(BaseResponse):
|
||||
allow_classic = self._get_bool_param("AllowClassicFlow")
|
||||
login_providers = self._get_param("SupportedLoginProviders")
|
||||
provider_name = self._get_param("DeveloperProviderName")
|
||||
provider_arns = self._get_multi_param("OpenIdConnectProviderARNs")
|
||||
identity_providers = self._get_multi_param_dict("CognitoIdentityProviders")
|
||||
saml_providers = self._get_multi_param("SamlProviderARNs")
|
||||
pool_tags = self._get_multi_param_dict("IdentityPoolTags")
|
||||
provider_arns = self._get_param("OpenIdConnectProviderARNs")
|
||||
identity_providers = self._get_param("CognitoIdentityProviders")
|
||||
saml_providers = self._get_param("SamlProviderARNs")
|
||||
pool_tags = self._get_param("IdentityPoolTags")
|
||||
|
||||
return cognitoidentity_backends[self.region].update_identity_pool(
|
||||
identity_pool_id=pool_id,
|
||||
@ -49,7 +51,7 @@ class CognitoIdentityResponse(BaseResponse):
|
||||
provider_arns=provider_arns,
|
||||
identity_providers=identity_providers,
|
||||
saml_providers=saml_providers,
|
||||
pool_tags=pool_tags,
|
||||
tags=pool_tags,
|
||||
)
|
||||
|
||||
def get_id(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user