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

fix: codegen changes for calling aws sdk from local service #538

Open
wants to merge 256 commits into
base: rishav-awssdkFromLocal-Testmodel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 247 commits
Commits
Show all changes
256 commits
Select commit Hold shift + click to select a range
b6153fc
Add externs
rishav-karanjit Aug 23, 2024
60536c2
Update Model
rishav-karanjit Aug 23, 2024
5937497
Update project file
rishav-karanjit Aug 23, 2024
fb78c09
Add project file
rishav-karanjit Aug 23, 2024
18f0711
Project file dotnet'
rishav-karanjit Aug 23, 2024
0adee61
Add all updates
rishav-karanjit Aug 24, 2024
fcb2ecf
Lot of changes
rishav-karanjit Aug 24, 2024
0030cd3
Add DDB call
rishav-karanjit Aug 25, 2024
5dd7d6f
Add KMS
rishav-karanjit Aug 25, 2024
9e0542f
Update make file
rishav-karanjit Aug 25, 2024
5db5cfe
Format Java
rishav-karanjit Aug 26, 2024
3bf0b36
Add CallKMSEnsuresPublicly
rishav-karanjit Aug 26, 2024
1a5b4b5
Fix CallKMSEnsuresPublicly func params
rishav-karanjit Aug 26, 2024
4bbf2a6
Add CallingAWSSDKFromLocalService in disabled tests
rishav-karanjit Aug 26, 2024
a92f50c
Check for SDK error - TODO wrapped getting error
rishav-karanjit Aug 26, 2024
06d7889
Add Encrypt API and refactoring
rishav-karanjit Aug 27, 2024
32f14f5
Rename CallDDB to CallDDBGetKey
rishav-karanjit Aug 27, 2024
473be0f
Update table name for CI
rishav-karanjit Aug 27, 2024
478a2e1
rename CallDDBGetKey to CallDDBGetItem
rishav-karanjit Aug 27, 2024
2b598e7
Add pre and post condition
rishav-karanjit Sep 2, 2024
56cd0eb
Make error to ComAmazonawsDynamodb and ComAmazonawsKms
rishav-karanjit Sep 2, 2024
76840fa
Fixes
rishav-karanjit Sep 3, 2024
eb832a8
Fixes
rishav-karanjit Sep 3, 2024
e8ce1f4
Merge branch 'main-1.x' into rishav-add-CallingAWSSDK
rishav-karanjit Sep 3, 2024
2615a73
Refactor makefile
rishav-karanjit Sep 3, 2024
20199da
Refactor makefile again
rishav-karanjit Sep 3, 2024
93684bb
Add proj ref and compile include
rishav-karanjit Sep 3, 2024
0b0f1ed
Fixes
rishav-karanjit Sep 3, 2024
4ac299e
Change dotnet and test
rishav-karanjit Sep 3, 2024
327746c
Revert "Change dotnet and test"
rishav-karanjit Sep 4, 2024
992c669
Add MakeFile
rishav-karanjit Sep 4, 2024
31ab1d9
Update Makefile
rishav-karanjit Sep 4, 2024
8769cee
Revert "Revert "Change dotnet and test""
rishav-karanjit Sep 4, 2024
046b73c
Add python runtime
rishav-karanjit Sep 4, 2024
38aae8e
Update dependencies
rishav-karanjit Sep 4, 2024
7791bae
Update dependencies
rishav-karanjit Sep 4, 2024
6a4e630
Merge remote-tracking branch 'origin/Golang/dev' into rishav-add-Call…
rishav-karanjit Sep 4, 2024
72b4384
Revert changes to model.json in KMS
rishav-karanjit Sep 4, 2024
4bd8251
Update MakeFile with Go module
rishav-karanjit Sep 4, 2024
a4431a7
Add Go comment
rishav-karanjit Sep 4, 2024
a2cf766
Revert "Revert changes to model.json in KMS"
rishav-karanjit Sep 4, 2024
0e8c581
Update smithy model for v2 smithy of kms
rishav-karanjit Sep 4, 2024
d37b806
Update to return keyid:
rishav-karanjit Sep 5, 2024
2af2588
Merge branch 'Golang/dev' of https://github.com/smithy-lang/smithy-da…
rishav-karanjit Sep 11, 2024
a4cb20b
Merge branch 'Golang/dev' into rishav-add-CallingAWSSDK
rishav-karanjit Sep 12, 2024
be7301c
Commit go mod
rishav-karanjit Sep 12, 2024
db0e27a
Add everything
rishav-karanjit Sep 13, 2024
712cbcf
Add extern
rishav-karanjit Sep 13, 2024
ec09dc1
Push KMS runtime
rishav-karanjit Sep 13, 2024
7783d4e
Merge from Golang/dev
rishav-karanjit Sep 17, 2024
ed8eca6
Update make file
rishav-karanjit Sep 17, 2024
1d832a8
If dep service has no local service trait then continue
rishav-karanjit Sep 17, 2024
b7ace1c
Update make file
rishav-karanjit Sep 17, 2024
ba93f86
Service does not have a special logic for Referred shape
rishav-karanjit Sep 17, 2024
51ca930
Update smithyTypesNamespace
rishav-karanjit Sep 17, 2024
d4b7c82
Update structure shape in reference with serviceShape
rishav-karanjit Sep 17, 2024
9a8e588
Runtime changes
rishav-karanjit Sep 18, 2024
f362bb0
push everything for now
rishav-karanjit Sep 19, 2024
fa53236
Add support for recursive shapes in Go (#607)
rishav-karanjit Sep 23, 2024
015825f
Remove redundant files
rishav-karanjit Sep 23, 2024
355d74a
CI fixes
rishav-karanjit Sep 23, 2024
aee93ba
Remove redundant files
rishav-karanjit Sep 23, 2024
9a452e2
Refactoring
rishav-karanjit Sep 23, 2024
e92d40c
Update src module name
rishav-karanjit Sep 23, 2024
99df7d7
Update module name
rishav-karanjit Sep 23, 2024
401c64d
Update module name
rishav-karanjit Sep 23, 2024
0d4547e
Add go mod
rishav-karanjit Sep 23, 2024
ae6eecb
update module name
rishav-karanjit Sep 23, 2024
de202ba
Format
rishav-karanjit Sep 23, 2024
bb25f0a
Change shape name
rishav-karanjit Sep 23, 2024
78cca65
Remove redundant codes
rishav-karanjit Sep 23, 2024
1870322
Remove redundant codes
rishav-karanjit Sep 23, 2024
7ce1847
Add go mod
rishav-karanjit Sep 23, 2024
c8883fb
Update Makefile
rishav-karanjit Sep 23, 2024
dd83e91
rm go mod
rishav-karanjit Sep 23, 2024
94afffe
Add api client and go mod
rishav-karanjit Sep 23, 2024
013b2dd
Add go mod
rishav-karanjit Sep 23, 2024
d1b6f1f
Add runtime
rishav-karanjit Sep 24, 2024
99c98a9
Add runtime
rishav-karanjit Sep 24, 2024
e7c8cde
Go mod Go sum
rishav-karanjit Sep 24, 2024
3ca8c6f
Update test model
rishav-karanjit Sep 24, 2024
aaa0ddd
Update test model
rishav-karanjit Sep 24, 2024
c23a6cf
fix dafny client
rishav-karanjit Sep 25, 2024
5779b87
Local service fixes
rishav-karanjit Sep 25, 2024
b910eeb
Fix var name
rishav-karanjit Sep 26, 2024
31fabcf
update runtime
rishav-karanjit Sep 26, 2024
f1e5936
Update test model
rishav-karanjit Sep 26, 2024
d5291a3
Remove redundant codes
rishav-karanjit Sep 26, 2024
1226428
Update go mod
rishav-karanjit Sep 26, 2024
b7eabcd
rm redundant files
rishav-karanjit Sep 26, 2024
417f9be
wrap not opaque error into opaque error
rishav-karanjit Sep 26, 2024
dc3f5fa
Revert "Revert "Revert "Change dotnet and test"""
rishav-karanjit Sep 26, 2024
f0e08c7
Recursive shape support in aws sdk go
rishav-karanjit Sep 28, 2024
135309b
Add is timestamp
rishav-karanjit Sep 28, 2024
ec28625
Copy local service changes to sdk
rishav-karanjit Sep 29, 2024
622071e
PR Comment fix
rishav-karanjit Sep 29, 2024
0c6ff38
comment fix
rishav-karanjit Sep 29, 2024
a21c2ef
Namespace fix
rishav-karanjit Sep 30, 2024
4a70ece
Service does not have special logic
rishav-karanjit Sep 30, 2024
0b85561
Fix error handling sdk v2
rishav-karanjit Sep 30, 2024
99ce8d5
Remove print
rishav-karanjit Sep 30, 2024
8155e77
Fix comments
rishav-karanjit Sep 30, 2024
f176be6
Add recursive shape to disabled test except in go
rishav-karanjit Sep 30, 2024
c00a978
Delete redundant file
rishav-karanjit Sep 30, 2024
60ad10c
Add recursive shape to disabled test except in go
rishav-karanjit Sep 30, 2024
be6c61b
Revert "Add recursive shape to disabled test except in go"
rishav-karanjit Sep 30, 2024
e093887
revert formating -- think about it later
rishav-karanjit Oct 1, 2024
12e2aed
Revert "Add recursive shape to disabled test except in go"
rishav-karanjit Oct 1, 2024
477e6ef
Add {} to if else and make data type final whereever possible
rishav-karanjit Oct 1, 2024
84aec71
Don't move extern rn
rishav-karanjit Oct 1, 2024
b2d454b
Add todo to make file
rishav-karanjit Oct 1, 2024
a285f84
ENABLE_EXTERN_PROCESSING
rishav-karanjit Oct 1, 2024
3601472
nit fix
rishav-karanjit Oct 1, 2024
1241dc0
Remove Rust benerated in makefile
rishav-karanjit Oct 1, 2024
0a37314
bring make the makefile
rishav-karanjit Oct 1, 2024
5bd09e1
remove shim
rishav-karanjit Oct 1, 2024
dbbca19
Bring back makefile
rishav-karanjit Oct 1, 2024
00b06ad
add final
rishav-karanjit Oct 1, 2024
2ea8dbf
rm redundant call
rishav-karanjit Oct 1, 2024
87260b7
used switch case
rishav-karanjit Oct 2, 2024
d8977b4
used concat
rishav-karanjit Oct 2, 2024
eab1449
Extract out into a var and concat
rishav-karanjit Oct 2, 2024
80d8381
remove a hack for initialized and not used
rishav-karanjit Oct 2, 2024
3a7ed5d
Add some comments
rishav-karanjit Oct 2, 2024
7bac1de
remove a hack for initialized and not used
rishav-karanjit Oct 2, 2024
d88e9d0
remove boolean casting in isOptional
rishav-karanjit Oct 2, 2024
03cc3f5
Update output type
rishav-karanjit Oct 2, 2024
89c6054
Use GoCodegenUtils
rishav-karanjit Oct 2, 2024
2fc55a4
remove () in return
rishav-karanjit Oct 2, 2024
4274db5
remove () in return
rishav-karanjit Oct 2, 2024
152922b
remove hack for init but not used
rishav-karanjit Oct 2, 2024
bd2619d
remove hack for init but not used
rishav-karanjit Oct 2, 2024
c00fd79
remove hack for init but not used
rishav-karanjit Oct 2, 2024
dd0a5db
remove hack for init but not used
rishav-karanjit Oct 2, 2024
368f395
remove hack for init but not used
rishav-karanjit Oct 2, 2024
aa207bb
bring back removed files
rishav-karanjit Oct 2, 2024
c51bed4
Combine these two statements
rishav-karanjit Oct 2, 2024
0b6e0ba
Add todo and remove unused imports
rishav-karanjit Oct 2, 2024
842d5da
refactor get smithy type
rishav-karanjit Oct 2, 2024
1cf85e6
use GoCodegenUtils
rishav-karanjit Oct 2, 2024
e1099df
use GoCodegenUtils
rishav-karanjit Oct 2, 2024
9631e0b
update list and map to not get init and not use error
rishav-karanjit Oct 2, 2024
4e535fd
remove commented code
rishav-karanjit Oct 2, 2024
64f2109
add timestamp import
rishav-karanjit Oct 2, 2024
9bcd8cc
unAssertDataSource
rishav-karanjit Oct 2, 2024
3163256
Union wrapper optional only if isoptional
rishav-karanjit Oct 2, 2024
d3fa74f
union is Wrappers.Option if optional
rishav-karanjit Oct 2, 2024
2faf98d
Move to function
rishav-karanjit Oct 2, 2024
6f5bb33
Move to a function
rishav-karanjit Oct 2, 2024
ce6c4cb
Nit comment
rishav-karanjit Oct 2, 2024
012ec0b
nit comments
rishav-karanjit Oct 2, 2024
1e3ca27
use interface instead of Hashmap
rishav-karanjit Oct 2, 2024
424f689
Use Map instead of hashmap
rishav-karanjit Oct 2, 2024
67f8f03
update kms and ddb extern
rishav-karanjit Oct 3, 2024
5280f59
rm redundant runtime files in kms:
rishav-karanjit Oct 3, 2024
5c31d4a
add disabled test in all languages
rishav-karanjit Oct 3, 2024
f8031b5
Merge branch 'Golang/dev' into rishav-add-CallingAWSSDK
rishav-karanjit Oct 3, 2024
e61d71f
remove check for num of items
rishav-karanjit Oct 3, 2024
111ca7e
Merge branch 'rishav-add-CallingAWSSDK' of https://github.com/smithy-…
rishav-karanjit Oct 3, 2024
841c7f3
fix namespace for TrentService and DynamoDB_20120810
rishav-karanjit Oct 3, 2024
bb01ef8
add imports
rishav-karanjit Oct 3, 2024
7969a94
merge with recursive shape branch
rishav-karanjit Oct 3, 2024
86a755f
fix output type for interface client (IDynamoDBClient or ikmsclient)
rishav-karanjit Oct 3, 2024
b270c53
fix reference shape
rishav-karanjit Oct 3, 2024
cedd2c2
fix gap from MPL
rishav-karanjit Oct 7, 2024
0135c25
remove shapeNamespaceDafnyTranspiled and replace it with DafnyNameRes…
rishav-karanjit Oct 8, 2024
ee3fd1c
Shim namespace in pascal case
rishav-karanjit Oct 8, 2024
6c31fb6
Merge branch 'rishav-add-CallingAWSSDK' of https://github.com/smithy-…
rishav-karanjit Oct 8, 2024
b186a1d
fix old commits
rishav-karanjit Oct 8, 2024
b34be61
fix old commits
rishav-karanjit Oct 8, 2024
c124806
add import errors
rishav-karanjit Oct 8, 2024
5afef0f
add import time
rishav-karanjit Oct 8, 2024
11823a9
add import time
rishav-karanjit Oct 8, 2024
bf415a4
merge with Golang/dev
rishav-karanjit Oct 18, 2024
82ce455
Shim namespace in pascal case
rishav-karanjit Oct 21, 2024
23148b6
Remove redundant import
rishav-karanjit Oct 21, 2024
95a1eb5
Merge branch 'Golang/dev' into rishav-add-CallingAWSSDK
rishav-karanjit Oct 21, 2024
d46203c
reference to a shape needs change. TODO: will this work in MPL
rishav-karanjit Oct 21, 2024
13f0c65
Add TODO: will this work in MPL?
rishav-karanjit Oct 21, 2024
e71ef6e
Merge branch 'rishav-add-CallingAWSSDK' of https://github.com/smithy-…
rishav-karanjit Oct 21, 2024
e15c0a0
Merge branch 'Golang/dev' into rishav-add-CallingAWSSDK
rishav-karanjit Oct 23, 2024
93d7085
Formatting and auto merge fix
rishav-karanjit Oct 23, 2024
8a4021d
Revert back namespace in shim
rishav-karanjit Oct 23, 2024
e8804ed
Remove the test model rn. Will merge from another branch
rishav-karanjit Oct 23, 2024
af8a690
Merge branch 'rishav-awssdkFromLocal-Testmodel' into rishav-add-Calli…
rishav-karanjit Oct 23, 2024
1a5c6dd
Add Shim
rishav-karanjit Oct 23, 2024
29e456e
Add Shim
rishav-karanjit Oct 23, 2024
ca2d447
Add Shim
rishav-karanjit Oct 23, 2024
dd055c6
rm shim from implementation
rishav-karanjit Oct 23, 2024
02cf7c5
Enable calling aws SDK from local
rishav-karanjit Oct 23, 2024
f7ce0ab
remove redundant imports
rishav-karanjit Oct 23, 2024
8461540
Add comments
rishav-karanjit Oct 23, 2024
e2913ab
Wrapped test are different in AWS SDK failure
rishav-karanjit Oct 23, 2024
5765911
Remove a white space
rishav-karanjit Oct 23, 2024
749d216
Revert "Remove a white space"
rishav-karanjit Oct 23, 2024
8de40a1
Revert "Wrapped test are different in AWS SDK failure"
rishav-karanjit Oct 23, 2024
3d1059c
Fix opaque error
rishav-karanjit Oct 24, 2024
ec7791b
Update go mod
rishav-karanjit Oct 24, 2024
f091075
Update go mod
rishav-karanjit Oct 24, 2024
72d425a
update Shim
rishav-karanjit Oct 24, 2024
7679bb9
Add imports for SMITHY_SOURCE_PATH
rishav-karanjit Oct 24, 2024
8d03d82
Service shape can or cannot have service trait
rishav-karanjit Oct 24, 2024
d63c923
Add UNDERSCORE
rishav-karanjit Oct 24, 2024
1f82a5d
Add comments
rishav-karanjit Oct 24, 2024
d249234
Combine if and else if
rishav-karanjit Oct 24, 2024
fb1752d
Formatting
rishav-karanjit Oct 24, 2024
67d36cd
Remove extra attribute
rishav-karanjit Oct 24, 2024
994adfa
remove redundant code
rishav-karanjit Oct 24, 2024
dee1525
Bring back panic
rishav-karanjit Oct 24, 2024
e5e2b17
Change if else to switch
rishav-karanjit Oct 24, 2024
c154ce2
format fix
rishav-karanjit Oct 24, 2024
26bfca6
Fix extra relative variable
rishav-karanjit Oct 24, 2024
c636ea5
Refactor handleServiceError into a function
rishav-karanjit Oct 24, 2024
b301c39
Comment
rishav-karanjit Oct 24, 2024
c55a347
Add finals
rishav-karanjit Oct 24, 2024
b509f67
Add {} to else
rishav-karanjit Oct 24, 2024
2cc9112
Add comments
rishav-karanjit Oct 24, 2024
2a5e6e2
formatting
rishav-karanjit Oct 24, 2024
0f167f4
check for service trait
rishav-karanjit Oct 24, 2024
36e48f3
Use ServiceTrait and DafnyNameResolver
rishav-karanjit Oct 24, 2024
cfafd7b
isService && referredShape.hasTrait(ServiceTrait.class)
rishav-karanjit Oct 24, 2024
5c96987
&& to ||
rishav-karanjit Oct 24, 2024
2fae3a5
Delegate to both kms and ddb
rishav-karanjit Oct 24, 2024
dfacd4c
Use service trait
rishav-karanjit Oct 24, 2024
b122673
Use dafnyTypesNamespace for shape with service trait
rishav-karanjit Oct 24, 2024
5171357
Use DafnyNameResolver.getDafnyClient
rishav-karanjit Oct 24, 2024
658a854
Remove dafny type handling in smithy
rishav-karanjit Oct 24, 2024
0294d5b
Add missed ;
rishav-karanjit Oct 24, 2024
0a204bf
Add getDafnyClientName
rishav-karanjit Oct 24, 2024
a1fb3ae
Formatting
rishav-karanjit Oct 24, 2024
c7ef196
refactor error handling for sdk error
rishav-karanjit Oct 25, 2024
f76fc10
formatting
rishav-karanjit Oct 25, 2024
c1ee6ab
Fix imports
rishav-karanjit Oct 25, 2024
60db6e3
Remove extra comments
rishav-karanjit Oct 25, 2024
83b721b
Refactor to handleDepErrorSerializer method
rishav-karanjit Oct 25, 2024
dd656a6
Formatting
rishav-karanjit Oct 25, 2024
6a10e5e
Remove unused import
rishav-karanjit Oct 25, 2024
39c526e
Remove unused constant
rishav-karanjit Oct 25, 2024
e5bd697
Use DafnyNameResolver.dafnyNamespace
rishav-karanjit Oct 25, 2024
ce4967a
Bring back ternary statement
rishav-karanjit Oct 25, 2024
7f09065
Merge branch 'rishav-awssdkFromLocal-Testmodel' into rishav-add-Calli…
rishav-karanjit Oct 25, 2024
a2150b2
Update SymbolVisitor.java
ShubhamChaturvedi7 Oct 25, 2024
e1a2026
Update SymbolVisitor.java
ShubhamChaturvedi7 Oct 25, 2024
d00ec0b
Put in lowercase
rishav-karanjit Oct 25, 2024
f887855
All low case package name
rishav-karanjit Oct 25, 2024
036b05f
Merge branch 'rishav-add-CallingAWSSDK' of https://github.com/smithy-…
rishav-karanjit Oct 25, 2024
cf2096f
rm shim
rishav-karanjit Oct 25, 2024
9107136
All low case package name rename file
rishav-karanjit Oct 25, 2024
1a6f1c9
Create only opaque error not service based opaque
rishav-karanjit Oct 25, 2024
c1bf94f
formatting
rishav-karanjit Oct 25, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ require (

replace github.com/dafny-lang/DafnyStandardLibGo => ../../../../dafny-dependencies/StandardLibrary/runtimes/go/ImplementationFromDafny-go/

replace github.com/smithy-lang/smithy-dafny/kmsv2 => /Users/rishavkj/Documents/Storage/Team-Repos/smithy-dafny/TestModels/aws-sdks/kmsv2/runtimes/go/ImplementationFromDafny-go/
replace github.com/smithy-lang/smithy-dafny/kmsv2 => ../../../../aws-sdks/kmsv2/runtimes/go/ImplementationFromDafny-go/

replace github.com/smithy-lang/smithy-dafny/ddbv2 => /Users/rishavkj/Documents/Storage/Team-Repos/smithy-dafny/TestModels/aws-sdks/ddbv2/runtimes/go/ImplementationFromDafny-go/
replace github.com/smithy-lang/smithy-dafny/ddbv2 => ../../../../aws-sdks/ddbv2/runtimes/go/ImplementationFromDafny-go/

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

Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ replace github.com/smithy-lang/smithy-dafny/TestModels/CallingAWSSDKFromLocalSer

replace github.com/dafny-lang/DafnyStandardLibGo => ../../../../dafny-dependencies/StandardLibrary/runtimes/go/ImplementationFromDafny-go/

replace github.com/smithy-lang/smithy-dafny/kmsv2 => /Users/rishavkj/Documents/Storage/Team-Repos/smithy-dafny/TestModels/aws-sdks/kmsv2/runtimes/go/ImplementationFromDafny-go/
replace github.com/smithy-lang/smithy-dafny/kmsv2 => ../../../../aws-sdks/kmsv2/runtimes/go/ImplementationFromDafny-go/

replace github.com/smithy-lang/smithy-dafny/ddbv2 => /Users/rishavkj/Documents/Storage/Team-Repos/smithy-dafny/TestModels/aws-sdks/ddbv2/runtimes/go/ImplementationFromDafny-go/
replace github.com/smithy-lang/smithy-dafny/ddbv2 => ../../../../aws-sdks/ddbv2/runtimes/go/ImplementationFromDafny-go/
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,6 @@ module SimpleCallingAWSSDKFromLocalServiceImplTest {
var resFailure := client.CallDDBScan(SimpleCallingAWSSDKFromLocalService.Types.CallDDBScanInput(ddbClient := ddbClient, tableArn := TABLE_ARN_FAILURE_CASE));

expect resFailure.Failure?;
// Note: As of this writing, Go delegates the error first to KMS.
// If KMS is opaque, it is going to delegate to DDB. And return a DDB error (opaque or non opaque)
// If KMS is not opaque, it returns ComAmazonawsKms error.
expect resFailure.error.ComAmazonawsDynamodb?;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem was this was opaque and this could be created by KMS or DDB in this model as the smithy model has both KMS and DDB

Copy link
Contributor

@ShubhamChaturvedi7 ShubhamChaturvedi7 Oct 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this is the AcessDeniedException?

EDIT: Maybe in a follow up PR we assert that we do end up with non-opaque exceptions?

// If a table is not found and IAM user have permission on limited DDB table, DDB client returns an opaque error.
expect resFailure.error.ComAmazonawsDynamodb.Opaque?;
}

method{:test} CallKMSEncrypt(){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ require (
github.com/aws/aws-sdk-go-v2/service/dynamodb v1.34.9
github.com/dafny-lang/DafnyRuntimeGo/v4 v4.8.0
github.com/dafny-lang/DafnyStandardLibGo v0.0.0-00010101000000-000000000000
github.com/aws/smithy-go v1.22.0
)

require (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ require (
github.com/aws/aws-sdk-go-v2/service/kms v1.35.5
github.com/dafny-lang/DafnyRuntimeGo/v4 v4.8.0
github.com/dafny-lang/DafnyStandardLibGo v0.0.0-00010101000000-000000000000
github.com/aws/smithy-go v1.22.0
)

require (
Expand All @@ -23,5 +24,4 @@ require (
github.com/aws/aws-sdk-go-v2/service/sso v1.24.2 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.2 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.32.2 // indirect
github.com/aws/smithy-go v1.22.0 // indirect
)
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ class GoTestModels extends TestModelTest {

static {
DISABLED_TESTS.add("AggregateReferences");
DISABLED_TESTS.add("CallingAWSSDKFromLocalService");
DISABLED_TESTS.add("Documentation");
DISABLED_TESTS.add("LanguageSpecificLogic");
DISABLED_TESTS.add("SimpleTypes/BigDecimal");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -713,11 +713,14 @@ private void generateErrorDeserializer(final GenerationContext context) {
),
SmithyNameResolver.shapeNamespace(serviceShape),
writer -> {
writer.addUseImports(SmithyGoDependency.FMT);
writer.addImport(SmithyGoDependency.SMITHY_SOURCE_PATH);
writer.write(
"""
func OpaqueError_Output_FromDafny(dafnyOutput $L.Error)(error) {
return fmt.Errorf(fmt.Sprintf("%v", dafnyOutput.Dtor_obj()))
apiError := &smithy.GenericAPIError{
Message: dafnyOutput.Dtor_obj().(*smithy.OperationError).Err.Error(),
}
return apiError
}""",
DafnyNameResolver.dafnyTypesNamespace(serviceShape)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public final class SmithyGoDependency {
public static final GoDependency GO_JMESPATH = goJmespath(null);
public static final GoDependency MATH = stdlib("math");

private static final String SMITHY_SOURCE_PATH = "github.com/aws/smithy-go";
public static final String SMITHY_SOURCE_PATH = "github.com/aws/smithy-go";
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have used public static variable in a lot of places and smithy dafny will not be in production code. So, I made it public instead of having a getter method.

private static final String GO_CMP_SOURCE_PATH = "github.com/google/go-cmp";
private static final String GO_JMESPATH_SOURCE_PATH =
"github.com/jmespath/go-jmespath";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,18 @@

package software.amazon.polymorph.smithygo.codegen;

import static software.amazon.polymorph.smithygo.codegen.SymbolUtils.POINTABLE;

import java.math.BigDecimal;
import java.util.HashSet;
import java.util.HashSet;
import java.util.Optional;
import java.util.Set;
import software.amazon.polymorph.smithygo.localservice.nameresolver.DafnyNameResolver;
import software.amazon.polymorph.smithygo.localservice.nameresolver.SmithyNameResolver;
import software.amazon.polymorph.traits.DafnyUtf8BytesTrait;
import software.amazon.polymorph.traits.ReferenceTrait;
import software.amazon.smithy.aws.traits.ServiceTrait;
import software.amazon.smithy.codegen.core.Symbol;
import software.amazon.smithy.codegen.core.SymbolProvider;
import software.amazon.smithy.model.Model;
import software.amazon.smithy.model.shapes.MemberShape;
import software.amazon.smithy.model.shapes.Shape;
import software.amazon.smithy.model.shapes.StructureShape;
import software.amazon.smithy.model.traits.ErrorTrait;
import software.amazon.smithy.model.traits.LengthTrait;
import software.amazon.smithy.model.traits.RangeTrait;
import software.amazon.smithy.model.traits.RequiredTrait;
import software.amazon.smithy.model.traits.StreamingTrait;
import software.amazon.smithy.utils.SetUtils;

Expand Down Expand Up @@ -131,10 +123,21 @@ public void renderStructure(Runnable runnable, boolean isInputStructure) {
memberSymbol.getProperty("Referred", Symbol.class).get();
var refShape = targetShape.expectTrait(ReferenceTrait.class);
if (refShape.isService()) {
namespace =
SmithyNameResolver.shapeNamespace(
model.expectShape(refShape.getReferentId())
);
if (
model
.expectShape(refShape.getReferentId())
.hasTrait(ServiceTrait.class)
) {
namespace =
DafnyNameResolver.dafnyTypesNamespace(
model.expectShape(refShape.getReferentId())
);
} else {
namespace =
SmithyNameResolver.shapeNamespace(
model.expectShape(refShape.getReferentId())
);
}
}
if (
!member
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
import java.util.Optional;
import java.util.logging.Logger;
import software.amazon.polymorph.smithygo.codegen.knowledge.GoPointableIndex;
import software.amazon.polymorph.smithygo.localservice.nameresolver.DafnyNameResolver;
import software.amazon.polymorph.smithygo.localservice.nameresolver.SmithyNameResolver;
import software.amazon.polymorph.traits.ReferenceTrait;
import software.amazon.smithy.aws.traits.ServiceTrait;
import software.amazon.smithy.codegen.core.CodegenException;
import software.amazon.smithy.codegen.core.ReservedWordSymbolProvider;
import software.amazon.smithy.codegen.core.ReservedWords;
Expand Down Expand Up @@ -270,6 +272,11 @@ private String getDefaultShapeName(Shape shape) {
settings.getService(),
ServiceShape.class
);
if (shape.hasTrait(ServiceTrait.class)) {
return DafnyNameResolver.getDafnyClientName(
shape.expectTrait(ServiceTrait.class).getSdkId()
);
}
return StringUtils.capitalize(
removeLeadingInvalidIdentCharacters(shape.getId().getName(serviceShape))
);
Expand Down Expand Up @@ -384,19 +391,20 @@ public Symbol mapShape(MapShape shape) {
}

private Symbol.Builder symbolBuilderFor(Shape shape, String typeName) {
final String namespace;
if (shape.hasTrait(ServiceTrait.class)) {
namespace = DafnyNameResolver.dafnyTypesNamespace(shape);
} else {
namespace = SmithyNameResolver.smithyTypesNamespace(shape);
}
if (pointableIndex.isPointable(shape)) {
return SymbolUtils.createPointableSymbolBuilder(
shape,
typeName,
SmithyNameResolver.smithyTypesNamespace(shape)
namespace
);
}

return SymbolUtils.createValueSymbolBuilder(
shape,
typeName,
SmithyNameResolver.smithyTypesNamespace(shape)
);
return SymbolUtils.createValueSymbolBuilder(shape, typeName, namespace);
}

private Symbol.Builder symbolBuilderFor(
Expand Down Expand Up @@ -575,25 +583,25 @@ public Symbol structureShape(StructureShape shape) {
shape.expectTrait(ReferenceTrait.class).getReferentId()
);
var isService = shape.expectTrait(ReferenceTrait.class).isService();
if (isService) {
if (!isService || referredShape.hasTrait(ServiceTrait.class)) {
builder.putProperty(
"Referred",
symbolBuilderFor(
referredShape,
"Client",
SmithyNameResolver.shapeNamespace(referredShape)
"I".concat(getDefaultShapeName(referredShape))
)
.putProperty(SymbolUtils.POINTABLE, true)
.putProperty(SymbolUtils.POINTABLE, false)
.build()
);
} else {
builder.putProperty(
"Referred",
symbolBuilderFor(
referredShape,
"I".concat(getDefaultShapeName(referredShape))
"Client",
SmithyNameResolver.shapeNamespace(referredShape)
)
.putProperty(SymbolUtils.POINTABLE, false)
.putProperty(SymbolUtils.POINTABLE, true)
.build()
);
}
Expand Down
Loading
Loading