@@ -81,7 +81,7 @@ type SubnetsClient interface {
81
81
82
82
// SecurityGroupsClient defines needed functions for azure network.SecurityGroupsClient
83
83
type SecurityGroupsClient interface {
84
- CreateOrUpdate (ctx context.Context , resourceGroupName string , networkSecurityGroupName string , parameters network.SecurityGroup ) (resp * http.Response , err error )
84
+ CreateOrUpdate (ctx context.Context , resourceGroupName string , networkSecurityGroupName string , parameters network.SecurityGroup , etag string ) (resp * http.Response , err error )
85
85
Delete (ctx context.Context , resourceGroupName string , networkSecurityGroupName string ) (resp * http.Response , err error )
86
86
Get (ctx context.Context , resourceGroupName string , networkSecurityGroupName string , expand string ) (result network.SecurityGroup , err error )
87
87
List (ctx context.Context , resourceGroupName string ) (result []network.SecurityGroup , err error )
@@ -714,7 +714,7 @@ func newAzSecurityGroupsClient(config *azClientConfig) *azSecurityGroupsClient {
714
714
}
715
715
}
716
716
717
- func (az * azSecurityGroupsClient ) CreateOrUpdate (ctx context.Context , resourceGroupName string , networkSecurityGroupName string , parameters network.SecurityGroup ) (resp * http.Response , err error ) {
717
+ func (az * azSecurityGroupsClient ) CreateOrUpdate (ctx context.Context , resourceGroupName string , networkSecurityGroupName string , parameters network.SecurityGroup , etag string ) (resp * http.Response , err error ) {
718
718
/* Write rate limiting */
719
719
if ! az .rateLimiterWriter .TryAccept () {
720
720
err = createRateLimitErr (true , "NSGCreateOrUpdate" )
@@ -727,7 +727,13 @@ func (az *azSecurityGroupsClient) CreateOrUpdate(ctx context.Context, resourceGr
727
727
}()
728
728
729
729
mc := newMetricContext ("security_groups" , "create_or_update" , resourceGroupName , az .client .SubscriptionID )
730
- future , err := az .client .CreateOrUpdate (ctx , resourceGroupName , networkSecurityGroupName , parameters )
730
+ req , err := az .createOrUpdatePreparer (ctx , resourceGroupName , networkSecurityGroupName , parameters , etag )
731
+ if err != nil {
732
+ mc .Observe (err )
733
+ return nil , err
734
+ }
735
+
736
+ future , err := az .client .CreateOrUpdateSender (req )
731
737
if err != nil {
732
738
mc .Observe (err )
733
739
return future .Response (), err
@@ -738,6 +744,34 @@ func (az *azSecurityGroupsClient) CreateOrUpdate(ctx context.Context, resourceGr
738
744
return future .Response (), err
739
745
}
740
746
747
+ // createOrUpdatePreparer prepares the CreateOrUpdate request.
748
+ func (az * azSecurityGroupsClient ) createOrUpdatePreparer (ctx context.Context , resourceGroupName string , networkSecurityGroupName string , parameters network.SecurityGroup , etag string ) (* http.Request , error ) {
749
+ pathParameters := map [string ]interface {}{
750
+ "networkSecurityGroupName" : autorest .Encode ("path" , networkSecurityGroupName ),
751
+ "resourceGroupName" : autorest .Encode ("path" , resourceGroupName ),
752
+ "subscriptionId" : autorest .Encode ("path" , az .client .SubscriptionID ),
753
+ }
754
+
755
+ const APIVersion = "2017-09-01"
756
+ queryParameters := map [string ]interface {}{
757
+ "api-version" : APIVersion ,
758
+ }
759
+
760
+ preparerDecorators := []autorest.PrepareDecorator {
761
+ autorest .AsContentType ("application/json; charset=utf-8" ),
762
+ autorest .AsPut (),
763
+ autorest .WithBaseURL (az .client .BaseURI ),
764
+ autorest .WithPathParameters ("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityGroups/{networkSecurityGroupName}" , pathParameters ),
765
+ autorest .WithJSON (parameters ),
766
+ autorest .WithQueryParameters (queryParameters ),
767
+ }
768
+ if etag != "" {
769
+ preparerDecorators = append (preparerDecorators , autorest .WithHeader ("If-Match" , autorest .String (etag )))
770
+ }
771
+ preparer := autorest .CreatePreparer (preparerDecorators ... )
772
+ return preparer .Prepare ((& http.Request {}).WithContext (ctx ))
773
+ }
774
+
741
775
func (az * azSecurityGroupsClient ) Delete (ctx context.Context , resourceGroupName string , networkSecurityGroupName string ) (resp * http.Response , err error ) {
742
776
/* Write rate limiting */
743
777
if ! az .rateLimiterWriter .TryAccept () {
0 commit comments