Skip to content

Commit 5e40a85

Browse files
authored
FFM-11364 Use target-segments v2-rule parameter (#115)
1 parent d73ab3e commit 5e40a85

File tree

8 files changed

+586
-110
lines changed

8 files changed

+586
-110
lines changed

Diff for: api.yaml renamed to client-v1.yaml

+125-4
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ servers:
1414
tags:
1515
- name: client
1616
- name: metrics
17+
- name: Proxy
18+
description: APIs used by the ff-proxy
1719
paths:
1820
'/client/env/{environmentUUID}/feature-configs':
1921
get:
@@ -85,6 +87,7 @@ paths:
8587
schema:
8688
type: string
8789
- $ref: '#/components/parameters/clusterQueryOptionalParam'
90+
- $ref: '#/components/parameters/segmentRulesV2QueryParam'
8891
security:
8992
- BearerAuth: []
9093
responses:
@@ -125,6 +128,7 @@ paths:
125128
schema:
126129
type: string
127130
- $ref: '#/components/parameters/clusterQueryOptionalParam'
131+
- $ref: '#/components/parameters/segmentRulesV2QueryParam'
128132
security:
129133
- BearerAuth: []
130134
responses:
@@ -199,10 +203,7 @@ paths:
199203
schema:
200204
allOf:
201205
- $ref: '#/components/schemas/Pagination'
202-
- type: object
203-
properties:
204-
evaluations:
205-
$ref: '#/components/schemas/Evaluations'
206+
- $ref: '#/components/schemas/Evaluations'
206207
'/client/env/{environmentUUID}/target/{target}/evaluations/{feature}':
207208
get:
208209
summary: Get feature evaluations for target
@@ -302,6 +303,84 @@ paths:
302303
default: '*'
303304
'503':
304305
description: Service Unavailable
306+
/proxy/config:
307+
get:
308+
summary: Gets Proxy config for multiple environments
309+
description: >-
310+
Gets Proxy config for multiple environments if the Key query param is
311+
provided or gets config for a single environment if an environment query
312+
param is provided
313+
operationId: GetProxyConfig
314+
tags:
315+
- Proxy
316+
parameters:
317+
- $ref: '#/components/parameters/pageNumber'
318+
- $ref: '#/components/parameters/pageSize'
319+
- $ref: '#/components/parameters/clusterQueryOptionalParam'
320+
- in: query
321+
name: environment
322+
description: >-
323+
Accepts an EnvironmentID. If this is provided then the endpoint will
324+
only return config for this environment. If this is left empty then
325+
the Proxy will return config for all environments associated with
326+
the Proxy Key.
327+
required: false
328+
schema:
329+
type: string
330+
- in: query
331+
name: key
332+
description: Accpets a Proxy Key.
333+
required: true
334+
schema:
335+
type: string
336+
security:
337+
- BearerAuth: []
338+
responses:
339+
'200':
340+
$ref: '#/components/responses/ProxyConfigResponse'
341+
'400':
342+
$ref: '#/components/responses/BadRequest'
343+
'401':
344+
$ref: '#/components/responses/Unauthenticated'
345+
'403':
346+
$ref: '#/components/responses/Unauthorized'
347+
'404':
348+
$ref: '#/components/responses/NotFound'
349+
'500':
350+
$ref: '#/components/responses/InternalServerError'
351+
/proxy/auth:
352+
post:
353+
summary: Endpoint that the Proxy can use to authenticate with the client server
354+
description: Endpoint that the Proxy can use to authenticate with the client server
355+
operationId: AuthenticateProxyKey
356+
tags:
357+
- Proxy
358+
requestBody:
359+
content:
360+
application/json:
361+
schema:
362+
type: object
363+
properties:
364+
proxyKey:
365+
type: string
366+
example: 896045f3-42ee-4e73-9154-086644768b96
367+
required:
368+
- proxyKey
369+
responses:
370+
'200':
371+
description: OK
372+
content:
373+
application/json:
374+
schema:
375+
$ref: '#/components/schemas/AuthenticationResponse'
376+
'401':
377+
$ref: '#/components/responses/Unauthenticated'
378+
'403':
379+
$ref: '#/components/responses/Unauthorized'
380+
'404':
381+
$ref: '#/components/responses/NotFound'
382+
'500':
383+
$ref: '#/components/responses/InternalServerError'
305384
components:
306385
schemas:
307386
FeatureState:
@@ -833,6 +912,31 @@ components:
833912
type: array
834913
items:
835914
$ref: '#/components/schemas/MetricsData'
915+
ProxyConfig:
916+
type: object
917+
description: TBD
918+
allOf:
919+
- $ref: '#/components/schemas/Pagination'
920+
- properties:
921+
environments:
922+
type: array
923+
items:
924+
type: object
925+
properties:
926+
id:
927+
type: string
928+
apiKeys:
929+
type: array
930+
items:
931+
type: string
932+
featureConfigs:
933+
type: array
934+
items:
935+
$ref: '#/components/schemas/FeatureConfig'
936+
segments:
937+
type: array
938+
items:
939+
$ref: '#/components/schemas/Segment'
836940
securitySchemes:
837941
ApiKeyAuth:
838942
type: apiKey
@@ -850,6 +954,17 @@ components:
850954
description: Unique identifier for the cluster for the account
851955
schema:
852956
type: string
957+
segmentRulesV2QueryParam:
958+
name: rules
959+
in: query
960+
required: false
961+
description: >-
962+
When set to rules=v2 will return AND rule compatible serving_rules
963+
field. When not set or set to any other value will return old rules
964+
field only compatible with OR rules.
965+
allowEmptyValue: true
966+
schema:
967+
type: string
853968
environmentPathParam:
854969
name: environmentUUID
855970
in: path
@@ -896,6 +1011,12 @@ components:
8961011
application/json:
8971012
schema:
8981013
$ref: '#/components/schemas/Error'
1014+
ProxyConfigResponse:
1015+
description: OK
1016+
content:
1017+
application/json:
1018+
schema:
1019+
$ref: '#/components/schemas/ProxyConfig'
8991020
BadRequest:
9001021
description: Bad request
9011022
content:

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"coverage": "jest --coverage",
5252
"test:junit": "jest --reporters=default --reporters=jest-junit",
5353
"test:watch": "jest --watch",
54-
"generate": "openapi-generator-cli generate -i ./api.yaml -g typescript-axios -o src/openapi"
54+
"generate": "openapi-generator-cli generate -i client-v1.yaml -g typescript-axios -o src/openapi"
5555
},
5656
"author": "Enver Bisevac <[email protected]>",
5757
"license": "Apache-2.0",

Diff for: src/client.ts

+11-2
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,19 @@ import EventEmitter from 'events';
22
import jwt_decode from 'jwt-decode';
33
import axios, { AxiosInstance, AxiosRequestConfig } from 'axios';
44
import axiosRetry from 'axios-retry';
5-
import { Claims, Options, StreamEvent, Target } from './types';
5+
import {
6+
APIConfiguration,
7+
Claims,
8+
Options,
9+
StreamEvent,
10+
Target,
11+
} from './types';
612
import { Configuration, ClientApi, FeatureConfig, Variation } from './openapi';
713
import { VERSION } from './version';
814
import { PollerEvent, PollingProcessor } from './polling';
915
import { StreamProcessor } from './streaming';
1016
import { Evaluator } from './evaluator';
11-
import { defaultOptions } from './constants';
17+
import { apiConfiguration, defaultOptions } from './constants';
1218
import { Repository, RepositoryEvent, StorageRepository } from './repository';
1319
import {
1420
MetricEvent,
@@ -55,6 +61,7 @@ export default class Client {
5561
private environment: string;
5662
private configuration: Configuration;
5763
private options: Options;
64+
private apiConfiguration: APIConfiguration = apiConfiguration;
5865
private cluster = '1';
5966
private eventBus = new EventEmitter();
6067
private pollProcessor: PollingProcessor;
@@ -356,6 +363,7 @@ export default class Client {
356363
this.environment,
357364
this.cluster,
358365
this.api,
366+
this.apiConfiguration,
359367
this.options,
360368
this.eventBus,
361369
this.repository,
@@ -367,6 +375,7 @@ export default class Client {
367375
this.streamProcessor = new StreamProcessor(
368376
this.api,
369377
this.sdkKey,
378+
apiConfiguration,
370379
this.environment,
371380
this.authToken,
372381
this.options,

Diff for: src/constants.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import LRU from 'lru-cache';
22
import { ConsoleLog } from './log';
33
import { FileStore } from './store';
4-
import { Options } from './types';
4+
import { APIConfiguration, Options } from './types';
55

66
export const ONE_HUNDRED = 100;
77

@@ -46,3 +46,8 @@ export const defaultOptions: Options = {
4646
logger: new ConsoleLog(),
4747
axiosTimeout: 30000,
4848
};
49+
50+
const TARGET_SEGMENT_RULES_QUERY_PARAMETER = 'v2';
51+
export const apiConfiguration: APIConfiguration = {
52+
targetSegmentRulesQueryParameter: TARGET_SEGMENT_RULES_QUERY_PARAMETER,
53+
};

0 commit comments

Comments
 (0)