Skip to content

Commit

Permalink
Clean up constants in aztables (#21258)
Browse files Browse the repository at this point in the history
* Clean up constants in aztables

Older versions of autorest implicitly sealed single-value enums, so
enable the legacy behavior to avoid having to pass constant values.
Updated the perf test to use the current version of aztables.

* update perf test with renamed APIs
  • Loading branch information
jhendrixMSFT authored Jul 28, 2023
1 parent 0b38572 commit 9ca702d
Show file tree
Hide file tree
Showing 13 changed files with 116 additions and 256 deletions.
1 change: 1 addition & 0 deletions sdk/data/aztables/autorest.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ security-scopes: "https://storage.azure.com/.default"
honor-body-placement: true
modelerfour:
group-parameters: false
seal-single-value-enum-by-default: true

directive:
- from: source-file-go
Expand Down
18 changes: 7 additions & 11 deletions sdk/data/aztables/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func (t *Client) CreateTable(ctx context.Context, options *CreateTableOptions) (
if options == nil {
options = &CreateTableOptions{}
}
resp, err := t.client.Create(ctx, generated.Enum1Three0, generated.TableProperties{TableName: &t.name}, options.toGenerated(), &generated.QueryOptions{})
resp, err := t.client.Create(ctx, generated.TableProperties{TableName: &t.name}, options.toGenerated(), &generated.QueryOptions{})
if err != nil {
return CreateTableResponse{}, err
}
Expand Down Expand Up @@ -241,7 +241,7 @@ func (t *Client) NewListEntitiesPager(listOptions *ListEntitiesOptions) *runtime
partKey = listOptions.NextPartitionKey
rowKey = listOptions.NextRowKey
}
resp, err := t.client.QueryEntities(ctx, generated.Enum1Three0, t.name, &generated.TableClientQueryEntitiesOptions{
resp, err := t.client.QueryEntities(ctx, t.name, &generated.TableClientQueryEntitiesOptions{
NextPartitionKey: partKey,
NextRowKey: rowKey,
}, listOptions.toQueryOptions())
Expand Down Expand Up @@ -297,7 +297,7 @@ func (t *Client) GetEntity(ctx context.Context, partitionKey string, rowKey stri
}

genOptions, queryOptions := options.toGenerated()
resp, err := t.client.QueryEntityWithPartitionAndRowKey(ctx, generated.Enum1Three0, t.name, prepareKey(partitionKey), prepareKey(rowKey), genOptions, queryOptions)
resp, err := t.client.QueryEntityWithPartitionAndRowKey(ctx, t.name, prepareKey(partitionKey), prepareKey(rowKey), genOptions, queryOptions)
if err != nil {
return GetEntityResponse{}, err
}
Expand Down Expand Up @@ -338,7 +338,7 @@ func (t *Client) AddEntity(ctx context.Context, entity []byte, options *AddEntit
if err != nil {
return AddEntityResponse{}, err
}
resp, err := t.client.InsertEntity(ctx, generated.Enum1Three0, t.name, &generated.TableClientInsertEntityOptions{TableEntityProperties: mapEntity, ResponsePreference: to.Ptr(generated.ResponseFormatReturnNoContent)}, nil)
resp, err := t.client.InsertEntity(ctx, t.name, &generated.TableClientInsertEntityOptions{TableEntityProperties: mapEntity, ResponsePreference: to.Ptr(generated.ResponseFormatReturnNoContent)}, nil)
if err != nil {
err = checkEntityForPkRk(&mapEntity, err)
return AddEntityResponse{}, err
Expand Down Expand Up @@ -374,7 +374,7 @@ func (t *Client) DeleteEntity(ctx context.Context, partitionKey string, rowKey s
nilEtag := azcore.ETag("*")
options.IfMatch = &nilEtag
}
resp, err := t.client.DeleteEntity(ctx, generated.Enum1Three0, t.name, prepareKey(partitionKey), prepareKey(rowKey), string(*options.IfMatch), options.toGenerated(), &generated.QueryOptions{})
resp, err := t.client.DeleteEntity(ctx, t.name, prepareKey(partitionKey), prepareKey(rowKey), string(*options.IfMatch), options.toGenerated(), &generated.QueryOptions{})
if err != nil {
return DeleteEntityResponse{}, err
}
Expand Down Expand Up @@ -474,7 +474,6 @@ func (t *Client) UpdateEntity(ctx context.Context, entity []byte, options *Updat
case UpdateModeMerge:
resp, err := t.client.MergeEntity(
ctx,
generated.Enum1Three0,
t.name,
prepareKey(partKey),
prepareKey(rowkey),
Expand All @@ -488,7 +487,6 @@ func (t *Client) UpdateEntity(ctx context.Context, entity []byte, options *Updat
case UpdateModeReplace:
resp, err := t.client.UpdateEntity(
ctx,
generated.Enum1Three0,
t.name,
prepareKey(partKey),
prepareKey(rowkey),
Expand Down Expand Up @@ -577,7 +575,6 @@ func (t *Client) UpsertEntity(ctx context.Context, entity []byte, options *Upser
case UpdateModeMerge:
resp, err := t.client.MergeEntity(
ctx,
generated.Enum1Three0,
t.name,
prepareKey(partKey),
prepareKey(rowkey),
Expand All @@ -591,7 +588,6 @@ func (t *Client) UpsertEntity(ctx context.Context, entity []byte, options *Upser
case UpdateModeReplace:
resp, err := t.client.UpdateEntity(
ctx,
generated.Enum1Three0,
t.name,
prepareKey(partKey),
prepareKey(rowkey),
Expand Down Expand Up @@ -641,7 +637,7 @@ func getAccessPolicyResponseFromGenerated(g *generated.TableClientGetAccessPolic
// If the service returns a non-successful HTTP status code, the function returns an *azcore.ResponseError type.
// Specify nil for options if you want to use the default options.
func (t *Client) GetAccessPolicy(ctx context.Context, options *GetAccessPolicyOptions) (GetAccessPolicyResponse, error) {
resp, err := t.client.GetAccessPolicy(ctx, t.name, generated.Enum4ACL, options.toGenerated())
resp, err := t.client.GetAccessPolicy(ctx, t.name, options.toGenerated())
if err != nil {
return GetAccessPolicyResponse{}, err
}
Expand Down Expand Up @@ -679,7 +675,7 @@ func (t *Client) SetAccessPolicy(ctx context.Context, options *SetAccessPolicyOp
if options == nil {
options = &SetAccessPolicyOptions{}
}
response, err := t.client.SetAccessPolicy(ctx, t.name, generated.Enum4ACL, options.toGenerated())
response, err := t.client.SetAccessPolicy(ctx, t.name, options.toGenerated())
if err != nil && len(options.TableACL) > 5 {
err = errTooManyAccessPoliciesError
}
Expand Down
1 change: 0 additions & 1 deletion sdk/data/aztables/internal/service_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ func NewServiceClient(endpoint string, plOpts runtime.PipelineOptions, options *
return &ServiceClient{
endpoint: endpoint,
internal: client,
version: Enum0TwoThousandNineteen0202,
}, nil
}

Expand Down
1 change: 0 additions & 1 deletion sdk/data/aztables/internal/table_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ func NewTableClient(endpoint string, plOpts runtime.PipelineOptions, options *az
return &TableClient{
endpoint: endpoint,
internal: client,
version: Enum0TwoThousandNineteen0202,
}, nil
}

Expand Down
78 changes: 0 additions & 78 deletions sdk/data/aztables/internal/zz_constants.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 18 additions & 25 deletions sdk/data/aztables/internal/zz_service_client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9ca702d

Please sign in to comment.