-
Notifications
You must be signed in to change notification settings - Fork 13
/
WebPubSub_CreateOrUpdate.go
69 lines (66 loc) · 2.25 KB
/
WebPubSub_CreateOrUpdate.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
package armwebpubsub_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/webpubsub/armwebpubsub"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/webpubsub/resource-manager/Microsoft.SignalRService/preview/2022-08-01-preview/examples/WebPubSub_CreateOrUpdate.json
func ExampleClient_BeginCreateOrUpdate() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
client, err := armwebpubsub.NewClient("00000000-0000-0000-0000-000000000000", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := client.BeginCreateOrUpdate(ctx, "myResourceGroup", "myWebPubSubService", armwebpubsub.ResourceInfo{
Location: to.Ptr("eastus"),
Tags: map[string]*string{
"key1": to.Ptr("value1"),
},
Identity: &armwebpubsub.ManagedIdentity{
Type: to.Ptr(armwebpubsub.ManagedIdentityTypeSystemAssigned),
},
Properties: &armwebpubsub.Properties{
DisableAADAuth: to.Ptr(false),
DisableLocalAuth: to.Ptr(false),
LiveTraceConfiguration: &armwebpubsub.LiveTraceConfiguration{
Categories: []*armwebpubsub.LiveTraceCategory{
{
Name: to.Ptr("ConnectivityLogs"),
Enabled: to.Ptr("true"),
}},
Enabled: to.Ptr("false"),
},
NetworkACLs: &armwebpubsub.NetworkACLs{
DefaultAction: to.Ptr(armwebpubsub.ACLActionDeny),
PublicNetwork: &armwebpubsub.NetworkACL{
Allow: []*armwebpubsub.WebPubSubRequestType{
to.Ptr(armwebpubsub.WebPubSubRequestTypeClientConnection)},
},
},
PublicNetworkAccess: to.Ptr("Enabled"),
TLS: &armwebpubsub.TLSSettings{
ClientCertEnabled: to.Ptr(false),
},
},
SKU: &armwebpubsub.ResourceSKU{
Name: to.Ptr("Premium_P1"),
Capacity: to.Ptr[int32](1),
Tier: to.Ptr(armwebpubsub.WebPubSubSKUTierPremium),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// TODO: use response item
_ = res
}