-
Notifications
You must be signed in to change notification settings - Fork 12
/
PutSecurityConnector_example.go
80 lines (77 loc) · 3.74 KB
/
PutSecurityConnector_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
package armsecurity_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"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/af3f7994582c0cbd61a48b636907ad2ac95d332c/specification/security/resource-manager/Microsoft.Security/preview/2022-08-01-preview/examples/SecurityConnectors/PutSecurityConnector_example.json
func ExampleConnectorsClient_CreateOrUpdate() {
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)
}
res, err := clientFactory.NewConnectorsClient().CreateOrUpdate(ctx, "exampleResourceGroup", "exampleSecurityConnectorName", armsecurity.Connector{
Location: to.Ptr("Central US"),
Etag: to.Ptr("etag value (must be supplied for update)"),
Tags: map[string]*string{},
Properties: &armsecurity.ConnectorProperties{
EnvironmentData: &armsecurity.AwsEnvironmentData{
EnvironmentType: to.Ptr(armsecurity.EnvironmentTypeAwsAccount),
},
EnvironmentName: to.Ptr(armsecurity.CloudNameAWS),
HierarchyIdentifier: to.Ptr("exampleHierarchyId"),
Offerings: []armsecurity.CloudOfferingClassification{
&armsecurity.CspmMonitorAwsOffering{
OfferingType: to.Ptr(armsecurity.OfferingTypeCspmMonitorAws),
NativeCloudConnection: &armsecurity.CspmMonitorAwsOfferingNativeCloudConnection{
CloudRoleArn: to.Ptr("arn:aws:iam::00000000:role/ASCMonitor"),
},
}},
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.Connector = armsecurity.Connector{
// Location: to.Ptr("Central US"),
// Etag: to.Ptr(""),
// Kind: to.Ptr(""),
// Name: to.Ptr("exampleSecurityConnectorName"),
// Type: to.Ptr("Microsoft.Security/securityConnectors"),
// ID: to.Ptr("/subscriptions/a5caac9c-5c04-49af-b3d0-e204f40345d5/resourceGroups/exampleResourceGroup/providers/Microsoft.Security/securityConnectors/exampleSecurityConnectorName"),
// Tags: map[string]*string{
// },
// Properties: &armsecurity.ConnectorProperties{
// EnvironmentData: &armsecurity.AwsEnvironmentData{
// EnvironmentType: to.Ptr(armsecurity.EnvironmentTypeAwsAccount),
// },
// EnvironmentName: to.Ptr(armsecurity.CloudNameAWS),
// HierarchyIdentifier: to.Ptr("exampleHierarchyId"),
// Offerings: []armsecurity.CloudOfferingClassification{
// &armsecurity.CspmMonitorAwsOffering{
// OfferingType: to.Ptr(armsecurity.OfferingTypeCspmMonitorAws),
// NativeCloudConnection: &armsecurity.CspmMonitorAwsOfferingNativeCloudConnection{
// CloudRoleArn: to.Ptr("arn:aws:iam::00000000:role/ASCMonitor"),
// },
// }},
// },
// SystemData: &armsecurity.SystemData{
// CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-08-31T13:47:50.328Z"); return t}()),
// CreatedBy: to.Ptr("user@contoso.com"),
// CreatedByType: to.Ptr(armsecurity.CreatedByTypeUser),
// LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-08-31T13:47:50.328Z"); return t}()),
// LastModifiedBy: to.Ptr("user@contoso.com"),
// LastModifiedByType: to.Ptr(armsecurity.CreatedByTypeUser),
// },
// }
}