Skip to content
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

More cleanup in aztables #22453

Merged
merged 1 commit into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 82 additions & 0 deletions sdk/data/aztables/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@

package aztables

import (
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
generated "github.com/Azure/azure-sdk-for-go/sdk/data/aztables/internal"
)

const (
headerXmsDate = "x-ms-date"
headerAuthorization = "Authorization"
Expand All @@ -17,6 +22,83 @@ const (
rowKey = "RowKey"
)

// GeoReplicationStatus - The status of the secondary location.
type GeoReplicationStatus string

const (
GeoReplicationStatusBootstrap GeoReplicationStatus = "bootstrap"
GeoReplicationStatusLive GeoReplicationStatus = "live"
GeoReplicationStatusUnavailable GeoReplicationStatus = "unavailable"
)

// PossibleGeoReplicationStatusValues returns the possible values for the GeoReplicationStatus const type.
func PossibleGeoReplicationStatusValues() []GeoReplicationStatus {
return []GeoReplicationStatus{
GeoReplicationStatusBootstrap,
GeoReplicationStatusLive,
GeoReplicationStatusUnavailable,
}
}

func toGeneratedStatusType(g *generated.GeoReplicationStatusType) *GeoReplicationStatus {
if g == nil {
return nil
}
if *g == generated.GeoReplicationStatusTypeBootstrap {
return to.Ptr(GeoReplicationStatusBootstrap)
}
if *g == generated.GeoReplicationStatusTypeLive {
return to.Ptr(GeoReplicationStatusLive)
}
if *g == generated.GeoReplicationStatusTypeUnavailable {
return to.Ptr(GeoReplicationStatusUnavailable)
}
return nil
}

// SASProtocol indicates the SAS protocol
type SASProtocol string

const (
// SASProtocolHTTPS can be specified for a SAS protocol
SASProtocolHTTPS SASProtocol = "https"

// SASProtocolHTTPSandHTTP can be specified for a SAS protocol
SASProtocolHTTPSandHTTP SASProtocol = "https,http"
)

// PossibleSASProtocolValues returns the possible values for the SASProtocol const type.
func PossibleSASProtocolValues() []SASProtocol {
return []SASProtocol{
SASProtocolHTTPS,
SASProtocolHTTPSandHTTP,
}
}

// TransactionType is the type for a specific transaction operation.
type TransactionType string

const (
TransactionTypeAdd TransactionType = "add"
TransactionTypeUpdateMerge TransactionType = "updatemerge"
TransactionTypeUpdateReplace TransactionType = "updatereplace"
TransactionTypeDelete TransactionType = "delete"
TransactionTypeInsertMerge TransactionType = "insertmerge"
TransactionTypeInsertReplace TransactionType = "insertreplace"
)

// PossibleTransactionTypeValues returns the possible values for the TransactionType const type.
func PossibleTransactionTypeValues() []TransactionType {
return []TransactionType{
TransactionTypeAdd,
TransactionTypeUpdateMerge,
TransactionTypeUpdateReplace,
TransactionTypeDelete,
TransactionTypeInsertMerge,
TransactionTypeInsertReplace,
}
}

// UpdateMode specifies what type of update to do on UpsertEntity or UpdateEntity. UpdateModeReplace
// will replace an existing entity, UpdateModeMerge will merge properties of the entities.
type UpdateMode string
Expand Down
58 changes: 15 additions & 43 deletions sdk/data/aztables/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,17 @@ func fromGeneratedCors(c *generated.CorsRule) *CorsRule {
}
}

func toGeneratedCorsRules(corsRules []*CorsRule) []*generated.CorsRule {
if len(corsRules) == 0 {
return nil
}
ret := make([]*generated.CorsRule, len(corsRules))
for i := range corsRules {
ret[i] = corsRules[i].toGenerated()
}
return ret
}

// ServiceProperties - Service Properties for a given table
type ServiceProperties struct {
// The set of CORS rules.
Expand Down Expand Up @@ -90,15 +101,10 @@ func (t *ServiceProperties) toGenerated() *generated.TableServiceProperties {
}
}

func toGeneratedCorsRules(corsRules []*CorsRule) []*generated.CorsRule {
if len(corsRules) == 0 {
return nil
}
ret := make([]*generated.CorsRule, len(corsRules))
for i := range corsRules {
ret[i] = corsRules[i].toGenerated()
}
return ret
// TableProperties contains the properties for a single Table
type TableProperties struct {
// The name of the table.
Name *string `json:"TableName,omitempty"`
}

// RetentionPolicy - The retention policy.
Expand Down Expand Up @@ -318,37 +324,3 @@ func fromGeneratedGeoReplication(g *generated.GeoReplication) *GeoReplication {
Status: toGeneratedStatusType(g.Status),
}
}

// GeoReplicationStatus - The status of the secondary location.
type GeoReplicationStatus string

const (
GeoReplicationStatusBootstrap GeoReplicationStatus = "bootstrap"
GeoReplicationStatusLive GeoReplicationStatus = "live"
GeoReplicationStatusUnavailable GeoReplicationStatus = "unavailable"
)

// PossibleGeoReplicationStatusValues returns the possible values for the GeoReplicationStatus const type.
func PossibleGeoReplicationStatusValues() []GeoReplicationStatus {
return []GeoReplicationStatus{
GeoReplicationStatusBootstrap,
GeoReplicationStatusLive,
GeoReplicationStatusUnavailable,
}
}

func toGeneratedStatusType(g *generated.GeoReplicationStatusType) *GeoReplicationStatus {
if g == nil {
return nil
}
if *g == generated.GeoReplicationStatusTypeBootstrap {
return to.Ptr(GeoReplicationStatusBootstrap)
}
if *g == generated.GeoReplicationStatusTypeLive {
return to.Ptr(GeoReplicationStatusLive)
}
if *g == generated.GeoReplicationStatusTypeUnavailable {
return to.Ptr(GeoReplicationStatusUnavailable)
}
return nil
}
19 changes: 0 additions & 19 deletions sdk/data/aztables/sas_query_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,6 @@ import (
"time"
)

// SASProtocol indicates the SAS protocol
type SASProtocol string

const (
// SASProtocolHTTPS can be specified for a SAS protocol
SASProtocolHTTPS SASProtocol = "https"

// SASProtocolHTTPSandHTTP can be specified for a SAS protocol
SASProtocolHTTPSandHTTP SASProtocol = "https,http"
)

// PossibleSASProtocolValues returns the possible values for the SASProtocol const type.
func PossibleSASProtocolValues() []SASProtocol {
return []SASProtocol{
SASProtocolHTTPS,
SASProtocolHTTPSandHTTP,
}
}

// FormatTimesForSASSigning converts a time.Time to a snapshotTimeFormat string suitable for a
// SASField's StartTime or ExpiryTime fields. Returns "" if value.IsZero().
func FormatTimesForSASSigning(startTime, expiryTime time.Time) (string, string) {
Expand Down
6 changes: 0 additions & 6 deletions sdk/data/aztables/service_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,6 @@ func (t *ServiceClient) DeleteTable(ctx context.Context, name string, options *D
return DeleteTableResponse{}, err
}

// TableProperties contains the properties for a single Table
type TableProperties struct {
// The name of the table.
Name *string `json:"TableName,omitempty"`
}

// NewListTablesPager queries the existing tables using the specified ListTablesOptions.
// listOptions can specify the following properties to affect the query results returned:
//
Expand Down
24 changes: 0 additions & 24 deletions sdk/data/aztables/transactional_batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,30 +24,6 @@ import (
"github.com/Azure/azure-sdk-for-go/sdk/internal/uuid"
)

// TransactionType is the type for a specific transaction operation.
type TransactionType string

const (
TransactionTypeAdd TransactionType = "add"
TransactionTypeUpdateMerge TransactionType = "updatemerge"
TransactionTypeUpdateReplace TransactionType = "updatereplace"
TransactionTypeDelete TransactionType = "delete"
TransactionTypeInsertMerge TransactionType = "insertmerge"
TransactionTypeInsertReplace TransactionType = "insertreplace"
)

// PossibleTransactionTypeValues returns the possible values for the TransactionType const type.
func PossibleTransactionTypeValues() []TransactionType {
return []TransactionType{
TransactionTypeAdd,
TransactionTypeUpdateMerge,
TransactionTypeUpdateReplace,
TransactionTypeDelete,
TransactionTypeInsertMerge,
TransactionTypeInsertReplace,
}
}

// TransactionAction represents a single action within a Transaction
type TransactionAction struct {
ActionType TransactionType
Expand Down