1818
1919
2020GROUP_ID = 'com.azure'
21- LLC_ARGUMENTS = '--java -- low-level-client --sdk-integration --generate-samples'
21+ LLC_ARGUMENTS = '--low-level-client --sdk-integration --generate-samples'
2222
2323
2424def sdk_automation (config : dict ) -> List [dict ]:
@@ -38,14 +38,11 @@ def sdk_automation(config: dict) -> List[dict]:
3838 service = match .group (1 )
3939 file_name = match .group (2 )
4040 file_name_sans = '' .join (c for c in file_name if c .isalnum ())
41- module = 'azure-{0}-{1}' .format (service , file_name_sans )
41+ module = 'azure-{0}-{1}' .format (service , file_name_sans ). lower ()
4242 input_file = os .path .join (spec_root , file_path )
43- # placeholder, for lack of information
44- credential_types = 'tokencredential'
45- credential_scopes = 'https://{0}.azure.com/.default' .format (service )
4643
4744 succeeded = generate (sdk_root , input_file ,
48- service , module , credential_types , credential_scopes , '' ,
45+ service , module , '' , '' , '' ,
4946 AUTOREST_CORE_VERSION , AUTOREST_JAVA , '' )
5047
5148 generated_folder = 'sdk/{0}/{1}' .format (service , module )
@@ -79,8 +76,8 @@ def generate(
7976 input_file : str ,
8077 service : str ,
8178 module : str ,
82- credential_types : str ,
83- credential_scopes : str ,
79+ security : str ,
80+ security_scopes : str ,
8481 title : str ,
8582 autorest : str ,
8683 use : str ,
@@ -96,7 +93,7 @@ def generate(
9693 shutil .rmtree (os .path .join (output_dir , 'src/samples/java' , namespace .replace ('.' , '/' ), 'generated' ),
9794 ignore_errors = True )
9895
99- readme_relative_path = update_readme (output_dir , input_file , credential_types , credential_scopes , title )
96+ readme_relative_path = update_readme (output_dir , input_file , security , security_scopes , title )
10097 if readme_relative_path :
10198 logging .info ('[GENERATE] Autorest from README {}' .format (readme_relative_path ))
10299
@@ -114,17 +111,19 @@ def generate(
114111 else :
115112 logging .info ('[GENERATE] Autorest from JSON {}' .format (input_file ))
116113
117- credential_arguments = '--java.credential-types={0}' .format (credential_types )
118- if credential_scopes :
119- credential_arguments += ' --java.credential-scopes={0}' .format (credential_scopes )
114+ security_arguments = ''
115+ if security :
116+ security_arguments += '--security={0}' .format (security )
117+ if security_scopes :
118+ security_arguments += ' --security-scopes={0}' .format (security_scopes )
120119
121120 input_arguments = '--input-file={0}' .format (input_file )
122121
123122 artifact_arguments = '--artifact-id={0}' .format (module )
124123 if title :
125124 artifact_arguments += ' --title={0}' .format (title )
126125
127- command = 'autorest --version={0} --use={1} ' \
126+ command = 'autorest --version={0} --use={1} --java ' \
128127 '--java.azure-libraries-for-java-folder={2} --java.output-folder={3} ' \
129128 '--java.namespace={4} {5}' \
130129 .format (
@@ -133,7 +132,7 @@ def generate(
133132 os .path .abspath (sdk_root ),
134133 os .path .abspath (output_dir ),
135134 namespace ,
136- ' ' .join ((LLC_ARGUMENTS , input_arguments , credential_arguments , artifact_arguments , autorest_options ))
135+ ' ' .join ((LLC_ARGUMENTS , input_arguments , security_arguments , artifact_arguments , autorest_options ))
137136 )
138137 logging .info (command )
139138 if os .system (command ) != 0 :
@@ -159,7 +158,7 @@ def compile_package(sdk_root: str, group_id: str, module: str) -> bool:
159158 return True
160159
161160
162- def update_readme (output_dir : str , input_file : str , credential_types : str , credential_scopes : str , title : str ) -> str :
161+ def update_readme (output_dir : str , input_file : str , security : str , security_scopes : str , title : str ) -> str :
163162 readme_relative_path = ''
164163
165164 swagger_dir = os .path .join (output_dir , 'swagger' )
@@ -179,10 +178,10 @@ def update_readme(output_dir: str, input_file: str, credential_types: str, crede
179178 yaml_json ['input-file' ] = [input_file ]
180179 if title :
181180 yaml_json ['title' ] = title
182- if credential_types :
183- yaml_json ['credential-types ' ] = credential_types
184- if credential_scopes :
185- yaml_json ['credential -scopes' ] = credential_scopes
181+ if security :
182+ yaml_json ['security ' ] = security
183+ if security_scopes :
184+ yaml_json ['security -scopes' ] = security_scopes
186185
187186 # write updated yaml
188187 updated_yaml_str = yaml .dump (yaml_json ,
@@ -226,17 +225,30 @@ def parse_args() -> argparse.Namespace:
226225 required = True ,
227226 help = 'Module name under sdk/<service>/. Sample: azure-storage-blob' ,
228227 )
228+ parser .add_argument (
229+ '--security' ,
230+ required = False ,
231+ help = 'Security schemes for authentication. '
232+ 'Sample: "AADToken" for AAD credential for OAuth 2.0 authentication; '
233+ '"AzureKey" for Azure key credential; "[AADToken,AzureKey]" for both' ,
234+ )
235+ parser .add_argument (
236+ '--security-scopes' ,
237+ required = False ,
238+ help = 'OAuth 2.0 scopes when "security" includes "AADToken". '
239+ 'Sample: https://storage.azure.com/.default' ,
240+ )
229241 parser .add_argument (
230242 '--credential-types' ,
231- required = True ,
232- help = 'Credential types. '
243+ required = False ,
244+ help = '[DEPRECATED] Credential types. '
233245 'Sample: "tokencredential" for AAD credential for OAuth 2.0 authentication; '
234246 '"azurekeycredential" for Azure key credential' ,
235247 )
236248 parser .add_argument (
237249 '--credential-scopes' ,
238250 required = False ,
239- help = 'OAuth 2.0 scopes when credential-types includes "tokencredential". '
251+ help = '[DEPRECATED] OAuth 2.0 scopes when " credential-types" includes "tokencredential". '
240252 'Sample: https://storage.azure.com/.default' ,
241253 )
242254 parser .add_argument (
0 commit comments