-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support for version 2023-11-03
#89
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Storage API Version 2023-11-03 | ||
|
||
The following APIs are supported by this SDK - more information about each SDK can be found within the README in each package. | ||
|
||
## Blob Storage | ||
|
||
- [Blobs API](blob/blobs) | ||
- [Containers API](blob/containers) | ||
- [Accounts API](blob/accounts) | ||
|
||
## DataLakeStore Gen2 | ||
|
||
- [FileSystems API](datalakestore/filesystems) | ||
- [Paths API](datalakestore/paths) | ||
|
||
## File Storage | ||
|
||
- [Directories API](file/directories) | ||
- [Files API](file/files) | ||
- [Shares API](file/shares) | ||
|
||
## Queue Storage | ||
|
||
- [Queues API](queue/queues) | ||
- [Messages API](queue/messages) | ||
|
||
## Table Storage | ||
|
||
- [Entities API](table/entities) | ||
- [Tables API](table/tables) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
## Blob Storage Account SDK for API version 2020-08-04 | ||
|
||
This package allows you to interact with the Accounts Blob Storage API | ||
|
||
### Supported Authorizers | ||
|
||
* Azure Active Directory | ||
|
||
### Example Usage | ||
|
||
```go | ||
package main | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"time" | ||
|
||
"github.com/Azure/go-autorest/autorest" | ||
"github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/accounts" | ||
) | ||
|
||
func Example() error { | ||
accountName := "storageaccount1" | ||
|
||
// e.g. https://github.com/tombuildsstuff/giovanni/blob/76f5f686c99ecdcc3fa533a0330d0e1aacb1c327/example/azuread-auth/main.go#L54 | ||
client, err := buildClient() | ||
if err != nil { | ||
return fmt.Errorf("error building client: %s", err) | ||
} | ||
|
||
ctx := context.TODO() | ||
|
||
input := StorageServiceProperties{ | ||
StaticWebsite: &StaticWebsite{ | ||
Enabled: true, | ||
IndexDocument: index, | ||
ErrorDocument404Path: errorDocument, | ||
}, | ||
} | ||
|
||
_, err = client.SetServiceProperties(ctx, accountName, input) | ||
if err != nil { | ||
return fmt.Errorf("error setting properties: %s", err) | ||
} | ||
|
||
time.Sleep(2 * time.Second) | ||
|
||
_, err = accountsClient.GetServiceProperties(ctx, accountName) | ||
if err != nil { | ||
return fmt.Errorf("error getting properties: %s", err) | ||
} | ||
|
||
return nil | ||
} | ||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package accounts | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/hashicorp/go-azure-sdk/sdk/client/dataplane/storage" | ||
) | ||
|
||
// Client is the base client for Blob Storage Blobs. | ||
type Client struct { | ||
Client *storage.BaseClient | ||
} | ||
|
||
func NewWithBaseUri(baseUri string) (*Client, error) { | ||
baseClient, err := storage.NewBaseClient(baseUri, componentName, apiVersion) | ||
if err != nil { | ||
return nil, fmt.Errorf("building base client: %+v", err) | ||
} | ||
return &Client{ | ||
Client: baseClient, | ||
}, nil | ||
} |
49 changes: 49 additions & 0 deletions
49
storage/2023-11-03/blob/accounts/get_service_properties.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package accounts | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"net/http" | ||
|
||
"github.com/hashicorp/go-azure-sdk/sdk/client" | ||
) | ||
|
||
type GetServicePropertiesResult struct { | ||
HttpResponse *client.Response | ||
Model *StorageServiceProperties | ||
} | ||
|
||
func (c Client) GetServiceProperties(ctx context.Context, accountName string) (resp GetServicePropertiesResult, err error) { | ||
if accountName == "" { | ||
return resp, fmt.Errorf("`accountName` cannot be an empty string") | ||
} | ||
|
||
opts := client.RequestOptions{ | ||
ContentType: "text/xml", | ||
ExpectedStatusCodes: []int{ | ||
http.StatusOK, | ||
}, | ||
HttpMethod: http.MethodGet, | ||
OptionsObject: servicePropertiesOptions{}, | ||
Path: "/", | ||
} | ||
req, err := c.Client.NewRequest(ctx, opts) | ||
if err != nil { | ||
err = fmt.Errorf("building request: %+v", err) | ||
return | ||
} | ||
resp.HttpResponse, err = req.Execute(ctx) | ||
if err != nil { | ||
err = fmt.Errorf("executing request: %+v", err) | ||
return | ||
} | ||
|
||
if resp.HttpResponse != nil { | ||
if err = resp.HttpResponse.Unmarshal(&resp.Model); err != nil { | ||
err = fmt.Errorf("unmarshaling response: %+v", err) | ||
return | ||
} | ||
} | ||
|
||
return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package accounts | ||
|
||
type StorageServiceProperties struct { | ||
// Cors - Specifies CORS rules for the Blob service. You can include up to five CorsRule elements in the request. If no CorsRule elements are included in the request body, all CORS rules will be deleted, and CORS will be disabled for the Blob service. | ||
Cors *CorsRules `xml:"Cors,omitempty"` | ||
// DefaultServiceVersion - DefaultServiceVersion indicates the default version to use for requests to the Blob service if an incoming request’s version is not specified. Possible values include version 2008-10-27 and all more recent versions. | ||
DefaultServiceVersion *string `xml:"DefaultServiceVersion,omitempty"` | ||
// DeleteRetentionPolicy - The blob service properties for soft delete. | ||
DeleteRetentionPolicy *DeleteRetentionPolicy `xml:"DeleteRetentionPolicy,omitempty"` | ||
// Logging - The blob service properties for logging access | ||
Logging *Logging `xml:"Logging,omitempty"` | ||
// HourMetrics - The blob service properties for hour metrics | ||
HourMetrics *MetricsConfig `xml:"HourMetrics,omitempty"` | ||
// HourMetrics - The blob service properties for minute metrics | ||
MinuteMetrics *MetricsConfig `xml:"MinuteMetrics,omitempty"` | ||
// StaticWebsite - Optional | ||
StaticWebsite *StaticWebsite `xml:"StaticWebsite,omitempty"` | ||
} | ||
|
||
// StaticWebsite sets the static website support properties on the Blob service. | ||
type StaticWebsite struct { | ||
// Enabled - Required. Indicates whether static website support is enabled for the given account. | ||
Enabled bool `xml:"Enabled"` | ||
// IndexDocument - Optional. The webpage that Azure Storage serves for requests to the root of a website or any subfolder. For example, index.html. The value is case-sensitive. | ||
IndexDocument string `xml:"IndexDocument,omitempty"` | ||
// ErrorDocument404Path - Optional. The absolute path to a webpage that Azure Storage serves for requests that do not correspond to an existing file. For example, error/404.html. Only a single custom 404 page is supported in each static website. The value is case-sensitive. | ||
ErrorDocument404Path string `xml:"ErrorDocument404Path,omitempty"` | ||
} | ||
|
||
// CorsRules sets the CORS rules. You can include up to five CorsRule elements in the request. | ||
type CorsRules struct { | ||
// CorsRules - The List of CORS rules. You can include up to five CorsRule elements in the request. | ||
CorsRules []CorsRule `xml:"CorsRules,omitempty"` | ||
} | ||
|
||
// DeleteRetentionPolicy the blob service properties for soft delete. | ||
type DeleteRetentionPolicy struct { | ||
// Enabled - Indicates whether DeleteRetentionPolicy is enabled for the Blob service. | ||
Enabled bool `xml:"Enabled,omitempty"` | ||
// Days - Indicates the number of days that the deleted blob should be retained. The minimum specified value can be 1 and the maximum value can be 365. | ||
Days int32 `xml:"Days,omitempty"` | ||
} | ||
|
||
// CorsRule specifies a CORS rule for the Blob service. | ||
type CorsRule struct { | ||
// AllowedOrigins - Required if CorsRule element is present. A list of origin domains that will be allowed via CORS, or "" to allow all domains | ||
AllowedOrigins []string `xml:"AllowedOrigins,omitempty"` | ||
// AllowedMethods - Required if CorsRule element is present. A list of HTTP methods that are allowed to be executed by the origin. | ||
AllowedMethods []string `xml:"AllowedMethods,omitempty"` | ||
// MaxAgeInSeconds - Required if CorsRule element is present. The number of seconds that the client/browser should cache a preflight response. | ||
MaxAgeInSeconds int32 `xml:"MaxAgeInSeconds,omitempty"` | ||
// ExposedHeaders - Required if CorsRule element is present. A list of response headers to expose to CORS clients. | ||
ExposedHeaders []string `xml:"ExposedHeaders,omitempty"` | ||
// AllowedHeaders - Required if CorsRule element is present. A list of headers allowed to be part of the cross-origin request. | ||
AllowedHeaders []string `xml:"AllowedHeaders,omitempty"` | ||
} | ||
|
||
// Logging specifies the access logging options for the Blob service. | ||
type Logging struct { | ||
Version string `xml:"Version"` | ||
Delete bool `xml:"Delete"` | ||
Read bool `xml:"Read"` | ||
Write bool `xml:"Write"` | ||
RetentionPolicy DeleteRetentionPolicy `xml:"RetentionPolicy"` | ||
} | ||
|
||
// MetricsConfig specifies the hour and/or minute metrics options for the Blob service. | ||
// Elements are all expected | ||
type MetricsConfig struct { | ||
Version string `xml:"Version"` | ||
Enabled bool `xml:"Enabled"` | ||
RetentionPolicy DeleteRetentionPolicy `xml:"RetentionPolicy"` | ||
IncludeAPIs bool `xml:"IncludeAPIs"` | ||
} |
26 changes: 26 additions & 0 deletions
26
storage/2023-11-03/blob/accounts/service_properties_shared.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package accounts | ||
|
||
import ( | ||
"github.com/hashicorp/go-azure-sdk/sdk/client" | ||
"github.com/hashicorp/go-azure-sdk/sdk/odata" | ||
) | ||
|
||
var _ client.Options = servicePropertiesOptions{} | ||
|
||
type servicePropertiesOptions struct { | ||
} | ||
|
||
func (servicePropertiesOptions) ToHeaders() *client.Headers { | ||
return nil | ||
} | ||
|
||
func (servicePropertiesOptions) ToOData() *odata.Query { | ||
return nil | ||
} | ||
|
||
func (servicePropertiesOptions) ToQuery() *client.QueryParams { | ||
out := &client.QueryParams{} | ||
out.Append("comp", "properties") | ||
out.Append("restype", "service") | ||
return out | ||
} |
45 changes: 45 additions & 0 deletions
45
storage/2023-11-03/blob/accounts/set_service_properties.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package accounts | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"net/http" | ||
|
||
"github.com/hashicorp/go-azure-sdk/sdk/client" | ||
) | ||
|
||
type SetServicePropertiesResult struct { | ||
HttpResponse *client.Response | ||
} | ||
|
||
func (c Client) SetServiceProperties(ctx context.Context, accountName string, input StorageServiceProperties) (resp SetServicePropertiesResult, err error) { | ||
if accountName == "" { | ||
return resp, fmt.Errorf("`accountName` cannot be an empty string") | ||
} | ||
|
||
opts := client.RequestOptions{ | ||
ContentType: "text/xml", | ||
ExpectedStatusCodes: []int{ | ||
http.StatusAccepted, | ||
}, | ||
HttpMethod: http.MethodPut, | ||
OptionsObject: servicePropertiesOptions{}, | ||
Path: "/", | ||
} | ||
req, err := c.Client.NewRequest(ctx, opts) | ||
if err != nil { | ||
err = fmt.Errorf("building request: %+v", err) | ||
return | ||
} | ||
if err = req.Marshal(&input); err != nil { | ||
err = fmt.Errorf("marshaling request: %+v", err) | ||
return | ||
} | ||
resp.HttpResponse, err = req.Execute(ctx) | ||
if err != nil { | ||
err = fmt.Errorf("executing request: %+v", err) | ||
return | ||
} | ||
|
||
return | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whilst the examples need updating to account for this API version, they also need updating to use the updated SDK - as such can we update these but in a separate PR / as a part of fixing #73?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking the same - do you want me to remove them completely from this PR or fix them up in the next one with the rest of the readmes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, fixing this up in the next one makes sense, let's merge this for now then 👍