11
11
from botocore .config import Config
12
12
13
13
if TYPE_CHECKING :
14
- from mypy_boto3_appconfig import AppConfigClient
14
+ from mypy_boto3_appconfigdata import AppConfigDataClient
15
15
16
16
from ...shared import constants
17
17
from ...shared .functions import resolve_env_var_choice
@@ -34,8 +34,8 @@ class AppConfigProvider(BaseProvider):
34
34
Botocore configuration to pass during client initialization
35
35
boto3_session : boto3.session.Session, optional
36
36
Boto3 session to create a boto3_client from
37
- boto3_client: AppConfigClient , optional
38
- Boto3 AppConfig Client to use, boto3_session will be ignored if both are provided
37
+ boto3_client: AppConfigDataClient , optional
38
+ Boto3 AppConfigData Client to use, boto3_session will be ignored if both are provided
39
39
40
40
Example
41
41
-------
@@ -73,16 +73,16 @@ def __init__(
73
73
application : Optional [str ] = None ,
74
74
config : Optional [Config ] = None ,
75
75
boto3_session : Optional [boto3 .session .Session ] = None ,
76
- boto3_client : Optional ["AppConfigClient " ] = None ,
76
+ boto3_client : Optional ["AppConfigDataClient " ] = None ,
77
77
):
78
78
"""
79
79
Initialize the App Config client
80
80
"""
81
81
82
82
super ().__init__ ()
83
83
84
- self .client : "AppConfigClient " = self ._build_boto3_client (
85
- service_name = "appconfig " , client = boto3_client , session = boto3_session , config = config
84
+ self .client : "AppConfigDataClient " = self ._build_boto3_client (
85
+ service_name = "appconfigdata " , client = boto3_client , session = boto3_session , config = config
86
86
)
87
87
88
88
self .application = resolve_env_var_choice (
@@ -91,6 +91,10 @@ def __init__(
91
91
self .environment = environment
92
92
self .current_version = ""
93
93
94
+ # new appconfidgdata apis
95
+ self .api_token = ""
96
+ self .last_returned_value = ""
97
+
94
98
def _get (self , name : str , ** sdk_options ) -> str :
95
99
"""
96
100
Retrieve a parameter value from AWS App config.
@@ -102,14 +106,24 @@ def _get(self, name: str, **sdk_options) -> str:
102
106
sdk_options: dict, optional
103
107
Dictionary of options that will be passed to the client's get_configuration API call
104
108
"""
109
+ if not self .api_token :
110
+ print ("TOKEN" )
111
+ sdk_options ["ConfigurationProfileIdentifier" ] = name
112
+ sdk_options ["ApplicationIdentifier" ] = self .application
113
+ sdk_options ["EnvironmentIdentifier" ] = self .environment
114
+
115
+ response_configuration = self .client .start_configuration_session (** sdk_options )
116
+
117
+ self .api_token = response_configuration ["InitialConfigurationToken" ]
118
+
119
+ response = self .client .get_latest_configuration (ConfigurationToken = self .api_token )
120
+ return_value = response ["Content" ].read ()
121
+ self .api_token = response ["NextPollConfigurationToken" ]
105
122
106
- sdk_options ["Configuration" ] = name
107
- sdk_options ["Application" ] = self .application
108
- sdk_options ["Environment" ] = self .environment
109
- sdk_options ["ClientId" ] = CLIENT_ID
123
+ if return_value :
124
+ self .last_returned_value = return_value
110
125
111
- response = self .client .get_configuration (** sdk_options )
112
- return response ["Content" ].read () # read() of botocore.response.StreamingBody
126
+ return self .last_returned_value
113
127
114
128
def _get_multiple (self , path : str , ** sdk_options ) -> Dict [str , str ]:
115
129
"""
0 commit comments