| 1 | ## Data Lake Storage Gen2 File Systems SDK for API version 2018-11-09 |
| 2 | |
| 3 | This package allows you to interact with the Data Lake Storage Gen2 File Systems API |
| 4 | |
| 5 | ### Supported Authorizers |
| 6 | |
| 7 | * Azure Active Directory (for the Resource Endpoint `https://storage.azure.com`) |
| 8 | |
| 9 | ### Example Usage |
| 10 | |
| 11 | ```go |
| 12 | package main |
| 13 | |
| 14 | import ( |
| 15 | "context" |
| 16 | "fmt" |
| 17 | "os" |
| 18 | "time" |
| 19 | |
| 20 | "github.com/Azure/go-autorest/autorest" |
| 21 | "github.com/Azure/go-autorest/autorest/adal" |
| 22 | "github.com/Azure/go-autorest/autorest/azure" |
| 23 | "github.com/hashicorp/go-azure-helpers/authentication" |
| 24 | "github.com/hashicorp/go-azure-helpers/sender" |
| 25 | "github.com/tombuildsstuff/giovanni/storage/2018-11-09/datalakestore/filesystems" |
| 26 | ) |
| 27 | |
| 28 | func Example() error { |
| 29 | accountName := "storageaccount1" |
| 30 | fileSystemName := "filesystem1" |
| 31 | |
| 32 | builder := &authentication.Builder{ |
| 33 | SubscriptionID: os.Getenv("ARM_SUBSCRIPTION_ID"), |
| 34 | ClientID: os.Getenv("ARM_CLIENT_ID"), |
| 35 | ClientSecret: os.Getenv("ARM_CLIENT_SECRET"), |
| 36 | TenantID: os.Getenv("ARM_TENANT_ID"), |
| 37 | Environment: os.Getenv("ARM_ENVIRONMENT"), |
| 38 | |
| 39 | // Feature Toggles |
| 40 | SupportsClientSecretAuth: true, |
| 41 | } |
| 42 | |
| 43 | c, err := builder.Build() |
| 44 | if err != nil { |
| 45 | return fmt.Errorf("Error building AzureRM Client: %s", err) |
| 46 | } |
| 47 | |
| 48 | env, err := authentication.DetermineEnvironment(c.Environment) |
| 49 | if err != nil { |
| 50 | return err |
| 51 | } |
| 52 | |
| 53 | oauthConfig, err := adal.NewOAuthConfig(env.ActiveDirectoryEndpoint, c.TenantID) |
| 54 | if err != nil { |
| 55 | return err |
| 56 | } |
| 57 | |
| 58 | // OAuthConfigForTenant returns a pointer, which can be nil. |
| 59 | if oauthConfig == nil { |
| 60 | return fmt.Errorf("Unable to configure OAuthConfig for tenant %s", c.TenantID) |
| 61 | } |
| 62 | |
| 63 | sender := sender.BuildSender("AzureRM") |
| 64 | ctx := context.Background() |
| 65 | |
| 66 | storageAuth, err := config.GetAuthorizationToken(sender, oauthConfig, "https://storage.azure.com/") |
| 67 | if err != nil { |
| 68 | return fmt.Errorf("Error retrieving Authorization Token") |
| 69 | } |
| 70 | |
| 71 | |
| 72 | fileSystemsClient := filesystems.NewWithEnvironment(env) |
| 73 | fileSystemsClient.Client.Authorizer = storageAuth |
| 74 | |
| 75 | input := filesystems.CreateInput{ |
| 76 | Properties: map[string]string{}, |
| 77 | } |
| 78 | if _, err = fileSystemsClient.Create(ctx, accountName, fileSystemName, input); err != nil { |
| 79 | return fmt.Errorf("Error creating: %s", err) |
| 80 | } |
| 81 | |
| 82 | return nil |
| 83 | } |
| 84 | ``` |