Skip to content

Commit 978fa5d

Browse files
author
Ryan Miville
committed
fix some names
1 parent 93776fb commit 978fa5d

6 files changed

+49
-49
lines changed

birdie_snapshots/api_gateway_v2_http_request_with_iam_authorizer.accepted

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
version: 1.2.3
33
title: API Gateway V2 HTTP request with IAM authorizer
44
file: ./test/glambda_test.gleam
5-
test_name: api_gateway_v2_http_request_iam_marshaling_test
5+
test_name: api_gateway_v2_http_request_iam_authorizer_test
66
---
77
ApiGatewayProxyEventV2(
88
version: "2.0",
@@ -50,13 +50,13 @@ ApiGatewayProxyEventV2(
5050
source_ip: "IP",
5151
user_agent: "agent",
5252
),
53-
authentication: Some(ApiGatewayEventRequestContextAuthentication(client_cert: APIGatewayEventClientCertificate(
53+
authentication: Some(ApiGatewayEventRequestContextAuthentication(client_cert: ApiGatewayEventClientCertificate(
5454
client_cert_pem: "-----BEGIN CERTIFICATE-----
5555
MIIEZTCCAk0CAQEwDQ...",
5656
issuer_dn: "C=US,ST=Washington,L=Seattle,O=Amazon Web Services,OU=Security,CN=My Private CA",
5757
serial_number: "1",
5858
subject_dn: "C=US,ST=Washington,L=Seattle,O=Amazon Web Services,OU=Security,CN=My Client",
59-
validity: APIGatewayEventValidity(
59+
validity: ApiGatewayEventValidity(
6060
not_after: "Aug 5 00:28:21 2120 GMT",
6161
not_before: "Aug 29 00:28:21 2020 GMT",
6262
),

birdie_snapshots/api_gateway_v2_http_request_with_jwt_authorizer.accepted

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,13 @@ ApiGatewayProxyEventV2(
5656
source_ip: "IP",
5757
user_agent: "agent",
5858
),
59-
authentication: Some(ApiGatewayEventRequestContextAuthentication(client_cert: APIGatewayEventClientCertificate(
59+
authentication: Some(ApiGatewayEventRequestContextAuthentication(client_cert: ApiGatewayEventClientCertificate(
6060
client_cert_pem: "-----BEGIN CERTIFICATE-----
6161
MIIEZTCCAk0CAQEwDQ...",
6262
issuer_dn: "C=US,ST=Washington,L=Seattle,O=Amazon Web Services,OU=Security,CN=My Private CA",
6363
serial_number: "1",
6464
subject_dn: "C=US,ST=Washington,L=Seattle,O=Amazon Web Services,OU=Security,CN=My Client",
65-
validity: APIGatewayEventValidity(
65+
validity: ApiGatewayEventValidity(
6666
not_after: "Aug 5 00:28:21 2120 GMT",
6767
not_before: "Aug 29 00:28:21 2020 GMT",
6868
),

birdie_snapshots/api_gateway_v2_http_request_with_lambda_authorizer.accepted

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ ApiGatewayProxyEventV2(
4545
source_ip: "IP",
4646
user_agent: "agent",
4747
),
48-
authentication: Some(ApiGatewayEventRequestContextAuthentication(client_cert: APIGatewayEventClientCertificate(
48+
authentication: Some(ApiGatewayEventRequestContextAuthentication(client_cert: ApiGatewayEventClientCertificate(
4949
client_cert_pem: "-----BEGIN CERTIFICATE-----
5050
MIIEZTCCAk0CAQEwDQ...",
5151
issuer_dn: "C=US,ST=Washington,L=Seattle,O=Amazon Web Services,OU=Security,CN=My Private CA",
5252
serial_number: "1",
5353
subject_dn: "C=US,ST=Washington,L=Seattle,O=Amazon Web Services,OU=Security,CN=My Client",
54-
validity: APIGatewayEventValidity(
54+
validity: ApiGatewayEventValidity(
5555
not_after: "Aug 5 00:28:21 2120 GMT",
5656
not_before: "Aug 29 00:28:21 2020 GMT",
5757
),

birdie_snapshots/api_gateway_v2_http_request_with_no_authorizer.accepted

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ ApiGatewayProxyEventV2(
4141
source_ip: "1.2.3.4",
4242
user_agent: "curl/7.58.0",
4343
),
44-
authentication: Some(ApiGatewayEventRequestContextAuthentication(client_cert: APIGatewayEventClientCertificate(
44+
authentication: Some(ApiGatewayEventRequestContextAuthentication(client_cert: ApiGatewayEventClientCertificate(
4545
client_cert_pem: "-----BEGIN CERTIFICATE-----
4646
MIIEZTCCAk0CAQEwDQ...",
4747
issuer_dn: "C=US,ST=Washington,L=Seattle,O=Amazon Web Services,OU=Security,CN=My Private CA",
4848
serial_number: "1",
4949
subject_dn: "C=US,ST=Washington,L=Seattle,O=Amazon Web Services,OU=Security,CN=My Client",
50-
validity: APIGatewayEventValidity(
50+
validity: ApiGatewayEventValidity(
5151
not_after: "Aug 5 00:28:21 2120 GMT",
5252
not_before: "Aug 29 00:28:21 2020 GMT",
5353
),

src/glambda.gleam

+9-9
Original file line numberDiff line numberDiff line change
@@ -133,22 +133,22 @@ pub type ApiGatewayEventRequestContextHttp {
133133

134134
pub type ApiGatewayEventRequestContextAuthentication {
135135
ApiGatewayEventRequestContextAuthentication(
136-
client_cert: APIGatewayEventClientCertificate,
136+
client_cert: ApiGatewayEventClientCertificate,
137137
)
138138
}
139139

140-
pub type APIGatewayEventClientCertificate {
141-
APIGatewayEventClientCertificate(
140+
pub type ApiGatewayEventClientCertificate {
141+
ApiGatewayEventClientCertificate(
142142
client_cert_pem: String,
143143
issuer_dn: String,
144144
serial_number: String,
145145
subject_dn: String,
146-
validity: APIGatewayEventValidity,
146+
validity: ApiGatewayEventValidity,
147147
)
148148
}
149149

150-
pub type APIGatewayEventValidity {
151-
APIGatewayEventValidity(not_after: String, not_before: String)
150+
pub type ApiGatewayEventValidity {
151+
ApiGatewayEventValidity(not_after: String, not_before: String)
152152
}
153153

154154
pub type ApiGatewayEventRequestContextIamAuthorizer {
@@ -299,13 +299,13 @@ pub fn api_gateway_proxy_v2_handler(
299299

300300
// --- FFI --------------------------------------------------------------------
301301

302-
@external(javascript, "./glambda_ffi.mjs", "to_api_gateway_proxy_event_v2")
302+
@external(javascript, "./glambda_ffi.mjs", "toApiGatewayProxyEventV2")
303303
pub fn to_api_gateway_proxy_event_v2(event: JsEvent) -> ApiGatewayProxyEventV2
304304

305-
@external(javascript, "./glambda_ffi.mjs", "from_api_gateway_proxy_result_v2")
305+
@external(javascript, "./glambda_ffi.mjs", "fromApiGatewayProxyResultV2")
306306
pub fn from_api_gateway_proxy_result_v2(
307307
result: ApiGatewayProxyResultV2,
308308
) -> JsResult
309309

310-
@external(javascript, "./glambda_ffi.mjs", "to_context")
310+
@external(javascript, "./glambda_ffi.mjs", "toContext")
311311
fn to_context(ctx: JsContext) -> Context

src/glambda_ffi.mjs

+31-31
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ import {
1111
Jwt,
1212
Lambda,
1313
ApiGatewayEventRequestContextHttp,
14-
APIGatewayEventClientCertificate,
14+
ApiGatewayEventClientCertificate,
1515
Context,
1616
CognitoIdentity,
1717
ClientContext,
1818
ClientContextClient,
1919
ClientContextEnv,
20-
APIGatewayEventValidity,
20+
ApiGatewayEventValidity,
2121
} from "./glambda.mjs";
2222

23-
export function to_api_gateway_proxy_event_v2(event) {
23+
export function toApiGatewayProxyEventV2(event) {
2424
return new ApiGatewayProxyEventV2(
2525
event.version,
2626
event.routeKey,
@@ -31,30 +31,30 @@ export function to_api_gateway_proxy_event_v2(event) {
3131
maybeDict(event.queryStringParameters),
3232
maybeDict(event.pathParameters),
3333
maybeDict(event.stageVariables),
34-
to_request_context(event.requestContext),
34+
toRequestContext(event.requestContext),
3535
maybe(event.body),
3636
event.isBase64Encoded,
3737
);
3838
}
3939

40-
function to_request_context(ctx) {
40+
function toRequestContext(ctx) {
4141
return new ApiGatewayRequestContextV2(
4242
ctx.routeKey,
4343
ctx.accountId,
4444
ctx.stage,
4545
ctx.requestId,
46-
maybe(to_authorizer(ctx.authorizer)),
46+
maybe(toAuthorizer(ctx.authorizer)),
4747
ctx.apiId,
4848
ctx.domainName,
4949
ctx.domainPrefix,
5050
ctx.time,
5151
ctx.timeEpoch,
52-
to_http(ctx.http),
53-
maybe(to_authentication(ctx.authentication)),
52+
toHttp(ctx.http),
53+
maybe(toAuthentication(ctx.authentication)),
5454
);
5555
}
5656

57-
function to_http(http) {
57+
function toHttp(http) {
5858
return new ApiGatewayEventRequestContextHttp(
5959
http.method,
6060
http.path,
@@ -64,46 +64,46 @@ function to_http(http) {
6464
);
6565
}
6666

67-
function to_authentication(auth) {
67+
function toAuthentication(auth) {
6868
if (!auth) {
6969
return undefined;
7070
}
7171
return new ApiGatewayEventRequestContextAuthentication(
72-
to_client_cert(auth.clientCert),
72+
toClientCert(auth.clientCert),
7373
);
7474
}
7575

76-
function to_client_cert(cert) {
77-
return new APIGatewayEventClientCertificate(
76+
function toClientCert(cert) {
77+
return new ApiGatewayEventClientCertificate(
7878
cert.clientCertPem,
7979
cert.issuerDN,
8080
cert.serialNumber,
8181
cert.subjectDN,
82-
to_validity(cert.validity),
82+
toValidity(cert.validity),
8383
);
8484
}
8585

86-
function to_validity(validity) {
87-
return new APIGatewayEventValidity(validity.notAfter, validity.notBefore);
86+
function toValidity(validity) {
87+
return new ApiGatewayEventValidity(validity.notAfter, validity.notBefore);
8888
}
89-
function to_authorizer(auth) {
89+
function toAuthorizer(auth) {
9090
if (!auth) {
9191
return undefined;
9292
}
9393
if (auth.iam) {
94-
return new Iam(to_iam_authorizer(auth.iam));
94+
return new Iam(toIamAuthorizer(auth.iam));
9595
}
9696
if (auth.jwt) {
9797
return new Jwt(
9898
auth.principalId,
9999
auth.integrationLatency,
100-
to_jwt_authorizer(auth.jwt),
100+
toJwtAuthorizer(auth.jwt),
101101
);
102102
}
103103
return new Lambda(auth.lambda);
104104
}
105105

106-
function to_iam_authorizer(iam) {
106+
function toIamAuthorizer(iam) {
107107
return new ApiGatewayEventRequestContextIamAuthorizer(
108108
iam.accessKey,
109109
iam.accountId,
@@ -114,7 +114,7 @@ function to_iam_authorizer(iam) {
114114
);
115115
}
116116

117-
function to_jwt_authorizer(jwt) {
117+
function toJwtAuthorizer(jwt) {
118118
return new ApiGatewayEventRequestContextJwtAuthorizer(
119119
jwt.claims,
120120
maybeList(jwt.scopes),
@@ -142,7 +142,7 @@ function maybeDict(a) {
142142
return new None();
143143
}
144144

145-
export function from_api_gateway_proxy_result_v2(result) {
145+
export function fromApiGatewayProxyResultV2(result) {
146146
return {
147147
statusCode: result.status_code,
148148
headers: Object.fromEntries(result.headers.entries()),
@@ -152,7 +152,7 @@ export function from_api_gateway_proxy_result_v2(result) {
152152
};
153153
}
154154

155-
export function to_context(ctx) {
155+
export function toContext(ctx) {
156156
return new Context(
157157
ctx.callbackWaitsForEmptyEventLoop,
158158
ctx.functionName,
@@ -162,12 +162,12 @@ export function to_context(ctx) {
162162
ctx.awsRequestId,
163163
ctx.logGroupName,
164164
ctx.logStreamName,
165-
maybe(to_cognito_identity(ctx.identity)),
166-
maybe(to_client_context(ctx.clientContext)),
165+
maybe(toCognitoIdentity(ctx.identity)),
166+
maybe(toClientContext(ctx.clientContext)),
167167
);
168168
}
169169

170-
function to_cognito_identity(identity) {
170+
function toCognitoIdentity(identity) {
171171
if (!identity) {
172172
return undefined;
173173
}
@@ -177,18 +177,18 @@ function to_cognito_identity(identity) {
177177
);
178178
}
179179

180-
function to_client_context(ctx) {
180+
function toClientContext(ctx) {
181181
if (!ctx) {
182182
return undefined;
183183
}
184184
return new ClientContext(
185-
to_client_context_client(ctx.client),
185+
toClientContextClient(ctx.client),
186186
maybe(ctx.custom),
187-
to_client_context_env(ctx.env),
187+
toClientContextEnv(ctx.env),
188188
);
189189
}
190190

191-
function to_client_context_client(client) {
191+
function toClientContextClient(client) {
192192
return new ClientContextClient(
193193
client.appTitle,
194194
client.appVersionName,
@@ -197,7 +197,7 @@ function to_client_context_client(client) {
197197
);
198198
}
199199

200-
function to_client_context_env(env) {
200+
function toClientContextEnv(env) {
201201
return new ClientContextEnv(
202202
env.platformVersion,
203203
env.platform,

0 commit comments

Comments
 (0)