Skip to content

Commit

Permalink
Backfill missing serviceIds
Browse files Browse the repository at this point in the history
  • Loading branch information
skmcgrail committed Jun 3, 2022
1 parent 7cf5d62 commit 048c19c
Show file tree
Hide file tree
Showing 11 changed files with 324 additions and 301 deletions.
1 change: 1 addition & 0 deletions models/apis/cloudsearchdomain/2013-01-01/api-2.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"jsonVersion":"1.1",
"protocol":"rest-json",
"serviceFullName":"Amazon CloudSearch Domain",
"serviceId":"CloudSearch Domain",
"signatureVersion":"v4",
"signingName":"cloudsearch",
"uid":"cloudsearchdomain-2013-01-01"
Expand Down
1 change: 1 addition & 0 deletions models/apis/entitlement.marketplace/2017-01-11/api-2.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"jsonVersion":"1.1",
"protocol":"json",
"serviceFullName":"AWS Marketplace Entitlement Service",
"serviceId":"Marketplace Entitlement Service",
"signatureVersion":"v4",
"signingName":"aws-marketplace",
"targetPrefix":"AWSMPEntitlementService",
Expand Down
1 change: 1 addition & 0 deletions models/apis/importexport/2010-06-01/api-2.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"apiVersion":"2010-06-01",
"endpointPrefix":"importexport",
"globalEndpoint":"importexport.amazonaws.com",
"serviceId": "Import Export",
"serviceFullName":"AWS Import/Export",
"signatureVersion":"v2",
"xmlNamespace":"http://importexport.amazonaws.com/doc/2010-06-01/",
Expand Down
1 change: 1 addition & 0 deletions models/apis/mobile/2017-07-01/api-2.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"jsonVersion":"1.1",
"protocol":"rest-json",
"serviceFullName":"AWS Mobile",
"serviceId":"Mobile",
"signatureVersion":"v4",
"signingName":"AWSMobileHubService",
"uid":"mobile-2017-07-01"
Expand Down
1 change: 1 addition & 0 deletions models/apis/mobileanalytics/2014-06-05/api-2.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"metadata":{
"apiVersion":"2014-06-05",
"endpointPrefix":"mobileanalytics",
"serviceId": "Mobile Analytics",
"serviceFullName":"Amazon Mobile Analytics",
"signatureVersion":"v4",
"protocol":"rest-json"
Expand Down
1 change: 1 addition & 0 deletions models/apis/sdb/2009-04-15/api-2.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"metadata":{
"apiVersion":"2009-04-15",
"endpointPrefix":"sdb",
"serviceId": "SimpleDB",
"serviceFullName":"Amazon SimpleDB",
"signatureVersion":"v2",
"xmlNamespace":"http://sdb.amazonaws.com/doc/2009-04-15/",
Expand Down
27 changes: 17 additions & 10 deletions private/model/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,26 +136,23 @@ func (a *API) StructName() string {
if len(name) == 0 {
panic("expect serviceId to be set, but was not")
}
if legacyName, ok := legacyStructNames[name]; ok {
name = legacyName
if legacyName, ok := legacyStructNames[strings.ToLower(name)]; ok {
// The legacy names come from service abbreviations or service full names,
// so we will want to apply the old procedure to them.
name = makeLikeServiceId(legacyName)
}
} else {
name = a.Metadata.ServiceAbbreviation
if len(name) == 0 {
name = a.Metadata.ServiceFullName
}
// If we aren't using the strictly modeled service id, then
// strip out prefix names not reflected in service client symbol names.
name = makeLikeServiceId(name)
}

name = strings.TrimSpace(name)

// Strip out prefix names not reflected in service client symbol names.
for _, prefix := range stripServiceNamePrefixes {
if strings.HasPrefix(name, prefix) {
name = name[len(prefix):]
break
}
}

// Replace all Non-letter/number values with space
runes := []rune(name)
for i := 0; i < len(runes); i++ {
Expand Down Expand Up @@ -1079,3 +1076,13 @@ func getDeprecatedMessage(msg string, name string) string {

return msg
}

func makeLikeServiceId(name string) string {
for _, prefix := range stripServiceNamePrefixes {
if strings.HasPrefix(name, prefix) {
name = name[len(prefix):]
break
}
}
return name
}
13 changes: 12 additions & 1 deletion private/model/api/customization_passes.go
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,18 @@ func mergeServicesCustomizations(a *API) error {

file := filepath.Join(p, "api-2.json")

serviceAPI := API{}
serviceAPI := API{
IgnoreUnsupportedAPIs: a.IgnoreUnsupportedAPIs,
NoRemoveUnusedShapes: a.NoRemoveUnusedShapes,
NoRenameToplevelShapes: a.NoRenameToplevelShapes,
NoInitMethods: a.NoInitMethods,
NoStringerMethods: a.NoStringerMethods,
NoConstServiceNames: a.NoConstServiceNames,
NoValidataShapeMethods: a.NoValidataShapeMethods,
NoGenStructFieldAccessors: a.NoGenStructFieldAccessors,
NoRemoveUnsupportedJSONValue: a.NoRemoveUnsupportedJSONValue,
StrictServiceId: a.StrictServiceId,
}
serviceAPI.Attach(file)
serviceAPI.Setup()

Expand Down
566 changes: 283 additions & 283 deletions private/model/api/legacy_struct_names.go

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions private/model/api/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ func loadAPI(modelPath, baseImport string, opts ...func(*API)) (*API, error) {
BaseCrosslinkURL: "https://docs.aws.amazon.com",
}

for _, opt := range opts {
opt(a)
}

modelFile := filepath.Base(modelPath)
modelDir := filepath.Dir(modelPath)
err := attachModelFiles(modelDir,
Expand All @@ -84,10 +88,6 @@ func loadAPI(modelPath, baseImport string, opts ...func(*API)) (*API, error) {
return nil, err
}

for _, opt := range opts {
opt(a)
}

if err = a.Setup(); err != nil {
return nil, err
}
Expand Down
5 changes: 2 additions & 3 deletions private/model/cli/gen-api/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@ package main
import (
"flag"
"fmt"
"github.com/aws/aws-sdk-go/private/model/api"
"github.com/aws/aws-sdk-go/private/util"
"io/ioutil"
"os"
"path/filepath"
"runtime/debug"
"strings"
"sync"

"github.com/aws/aws-sdk-go/private/model/api"
"github.com/aws/aws-sdk-go/private/util"
)

func usage() {
Expand Down

0 comments on commit 048c19c

Please sign in to comment.