11
11
import bio .terra .model .BillingProfileRequestModel ;
12
12
import bio .terra .model .BillingProfileUpdateModel ;
13
13
import bio .terra .model .EnumerateBillingProfileModel ;
14
+ import bio .terra .model .EnumerateBillingProfileResourcesModel ;
14
15
import bio .terra .model .JobModel ;
15
16
import bio .terra .model .PolicyMemberRequest ;
16
17
import bio .terra .model .PolicyModel ;
20
21
import bio .terra .service .auth .iam .IamService ;
21
22
import bio .terra .service .auth .iam .PolicyMemberValidator ;
22
23
import bio .terra .service .job .JobService ;
23
- import com .fasterxml .jackson .databind .ObjectMapper ;
24
24
import io .swagger .annotations .Api ;
25
25
import jakarta .servlet .http .HttpServletRequest ;
26
26
import jakarta .validation .Valid ;
27
27
import java .util .Collections ;
28
28
import java .util .List ;
29
- import java .util .Optional ;
30
29
import java .util .UUID ;
31
30
import org .springframework .beans .factory .annotation .Autowired ;
32
31
import org .springframework .http .HttpStatus ;
42
41
@ Api (tags = {"profiles" })
43
42
public class ProfileApiController implements ProfilesApi {
44
43
45
- private final ObjectMapper objectMapper ;
46
44
private final HttpServletRequest request ;
47
45
private final ProfileService profileService ;
48
46
private final ProfileRequestValidator billingProfileRequestValidator ;
@@ -56,7 +54,6 @@ public class ProfileApiController implements ProfilesApi {
56
54
57
55
@ Autowired
58
56
public ProfileApiController (
59
- ObjectMapper objectMapper ,
60
57
HttpServletRequest request ,
61
58
ProfileService profileService ,
62
59
ProfileRequestValidator billingProfileRequestValidator ,
@@ -66,7 +63,6 @@ public ProfileApiController(
66
63
AuthenticatedUserRequestFactory authenticatedUserRequestFactory ,
67
64
IamService iamService ,
68
65
ApplicationConfiguration applicationConfiguration ) {
69
- this .objectMapper = objectMapper ;
70
66
this .request = request ;
71
67
this .profileService = profileService ;
72
68
this .billingProfileRequestValidator = billingProfileRequestValidator ;
@@ -78,16 +74,6 @@ public ProfileApiController(
78
74
this .applicationConfiguration = applicationConfiguration ;
79
75
}
80
76
81
- @ Override
82
- public Optional <ObjectMapper > getObjectMapper () {
83
- return Optional .ofNullable (objectMapper );
84
- }
85
-
86
- @ Override
87
- public Optional <HttpServletRequest > getRequest () {
88
- return Optional .ofNullable (request );
89
- }
90
-
91
77
@ InitBinder
92
78
protected void initBinder (final WebDataBinder binder ) {
93
79
binder .addValidators (profileUpdateRequestValidator );
@@ -199,4 +185,14 @@ private void verifyAuthorization(
199
185
// Verify permissions
200
186
iamService .verifyAuthorization (userReq , resourceType , resourceId , action );
201
187
}
188
+
189
+ @ Override
190
+ public ResponseEntity <EnumerateBillingProfileResourcesModel > getProfileResources (UUID id ) {
191
+ AuthenticatedUserRequest user = authenticatedUserRequestFactory .from (request );
192
+ var resources =
193
+ profileService .getProfileResources (id , user ).stream ()
194
+ .map (ProfileOwnedResource ::toModel )
195
+ .toList ();
196
+ return ResponseEntity .ok (new EnumerateBillingProfileResourcesModel ().items (resources ));
197
+ }
202
198
}
0 commit comments