15
15
"apic api create" ,
16
16
)
17
17
class Create (AAZCommand ):
18
- """Create new or updates existing API.
18
+ """Register a new API or update an existing API.
19
19
20
20
:example: Create API
21
- az apic api create -g contoso-resources -s contoso --name echo-api --title "Echo API"
21
+ az apic api create -g contoso-resources -s contoso --api-id echo-api --title "Echo API" --type REST
22
+
23
+ :example: Create API with custom properties
24
+ az apic api create -g contoso-resources -s contoso --api-id echo-api --title "Echo API" --type REST --custom-properties '{\" public-facing\" :true}'
22
25
"""
23
26
24
27
_aaz_info = {
@@ -44,11 +47,12 @@ def _build_arguments_schema(cls, *args, **kwargs):
44
47
# define Arg Group ""
45
48
46
49
_args_schema = cls ._args_schema
47
- _args_schema .api_name = AAZStrArg (
48
- options = ["--api" , "--name" , "--api-name " ],
49
- help = "The name of the API." ,
50
+ _args_schema .api_id = AAZStrArg (
51
+ options = ["--api-id " ],
52
+ help = "The id of the API." ,
50
53
required = True ,
51
54
fmt = AAZStrArgFormat (
55
+ pattern = "^[a-zA-Z0-9-]{3,90}$" ,
52
56
max_length = 90 ,
53
57
min_length = 1 ,
54
58
),
@@ -61,6 +65,7 @@ def _build_arguments_schema(cls, *args, **kwargs):
61
65
help = "The name of the API Center service." ,
62
66
required = True ,
63
67
fmt = AAZStrArgFormat (
68
+ pattern = "^[a-zA-Z0-9-]{3,90}$" ,
64
69
max_length = 90 ,
65
70
min_length = 1 ,
66
71
),
@@ -71,6 +76,7 @@ def _build_arguments_schema(cls, *args, **kwargs):
71
76
required = True ,
72
77
default = "default" ,
73
78
fmt = AAZStrArgFormat (
79
+ pattern = "^[a-zA-Z0-9-]{3,90}$" ,
74
80
max_length = 90 ,
75
81
min_length = 1 ,
76
82
),
@@ -84,7 +90,7 @@ def _build_arguments_schema(cls, *args, **kwargs):
84
90
arg_group = "Properties" ,
85
91
help = "The contact information for the API." ,
86
92
)
87
- _args_schema .custom_properties = AAZObjectArg (
93
+ _args_schema .custom_properties = AAZFreeFormDictArg (
88
94
options = ["--custom-properties" ],
89
95
arg_group = "Properties" ,
90
96
help = "The custom metadata defined for API catalog entities." ,
@@ -103,10 +109,11 @@ def _build_arguments_schema(cls, *args, **kwargs):
103
109
arg_group = "Properties" ,
104
110
help = "Additional, external documentation for the API." ,
105
111
)
106
- _args_schema .kind = AAZStrArg (
107
- options = ["--kind " ],
112
+ _args_schema .type = AAZStrArg (
113
+ options = ["--type " ],
108
114
arg_group = "Properties" ,
109
- help = "Kind of API. For example, REST or GraphQL." ,
115
+ help = "Type of API." ,
116
+ required = True ,
110
117
enum = {"graphql" : "graphql" , "grpc" : "grpc" , "rest" : "rest" , "soap" : "soap" , "webhook" : "webhook" , "websocket" : "websocket" },
111
118
)
112
119
_args_schema .license = AAZObjectArg (
@@ -122,15 +129,11 @@ def _build_arguments_schema(cls, *args, **kwargs):
122
129
max_length = 200 ,
123
130
),
124
131
)
125
- _args_schema .terms_of_service = AAZObjectArg (
126
- options = ["--terms-of-service" ],
127
- arg_group = "Properties" ,
128
- help = "Terms of service for the API." ,
129
- )
130
132
_args_schema .title = AAZStrArg (
131
133
options = ["--title" ],
132
134
arg_group = "Properties" ,
133
135
help = "API title." ,
136
+ required = True ,
134
137
fmt = AAZStrArgFormat (
135
138
max_length = 50 ,
136
139
min_length = 1 ,
@@ -212,16 +215,6 @@ def _build_arguments_schema(cls, *args, **kwargs):
212
215
max_length = 200 ,
213
216
),
214
217
)
215
-
216
- terms_of_service = cls ._args_schema .terms_of_service
217
- terms_of_service .url = AAZStrArg (
218
- options = ["url" ],
219
- help = "URL pointing to the terms of service." ,
220
- required = True ,
221
- fmt = AAZStrArgFormat (
222
- max_length = 200 ,
223
- ),
224
- )
225
218
return cls ._args_schema
226
219
227
220
def _execute_operations (self ):
@@ -271,7 +264,7 @@ def error_format(self):
271
264
def url_parameters (self ):
272
265
parameters = {
273
266
** self .serialize_url_param (
274
- "apiName" , self .ctx .args .api_name ,
267
+ "apiName" , self .ctx .args .api_id ,
275
268
required = True ,
276
269
),
277
270
** self .serialize_url_param (
@@ -322,18 +315,17 @@ def content(self):
322
315
typ = AAZObjectType ,
323
316
typ_kwargs = {"flags" : {"required" : True , "client_flatten" : True }}
324
317
)
325
- _builder .set_prop ("properties" , AAZObjectType , typ_kwargs = {"flags" : {"client_flatten" : True }})
318
+ _builder .set_prop ("properties" , AAZObjectType , "." , typ_kwargs = {"flags" : {"required" : True , "client_flatten" : True }})
326
319
327
320
properties = _builder .get (".properties" )
328
321
if properties is not None :
329
322
properties .set_prop ("contacts" , AAZListType , ".contacts" )
330
- properties .set_prop ("customProperties" , AAZObjectType , ".custom_properties" )
323
+ properties .set_prop ("customProperties" , AAZFreeFormDictType , ".custom_properties" )
331
324
properties .set_prop ("description" , AAZStrType , ".description" )
332
325
properties .set_prop ("externalDocumentation" , AAZListType , ".external_documentation" )
333
- properties .set_prop ("kind" , AAZStrType , ".kind " , typ_kwargs = {"flags" : {"required" : True }})
326
+ properties .set_prop ("kind" , AAZStrType , ".type " , typ_kwargs = {"flags" : {"required" : True }})
334
327
properties .set_prop ("license" , AAZObjectType , ".license" )
335
328
properties .set_prop ("summary" , AAZStrType , ".summary" )
336
- properties .set_prop ("termsOfService" , AAZObjectType , ".terms_of_service" )
337
329
properties .set_prop ("title" , AAZStrType , ".title" , typ_kwargs = {"flags" : {"required" : True }})
338
330
339
331
contacts = _builder .get (".properties.contacts" )
@@ -346,6 +338,10 @@ def content(self):
346
338
_elements .set_prop ("name" , AAZStrType , ".name" )
347
339
_elements .set_prop ("url" , AAZStrType , ".url" )
348
340
341
+ custom_properties = _builder .get (".properties.customProperties" )
342
+ if custom_properties is not None :
343
+ custom_properties .set_anytype_elements ("." )
344
+
349
345
external_documentation = _builder .get (".properties.externalDocumentation" )
350
346
if external_documentation is not None :
351
347
external_documentation .set_elements (AAZObjectType , "." )
@@ -362,10 +358,6 @@ def content(self):
362
358
license .set_prop ("name" , AAZStrType , ".name" )
363
359
license .set_prop ("url" , AAZStrType , ".url" )
364
360
365
- terms_of_service = _builder .get (".properties.termsOfService" )
366
- if terms_of_service is not None :
367
- terms_of_service .set_prop ("url" , AAZStrType , ".url" , typ_kwargs = {"flags" : {"required" : True }})
368
-
369
361
return self .serialize_content (_content_value )
370
362
371
363
def on_200_201 (self , session ):
@@ -393,7 +385,7 @@ def _build_schema_on_200_201(cls):
393
385
flags = {"read_only" : True },
394
386
)
395
387
_schema_on_200_201 .properties = AAZObjectType (
396
- flags = {"client_flatten" : True },
388
+ flags = {"required" : True , " client_flatten" : True },
397
389
)
398
390
_schema_on_200_201 .system_data = AAZObjectType (
399
391
serialized_name = "systemData" ,
@@ -405,7 +397,7 @@ def _build_schema_on_200_201(cls):
405
397
406
398
properties = cls ._schema_on_200_201 .properties
407
399
properties .contacts = AAZListType ()
408
- properties .custom_properties = AAZObjectType (
400
+ properties .custom_properties = AAZFreeFormDictType (
409
401
serialized_name = "customProperties" ,
410
402
)
411
403
properties .description = AAZStrType ()
@@ -418,6 +410,7 @@ def _build_schema_on_200_201(cls):
418
410
properties .license = AAZObjectType ()
419
411
properties .lifecycle_stage = AAZStrType (
420
412
serialized_name = "lifecycleStage" ,
413
+ flags = {"read_only" : True },
421
414
)
422
415
properties .summary = AAZStrType ()
423
416
properties .terms_of_service = AAZObjectType (
0 commit comments