Skip to content

Commit 9ea6d4f

Browse files
seankane-msftchristothescatalinaperaltascbeddazure-sdk
authored andcommitted
[Tables] Track2 tables (Azure#15276)
* Initial generation of the aztables module (Azure#14441) * initial generation * Update ci.yml * Introduce internal/testFramework and test aztables with it (Azure#14491) * testFramework initial implementation * sanitizer fixes (Azure#14600) * Progress on aztables (Azure#14676) * implement batch operations and all entity operations * AsModels * rename * comments * comment tweaks, options as pointer * add EntityMapAsModel * refactors to AddEntity * update some code docs * doc fixes * doc fixes * doc improvements * rename testframework to recording * move ci.yml * ci path * ci path * [Tables] Update from testframework -> recording (Azure#14888) * Initial generation of the aztables module (Azure#14441) * initial generation * Update ci.yml * Introduce internal/testFramework and test aztables with it (Azure#14491) * testFramework initial implementation * sanitizer fixes (Azure#14600) * Progress on aztables (Azure#14676) * implement batch operations and all entity operations * AsModels * rename * comments * comment tweaks, options as pointer * add EntityMapAsModel * refactors to AddEntity * update some code docs * doc fixes * doc fixes * doc improvements * rename testframework to recording * fixing tables to go from testframework -> recording * renaming recordingInstance -> r * file name change Co-authored-by: Christopher Scott <[email protected]> Co-authored-by: catalinaperalta <[email protected]> * [Tables] ci fix (Azure#14956) * [Tables] Add post-request validation of entity (Azure#14960) * adds a secondary validation if the entity doesnt have pk/rk * creating an errors file just for handling errors * removing extra line * moving error to constants file, renaming constants file * improving test * [Tables] changing QueryOptions param to be a ptr (Azure#14961) * changing QueryOptions param to be a ptr * feedback from catalina * [Tables] linting Fixes (Azure#15028) * small fixes * small fixes * small fixes * small fixes * small fixes * small fixes * adding error checking to transactional batching * adding error checking to test set up * adding more error checking * adding more error checking * fixing two tests * fixing error reporting * fixing error reporting * fixing error reporting * fixing last lint failure * [Tables] Adding swagger.md (Azure#15016) * adding swagger * updating swagger with autorest command * more fixes * fixing directive * updating swagger.md * fixed swagger * fixing directive * add dataplane flag * updating swagger * commented out tests, passes remaining * addressing chris hamons feedback * undoing changes * undoing the rest of changes * updating generated code * formatting gen code * more formatting corrections * one last formatting correction * [Tables] Add get/set access policy (Azure#15027) * adding a way to skip cosmos tests, adding access policies * adding support for getting/setting access policies * tests working * does not work for multiple access policies * adding post validation * added error validation, note about possible issue * set policy works * removing table access policy file * [Tables] Add GetStats, GetProperties, and SetProperties methods (Azure#15112) * adding GetProperties * basic test of set properties * added logging and metrics tests * tests for setting service properties * adding test for retention too long * adding samples and docs * [Tables] Add support for Entity struct (Azure#15003) * adding test for custom entity * further * starting access policy * working for basic entity * adding to test * new generated code, removed one more test * AddEntity now takes []bytes * adding directive to change entity to []byte, changes to compile and be able to pass * converting Value map[string]interface{} -> []byte in convenience layer * paging works the same way now too * fixing two tests, update complex and basic test entities, need to add type hints for int64/float64 types * adding test for delete method, changed delete etag to be nil * working test for merge * Added Merge test * fix up test query simple entity * complex query test * everything except for batch tests * basic batch functionality * fixing batch mixed test * fixed last batch test * added separate file for testing batch actions * fixing query on table service client to take a pointer as well * working on annotating entities * fixing recordings * working with odata annotations * working test for using odata to annotate entity * adding options to get * working with embedded entity now too * adding to entity, peeling off prints * converted to a type * first change to add EdmEntity type * updated unmarshalling * removing two files * fix editLink * removing sample * cleaning up * removing more code * cleaning up * formatting * formatting * [Tables] change Query to List (Azure#15099) * adding List methods * moving helper to zt file * improving docstrings * changing all query methods to list * updating docstrings * [Tables] Update transactions method (Azure#15125) * adding test for custom entity * further * starting access policy * working for basic entity * adding to test * new generated code, removed one more test * AddEntity now takes []bytes * adding directive to change entity to []byte, changes to compile and be able to pass * converting Value map[string]interface{} -> []byte in convenience layer * paging works the same way now too * fixing two tests, update complex and basic test entities, need to add type hints for int64/float64 types * adding test for delete method, changed delete etag to be nil * working test for merge * Added Merge test * fix up test query simple entity * complex query test * everything except for batch tests * basic batch functionality * fixing batch mixed test * fixed last batch test * added separate file for testing batch actions * fixing query on table service client to take a pointer as well * working on annotating entities * fixing recordings * working with odata annotations * working test for using odata to annotate entity * adding options to get * working with embedded entity now too * adding to entity, peeling off prints * converted to a type * first change to add EdmEntity type * updated unmarshalling * removing two files * fix editLink * removing sample * cleaning up * removing more code * cleaning up * re-record and remove methods * more cleanup * formatting * having issues with cosmos tests * Adding Table suffix to Create, Delete, and List methods on service client (Azure#15181) * [Tables] Architect Feedback (Azure#15196) * architect feedback * docstrings * feedback * fixing eng pipelines * figuring out pipeline failure * missing recording * restore eng changes * [EngSys] Test proxy (Azure#15101) * [Tables] Add authentication via SAS credential (Azure#15256) * changing recording to use test-proxy * updating client and test proxy * updated Transport Do to send actual request * whitespace * working implementation * updating internal recording * now I have a blank recording... * cleaning up * more clean up * transport Do is repeating, proxy is not parsing URL correctly * small changes * adding a policy to do the same thing * adding a second test for proxy and transport * further progress with Jeff, switching to only using a policy right now * cleaning up file * cleaning up * added more debugging, added two required headers that I was missing * proxy working on a single test, need to convert all tests to test proxy * cleaning up * moved over successfully :) * more helper functions * working for a subtest functionality * fixed up a service client test * converting more service tests * converted all service client tests * converted table client tests * fixed last two client tests * entity test * entity tests * converting access policy tests * all passing in record mode * batch tests * liveonly for batch tests * adding a sanitizer and more methods for recording * adding main method to start and stop the proxy automatically * adding test proxy step to pipeline * double dash on version arg * need a better way to get userful error reporting * explicitly running test-proxy in the background * adjust the proxy start and install to be compatible with specific process * dont run test proxy in background * didnt remove an import * header to proxy_test.go * fixes for pipeline * added loggin on accident * use nohup on linux machines * further simplify nohup usage * there are no exes on windows * fixing errors, passing in default env variable * force background for linux task. may need another iteration to place it within the quotes * fake aad credential * clean up after test-proxy * add print for record mode * another different attempt at starting the proxy * jobs apparently is an unrecognized command on our linux boxes * correct dumb typo in run tests * replace nuget install with docker * working fake credentials for client delete entity test * fixing fake credentials portion, passing locally * trying an insecureskipverify transport * debugging statements to find the cwd * removing blank recording * working implementation of sas * working sas credential for account signature * table sas is failing * leverage proxy tool, not docker * remove apostrophes * moving recordings one directory up * transitioning to using the sas written by storage team * using storage methods * copied storage code, sas needs to be appended in a different way * changing directory for test-proxy to start from * removing parenthesis * adding steps for validating ssl * switching to docker * adding start server script * working implementation if we can fix the prepending of 'recording' to the docker request finder * big refactor, moving stuff into recording file, cleaning up proxy_test.go file * last fixings * convert back to docker. windows and linux images now present * double condition * moving configuration to a separate file. preparing for eng/common move * tier 0 of trust. I don't expect this to work, but it's still worth a shot. maybe the devops agents do something differently * update condition to use variable syntax * guess I'm not using variables. removing * call start-server.ps1 * adjust build-test and configure-proxy to run the docker container in context * wrap in quotes for the container create. it's apparently a bad * adjust the initialize call * disable vet temporarily * looking for cert file in env variable PROXY_CERT * set proxy_cert environment variable to find that certificate * changing to crt file * use crt cert * want to see errors * powershell errors * correcting how the volume binds to the windows container * small modification for windows container * finally got the magic sauce * cleaning up to remove azcore from internal * removing recordings that use vcr * issue with the url creation * persist query params correctly in azcore.JoinPaths * removing print statements * return root * changing location of script * forgot the stop command * working table level sas implementation * adding start/end rk/pk functionality * removing print statements * removing more non-tables code * docstrings and removing storage only code * making sas tests live only * Fixing sas table name to be lowercase always, adding test to verify read only * Fixing sas table name to be lowercase always, adding test to verify read only * adding cosmos sas test * fix for params * apiview fixes * fixing test * undoing change * updates * error naming * fixed service client, was adding percallpolicies twice * simplification * aligning with main * converting from query pager to list pager for naming consistency * updating objects for consistency * jeffs feedback * small fixes * autorest.md changes * fixing tablename Co-authored-by: scbedd <[email protected]> * fixing internal (Azure#15315) * Fixes2 (Azure#15316) Makes a fix to azcore in track2-tables branch * [Tables] bump deps (Azure#15350) * Sync eng/common directory with azure-sdk-tools for PR 1912 (Azure#15314) * Attempt to purge all vaults, managed HSMs Reverts Azure#1910. Vaults and managed HSMs are automatically purged on their purge date. The point was to purge them daily to preserve capacity. The default purge date is +90 days. * Add timeout and more logging * Pass required -Resource * Fix log message * Ensure the $Resource is correctly captured Added comment to new code explaining why, since ScriptBlock.GetNewClosure() is not working as expected. * Add -ErrorAction to Receive-Job Worked without terminating when run locally, but failed on the first error in the AzDO agent. * Use $using:r instead of creating ScriptBlock More idiomatic for passing ScriptBlocks to jobs. * Resolve PR feedback * Change default DeleteAfterHours to 120 Resolves Azure#1917 * Use the Az cmdlets built-in -AsJob Co-authored-by: Heath Stewart <[email protected]> * Fix query batch processing (Azure#15319) Co-authored-by: Wes Haggard <[email protected]> * fix: three dots path not work in linux in build script (Azure#15297) * Release v56.3.0 1629350585 (Azure#15323) * Generated from specification/apimanagement/resource-manager/readme.md tag package-preview-2021-01 (commit hash: 30d1537f0c9aa49e6e04401b1d16f612b31231e7) * Generated from specification/purview/resource-manager/readme.md tag package-2021-07-01 (commit hash: 30d1537f0c9aa49e6e04401b1d16f612b31231e7) * v56.3.0 * fix * Remove old unused update changelog script (Azure#15326) Co-authored-by: Wes Haggard <[email protected]> * add clear output flag to build.ps1 (Azure#15255) * add clear output flag * remove the path parameter and make sure the process-sdk function only runs in current directory * change flag name * [tools/generator] add automation and release command for track2 (Azure#15271) * [tools/generator] add automation and release command for track2 * add copyright and do gofmt * Use semver to pump version, move git operation to repo package and fix some typo * Add specfic version to release cmd, seperate package for automation and remove test config file * add automation script and config for track2 * fix: three dots path not work in linux in build script * fix: ln pwsh.exe to pwsh to run in linux * fix: ignore dep check for go-git * chore: label name change for track2 * fix: wrong package path result in empty git commit * fix: repo addr replacement in autorest.md * chore: move script to eng folder and change name * fix: onboard generation need to replace NewClientMethod * chore: change all naming from track2 to v2 * fix: add new build constraint * fix: template compat with go 1.17 and change commit msg for release * chore: add v2 to readme begin regex to support future change of `track2` naming * chore: remove track2 naming * fix: duplicated and wrong expression * fix: add package title param to release cmd * fix: ci * Prevent ManagedIdentityCredential mutating GetToken arguments (Azure#15331) * [Azcore] bumps version of internal (Azure#15347) * bump internal to latest * upgrading internal * not the correct one * changelog update * [azidentity] bump azcore and internal dependencies (Azure#15348) * updating to latest core and identity * trying to fix merge * undoing changes to identity that should not be there * more changes * more changes * removing a bunch more * one last file * formatting * linting checks * linting * formatting Co-authored-by: Azure SDK Bot <[email protected]> Co-authored-by: Heath Stewart <[email protected]> Co-authored-by: Wes Haggard <[email protected]> Co-authored-by: tadelesh <[email protected]> Co-authored-by: JiahuiPeng <[email protected]> Co-authored-by: Arcturus <[email protected]> Co-authored-by: Charles Lowell <[email protected]> * [Tables] connection string parser (Azure#15187) * adding conn str parser * Basic conn str parser * adding support for custom domains * invalid tests * adding self note * Update sdk/tables/aztable/connection_string.go Co-authored-by: Richard Park <[email protected]> * Update sdk/tables/aztable/connection_string.go Co-authored-by: Richard Park <[email protected]> * improving testing * finishing connection string portion * formatting and improved error handling * docstring addition for private method * connection string error * splitn instead of split * sas comment * updating proxy-server script * configure proxy with hash of file, correct file location * using certs in main * trying download with no password * trying without the pfx file altogether * adding pfx portion back * manual copy of testproxy to common * using common * fixing path * adding trust ps1 script * adding step to run proxy * formatting and go mod x/net * fixing for latest azcore * fixing rqeuire * removing eng stuff * conn str * running tests * run tests = true * adding build sourcesDir * relative path * fixing up path * build-test * moving byte array response inside table pager * env var playing to fix ci lint * changing package name Co-authored-by: Richard Park <[email protected]> * [Tables] simplify code space by moving generated to `internal` module (Azure#15299) * changing to internal package, everything except batching works * back to working * converting more things to private * renamings * still working, checkpoint * most of tableclient done * finished table client options/responses * finished with service client * cors rule done * retentionpolicy * retentionpolicy and cors * last piece * final comments * updating with newest autorest * formatting * fixing go mod in internal package * update versions * flipping param order * convert internal to a subpackage * fixing telemetry and bumping go version * updating proxy, adding test-resources.json file * cert issues * formatting and x/net * fixing build-test * correcting file path * lint and formatting * go fmt * dropping coverage for internal * updates from pre-arch board * checking error * doing scopes work in generated code * linting * removing old file * consistent namings * removing types and simplifying pageresponse for list entities * formatting * renames, removing Table prefix, removing TableTRansactionError * fixed error type, placeholder while azcore is in PR * running tests live, fixing one test, converting to always using shared key * formatting * linter * fixing playback for storage * fixing playback credential * fixing serviceURL to expect tableName in service url * moving update mode into options for update/insert entity * return *Client from CreateTable method * cleaning up structs * flipping order of strings in conn str constructor * renaming param of transactionAction from ETag -> IfMatch * remove XMS prefix, change Value to Entities/Tables * moving GetTableSASToken to Client struct * making MinimalOdata the default, removing option to set it, new recordings * renaming ETag -> IfMatch for Options * formatting * renaming file, adding version to constants.go file * adding version * updating to latest azcore * updating autorest * formatting * updates for SAS * fixing tests, fixing conn str parser * formatting * missing error check * [Tables] Docs and cleanup (Azure#15428) * removing to library * cleanup * fixing two tests for live * removing options, responses, and table_pagers files * removing table_ prefix on files * removing byte_array_response.go file * fixing up two reponses, adding proper comments and fixing samples * removing NewClientFromConnStr * wrong 'to' library * [Tables]Rename package (Azure#15448) <!-- Thank you for contributing to the Azure SDK for Go. Please verify the following before submitting your PR, thank you! --> - [ ] The purpose of this PR is explained in this or a referenced issue. - [ ] The PR does not update generated files. - These files are managed by the codegen framework at [Azure/autorest.go][]. - [ ] Tests are included and/or updated for code changes. - [ ] Updates to [CHANGELOG.md][] are included. - [ ] MIT license headers are included in each file. [Azure/autorest.go]: https://github.com/Azure/autorest.go [CHANGELOG.md]: https://github.com/Azure/azure-sdk-for-go/blob/main/CHANGELOG.md * [Tables] Merging internal (Azure#15451) * updating * formatting Co-authored-by: Christopher Scott <[email protected]> Co-authored-by: catalinaperalta <[email protected]> Co-authored-by: scbedd <[email protected]> Co-authored-by: Azure SDK Bot <[email protected]> Co-authored-by: Heath Stewart <[email protected]> Co-authored-by: Wes Haggard <[email protected]> Co-authored-by: tadelesh <[email protected]> Co-authored-by: JiahuiPeng <[email protected]> Co-authored-by: Arcturus <[email protected]> Co-authored-by: Charles Lowell <[email protected]> Co-authored-by: Richard Park <[email protected]>
1 parent d80c528 commit 9ea6d4f

File tree

96 files changed

+17304
-20
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+17304
-20
lines changed

eng/config.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@
1010
},
1111
{
1212
"Name": "internal",
13-
"CoverageGoal": 0.90
13+
"CoverageGoal": 0.70
14+
},
15+
{
16+
"Name": "data",
17+
"CoverageGoal": 0.40
1418
}
1519
]
1620
}

eng/pipelines/templates/steps/build-test.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ steps:
7171
- pwsh: ../eng/scripts/create_coverage.ps1 ${{parameters.ServiceDirectory}}
7272
displayName: 'Generate Coverage XML'
7373
workingDirectory: '${{parameters.GoWorkspace}}sdk'
74+
env:
75+
GO111MODULE: 'off'
7476

7577
- task: PublishTestResults@2
7678
condition: succeededOrFailed()
@@ -86,4 +88,4 @@ steps:
8688
codeCoverageTool: Cobertura
8789
summaryFileLocation: '${{parameters.GoWorkspace}}sdk/${{parameters.ServiceDirectory}}/coverage.xml'
8890
additionalCodeCoverageFiles: '${{parameters.GoWorkspace}}sdk/${{parameters.ServiceDirectory}}/coverage.html'
89-
failIfCoverageEmpty: true
91+
failIfCoverageEmpty: true

sdk/data/autorest.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
## Go
2+
3+
These settings apply only when `--go` is specified on the command line.
4+
5+
<!-- Original autorest command used by Chris Scott -->
6+
<!-- autorest --use=@autorest/[email protected] https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/cosmos-db/data-plane/readme.md --tag=package-2019-02 --file-prefix="zz_generated_" --modelerfour.lenient-model-deduplication --license-header=MICROSOFT_MIT_NO_VERSION --output-folder=aztables --module=aztables --openapi-type="data-plane" --credential-scope=none -->
7+
8+
``` yaml
9+
go: true
10+
version: "^3.0.0"
11+
input-file: https://github.com/Azure/azure-rest-api-specs/blob/d744b6bcb95ab4034832ded556dbbe58f4287c5b/specification/cosmos-db/data-plane/Microsoft.Tables/preview/2019-02-02/table.json
12+
license-header: MICROSOFT_MIT_NO_VERSION
13+
clear-output-folder: false
14+
output-folder: aztables/internal
15+
tag: package-2019-02
16+
credential-scope: none
17+
use: "@autorest/[email protected]"
18+
module-version: 0.1.0
19+
security: "AADToken"
20+
security-scopes: "https://storage.azure.com/.default"
21+
modelerfour:
22+
group-parameters: false
23+
```
24+
25+
### Go multi-api
26+
27+
``` yaml $(go) && $(multiapi)
28+
batch:
29+
- tag: package-2019-02
30+
```

sdk/data/aztables/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Release History
2+
3+
## v0.1.0 (09-07-2021)
4+
* This is the initial release of the `aztables` library

sdk/data/aztables/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) Microsoft Corporation. All rights reserved.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE

sdk/data/aztables/README.md

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
# Azure Tables client library for Go
2+
3+
Azure Table storage is a service that stores large amounts of structured NoSQL data in the cloud, providing
4+
a key/attribute store with a schema-less design.
5+
6+
Azure Cosmos DB provides a Table API for applications that are written for Azure Table storage that need premium capabilities like:
7+
8+
- Turnkey global distribution.
9+
- Dedicated throughput worldwide.
10+
- Single-digit millisecond latencies at the 99th percentile.
11+
- Guaranteed high availability.
12+
- Automatic secondary indexing.
13+
14+
The Azure Tables client library can seamlessly target either Azure Table storage or Azure Cosmos DB table service endpoints with no code changes.
15+
16+
## Getting started
17+
18+
### Install the package
19+
Install the Azure Tables client library for Go :
20+
21+
### Prerequisites
22+
* An [Azure subscription][azure_sub].
23+
* An existing Azure storage account or Azure Cosmos DB database with Azure Table API specified.
24+
25+
If you need to create either of these, you can use the [Azure CLI][azure_cli].
26+
27+
#### Creating a storage account
28+
29+
Create a storage account `mystorageaccount` in resource group `MyResourceGroup`
30+
in the subscription `MySubscription` in the West US region.
31+
32+
33+
#### Creating a Cosmos DB
34+
35+
Create a Cosmos DB account `MyCosmosDBDatabaseAccount` in resource group `MyResourceGroup`
36+
in the subscription `MySubscription` and a table named `MyTableName` in the account.
37+
38+
39+
### Authenticate the Client
40+
41+
Learn more about options for authentication _(including Connection Strings, Shared Key, and Shared Key Signatures)_ in our samples.
42+
43+
## Key concepts
44+
45+
- `TableServiceClient` - Client that provides methods to interact at the Table Service level such as creating, listing, and deleting tables
46+
- `TableClient` - Client that provides methods to interact at an table entity level such as creating, querying, and deleting entities within a table.
47+
- `Table` - Tables store data as collections of entities.
48+
- `Entity` - Entities are similar to rows. An entity has a primary key and a set of properties. A property is a name value pair, similar to a column.
49+
50+
Common uses of the Table service include:
51+
52+
- Storing TBs of structured data capable of serving web scale applications
53+
- Storing datasets that don't require complex joins, foreign keys, or stored procedures and can be de-normalized for fast access
54+
- Quickly querying data using a clustered index
55+
### Create the Table service client
56+
57+
First, we need to construct a `TableServiceClient`.
58+
59+
### Create an Azure table
60+
Next, we can create a new table.
61+
62+
63+
### Get an Azure table
64+
The set of existing Azure tables can be queries using an OData filter.
65+
66+
67+
### Delete an Azure table
68+
69+
Individual tables can be deleted from the service.
70+
71+
72+
### Create the Table client
73+
74+
To interact with table entities, we must first construct a `TableClient`.
75+
76+
77+
### Add table entities
78+
79+
Let's define a new `TableEntity` so that we can add it to the table.
80+
81+
Using the `TableClient` we can now add our new entity to the table.
82+
83+
84+
### Query table entities
85+
86+
To inspect the set of existing table entities, we can query the table using an OData filter.
87+
88+
89+
If you prefer LINQ style query expressions, we can query the table using that syntax as well.
90+
91+
92+
### Delete table entities
93+
94+
If we no longer need our new table entity, it can be deleted.
95+
96+
97+
## Troubleshooting
98+
99+
When you interact with the Azure table library using the .NET SDK, errors returned by the service correspond to the same HTTP
100+
status codes returned for [REST API][tables_rest] requests.
101+
102+
For example, if you try to create a table that already exists, a `409` error is returned, indicating "Conflict".
103+
104+
105+
### Setting up console logging
106+
107+
The simplest way to see the logs is to enable the console logging.
108+
To create an Azure SDK log listener that outputs messages to console use AzureEventSourceListener.CreateConsoleLogger method.
109+
110+
111+
To learn more about other logging mechanisms see [here][logging].
112+
113+
## Next steps
114+
115+
Get started with our [Table samples][table_client_samples].
116+
117+
## Known Issues
118+
119+
A list of currently known issues relating to Cosmos DB table endpoints can be found [here](https://aka.ms/tablesknownissues).
120+
121+
## Contributing
122+
123+
This project welcomes contributions and suggestions. Most contributions require
124+
you to agree to a Contributor License Agreement (CLA) declaring that you have
125+
the right to, and actually do, grant us the rights to use your contribution. For
126+
details, visit [cla.microsoft.com][cla].
127+
128+
This project has adopted the [Microsoft Open Source Code of Conduct][coc].
129+
For more information see the [Code of Conduct FAQ][coc_faq] or contact
130+
[[email protected]][coc_contact] with any additional questions or comments.
131+
132+
## Generating the client
133+
134+
From the tables dir:
135+
136+
autorest --use=@autorest/go@4.0.0-preview.20 https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/cosmos-db/data-plane/readme.md --tag=package-2019-02 --file-prefix="zz_generated_" --modelerfour.lenient-model-deduplication --license-header=MICROSOFT_MIT_NO_VERSION --output-folder=aztables --module=aztables --openapi-type="data-plane" --credential-scope=none
137+
138+
<!-- LINKS -->
139+
[tables_rest]: https://docs.microsoft.com/rest/api/storageservices/table-service-rest-api
140+
[azure_cli]: https://docs.microsoft.com/cli/azure
141+
[azure_sub]: https://azure.microsoft.com/free/
142+
[table_client_nuget_package]: https://www.nuget.org/packages?q=Azure.Data.Tables
143+
[table_client_samples]: https://github\.com/Azure/azure-sdk-for-go
144+
[table_client_src]: https://github\.com/Azure/azure-sdk-for-go
145+
[logging]: https://github\.com/Azure/azure-sdk-for-go
146+
[cla]: https://cla.microsoft.com
147+
[coc]: https://opensource.microsoft.com/codeofconduct/
148+
[coc_faq]: https://opensource.microsoft.com/codeofconduct/faq/
149+
[coc_contact]: mailto:[email protected]
150+
151+
![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-net%2Fsdk%2Ftables%2FAzure.Data.Tables%2FREADME.png)
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
package aztables
5+
6+
import (
7+
"strconv"
8+
"testing"
9+
"time"
10+
11+
"github.com/stretchr/testify/require"
12+
)
13+
14+
func TestSetEmptyAccessPolicy(t *testing.T) {
15+
client, delete := initClientTest(t, "storage", true)
16+
defer delete()
17+
18+
_, err := client.SetAccessPolicy(ctx, &SetAccessPolicyOptions{})
19+
require.NoError(t, err)
20+
}
21+
22+
func TestSetAccessPolicy(t *testing.T) {
23+
client, delete := initClientTest(t, "storage", true)
24+
defer delete()
25+
26+
start := time.Date(2020, 1, 1, 0, 0, 0, 0, time.UTC)
27+
expiration := time.Date(2024, 1, 1, 0, 0, 0, 0, time.UTC)
28+
permission := "r"
29+
id := "1"
30+
31+
signedIdentifiers := make([]*SignedIdentifier, 0)
32+
33+
signedIdentifiers = append(signedIdentifiers, &SignedIdentifier{
34+
AccessPolicy: &AccessPolicy{
35+
Expiry: &expiration,
36+
Start: &start,
37+
Permission: &permission,
38+
},
39+
ID: &id,
40+
})
41+
42+
param := SetAccessPolicyOptions{
43+
TableACL: signedIdentifiers,
44+
}
45+
46+
_, err := client.SetAccessPolicy(ctx, &param)
47+
require.NoError(t, err)
48+
}
49+
50+
func TestSetMultipleAccessPolicies(t *testing.T) {
51+
client, delete := initClientTest(t, "storage", true)
52+
defer delete()
53+
54+
id := "empty"
55+
56+
signedIdentifiers := make([]*SignedIdentifier, 0)
57+
signedIdentifiers = append(signedIdentifiers, &SignedIdentifier{
58+
ID: &id,
59+
})
60+
61+
permission2 := "r"
62+
id2 := "partial"
63+
64+
signedIdentifiers = append(signedIdentifiers, &SignedIdentifier{
65+
ID: &id2,
66+
AccessPolicy: &AccessPolicy{
67+
Permission: &permission2,
68+
},
69+
})
70+
71+
id3 := "full"
72+
permission3 := "r"
73+
start := time.Date(2021, 6, 8, 2, 10, 9, 0, time.UTC)
74+
expiry := time.Date(2021, 6, 8, 2, 10, 9, 0, time.UTC)
75+
76+
signedIdentifiers = append(signedIdentifiers, &SignedIdentifier{
77+
ID: &id3,
78+
AccessPolicy: &AccessPolicy{
79+
Start: &start,
80+
Expiry: &expiry,
81+
Permission: &permission3,
82+
},
83+
})
84+
85+
param := SetAccessPolicyOptions{
86+
TableACL: signedIdentifiers,
87+
}
88+
89+
_, err := client.SetAccessPolicy(ctx, &param)
90+
require.NoError(t, err)
91+
92+
// Make a Get to assert two access policies
93+
resp, err := client.GetAccessPolicy(ctx, nil)
94+
require.NoError(t, err)
95+
require.Equal(t, len(resp.SignedIdentifiers), 3)
96+
}
97+
98+
func TestSetTooManyAccessPolicies(t *testing.T) {
99+
client, delete := initClientTest(t, "storage", true)
100+
defer delete()
101+
102+
start := time.Date(2020, 1, 1, 0, 0, 0, 0, time.UTC)
103+
expiration := time.Date(2024, 1, 1, 0, 0, 0, 0, time.UTC)
104+
permission := "r"
105+
id := "1"
106+
signedIdentifiers := make([]*SignedIdentifier, 0)
107+
108+
for i := 0; i < 6; i++ {
109+
expiration = time.Date(2024+i, 1, 1, 0, 0, 0, 0, time.UTC)
110+
id = strconv.Itoa(i)
111+
112+
signedIdentifiers = append(signedIdentifiers, &SignedIdentifier{
113+
AccessPolicy: &AccessPolicy{
114+
Expiry: &expiration,
115+
Start: &start,
116+
Permission: &permission,
117+
},
118+
ID: &id,
119+
})
120+
121+
}
122+
123+
param := SetAccessPolicyOptions{TableACL: signedIdentifiers}
124+
125+
_, err := client.SetAccessPolicy(ctx, &param)
126+
require.NotNil(t, err, "Set access policy succeeded but should have failed")
127+
require.Contains(t, err.Error(), errTooManyAccessPoliciesError.Error())
128+
}
129+
130+
func TestSetNullAccessPolicy(t *testing.T) {
131+
client, delete := initClientTest(t, "storage", true)
132+
defer delete()
133+
134+
id := "null"
135+
136+
signedIdentifiers := make([]*SignedIdentifier, 0)
137+
signedIdentifiers = append(signedIdentifiers, &SignedIdentifier{
138+
ID: &id,
139+
})
140+
141+
param := SetAccessPolicyOptions{
142+
TableACL: signedIdentifiers,
143+
}
144+
145+
_, err := client.SetAccessPolicy(ctx, &param)
146+
require.NoError(t, err)
147+
148+
resp, err := client.GetAccessPolicy(ctx, nil)
149+
require.NoError(t, err)
150+
require.Equal(t, len(resp.SignedIdentifiers), 1)
151+
}

0 commit comments

Comments
 (0)