@@ -96,15 +96,15 @@ def main(
9696 headers .append (
9797 (
9898 "login-account" ,
99- f"accountTypes/{ login_account_type } /accounts/{ login_account_id } " ,
99+ f"accountTypes/{ login_account_type . name } /accounts/{ login_account_id } " ,
100100 )
101101 )
102102
103103 if linked_account_id :
104104 headers .append (
105105 (
106106 "linked-account" ,
107- f"accountTypes/{ linked_account_type } /accounts/{ linked_account_id } " ,
107+ f"accountTypes/{ linked_account_type . name } /accounts/{ linked_account_id } " ,
108108 )
109109 )
110110
@@ -173,7 +173,7 @@ def main(
173173
174174 # Builds the request targeting the parent operating account.
175175 request = datamanager_v1 .CreateUserListRequest (
176- parent = f"accountTypes/{ operating_account_type } /accounts/{ operating_account_id } " ,
176+ parent = f"accountTypes/{ operating_account_type . name } /accounts/{ operating_account_id } " ,
177177 user_list = user_list ,
178178 # Sets validate_only. If true, then the Data Manager API only
179179 # validates the request but doesn't apply changes.
@@ -197,14 +197,21 @@ def main(
197197 # Configures logging.
198198 logging .basicConfig (level = logging .INFO )
199199
200+ account_type_choices = [
201+ account_type .name
202+ for account_type in datamanager_v1 .ProductAccount .AccountType
203+ if account_type
204+ != datamanager_v1 .ProductAccount .AccountType .ACCOUNT_TYPE_UNSPECIFIED
205+ ]
206+
200207 parser = argparse .ArgumentParser (
201208 description = "Creates a user list in an operating account." ,
202209 fromfile_prefix_chars = "@" ,
203210 )
204211 # The following argument(s) should be provided to run the example.
205212 parser .add_argument (
206213 "--operating_account_type" ,
207- type = str ,
214+ choices = account_type_choices ,
208215 required = True ,
209216 help = "The account type of the operating account." ,
210217 )
@@ -222,7 +229,7 @@ def main(
222229 )
223230 parser .add_argument (
224231 "--login_account_type" ,
225- type = str ,
232+ choices = account_type_choices ,
226233 required = False ,
227234 help = "The account type of the login account." ,
228235 )
@@ -234,7 +241,7 @@ def main(
234241 )
235242 parser .add_argument (
236243 "--linked_account_type" ,
237- type = str ,
244+ choices = account_type_choices ,
238245 required = False ,
239246 help = "The account type of the linked account." ,
240247 )
@@ -270,13 +277,21 @@ def main(
270277 args = parser .parse_args ()
271278
272279 main (
273- args .operating_account_type ,
280+ datamanager_v1 . ProductAccount . AccountType [ args .operating_account_type ] ,
274281 args .operating_account_id ,
275282 args .validate_only == "true" ,
276283 datamanager_v1 .IngestedUserListInfo .UploadKeyType [args .upload_key_type ],
277- args .login_account_type ,
284+ (
285+ datamanager_v1 .ProductAccount .AccountType [args .login_account_type ]
286+ if args .login_account_type
287+ else None
288+ ),
278289 args .login_account_id ,
279- args .linked_account_type ,
290+ (
291+ datamanager_v1 .ProductAccount .AccountType [args .linked_account_type ]
292+ if args .linked_account_type
293+ else None
294+ ),
280295 args .linked_account_id ,
281296 (
282297 datamanager_v1 .MobileIdInfo .KeySpace [args .key_space ]
0 commit comments