Skip to content

Commit

Permalink
version 2020-08-04 readmes
Browse files Browse the repository at this point in the history
  • Loading branch information
catriona-m committed Nov 16, 2023
1 parent 8bee545 commit ce51e5d
Show file tree
Hide file tree
Showing 11 changed files with 151 additions and 107 deletions.
1 change: 0 additions & 1 deletion storage/2020-08-04/blob/accounts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"fmt"
"time"

"github.com/Azure/go-autorest/autorest"
"github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/accounts"
)

Expand Down
20 changes: 14 additions & 6 deletions storage/2020-08-04/blob/blobs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,34 @@ import (
"fmt"
"time"

"github.com/Azure/go-autorest/autorest"
"github.com/hashicorp/go-azure-sdk/sdk/auth"
"github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs"
)

func Example() error {
accountName := "storageaccount1"
storageAccountKey := "ABC123...."
containerName := "mycontainer"
domainSuffix := "core.windows.net"
fileName := "example-large-file.iso"

storageAuth := autorest.NewSharedKeyLiteAuthorizer(accountName, storageAccountKey)
blobClient := blobs.New()
blobClient.Client.Authorizer = storageAuth

blobClient, err := blobs.NewWithBaseUri(fmt.Sprintf("https://%s.blob.%s", accountName, domainSuffix))
if err != nil {
t.Fatalf("building client for environment: %+v", err)
}

auth, err := auth.NewSharedKeyAuthorizer(accountName, storageAccountKey, auth.SharedKey)
if err != nil {
return fmt.Errorf("building SharedKey authorizer: %+v", err)
}
blobClient.Client.WithAuthorizer(auth)

ctx := context.TODO()
copyInput := blobs.CopyInput{
CopySource: "http://releases.ubuntu.com/14.04/ubuntu-14.04.6-desktop-amd64.iso",
}
refreshInterval := 5 * time.Second
if err := blobClient.CopyAndWait(ctx, accountName, containerName, fileName, copyInput, refreshInterval); err != nil {
if err := blobClient.CopyAndWait(ctx, containerName, fileName, copyInput, refreshInterval); err != nil {
return fmt.Errorf("Error copying: %s", err)
}

Expand Down
23 changes: 15 additions & 8 deletions storage/2020-08-04/blob/containers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,33 @@ package main
import (
"context"
"fmt"
"time"

"github.com/Azure/go-autorest/autorest"

"github.com/hashicorp/go-azure-sdk/sdk/auth"
"github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/containers"
)

func Example() error {
accountName := "storageaccount1"
storageAccountKey := "ABC123...."
containerName := "mycontainer"

storageAuth := autorest.NewSharedKeyLiteAuthorizer(accountName, storageAccountKey)
containersClient := containers.New()
containersClient.Client.Authorizer = storageAuth
domainSuffix := "core.windows.net"

containersClient, err := containers.NewWithBaseUri(fmt.Sprintf("https://%s.blob.%s", accountName, domainSuffix))
if err != nil {
t.Fatalf("building client for environment: %+v", err)
}

auth, err := auth.NewSharedKeyAuthorizer(accountName, storageAccountKey, auth.SharedKey)
if err != nil {
return fmt.Errorf("building SharedKey authorizer: %+v", err)
}
containersClient.Client.WithAuthorizer(auth)

ctx := context.TODO()
createInput := containers.CreateInput{
AccessLevel: containers.Private,
}
if _, err := containersClient.Create(ctx, accountName, containerName, createInput); err != nil {
if _, err := containersClient.Create(ctx, containerName, createInput); err != nil {
return fmt.Errorf("Error creating Container: %s", err)
}

Expand Down
49 changes: 12 additions & 37 deletions storage/2020-08-04/datalakestore/filesystems/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,58 +18,33 @@ import (

"github.com/hashicorp/go-azure-helpers/authentication"
"github.com/hashicorp/go-azure-helpers/sender"
"github.com/hashicorp/go-azure-sdk/sdk/auth"
"github.com/tombuildsstuff/giovanni/storage/2020-08-04/datalakestore/filesystems"
)

func Example() error {
accountName := "storageaccount1"
fileSystemName := "filesystem1"
storageAccountKey := "ABC123...."
domainSuffix := "core.windows.net"


builder := &authentication.Builder{
SubscriptionID: os.Getenv("ARM_SUBSCRIPTION_ID"),
ClientID: os.Getenv("ARM_CLIENT_ID"),
ClientSecret: os.Getenv("ARM_CLIENT_SECRET"),
TenantID: os.Getenv("ARM_TENANT_ID"),
Environment: os.Getenv("ARM_ENVIRONMENT"),

// Feature Toggles
SupportsClientSecretAuth: true,
}

c, err := builder.Build()
if err != nil {
return fmt.Errorf("Error building AzureRM Client: %s", err)
}

env, err := authentication.DetermineEnvironment(c.Environment)
if err != nil {
return err
}

oauthConfig, err := adal.NewOAuthConfig(env.ActiveDirectoryEndpoint, c.TenantID)
auth, err := auth.NewSharedKeyAuthorizer(accountName, storageAccountKey, auth.SharedKey)
if err != nil {
return err
}

// OAuthConfigForTenant returns a pointer, which can be nil.
if oauthConfig == nil {
return fmt.Errorf("Unable to configure OAuthConfig for tenant %s", c.TenantID)
return fmt.Errorf("building SharedKey authorizer: %+v", err)
}

sender := sender.BuildSender("AzureRM")
ctx := context.Background()

storageAuth, err := config.GetAuthorizationToken(sender, oauthConfig, "https://storage.azure.com/")

fileSystemsClient, err := filesystems.NewWithBaseUri(fmt.Sprintf("https://%s.dfs.%s", accountName, domainSuffix))
if err != nil {
return fmt.Errorf("Error retrieving Authorization Token")
t.Fatalf("building client for environment: %+v", err)
}

fileSystemsClient, err := filesystems.NewWithBaseUri(fmt.Sprintf("https://%s.dfs.core.windows.net", accountName))
fileSystemsClient.Client.WithAuthorizer(storageAuth)
fileSystemsClient.Client.WithAuthorizer(auth)

input := filesystems.CreateInput{
Properties: map[string]string{},
}

ctx := context.Background()
if _, err = fileSystemsClient.Create(ctx, fileSystemName, input); err != nil {
return fmt.Errorf("Error creating: %s", err)
}
Expand Down
27 changes: 19 additions & 8 deletions storage/2020-08-04/file/directories/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ package main
import (
"context"
"fmt"
"time"

"github.com/Azure/go-autorest/autorest"

"github.com/hashicorp/go-azure-sdk/sdk/auth"
"github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/directories"
)

Expand All @@ -30,16 +29,28 @@ func Example() error {
storageAccountKey := "ABC123...."
shareName := "myshare"
directoryName := "myfiles"

storageAuth := autorest.NewSharedKeyLiteAuthorizer(accountName, storageAccountKey)
directoriesClient := directories.New()
directoriesClient.Client.Authorizer = storageAuth
domainSuffix := "core.windows.net"

auth, err := auth.NewSharedKeyAuthorizer(accountName, storageAccountKey, auth.SharedKey)
if err != nil {
return fmt.Errorf("building SharedKey authorizer: %+v", err)
}

directoriesClient, err := directories.NewWithBaseUri(fmt.Sprintf("https://%s.dfs.%s", accountName, domainSuffix))
if err != nil {
t.Fatalf("building client for environment: %+v", err)
}
directoriesClient.Client.WithAuthorizer(auth)

ctx := context.TODO()
metadata := map[string]string{
"hello": "world",
}
if _, err := directoriesClient.Create(ctx, accountName, shareName, directoryName, metadata); err != nil {

input := directories.CreateDirectoryInput{
MetaData: metadata,
}
if _, err := directoriesClient.Create(ctx, shareName, directoryName, input); err != nil {
return fmt.Errorf("Error creating Directory: %s", err)
}

Expand Down
23 changes: 15 additions & 8 deletions storage/2020-08-04/file/files/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ package main
import (
"context"
"fmt"
"time"

"github.com/Azure/go-autorest/autorest"

"github.com/hashicorp/go-azure-sdk/sdk/auth"
"github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/files"
)

Expand All @@ -31,14 +30,22 @@ func Example() error {
shareName := "myshare"
directoryName := "myfiles"
fileName := "example.txt"

storageAuth := autorest.NewSharedKeyLiteAuthorizer(accountName, storageAccountKey)
filesClient := files.New()
filesClient.Client.Authorizer = storageAuth
domainSuffix := "core.windows.net"

auth, err := auth.NewSharedKeyAuthorizer(accountName, storageAccountKey, auth.SharedKey)
if err != nil {
return fmt.Errorf("building SharedKey authorizer: %+v", err)
}

filesClient, err := files.NewWithBaseUri(fmt.Sprintf("https://%s.file.%s", accountName, domainSuffix))
if err != nil {
t.Fatalf("building client for environment: %+v", err)
}
filesClient.Client.WithAuthorizer(auth)

ctx := context.TODO()
input := files.CreateInput{}
if _, err := filesClient.Create(ctx, accountName, shareName, directoryName, fileName, input); err != nil {
if _, err := filesClient.Create(ctx, shareName, directoryName, fileName, input); err != nil {
return fmt.Errorf("Error creating File: %s", err)
}

Expand Down
23 changes: 15 additions & 8 deletions storage/2020-08-04/file/shares/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,33 @@ package main
import (
"context"
"fmt"
"time"

"github.com/Azure/go-autorest/autorest"

"github.com/hashicorp/go-azure-sdk/sdk/auth"
"github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/shares"
)

func Example() error {
accountName := "storageaccount1"
storageAccountKey := "ABC123...."
shareName := "myshare"

storageAuth := autorest.NewSharedKeyLiteAuthorizer(accountName, storageAccountKey)
sharesClient := shares.New()
sharesClient.Client.Authorizer = storageAuth
domainSuffix := "core.windows.net"

auth, err := auth.NewSharedKeyAuthorizer(accountName, storageAccountKey, auth.SharedKey)
if err != nil {
return fmt.Errorf("building SharedKey authorizer: %+v", err)
}

sharesClient, err := shares.NewWithBaseUri(fmt.Sprintf("https://%s.file.%s", accountName, domainSuffix))
if err != nil {
return fmt.Errorf("building SharedKey authorizer: %+v", err)
}
sharesClient.Client.WithAuthorizer(auth)

ctx := context.TODO()
input := shares.CreateInput{
QuotaInGB: 2,
}
if _, err := sharesClient.Create(ctx, accountName, shareName, input); err != nil {
if _, err := sharesClient.Create(ctx, shareName, input); err != nil {
return fmt.Errorf("Error creating Share: %s", err)
}

Expand Down
21 changes: 14 additions & 7 deletions storage/2020-08-04/queue/messages/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,33 @@ package main
import (
"context"
"fmt"
"time"

"github.com/Azure/go-autorest/autorest"

"github.com/hashicorp/go-azure-sdk/sdk/auth"
"github.com/tombuildsstuff/giovanni/storage/2020-08-04/queue/messages"
)

func Example() error {
accountName := "storageaccount1"
storageAccountKey := "ABC123...."
queueName := "myqueue"
domainSuffix := "core.windows.net"

auth, err := auth.NewSharedKeyAuthorizer(accountName, storageAccountKey, auth.SharedKey)
if err != nil {
return fmt.Errorf("building SharedKey authorizer: %+v", err)
}

storageAuth := autorest.NewSharedKeyLiteAuthorizer(accountName, storageAccountKey)
messagesClient := messages.New()
messagesClient.Client.Authorizer = storageAuth
messagesClient, err := messages.NewWithBaseUri(fmt.Sprintf("https://%s.queue.%s", accountName, domainSuffix))
if err != nil {
t.Fatalf("building client for environment: %+v", err)
}
messagesClient.Client.WithAuthorizer(auth)

ctx := context.TODO()
input := messages.PutInput{
Message: "<over><message>hello</message></over>",
}
if _, err := messagesClient.Put(ctx, accountName, queueName, input); err != nil {
if _, err := messagesClient.Put(ctx, queueName, input); err != nil {
return fmt.Errorf("Error creating Message: %s", err)
}

Expand Down
26 changes: 18 additions & 8 deletions storage/2020-08-04/queue/queues/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,36 @@ package main
import (
"context"
"fmt"
"time"

"github.com/Azure/go-autorest/autorest"

"github.com/hashicorp/go-azure-sdk/sdk/auth"
"github.com/tombuildsstuff/giovanni/storage/2020-08-04/queue/queues"
)

func Example() error {
accountName := "storageaccount1"
storageAccountKey := "ABC123...."
queueName := "myqueue"

storageAuth := autorest.NewSharedKeyLiteAuthorizer(accountName, storageAccountKey)
queuesClient := queues.New()
queuesClient.Client.Authorizer = storageAuth
domainSuffix := "core.windows.net"

auth, err := auth.NewSharedKeyAuthorizer(accountName, storageAccountKey, auth.SharedKey)
if err != nil {
return fmt.Errorf("building SharedKey authorizer: %+v", err)
}

queuesClient, err := queues.NewWithBaseUri(fmt.Sprintf("https://%s.queue.%s", accountName, domainSuffix))
if err != nil {
t.Fatalf("building client for environment: %+v", err)
}
queuesClient.Client.WithAuthorizer(auth)

ctx := context.TODO()
metadata := map[string]string{
"hello": "world",
}
if _, err := queuesClient.Create(ctx, accountName, queueName, metadata); err != nil {
input := queues.CreateInput{
Metadata: metadata,
}
if _, err := queuesClient.Create(ctx, queueName, input); err != nil {
return fmt.Errorf("Error creating Queue: %s", err)
}

Expand Down
Loading

0 comments on commit ce51e5d

Please sign in to comment.