-
Notifications
You must be signed in to change notification settings - Fork 11
/
ListDeviceSecurityGroups_example.go
221 lines (218 loc) · 12.6 KB
/
ListDeviceSecurityGroups_example.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
package armsecurity_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/security/armsecurity"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e716082ac474f182e2220e4f38f1d6191e7636cf/specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/DeviceSecurityGroups/ListDeviceSecurityGroups_example.json
func ExampleDeviceSecurityGroupsClient_NewListPager() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armsecurity.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
pager := clientFactory.NewDeviceSecurityGroupsClient().NewListPager("subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/SampleRG/providers/Microsoft.Devices/iotHubs/sampleiothub", nil)
for pager.More() {
page, err := pager.NextPage(ctx)
if err != nil {
log.Fatalf("failed to advance page: %v", err)
}
for _, v := range page.Value {
// You could use page here. We use blank identifier for just demo purposes.
_ = v
}
// If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// page.DeviceSecurityGroupList = armsecurity.DeviceSecurityGroupList{
// Value: []*armsecurity.DeviceSecurityGroup{
// {
// Name: to.Ptr("samplesecuritygroup"),
// Type: to.Ptr("Microsoft.Security/deviceSecurityGroups"),
// ID: to.Ptr("/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/SampleRG/providers/Microsoft.Devices/iotHubs/sampleiothub/providers/Microsoft.Security/deviceSecurityGroups/samplesecuritygroup"),
// Properties: &armsecurity.DeviceSecurityGroupProperties{
// AllowlistRules: []armsecurity.AllowlistCustomAlertRuleClassification{
// &armsecurity.ConnectionToIPNotAllowed{
// Description: to.Ptr("Get an alert when an outbound connection is created between your device and an ip that isn't allowed"),
// DisplayName: to.Ptr("Outbound connection to an ip that isn't allowed"),
// IsEnabled: to.Ptr(false),
// RuleType: to.Ptr("ConnectionToIpNotAllowed"),
// ValueType: to.Ptr(armsecurity.ValueTypeIPCidr),
// AllowlistValues: []*string{
// },
// },
// &armsecurity.LocalUserNotAllowed{
// Description: to.Ptr("Get an alert when a local user that isn't allowed logins to the device"),
// DisplayName: to.Ptr("Login by a local user that isn't allowed"),
// IsEnabled: to.Ptr(false),
// RuleType: to.Ptr("LocalUserNotAllowed"),
// ValueType: to.Ptr(armsecurity.ValueTypeString),
// AllowlistValues: []*string{
// },
// },
// &armsecurity.ProcessNotAllowed{
// Description: to.Ptr("Get an alert when a process that isn't allowed is executed"),
// DisplayName: to.Ptr("Execution of a process that isn't allowed"),
// IsEnabled: to.Ptr(false),
// RuleType: to.Ptr("ProcessNotAllowed"),
// ValueType: to.Ptr(armsecurity.ValueTypeString),
// AllowlistValues: []*string{
// },
// }},
// DenylistRules: []*armsecurity.DenylistCustomAlertRule{
// },
// ThresholdRules: []armsecurity.ThresholdCustomAlertRuleClassification{
// },
// TimeWindowRules: []armsecurity.TimeWindowCustomAlertRuleClassification{
// &armsecurity.ActiveConnectionsNotInAllowedRange{
// Description: to.Ptr("Get an alert when the number of active connections of a device in the time window is not in the allowed range"),
// DisplayName: to.Ptr("Number of active connections is not in allowed range"),
// IsEnabled: to.Ptr(false),
// RuleType: to.Ptr("ActiveConnectionsNotInAllowedRange"),
// MaxThreshold: to.Ptr[int32](0),
// MinThreshold: to.Ptr[int32](0),
// TimeWindowSize: to.Ptr("PT15M"),
// },
// &armsecurity.AmqpC2DMessagesNotInAllowedRange{
// Description: to.Ptr("Get an alert when the number of cloud to device messages (AMQP protocol) in the time window is not in the allowed range"),
// DisplayName: to.Ptr("Number of cloud to device messages (AMQP protocol) is not in allowed range"),
// IsEnabled: to.Ptr(false),
// RuleType: to.Ptr("AmqpC2DMessagesNotInAllowedRange"),
// MaxThreshold: to.Ptr[int32](0),
// MinThreshold: to.Ptr[int32](0),
// TimeWindowSize: to.Ptr("PT15M"),
// },
// &armsecurity.MqttC2DMessagesNotInAllowedRange{
// Description: to.Ptr("Get an alert when the number of cloud to device messages (MQTT protocol) in the time window is not in the allowed range"),
// DisplayName: to.Ptr("Number of cloud to device messages (MQTT protocol) is not in allowed range"),
// IsEnabled: to.Ptr(false),
// RuleType: to.Ptr("MqttC2DMessagesNotInAllowedRange"),
// MaxThreshold: to.Ptr[int32](0),
// MinThreshold: to.Ptr[int32](0),
// TimeWindowSize: to.Ptr("PT15M"),
// },
// &armsecurity.HTTPC2DMessagesNotInAllowedRange{
// Description: to.Ptr("Get an alert when the number of cloud to device messages (HTTP protocol) in the time window is not in the allowed range"),
// DisplayName: to.Ptr("Number of cloud to device messages (HTTP protocol) is not in allowed range"),
// IsEnabled: to.Ptr(false),
// RuleType: to.Ptr("HttpC2DMessagesNotInAllowedRange"),
// MaxThreshold: to.Ptr[int32](0),
// MinThreshold: to.Ptr[int32](0),
// TimeWindowSize: to.Ptr("PT15M"),
// },
// &armsecurity.AmqpC2DRejectedMessagesNotInAllowedRange{
// Description: to.Ptr("Get an alert when the number of cloud to device messages (AMQP protocol) that were rejected by the device in the time window is not in the allowed range"),
// DisplayName: to.Ptr("Number of rejected cloud to device messages (AMQP protocol) is not in allowed range"),
// IsEnabled: to.Ptr(false),
// RuleType: to.Ptr("AmqpC2DRejectedMessagesNotInAllowedRange"),
// MaxThreshold: to.Ptr[int32](0),
// MinThreshold: to.Ptr[int32](0),
// TimeWindowSize: to.Ptr("PT15M"),
// },
// &armsecurity.MqttC2DRejectedMessagesNotInAllowedRange{
// Description: to.Ptr("Get an alert when the number of cloud to device messages (MQTT protocol) that were rejected by the device in the time window is not in the allowed range"),
// DisplayName: to.Ptr("Number of rejected cloud to device messages (MQTT protocol) is not in allowed range"),
// IsEnabled: to.Ptr(false),
// RuleType: to.Ptr("MqttC2DRejectedMessagesNotInAllowedRange"),
// MaxThreshold: to.Ptr[int32](0),
// MinThreshold: to.Ptr[int32](0),
// TimeWindowSize: to.Ptr("PT15M"),
// },
// &armsecurity.HTTPC2DRejectedMessagesNotInAllowedRange{
// Description: to.Ptr("Get an alert when the number of cloud to device messages (HTTP protocol) that were rejected by the device in the time window is not in the allowed range"),
// DisplayName: to.Ptr("Number of rejected cloud to device messages (HTTP protocol) is not in allowed range"),
// IsEnabled: to.Ptr(false),
// RuleType: to.Ptr("HttpC2DRejectedMessagesNotInAllowedRange"),
// MaxThreshold: to.Ptr[int32](0),
// MinThreshold: to.Ptr[int32](0),
// TimeWindowSize: to.Ptr("PT15M"),
// },
// &armsecurity.AmqpD2CMessagesNotInAllowedRange{
// Description: to.Ptr("Get an alert when the number of device to cloud messages (AMQP protocol) in the time window is not in the allowed range"),
// DisplayName: to.Ptr("Number of device to cloud messages (AMQP protocol) is not in allowed range"),
// IsEnabled: to.Ptr(false),
// RuleType: to.Ptr("AmqpD2CMessagesNotInAllowedRange"),
// MaxThreshold: to.Ptr[int32](0),
// MinThreshold: to.Ptr[int32](0),
// TimeWindowSize: to.Ptr("PT15M"),
// },
// &armsecurity.MqttD2CMessagesNotInAllowedRange{
// Description: to.Ptr("Get an alert when the number of device to cloud messages (MQTT protocol) in the time window is not in the allowed range"),
// DisplayName: to.Ptr("Number of device to cloud messages (MQTT protocol) is not in allowed range"),
// IsEnabled: to.Ptr(false),
// RuleType: to.Ptr("MqttD2CMessagesNotInAllowedRange"),
// MaxThreshold: to.Ptr[int32](0),
// MinThreshold: to.Ptr[int32](0),
// TimeWindowSize: to.Ptr("PT15M"),
// },
// &armsecurity.HTTPD2CMessagesNotInAllowedRange{
// Description: to.Ptr("Get an alert when the number of device to cloud messages (HTTP protocol) in the time window is not in the allowed range"),
// DisplayName: to.Ptr("Number of device to cloud messages (HTTP protocol) is not in allowed range"),
// IsEnabled: to.Ptr(false),
// RuleType: to.Ptr("HttpD2CMessagesNotInAllowedRange"),
// MaxThreshold: to.Ptr[int32](0),
// MinThreshold: to.Ptr[int32](0),
// TimeWindowSize: to.Ptr("PT15M"),
// },
// &armsecurity.DirectMethodInvokesNotInAllowedRange{
// Description: to.Ptr("Get an alert when the number of direct method invokes in the time window is not in the allowed range"),
// DisplayName: to.Ptr("Number of direct method invokes is not in allowed range"),
// IsEnabled: to.Ptr(false),
// RuleType: to.Ptr("DirectMethodInvokesNotInAllowedRange"),
// MaxThreshold: to.Ptr[int32](0),
// MinThreshold: to.Ptr[int32](0),
// TimeWindowSize: to.Ptr("PT15M"),
// },
// &armsecurity.FailedLocalLoginsNotInAllowedRange{
// Description: to.Ptr("Get an alert when the number of failed local logins on the device in the time window is not in the allowed range"),
// DisplayName: to.Ptr("Number of failed local logins is not in allowed range"),
// IsEnabled: to.Ptr(false),
// RuleType: to.Ptr("FailedLocalLoginsNotInAllowedRange"),
// MaxThreshold: to.Ptr[int32](0),
// MinThreshold: to.Ptr[int32](0),
// TimeWindowSize: to.Ptr("PT15M"),
// },
// &armsecurity.FileUploadsNotInAllowedRange{
// Description: to.Ptr("Get an alert when the number of file uploads from the device to the cloud in the time window is not in the allowed range"),
// DisplayName: to.Ptr("Number of file uploads is not in allowed range"),
// IsEnabled: to.Ptr(false),
// RuleType: to.Ptr("FileUploadsNotInAllowedRange"),
// MaxThreshold: to.Ptr[int32](0),
// MinThreshold: to.Ptr[int32](0),
// TimeWindowSize: to.Ptr("PT15M"),
// },
// &armsecurity.QueuePurgesNotInAllowedRange{
// Description: to.Ptr("Get an alert when the number of device queue purges in the time window is not in the allowed range"),
// DisplayName: to.Ptr("Number of device queue purges is not in allowed range"),
// IsEnabled: to.Ptr(false),
// RuleType: to.Ptr("QueuePurgesNotInAllowedRange"),
// MaxThreshold: to.Ptr[int32](0),
// MinThreshold: to.Ptr[int32](0),
// TimeWindowSize: to.Ptr("PT15M"),
// },
// &armsecurity.TwinUpdatesNotInAllowedRange{
// Description: to.Ptr("Get an alert when the number of twin updates (by the device or the service) in the time window is not in the allowed range"),
// DisplayName: to.Ptr("Number of twin updates is not in allowed range"),
// IsEnabled: to.Ptr(false),
// RuleType: to.Ptr("TwinUpdatesNotInAllowedRange"),
// MaxThreshold: to.Ptr[int32](0),
// MinThreshold: to.Ptr[int32](0),
// TimeWindowSize: to.Ptr("PT15M"),
// },
// &armsecurity.UnauthorizedOperationsNotInAllowedRange{
// Description: to.Ptr("Get an alert when the number unauthorized operations in the time window is not in the allowed range. Unauthorized operations are operations that affect the device (or done by it) that fail because of an unauthorized error"),
// DisplayName: to.Ptr("Number of unauthorized operations is not in allowed range"),
// IsEnabled: to.Ptr(false),
// RuleType: to.Ptr("UnauthorizedOperationsNotInAllowedRange"),
// MaxThreshold: to.Ptr[int32](0),
// MinThreshold: to.Ptr[int32](0),
// TimeWindowSize: to.Ptr("PT15M"),
// }},
// },
// }},
// }
}
}