implement rest calls
MODIFY
package.json
package.json
"hammerjs": "^2.0.8",
"keycloak-angular": "^7.0.1",
"keycloak-js": "^5.0.0",
- "rxjs": "~6.4.0",
+ "rxjs": "^6.4.0",
"tslib": "^1.10.0",
"zone.js": "~0.9.1"
},

ADD
src/app/api-data.service.spec.ts
+import { TestBed } from '@angular/core/testing';
+
+import { ApiDataService } from './api-data.service';
+
+describe('ApiDataService', () => {
+ beforeEach(() => TestBed.configureTestingModule({}));
+
+ it('should be created', () => {
+ const service: ApiDataService = TestBed.get(ApiDataService);
+ expect(service).toBeTruthy();
+ });
+});

ADD
src/app/api-data.service.ts
+import { Injectable } from '@angular/core';
+import {HttpClient, HttpHeaders} from '@angular/common/http';
+import {Observable} from 'rxjs';
+
+export interface ApiSearchData {
+ beans: Array<ApiDetails>;
+ totalSize: number;
+}
+
+export interface ApiDetails {
+ name: string;
+ id: string;
+ description: string;
+ createdOn: string;
+ organizationName: string;
+ organizationId: string;
+}
+
+export interface ApiEndpointDetails {
+ managedEndpoint: string;
+}
+
+export interface ApiKeyDetails {
+ apiKey: string;
+}
+
+export interface ClientDetails {
+ name: string;
+ id: string;
+ description: string;
+ organizationName: string;
+ organizationId: string;
+ numContracts: number;
+}
+
+export interface ApiVersionsDetails {
+ name: string;
+ id: string;
+ description: string;
+ version: string;
+ status: 'Created' | 'Ready' | 'Published' | 'Retired';
+ organizationName: string;
+ organizationId: string;
+ publicAPI: boolean;
+}
+
+export interface ClientVersionDetails {
+ name: string;
+ id: string;
+ description: string;
+ version: string;
+ status: 'Created' | 'Ready' | 'Registered' | 'Retired';
+ apiKey: string;
+ organizationName: string;
+ organizationId: string;
+}
+
+export interface ContractDetails {
+ createdOn: string;
+ clientVersion: string;
+ apiVersion: string;
+ planVersion: string;
+ clientOrganizationId: string;
+ clientOrganizationName: string;
+ apiOrganizationId: string;
+ apiOrganizationName: string;
+ apiDescription: string;
+ clientId: string;
+ planName: string;
+ contractId: number;
+ apiName: string;
+ clientName: string;
+ planId: string;
+ apiId: string;
+}
+
+export interface ApiVersionDetails {
+ id: number;
+ version: string;
+ status: 'Created' | 'Ready' | 'Published' | 'Retired';
+ modifiedOn: string;
+ createdOn: string;
+ modifiedBy: string;
+ createdBy: string;
+ retiredOn: string;
+ publishedOn: string;
+ api: Api;
+ definitionType: 'None' | 'SwaggerJSON' | 'SwaggerYAML' | 'WSDL' | 'WADL' | 'RAML' | 'External';
+ endpointContentType: 'json' | 'xml';
+ endpointProperties: object;
+ endpointType: 'rest' | 'soap';
+ plans: Array<Plan>;
+ endpoint: string;
+ publicAPI: boolean;
+ parsePayload: boolean;
+ gateways: Array<Gateway>;
+}
+
+export interface Plan {
+ version: string;
+ planId: string;
+}
+
+export interface Gateway {
+ gatewayId: string;
+}
+
+export interface Api {
+ name: string;
+ id: string;
+ description: string;
+ organization: Organization;
+ createdOn: string;
+ createdBy: string;
+ numPublished: number;
+}
+
+export interface Organization {
+ name: string;
+ id: string;
+ description: string;
+ modifiedOn: string;
+ createdOn: string;
+ modifiedBy: string;
+ createdBy: string;
+}
+
+@Injectable({
+ providedIn: 'root'
+})
+export class ApiDataService {
+
+ constructor(private http: HttpClient) { }
+
+ private gatewayEndpoint = 'https://pc0854.scheer.systems:8443/apiman';
+
+ public getAllApis(): Observable<ApiSearchData> {
+ const url = this.gatewayEndpoint + '/search/apis/';
+ const body = { filters: [{name: 'name', value: '***', operator: 'like'}], page: 1, pageSize: 10000};
+ return this.http.post(url, body) as Observable<ApiSearchData>;
+ }
+
+ public getApiEndpoint(organizationId, apiId, apiVersion) {
+ const url = this.gatewayEndpoint + '/organizations/' + organizationId + '/apis/' + apiId + '/versions/' + apiVersion + '/endpoint/';
+ return this.http.get(url) as Observable<ApiEndpointDetails>;
+ }
+
+ public getApiKey(organizationId, clientId, clientVersion) {
+ const url = this.gatewayEndpoint + '/organizations/' + organizationId + '/clients/' + clientId + '/versions/' + clientVersion + '/apikey/';
+ return this.http.get(url) as Observable<ApiKeyDetails>;
+ }
+
+ public getUserClients() {
+ const url = this.gatewayEndpoint + '/currentuser/clients/';
+ return this.http.get(url) as Observable<Array<ClientDetails>>;
+ }
+
+ public getUserApis() {
+ const url = this.gatewayEndpoint + '/currentuser/apis/';
+ return this.http.get(url) as Observable<Array<ApiDetails>>;
+ }
+
+ public getApiVersions(organizationId, apiId) {
+ const url = this.gatewayEndpoint + '/organizations/' + organizationId + '/apis/' + apiId + '/versions/';
+ return this.http.get(url) as Observable<Array<ApiVersionsDetails>>;
+ }
+
+ public getApiVersionDetails(organizationId, apiId, apiVersion) {
+ const url = this.gatewayEndpoint + '/organizations/' + organizationId + '/apis/' + apiId + '/versions/' + apiVersion;
+ return this.http.get(url) as Observable<ApiVersionDetails>;
+ }
+
+ public getClientVersions(organizationId, clientId) {
+ const url = this.gatewayEndpoint + '/organizations/' + organizationId + '/clients/' + clientId + '/versions/';
+ return this.http.get(url) as Observable<Array<ClientVersionDetails>>;
+ }
+
+ public getContracts(organizationId, clientId, clientVersion) {
+ const url = this.gatewayEndpoint + '/organizations/' + organizationId + '/clients/' + clientId + '/versions/' + clientVersion + '/contracts';
+ return this.http.get(url) as Observable<Array<ContractDetails>>;
+ }
+
+}

MODIFY
src/app/api-list/api-list.component.html
src/app/api-list/api-list.component.html
<table mat-table [dataSource]="apiData">
+ <ng-container matColumnDef="id">
+ <th mat-header-cell *matHeaderCellDef>API Id</th>
+ <td mat-cell *matCellDef="let element"> {{element.id}} </td>
+ </ng-container>
<ng-container matColumnDef="name">
<th mat-header-cell *matHeaderCellDef>API Name</th>
<td mat-cell *matCellDef="let element"> {{element.name}} </td>
</ng-container>
- <ng-container matColumnDef="public">
+ <ng-container matColumnDef="ispublic">
<th mat-header-cell *matHeaderCellDef>is public</th>
- <td mat-cell *matCellDef="let element"> {{element.public}} </td>
+ <td mat-cell *matCellDef="let element"> {{element.ispublic}} </td>
</ng-container>
<ng-container matColumnDef="endpoint">
<th mat-header-cell *matHeaderCellDef>Endpoint</th>

MODIFY
src/app/api-list/api-list.component.ts
src/app/api-list/api-list.component.ts
import { Component, OnInit } from '@angular/core';
+import { forkJoin } from 'rxjs';
+import {ApiDataService, ClientDetails, ClientVersionDetails} from '../api-data.service';
+
+export interface ApiListView {
+ id: string;
+ name: string;
+ endpoint: string;
+ ispublic: boolean;
+}
@Component({
selector: 'app-api-list',
templateUrl: './api-list.component.html',
styleUrls: ['./api-list.component.scss']
})
+
export class ApiListComponent implements OnInit {
- apiData: Array<object> = [{
- name: 'Petstore',
- endpoint: 'https://petstore.swagger.io/v2/',
- public: true
- },
- {
- name: 'Analytic API',
- endpoint: 'http://pc0854.scheer.systems:3040/analytics/',
- public: false
- }];
+ apiData: Array<ApiListView> = [];
- displayedColumns: string[] = ['public', 'name', 'endpoint'];
+ displayedColumns: string[] = ['id', 'ispublic', 'name', 'endpoint'];
- constructor() { }
+ constructor(private apiDataService: ApiDataService) { }
ngOnInit() {
+ this.apiDataService.getUserClients().subscribe((data: Array<ClientDetails>) => {
+ data.forEach((client) => {
+ this.apiDataService.getClientVersions(client.organizationId, client.id).subscribe((clientData: Array<ClientVersionDetails>) => {
+ clientData.forEach((clientDataDetail) => {
+ this.apiDataService.getContracts(client.organizationId, client.id, clientDataDetail.version).subscribe((contractDetails) => {
+ contractDetails.forEach((contractDetail) => {
+ forkJoin(this.apiDataService.getApiEndpoint(contractDetail.apiOrganizationId, contractDetail.apiId, contractDetail.apiVersion), this.apiDataService.getApiKey(contractDetail.apiOrganizationId, contractDetail.clientId, contractDetail.clientVersion),
+ this.apiDataService.getApiVersionDetails(contractDetail.clientOrganizationId, contractDetail.apiId, contractDetail.apiVersion)).subscribe((forkedData) => {
+ this.apiData = this.apiData.concat({
+ id: contractDetail.apiId,
+ name: contractDetail.apiName,
+ endpoint: forkedData[0].managedEndpoint + '?apikey=' + forkedData[1].apiKey,
+ ispublic: forkedData[2].publicAPI
+ });
+ });
+ });
+ });
+ });
+ });
+ });
+ });
}
-
}

implement rest calls