1 package network
2
3
4
5
6
7
8
9 import (
10 "context"
11 "github.com/Azure/go-autorest/autorest"
12 "github.com/Azure/go-autorest/autorest/azure"
13 "github.com/Azure/go-autorest/tracing"
14 "net/http"
15 )
16
17
18 type InboundSecurityRuleClient struct {
19 BaseClient
20 }
21
22
23 func NewInboundSecurityRuleClient(subscriptionID string) InboundSecurityRuleClient {
24 return NewInboundSecurityRuleClientWithBaseURI(DefaultBaseURI, subscriptionID)
25 }
26
27
28
29
30 func NewInboundSecurityRuleClientWithBaseURI(baseURI string, subscriptionID string) InboundSecurityRuleClient {
31 return InboundSecurityRuleClient{NewWithBaseURI(baseURI, subscriptionID)}
32 }
33
34
35
36
37
38
39
40
41 func (client InboundSecurityRuleClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, networkVirtualApplianceName string, ruleCollectionName string, parameters InboundSecurityRule) (result InboundSecurityRuleCreateOrUpdateFuture, err error) {
42 if tracing.IsEnabled() {
43 ctx = tracing.StartSpan(ctx, fqdn+"/InboundSecurityRuleClient.CreateOrUpdate")
44 defer func() {
45 sc := -1
46 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
47 sc = result.FutureAPI.Response().StatusCode
48 }
49 tracing.EndSpan(ctx, sc, err)
50 }()
51 }
52 req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, networkVirtualApplianceName, ruleCollectionName, parameters)
53 if err != nil {
54 err = autorest.NewErrorWithError(err, "network.InboundSecurityRuleClient", "CreateOrUpdate", nil, "Failure preparing request")
55 return
56 }
57
58 result, err = client.CreateOrUpdateSender(req)
59 if err != nil {
60 err = autorest.NewErrorWithError(err, "network.InboundSecurityRuleClient", "CreateOrUpdate", result.Response(), "Failure sending request")
61 return
62 }
63
64 return
65 }
66
67
68 func (client InboundSecurityRuleClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, networkVirtualApplianceName string, ruleCollectionName string, parameters InboundSecurityRule) (*http.Request, error) {
69 pathParameters := map[string]interface{}{
70 "networkVirtualApplianceName": autorest.Encode("path", networkVirtualApplianceName),
71 "resourceGroupName": autorest.Encode("path", resourceGroupName),
72 "ruleCollectionName": autorest.Encode("path", ruleCollectionName),
73 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
74 }
75
76 const APIVersion = "2022-01-01"
77 queryParameters := map[string]interface{}{
78 "api-version": APIVersion,
79 }
80
81 parameters.Etag = nil
82 parameters.Type = nil
83 preparer := autorest.CreatePreparer(
84 autorest.AsContentType("application/json; charset=utf-8"),
85 autorest.AsPut(),
86 autorest.WithBaseURL(client.BaseURI),
87 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkVirtualAppliances/{networkVirtualApplianceName}/inboundSecurityRules/{ruleCollectionName}", pathParameters),
88 autorest.WithJSON(parameters),
89 autorest.WithQueryParameters(queryParameters))
90 return preparer.Prepare((&http.Request{}).WithContext(ctx))
91 }
92
93
94
95 func (client InboundSecurityRuleClient) CreateOrUpdateSender(req *http.Request) (future InboundSecurityRuleCreateOrUpdateFuture, err error) {
96 var resp *http.Response
97 future.FutureAPI = &azure.Future{}
98 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
99 if err != nil {
100 return
101 }
102 var azf azure.Future
103 azf, err = azure.NewFutureFromResponse(resp)
104 future.FutureAPI = &azf
105 future.Result = future.result
106 return
107 }
108
109
110
111 func (client InboundSecurityRuleClient) CreateOrUpdateResponder(resp *http.Response) (result InboundSecurityRule, err error) {
112 err = autorest.Respond(
113 resp,
114 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
115 autorest.ByUnmarshallingJSON(&result),
116 autorest.ByClosing())
117 result.Response = autorest.Response{Response: resp}
118 return
119 }
120
View as plain text