-
Notifications
You must be signed in to change notification settings - Fork 11
/
LocalUserCreate.go
76 lines (73 loc) · 2.78 KB
/
LocalUserCreate.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
package armstorage_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/storage/armstorage"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b32e1896f30e6ea155449cb49719a6286e32b961/specification/storage/resource-manager/Microsoft.Storage/stable/2022-09-01/examples/LocalUserCreate.json
func ExampleLocalUsersClient_CreateOrUpdate_createLocalUser() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armstorage.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewLocalUsersClient().CreateOrUpdate(ctx, "res6977", "sto2527", "user1", armstorage.LocalUser{
Properties: &armstorage.LocalUserProperties{
HasSSHPassword: to.Ptr(true),
HomeDirectory: to.Ptr("homedirectory"),
PermissionScopes: []*armstorage.PermissionScope{
{
Permissions: to.Ptr("rwd"),
ResourceName: to.Ptr("share1"),
Service: to.Ptr("file"),
},
{
Permissions: to.Ptr("rw"),
ResourceName: to.Ptr("share2"),
Service: to.Ptr("file"),
}},
SSHAuthorizedKeys: []*armstorage.SSHPublicKey{
{
Description: to.Ptr("key name"),
Key: to.Ptr("ssh-rsa keykeykeykeykey="),
}},
},
}, 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.LocalUser = armstorage.LocalUser{
// Name: to.Ptr("user1"),
// Type: to.Ptr("Microsoft.Storage/storageAccounts/localUsers"),
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/res6977/providers/Microsoft.Storage/storageAccounts/sto2527/loalUsers/user1"),
// Properties: &armstorage.LocalUserProperties{
// HomeDirectory: to.Ptr("homedirectory"),
// PermissionScopes: []*armstorage.PermissionScope{
// {
// Permissions: to.Ptr("rwd"),
// ResourceName: to.Ptr("share1"),
// Service: to.Ptr("file"),
// },
// {
// Permissions: to.Ptr("rw"),
// ResourceName: to.Ptr("share2"),
// Service: to.Ptr("file"),
// }},
// Sid: to.Ptr("S-1-2-0-125132-153423-36235-1000"),
// SSHAuthorizedKeys: []*armstorage.SSHPublicKey{
// {
// Description: to.Ptr("key name"),
// Key: to.Ptr("ssh-rsa keykeykeykeykey="),
// }},
// },
// }
}