24
24
import software .amazon .awssdk .services .greengrassv2 .GreengrassV2ClientBuilder ;
25
25
import software .amazon .awssdk .services .greengrassv2 .model .AssociatedClientDevice ;
26
26
import software .amazon .awssdk .services .greengrassv2 .model .ListClientDevicesAssociatedWithCoreDeviceRequest ;
27
- import software .amazon .awssdk .services .greengrassv2 .model .ListClientDevicesAssociatedWithCoreDeviceResponse ;
28
27
import software .amazon .awssdk .services .greengrassv2 .paginators .ListClientDevicesAssociatedWithCoreDeviceIterable ;
29
28
import software .amazon .awssdk .services .greengrassv2data .GreengrassV2DataClient ;
30
29
import software .amazon .awssdk .services .greengrassv2data .model .ResourceNotFoundException ;
37
36
import java .util .List ;
38
37
import java .util .Objects ;
39
38
import java .util .Optional ;
40
- import java .util .stream .Stream ;
39
+ import java .util .stream .Collectors ;
41
40
import javax .inject .Inject ;
42
41
43
42
public interface IotAuthClient {
@@ -50,7 +49,7 @@ public interface IotAuthClient {
50
49
boolean isThingAttachedToCertificate (Thing thing , String certificateId ) throws CloudServiceInteractionException ;
51
50
52
51
53
- Stream < List <AssociatedClientDevice > > getThingsAssociatedWithCoreDevice ();
52
+ List <AssociatedClientDevice > getThingsAssociatedWithCoreDevice ();
54
53
55
54
class Default implements IotAuthClient {
56
55
private static final Logger logger = LogManager .getLogger (Default .class );
@@ -184,7 +183,7 @@ public boolean isThingAttachedToCertificate(Thing thing, String certificateId)
184
183
}
185
184
186
185
@ Override
187
- public Stream < List <AssociatedClientDevice > > getThingsAssociatedWithCoreDevice () {
186
+ public List <AssociatedClientDevice > getThingsAssociatedWithCoreDevice () {
188
187
String thingName = Coerce .toString (deviceConfiguration .getThingName ());
189
188
190
189
ListClientDevicesAssociatedWithCoreDeviceRequest request =
@@ -194,20 +193,19 @@ public Stream<List<AssociatedClientDevice>> getThingsAssociatedWithCoreDevice()
194
193
ListClientDevicesAssociatedWithCoreDeviceIterable responses =
195
194
client .listClientDevicesAssociatedWithCoreDevicePaginator (request );
196
195
197
- return responses .stream ()
198
- .map ( ListClientDevicesAssociatedWithCoreDeviceResponse :: associatedClientDevices );
196
+ return responses .stream (). flatMap ( response -> response . associatedClientDevices (). stream ())
197
+ .collect ( Collectors . toList () );
199
198
}
200
199
}
201
200
202
201
// TODO: This should not live here ideally it should be returned by the clientFactory but we
203
202
// are adding it here to avoid introducing new changes to the nucleus
204
203
private GreengrassV2Client getGGV2Client () {
205
204
String awsRegion = Coerce .toString (deviceConfiguration .getAWSRegion ());
206
- GreengrassV2ClientBuilder clientBuilder =
207
- GreengrassV2Client .builder ().httpClientBuilder (ProxyUtils .getSdkHttpClientBuilder ()
208
- .useIdleConnectionReaper (false ))
209
- .credentialsProvider (lazyCredentialProvider ).overrideConfiguration (
210
- ClientOverrideConfiguration .builder ().retryPolicy (RetryMode .STANDARD ).build ());
205
+ GreengrassV2ClientBuilder clientBuilder = GreengrassV2Client .builder ()
206
+ .httpClientBuilder (ProxyUtils .getSdkHttpClientBuilder ().useIdleConnectionReaper (false ))
207
+ .credentialsProvider (lazyCredentialProvider ).overrideConfiguration (
208
+ ClientOverrideConfiguration .builder ().retryPolicy (RetryMode .STANDARD ).build ());
211
209
212
210
if (Utils .isEmpty (awsRegion )) {
213
211
return clientBuilder .build ();
0 commit comments