@@ -32,6 +32,11 @@ import (
32
32
"k8s.io/client-go/util/flowcontrol"
33
33
)
34
34
35
+ const (
36
+ // The version number is taken from "github.com/Azure/azure-sdk-for-go/services/network/mgmt/2017-09-01/network".
37
+ azureNetworkAPIVersion = "2017-09-01"
38
+ )
39
+
35
40
// Helpers for rate limiting error/error channel creation
36
41
func createRateLimitErr (isWrite bool , opName string ) error {
37
42
opType := "read"
@@ -57,7 +62,7 @@ type InterfacesClient interface {
57
62
58
63
// LoadBalancersClient defines needed functions for azure network.LoadBalancersClient
59
64
type LoadBalancersClient interface {
60
- CreateOrUpdate (ctx context.Context , resourceGroupName string , loadBalancerName string , parameters network.LoadBalancer ) (resp * http.Response , err error )
65
+ CreateOrUpdate (ctx context.Context , resourceGroupName string , loadBalancerName string , parameters network.LoadBalancer , etag string ) (resp * http.Response , err error )
61
66
Delete (ctx context.Context , resourceGroupName string , loadBalancerName string ) (resp * http.Response , err error )
62
67
Get (ctx context.Context , resourceGroupName string , loadBalancerName string , expand string ) (result network.LoadBalancer , err error )
63
68
List (ctx context.Context , resourceGroupName string ) (result []network.LoadBalancer , err error )
@@ -103,13 +108,13 @@ type VirtualMachineScaleSetVMsClient interface {
103
108
104
109
// RoutesClient defines needed functions for azure network.RoutesClient
105
110
type RoutesClient interface {
106
- CreateOrUpdate (ctx context.Context , resourceGroupName string , routeTableName string , routeName string , routeParameters network.Route ) (resp * http.Response , err error )
111
+ CreateOrUpdate (ctx context.Context , resourceGroupName string , routeTableName string , routeName string , routeParameters network.Route , etag string ) (resp * http.Response , err error )
107
112
Delete (ctx context.Context , resourceGroupName string , routeTableName string , routeName string ) (resp * http.Response , err error )
108
113
}
109
114
110
115
// RouteTablesClient defines needed functions for azure network.RouteTablesClient
111
116
type RouteTablesClient interface {
112
- CreateOrUpdate (ctx context.Context , resourceGroupName string , routeTableName string , parameters network.RouteTable ) (resp * http.Response , err error )
117
+ CreateOrUpdate (ctx context.Context , resourceGroupName string , routeTableName string , parameters network.RouteTable , etag string ) (resp * http.Response , err error )
113
118
Get (ctx context.Context , resourceGroupName string , routeTableName string , expand string ) (result network.RouteTable , err error )
114
119
}
115
120
@@ -356,7 +361,7 @@ func newAzLoadBalancersClient(config *azClientConfig) *azLoadBalancersClient {
356
361
}
357
362
}
358
363
359
- func (az * azLoadBalancersClient ) CreateOrUpdate (ctx context.Context , resourceGroupName string , loadBalancerName string , parameters network.LoadBalancer ) (resp * http.Response , err error ) {
364
+ func (az * azLoadBalancersClient ) CreateOrUpdate (ctx context.Context , resourceGroupName string , loadBalancerName string , parameters network.LoadBalancer , etag string ) (resp * http.Response , err error ) {
360
365
/* Write rate limiting */
361
366
if ! az .rateLimiterWriter .TryAccept () {
362
367
err = createRateLimitErr (true , "LBCreateOrUpdate" )
@@ -369,9 +374,15 @@ func (az *azLoadBalancersClient) CreateOrUpdate(ctx context.Context, resourceGro
369
374
}()
370
375
371
376
mc := newMetricContext ("load_balancers" , "create_or_update" , resourceGroupName , az .client .SubscriptionID )
372
- future , err := az .client .CreateOrUpdate (ctx , resourceGroupName , loadBalancerName , parameters )
373
- mc .Observe (err )
377
+ req , err := az .createOrUpdatePreparer (ctx , resourceGroupName , loadBalancerName , parameters , etag )
374
378
if err != nil {
379
+ mc .Observe (err )
380
+ return nil , err
381
+ }
382
+
383
+ future , err := az .client .CreateOrUpdateSender (req )
384
+ if err != nil {
385
+ mc .Observe (err )
375
386
return future .Response (), err
376
387
}
377
388
@@ -380,6 +391,33 @@ func (az *azLoadBalancersClient) CreateOrUpdate(ctx context.Context, resourceGro
380
391
return future .Response (), err
381
392
}
382
393
394
+ // createOrUpdatePreparer prepares the CreateOrUpdate request.
395
+ func (az * azLoadBalancersClient ) createOrUpdatePreparer (ctx context.Context , resourceGroupName string , loadBalancerName string , parameters network.LoadBalancer , etag string ) (* http.Request , error ) {
396
+ pathParameters := map [string ]interface {}{
397
+ "loadBalancerName" : autorest .Encode ("path" , loadBalancerName ),
398
+ "resourceGroupName" : autorest .Encode ("path" , resourceGroupName ),
399
+ "subscriptionId" : autorest .Encode ("path" , az .client .SubscriptionID ),
400
+ }
401
+
402
+ queryParameters := map [string ]interface {}{
403
+ "api-version" : azureNetworkAPIVersion ,
404
+ }
405
+
406
+ preparerDecorators := []autorest.PrepareDecorator {
407
+ autorest .AsContentType ("application/json; charset=utf-8" ),
408
+ autorest .AsPut (),
409
+ autorest .WithBaseURL (az .client .BaseURI ),
410
+ autorest .WithPathParameters ("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}" , pathParameters ),
411
+ autorest .WithJSON (parameters ),
412
+ autorest .WithQueryParameters (queryParameters ),
413
+ }
414
+ if etag != "" {
415
+ preparerDecorators = append (preparerDecorators , autorest .WithHeader ("If-Match" , autorest .String (etag )))
416
+ }
417
+ preparer := autorest .CreatePreparer (preparerDecorators ... )
418
+ return preparer .Prepare ((& http.Request {}).WithContext (ctx ))
419
+ }
420
+
383
421
func (az * azLoadBalancersClient ) Delete (ctx context.Context , resourceGroupName string , loadBalancerName string ) (resp * http.Response , err error ) {
384
422
/* Write rate limiting */
385
423
if ! az .rateLimiterWriter .TryAccept () {
@@ -752,9 +790,8 @@ func (az *azSecurityGroupsClient) createOrUpdatePreparer(ctx context.Context, re
752
790
"subscriptionId" : autorest .Encode ("path" , az .client .SubscriptionID ),
753
791
}
754
792
755
- const APIVersion = "2017-09-01"
756
793
queryParameters := map [string ]interface {}{
757
- "api-version" : APIVersion ,
794
+ "api-version" : azureNetworkAPIVersion ,
758
795
}
759
796
760
797
preparerDecorators := []autorest.PrepareDecorator {
@@ -1051,7 +1088,7 @@ func newAzRoutesClient(config *azClientConfig) *azRoutesClient {
1051
1088
}
1052
1089
}
1053
1090
1054
- func (az * azRoutesClient ) CreateOrUpdate (ctx context.Context , resourceGroupName string , routeTableName string , routeName string , routeParameters network.Route ) (resp * http.Response , err error ) {
1091
+ func (az * azRoutesClient ) CreateOrUpdate (ctx context.Context , resourceGroupName string , routeTableName string , routeName string , routeParameters network.Route , etag string ) (resp * http.Response , err error ) {
1055
1092
/* Write rate limiting */
1056
1093
if ! az .rateLimiterWriter .TryAccept () {
1057
1094
err = createRateLimitErr (true , "RouteCreateOrUpdate" )
@@ -1064,7 +1101,13 @@ func (az *azRoutesClient) CreateOrUpdate(ctx context.Context, resourceGroupName
1064
1101
}()
1065
1102
1066
1103
mc := newMetricContext ("routes" , "create_or_update" , resourceGroupName , az .client .SubscriptionID )
1067
- future , err := az .client .CreateOrUpdate (ctx , resourceGroupName , routeTableName , routeName , routeParameters )
1104
+ req , err := az .createOrUpdatePreparer (ctx , resourceGroupName , routeTableName , routeName , routeParameters , etag )
1105
+ if err != nil {
1106
+ mc .Observe (err )
1107
+ return nil , err
1108
+ }
1109
+
1110
+ future , err := az .client .CreateOrUpdateSender (req )
1068
1111
if err != nil {
1069
1112
mc .Observe (err )
1070
1113
return future .Response (), err
@@ -1075,6 +1118,35 @@ func (az *azRoutesClient) CreateOrUpdate(ctx context.Context, resourceGroupName
1075
1118
return future .Response (), err
1076
1119
}
1077
1120
1121
+ // createOrUpdatePreparer prepares the CreateOrUpdate request.
1122
+ func (az * azRoutesClient ) createOrUpdatePreparer (ctx context.Context , resourceGroupName string , routeTableName string , routeName string , routeParameters network.Route , etag string ) (* http.Request , error ) {
1123
+ pathParameters := map [string ]interface {}{
1124
+ "resourceGroupName" : autorest .Encode ("path" , resourceGroupName ),
1125
+ "routeName" : autorest .Encode ("path" , routeName ),
1126
+ "routeTableName" : autorest .Encode ("path" , routeTableName ),
1127
+ "subscriptionId" : autorest .Encode ("path" , az .client .SubscriptionID ),
1128
+ }
1129
+
1130
+ queryParameters := map [string ]interface {}{
1131
+ "api-version" : azureNetworkAPIVersion ,
1132
+ }
1133
+
1134
+ preparerDecorators := []autorest.PrepareDecorator {
1135
+ autorest .AsContentType ("application/json; charset=utf-8" ),
1136
+ autorest .AsPut (),
1137
+ autorest .WithBaseURL (az .client .BaseURI ),
1138
+ autorest .WithPathParameters ("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/routeTables/{routeTableName}/routes/{routeName}" , pathParameters ),
1139
+ autorest .WithJSON (routeParameters ),
1140
+ autorest .WithQueryParameters (queryParameters ),
1141
+ }
1142
+ if etag != "" {
1143
+ preparerDecorators = append (preparerDecorators , autorest .WithHeader ("If-Match" , autorest .String (etag )))
1144
+ }
1145
+ preparer := autorest .CreatePreparer (preparerDecorators ... )
1146
+
1147
+ return preparer .Prepare ((& http.Request {}).WithContext (ctx ))
1148
+ }
1149
+
1078
1150
func (az * azRoutesClient ) Delete (ctx context.Context , resourceGroupName string , routeTableName string , routeName string ) (resp * http.Response , err error ) {
1079
1151
/* Write rate limiting */
1080
1152
if ! az .rateLimiterWriter .TryAccept () {
@@ -1124,7 +1196,7 @@ func newAzRouteTablesClient(config *azClientConfig) *azRouteTablesClient {
1124
1196
}
1125
1197
}
1126
1198
1127
- func (az * azRouteTablesClient ) CreateOrUpdate (ctx context.Context , resourceGroupName string , routeTableName string , parameters network.RouteTable ) (resp * http.Response , err error ) {
1199
+ func (az * azRouteTablesClient ) CreateOrUpdate (ctx context.Context , resourceGroupName string , routeTableName string , parameters network.RouteTable , etag string ) (resp * http.Response , err error ) {
1128
1200
/* Write rate limiting */
1129
1201
if ! az .rateLimiterWriter .TryAccept () {
1130
1202
err = createRateLimitErr (true , "RouteTableCreateOrUpdate" )
@@ -1137,9 +1209,15 @@ func (az *azRouteTablesClient) CreateOrUpdate(ctx context.Context, resourceGroup
1137
1209
}()
1138
1210
1139
1211
mc := newMetricContext ("route_tables" , "create_or_update" , resourceGroupName , az .client .SubscriptionID )
1140
- future , err := az .client .CreateOrUpdate (ctx , resourceGroupName , routeTableName , parameters )
1141
- mc .Observe (err )
1212
+ req , err := az .createOrUpdatePreparer (ctx , resourceGroupName , routeTableName , parameters , etag )
1142
1213
if err != nil {
1214
+ mc .Observe (err )
1215
+ return nil , err
1216
+ }
1217
+
1218
+ future , err := az .client .CreateOrUpdateSender (req )
1219
+ if err != nil {
1220
+ mc .Observe (err )
1143
1221
return future .Response (), err
1144
1222
}
1145
1223
@@ -1148,6 +1226,33 @@ func (az *azRouteTablesClient) CreateOrUpdate(ctx context.Context, resourceGroup
1148
1226
return future .Response (), err
1149
1227
}
1150
1228
1229
+ // createOrUpdatePreparer prepares the CreateOrUpdate request.
1230
+ func (az * azRouteTablesClient ) createOrUpdatePreparer (ctx context.Context , resourceGroupName string , routeTableName string , parameters network.RouteTable , etag string ) (* http.Request , error ) {
1231
+ pathParameters := map [string ]interface {}{
1232
+ "resourceGroupName" : autorest .Encode ("path" , resourceGroupName ),
1233
+ "routeTableName" : autorest .Encode ("path" , routeTableName ),
1234
+ "subscriptionId" : autorest .Encode ("path" , az .client .SubscriptionID ),
1235
+ }
1236
+
1237
+ queryParameters := map [string ]interface {}{
1238
+ "api-version" : azureNetworkAPIVersion ,
1239
+ }
1240
+ preparerDecorators := []autorest.PrepareDecorator {
1241
+ autorest .AsContentType ("application/json; charset=utf-8" ),
1242
+ autorest .AsPut (),
1243
+ autorest .WithBaseURL (az .client .BaseURI ),
1244
+ autorest .WithPathParameters ("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/routeTables/{routeTableName}" , pathParameters ),
1245
+ autorest .WithJSON (parameters ),
1246
+ autorest .WithQueryParameters (queryParameters ),
1247
+ }
1248
+ if etag != "" {
1249
+ preparerDecorators = append (preparerDecorators , autorest .WithHeader ("If-Match" , autorest .String (etag )))
1250
+ }
1251
+ preparer := autorest .CreatePreparer (preparerDecorators ... )
1252
+
1253
+ return preparer .Prepare ((& http.Request {}).WithContext (ctx ))
1254
+ }
1255
+
1151
1256
func (az * azRouteTablesClient ) Get (ctx context.Context , resourceGroupName string , routeTableName string , expand string ) (result network.RouteTable , err error ) {
1152
1257
if ! az .rateLimiterReader .TryAccept () {
1153
1258
err = createRateLimitErr (false , "GetRouteTable" )
0 commit comments