Skip to content

Commit

Permalink
rename new shapes that are suffixed as Input/Output in shape name (#3956
Browse files Browse the repository at this point in the history
)

* rename new shapes that are suffixed as Input/Output in shape name, but are not any operations input or output shape

* formatting test file
  • Loading branch information
skotambkar authored Jun 11, 2021
1 parent 019b384 commit c0d2e60
Show file tree
Hide file tree
Showing 4 changed files with 550 additions and 59 deletions.
247 changes: 247 additions & 0 deletions private/model/api/legacy_io_suffix.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,247 @@
// +build codegen

package api

// IoSuffix represents map of service to shape names that
// are suffixed with `Input`, `Output` string and are not
// Input or Output shapes used by any operation within
// the service enclosure.
type IoSuffix map[string]map[string]struct{}

// LegacyIoSuffix returns if the shape names are legacy
// names that contain "Input" and "Output" name as suffix.
func (i IoSuffix) LegacyIOSuffix(a *API, shapeName string) bool {
names, ok := i[a.name]
if !ok {
return false
}

_, ok = names[shapeName]
return ok
}

// legacyIOSuffixed is the list of known shapes that have "Input" and "Output"
// as suffix in shape name, but are not the actual input, output shape
// for a corresponding service operation.
var legacyIOSuffixed = IoSuffix{
"TranscribeService": {
"RedactionOutput": struct{}{},
},
"Textract": {"HumanLoopActivationOutput": struct{}{}},
"Synthetics": {
"CanaryRunConfigInput": struct{}{},
"CanaryScheduleOutput": struct{}{},
"VpcConfigInput": struct{}{},
"VpcConfigOutput": struct{}{},
"CanaryCodeOutput": struct{}{},
"CanaryCodeInput": struct{}{},
"CanaryRunConfigOutput": struct{}{},
"CanaryScheduleInput": struct{}{},
},
"SWF": {"FunctionInput": struct{}{}},
"SFN": {
"InvalidOutput": struct{}{},
"InvalidExecutionInput": struct{}{},
"SensitiveDataJobInput": struct{}{},
},
"SSM": {
"CommandPluginOutput": struct{}{},
"MaintenanceWindowStepFunctionsInput": struct{}{},
"InvocationTraceOutput": struct{}{},
},
"SSMIncidents": {"RegionMapInput": struct{}{}},

"SMS": {
"AppValidationOutput": struct{}{},
"ServerValidationOutput": struct{}{},
"ValidationOutput": struct{}{},
"SSMOutput": struct{}{},
},
"ServiceDiscovery": {"InvalidInput": struct{}{}},
"ServiceCatalog": {
"RecordOutput": struct{}{},
"ProvisioningArtifactOutput": struct{}{},
},
"Schemas": {
"GetDiscoveredSchemaVersionItemInput": struct{}{},
"__listOfGetDiscoveredSchemaVersionItemInput": struct{}{},
},

"SageMaker": {
"ProcessingOutput": struct{}{},
"TaskInput": struct{}{},
"TransformOutput": struct{}{},
"ModelBiasJobInput": struct{}{},
"TransformInput": struct{}{},
"LabelingJobOutput": struct{}{},
"DataQualityJobInput": struct{}{},
"MonitoringOutput": struct{}{},
"MonitoringS3Output": struct{}{},
"MonitoringInput": struct{}{},
"ProcessingS3Output": struct{}{},
"ModelQualityJobInput": struct{}{},
"ProcessingInput": struct{}{},
"ProcessingFeatureStoreOutput": struct{}{},
"ModelExplainabilityJobInput": struct{}{},
"ProcessingS3Input": struct{}{},
"MonitoringGroundTruthS3Input": struct{}{},
"EdgePresetDeploymentOutput": struct{}{},
"EndpointInput": struct{}{},
},

"AugmentedAIRuntime": {"HumanLoopOutput": struct{}{}, "HumanLoopInput": struct{}{}},

"S3": {
"ParquetInput": struct{}{},
"CSVOutput": struct{}{},
"JSONOutput": struct{}{},
"JSONInput": struct{}{},
"CSVInput": struct{}{},
},

"Route53Domains": {"InvalidInput": struct{}{}},
"Route53": {"InvalidInput": struct{}{}},
"RoboMaker": {"S3KeyOutput": struct{}{}},

"Rekognition": {
"StreamProcessorInput": struct{}{},
"HumanLoopActivationOutput": struct{}{},
"StreamProcessorOutput": struct{}{},
},

"Proton": {"TemplateVersionSourceInput": struct{}{}, "CompatibleEnvironmentTemplateInput": struct{}{}},

"Personalize": {
"BatchInferenceJobInput": struct{}{},
"BatchInferenceJobOutput": struct{}{},
"DatasetExportJobOutput": struct{}{},
},

"MWAA": {
"ModuleLoggingConfigurationInput": struct{}{},
"LoggingConfigurationInput": struct{}{},
"UpdateNetworkConfigurationInput": struct{}{},
},

"MQ": {"LdapServerMetadataOutput": struct{}{}, "LdapServerMetadataInput": struct{}{}},

"MediaLive": {
"InputDeviceConfiguredInput": struct{}{},
"__listOfOutput": struct{}{},
"Input": struct{}{},
"__listOfInput": struct{}{},
"Output": struct{}{},
"InputDeviceActiveInput": struct{}{},
},

"MediaConvert": {
"Input": struct{}{},
"__listOfOutput": struct{}{},
"Output": struct{}{},
"__listOfInput": struct{}{},
},
"MediaConnect": {"Output": struct{}{}, "__listOfOutput": struct{}{}},

"Lambda": {
"LayerVersionContentOutput": struct{}{},
"LayerVersionContentInput": struct{}{},
},

"KinesisAnalyticsV2": {
"KinesisStreamsInput": struct{}{},
"KinesisFirehoseInput": struct{}{},
"LambdaOutput": struct{}{},
"Output": struct{}{},
"KinesisFirehoseOutput": struct{}{},
"Input": struct{}{},
"KinesisStreamsOutput": struct{}{},
},

"KinesisAnalytics": {
"Output": struct{}{},
"KinesisFirehoseInput": struct{}{},
"LambdaOutput": struct{}{},
"KinesisFirehoseOutput": struct{}{},
"KinesisStreamsInput": struct{}{},
"Input": struct{}{},
"KinesisStreamsOutput": struct{}{},
},

"IoTEvents": {"Input": struct{}{}},
"IoT": {"PutItemInput": struct{}{}},

"Honeycode": {"CellInput": struct{}{}, "RowDataInput": struct{}{}},

"Glue": {
"TableInput": struct{}{},
"UserDefinedFunctionInput": struct{}{},
"DatabaseInput": struct{}{},
"PartitionInput": struct{}{},
"ConnectionInput": struct{}{},
},

"Glacier": {
"CSVInput": struct{}{},
"CSVOutput": struct{}{},
"InventoryRetrievalJobInput": struct{}{},
},

"FIS": {
"CreateExperimentTemplateTargetInput": struct{}{},
"CreateExperimentTemplateStopConditionInput": struct{}{},
"UpdateExperimentTemplateStopConditionInput": struct{}{},
"CreateExperimentTemplateActionInput": struct{}{},
"UpdateExperimentTemplateTargetInput": struct{}{},
},

"Firehose": {"DeliveryStreamEncryptionConfigurationInput": struct{}{}},

"CloudWatchEvents": {"TransformerInput": struct{}{}, "TargetInput": struct{}{}},

"EventBridge": {"TransformerInput": struct{}{}, "TargetInput": struct{}{}},

"ElasticsearchService": {
"AutoTuneOptionsOutput": struct{}{},
"SAMLOptionsInput": struct{}{},
"AdvancedSecurityOptionsInput": struct{}{},
"SAMLOptionsOutput": struct{}{},
"AutoTuneOptionsInput": struct{}{},
},

"ElasticTranscoder": {
"JobOutput": struct{}{},
"CreateJobOutput": struct{}{},
"JobInput": struct{}{},
},

"ElastiCache": {
"UserGroupIdListInput": struct{}{},
"PasswordListInput": struct{}{},
"UserIdListInput": struct{}{},
},

"ECRPublic": {"RepositoryCatalogDataInput": struct{}{}},
"DeviceFarm": {"TestGridUrlExpiresInSecondsInput": struct{}{}},

"GlueDataBrew": {"Output": struct{}{}, "Input": struct{}{}, "OverwriteOutput": struct{}{}},

"CodePipeline": {"ActionExecutionInput": struct{}{}, "ActionExecutionOutput": struct{}{}},

"CodeBuild": {"ValueInput": struct{}{}, "KeyInput": struct{}{}},

"CloudFormation": {"Output": struct{}{}},

"Backup": {
"PlanInput": struct{}{},
"RulesInput": struct{}{},
"RuleInput": struct{}{},
},

"ApplicationInsights": {"StatesInput": struct{}{}},

"ApiGatewayV2": {
"TlsConfigInput": struct{}{},
"MutualTlsAuthenticationInput": struct{}{},
},
"APIGateway": {"MutualTlsAuthenticationInput": struct{}{}},
}
1 change: 1 addition & 0 deletions private/model/api/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ func (a *API) Setup() error {
}
a.renameExportable()
a.applyShapeNameAliases()
a.renameIOSuffixedShapeNames()
a.createInputOutputShapes()
a.writeInputOutputLocationName()
a.renameAPIPayloadShapes()
Expand Down
55 changes: 55 additions & 0 deletions private/model/api/passes.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,61 @@ func (a *API) applyShapeNameAliases() {
}
}

// renameIOSuffixedShapeNames renames shapes that have `Input` or `Output`
// as suffix in their shape names. We add `_` and the end to avoid possible
// conflicts with the generated operation input/output types. SDK has already
// released quite a few shapes with input, output name suffixed with Input or Output.
// This change uses a legacy IO suffixed list and does not rename those legacy shapes.
// We do not rename aliased shapes. We do not rename shapes that are an input or output
// shape of an operation.
func (a *API) renameIOSuffixedShapeNames() {
// map all input shapes in service enclosure
inputShapes := make(map[string]*Shape, len(a.Operations))

// map all output shapes in service enclosure
outputShapes := make(map[string]*Shape, len(a.Operations))

for _, op := range a.Operations {
if len(op.InputRef.ShapeName) != 0 {
inputShapes[op.InputRef.Shape.ShapeName] = op.InputRef.Shape
}

if len(op.OutputRef.ShapeName) != 0 {
outputShapes[op.OutputRef.Shape.ShapeName] = op.OutputRef.Shape
}
}

for name, shape := range a.Shapes {
// skip if this shape is already aliased
if shape.AliasedShapeName {
continue
}

// skip if shape name is not suffixed with `Input` or `Output`
if !strings.HasSuffix(name, "Input") && !strings.HasSuffix(name, "Output") {
continue
}

// skip if this shape is an input shape
if s, ok := inputShapes[name]; ok && s == shape {
continue
}

// skip if this shape is an output shape
if s, ok := outputShapes[name]; ok && s == shape {
continue
}

// skip if this shape is a legacy io suffixed shape
if legacyIOSuffixed.LegacyIOSuffix(a, name) {
continue
}

// rename the shape to suffix with `_`
shape.Rename(name + "_")
}
}

// createInputOutputShapes creates toplevel input/output shapes if they
// have not been defined in the API. This normalizes all APIs to always
// have an input and output structure in the signature.
Expand Down
Loading

0 comments on commit c0d2e60

Please sign in to comment.