Skip to content

Commit

Permalink
fix(clients): use signing name from auth sigv4 trait (#1835)
Browse files Browse the repository at this point in the history
* chore(endpoints): signingService prefers auth trait name

* fix(clients): use signing name from auth sigv4 trait
  • Loading branch information
AllanZhengYP authored Dec 23, 2020
1 parent e7dce39 commit e539302
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion clients/client-apigatewaymanagementapi/endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,5 @@ export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, op
};
}
}
return Promise.resolve({ signingService: "apigateway", ...regionInfo });
return Promise.resolve({ signingService: "execute-api", ...regionInfo });
};
2 changes: 1 addition & 1 deletion clients/client-codeguruprofiler/endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,5 @@ export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, op
};
}
}
return Promise.resolve({ signingService: "codeguru-profiler", ...regionInfo });
return Promise.resolve({ signingService: "codeguruprofiler", ...regionInfo });
};
2 changes: 1 addition & 1 deletion clients/client-connectparticipant/endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,5 @@ export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, op
};
}
}
return Promise.resolve({ signingService: "connect", ...regionInfo });
return Promise.resolve({ signingService: "execute-api", ...regionInfo });
};
2 changes: 1 addition & 1 deletion clients/client-iot/endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,5 +237,5 @@ export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, op
};
}
}
return Promise.resolve({ signingService: "iot", ...regionInfo });
return Promise.resolve({ signingService: "execute-api", ...regionInfo });
};
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.Set;
import java.util.TreeMap;
import software.amazon.smithy.aws.traits.ServiceTrait;
import software.amazon.smithy.aws.traits.auth.SigV4Trait;
import software.amazon.smithy.codegen.core.CodegenException;
import software.amazon.smithy.model.node.Node;
import software.amazon.smithy.model.node.ObjectNode;
Expand All @@ -45,6 +46,7 @@ final class EndpointGenerator implements Runnable {
private final ObjectNode endpointData;
private final ServiceTrait serviceTrait;
private final String endpointPrefix;
private final String baseSigningSerivce;
private final Map<String, Partition> partitions = new TreeMap<>();
private final Map<String, ObjectNode> endpoints = new TreeMap<>();
private final Map<String, Partition> regionPartitionsMap = new TreeMap<>();
Expand All @@ -54,6 +56,8 @@ final class EndpointGenerator implements Runnable {
serviceTrait = service.getTrait(ServiceTrait.class)
.orElseThrow(() -> new CodegenException("No service trait found on " + service.getId()));
endpointPrefix = serviceTrait.getEndpointPrefix();
baseSigningSerivce = service.getTrait(SigV4Trait.class).map(SigV4Trait::getName)
.orElse(serviceTrait.getArnNamespace());
endpointData = Node.parse(IoUtils.readUtf8Resource(getClass(), "endpoints.json")).expectObjectNode();
validateVersion();
loadPartitions();
Expand Down Expand Up @@ -154,8 +158,7 @@ private void writeEndpointProviderFunction() {
writePartitionEndpointResolver(partitions.get("aws")); });
writer.dedent();
});
writer.write("return Promise.resolve({ signingService: $S, ...regionInfo });",
serviceTrait.getArnNamespace());
writer.write("return Promise.resolve({ signingService: $S, ...regionInfo });", baseSigningSerivce);
});
}

Expand Down
2 changes: 1 addition & 1 deletion protocol_tests/aws-json/endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,5 @@ export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, op
};
}
}
return Promise.resolve({ signingService: "jsonprotocol", ...regionInfo });
return Promise.resolve({ signingService: "foo", ...regionInfo });
};

0 comments on commit e539302

Please sign in to comment.