File tree 3 files changed +44
-0
lines changed
3 files changed +44
-0
lines changed Original file line number Diff line number Diff line change
1
+ import nock from "nock" ;
2
+ import LensPlatformClient from "./LensPlatformClient" ;
3
+ import { minimumOptions as options , apiEndpointAddress } from "./LensPlatformClient.test" ;
4
+
5
+ describe ( ".domain/features.*" , ( ) => {
6
+ const domain = "mirantis.com" ;
7
+
8
+ nock ( apiEndpointAddress ) . get ( `/domain/features?domain=${ domain } ` ) . reply ( 200 , {
9
+ domainMatchingEnabled : true ,
10
+ } ) ;
11
+
12
+ const lensPlatformClient = new LensPlatformClient ( options ) ;
13
+
14
+ it ( "can call get" , async ( ) => {
15
+ const features = await lensPlatformClient . domainFeatures . get ( { domain } ) ;
16
+
17
+ expect ( features . domainMatchingEnabled ) . toBeTruthy ( ) ;
18
+ } ) ;
19
+ } ) ;
Original file line number Diff line number Diff line change
1
+ import { Base } from "./Base" ;
2
+ import { UnauthorizedException , throwExpected } from "./exceptions" ;
3
+
4
+ export interface DomainFeatures {
5
+ domainMatchingEnabled : boolean ;
6
+ }
7
+
8
+ class DomainFeaturesService extends Base {
9
+ async get ( { domain } : { domain : string } ) : Promise < DomainFeatures > {
10
+ const { apiEndpointAddress, fetch } = this . lensPlatformClient ;
11
+ const url = `${ apiEndpointAddress } /domain/features?domain=${ encodeURIComponent ( domain ) } ` ;
12
+
13
+ const json = await throwExpected ( async ( ) => fetch . get ( url ) , {
14
+ 401 : ( error ) => new UnauthorizedException ( error ?. body . message ) ,
15
+ } ) ;
16
+
17
+ return json as unknown as DomainFeatures ;
18
+ }
19
+ }
20
+
21
+ export { DomainFeaturesService } ;
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ import https from "https";
17
17
import { LensDesktopKubeService } from "./LensDesktopKubeService" ;
18
18
import { DemoClusterService } from "./DemoClusterService" ;
19
19
import { SSOService } from "./SSOService" ;
20
+ import { DomainFeaturesService } from "./DomainFeaturesService" ;
20
21
21
22
// Axios defaults to xhr adapter if XMLHttpRequest is available.
22
23
// LensPlatformClient supports using the http adapter if httpAdapter
@@ -188,6 +189,8 @@ class LensPlatformClient {
188
189
189
190
sso : SSOService ;
190
191
192
+ domainFeatures : DomainFeaturesService ;
193
+
191
194
constructor ( options : LensPlatformClientOptions ) {
192
195
if ( ! options ) {
193
196
throw new Error ( `Options can not be ${ options } ` ) ;
@@ -228,6 +231,7 @@ class LensPlatformClient {
228
231
this . sso = new SSOService ( this ) ;
229
232
this . openIDConnect = new OpenIdConnect ( this ) ;
230
233
this . notification = new NotificationService ( this ) ;
234
+ this . domainFeatures = new DomainFeaturesService ( this ) ;
231
235
}
232
236
233
237
async getToken ( url ?: string ) {
You can’t perform that action at this time.
0 commit comments