Skip to content

Commit

Permalink
Merge pull request #3708 from cloudfoundry-incubator/entity-pipeline
Browse files Browse the repository at this point in the history
Entity Catalogue - Allow endpoints and actions to provide action pipelines
  • Loading branch information
KlapTrap authored Sep 3, 2019
2 parents e274a77 + 28248d2 commit 307d71a
Show file tree
Hide file tree
Showing 199 changed files with 3,390 additions and 1,487 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { ConfirmationDialogService } from '../../../../core/src/shared/component
import { PaginationMonitorFactory } from '../../../../core/src/shared/monitors/pagination-monitor.factory';
import { RouterNav } from '../../../../store/src/actions/router.actions';
import { AppState } from '../../../../store/src/app-state';
import { createEntityRelationPaginationKey } from '../../../../store/src/helpers/entity-relations/entity-relations.types';
import { ActionState } from '../../../../store/src/reducers/api-request-reducer/types';
import { getPaginationObservables } from '../../../../store/src/reducers/pagination-reducer/pagination-reducer.helper';
import { selectDeletionInfo } from '../../../../store/src/selectors/api.selectors';
Expand All @@ -41,6 +40,7 @@ import {
AppScalingTrigger,
} from '../../store/app-autoscaler.types';
import { appAutoscalerAppMetricEntityType, autoscalerEntityFactory } from '../../store/autoscaler-entity-factory';
import { createEntityRelationPaginationKey } from '../../../../cloud-foundry/src/entity-relations/entity-relations.types';

const enableAutoscaler = (appGuid: string, endpointGuid: string, esf: EntityServiceFactory): Observable<boolean> => {
// This will eventual be moved out into a service and made generic to the cf (one call per cf, rather than one call per app - See #3583)
Expand Down Expand Up @@ -144,8 +144,7 @@ export class AutoscalerTabExtensionComponent implements OnInit, OnDestroy {
ngOnInit() {
this.appAutoscalerPolicyService = this.entityServiceFactory.create(
this.applicationService.appGuid,
new GetAppAutoscalerPolicyAction(this.applicationService.appGuid, this.applicationService.cfGuid),
false
new GetAppAutoscalerPolicyAction(this.applicationService.appGuid, this.applicationService.cfGuid)
);
this.appAutoscalerPolicy$ = this.appAutoscalerPolicyService.entityObs$.pipe(
map(({ entity }) => entity ? entity.entity : null),
Expand Down Expand Up @@ -173,8 +172,7 @@ export class AutoscalerTabExtensionComponent implements OnInit, OnDestroy {
);
this.appAutoscalerScalingHistoryService = this.entityServiceFactory.create(
this.applicationService.appGuid,
this.scalingHistoryAction,
false
this.scalingHistoryAction
);
this.appAutoscalerScalingHistory$ = this.appAutoscalerScalingHistoryService.entityObs$.pipe(
map(({ entity }) => entity && entity.entity),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { RequestOptions } from '@angular/http';

import { applicationEntityType } from '../../../cloud-foundry/src/cf-entity-factory';
import { createEntityRelationPaginationKey } from '../../../store/src/helpers/entity-relations/entity-relations.types';
import { ApiRequestTypes } from '../../../store/src/reducers/api-request-reducer/request-helpers';
import { PaginatedAction } from '../../../store/src/types/pagination.types';
import { IRequestAction } from '../../../store/src/types/request.types';
import { PaginatedAction, PaginationParam } from '../../../store/src/types/pagination.types';
import { AppAutoscalerPolicyLocal, AppScalingTrigger } from './app-autoscaler.types';
import {
appAutoscalerAppMetricEntityType,
Expand All @@ -15,6 +13,8 @@ import {
AUTOSCALER_ENDPOINT_TYPE,
autoscalerEntityFactory,
} from './autoscaler-entity-factory';
import { createEntityRelationPaginationKey } from '../../../cloud-foundry/src/entity-relations/entity-relations.types';
import { EntityRequestAction } from '../../../store/src/types/request.types';

export const AppAutoscalerPolicyEvents = {
GET_APP_AUTOSCALER_POLICY: '[App Autoscaler] Get autoscaler policy',
Expand Down Expand Up @@ -50,7 +50,7 @@ export const FETCH_APP_AUTOSCALER_METRIC = '[New App Autoscaler] Fetch Metric';

export const UPDATE_APP_AUTOSCALER_POLICY_STEP = '[Edit Autoscaler Policy] Step';

export class GetAppAutoscalerHealthAction implements IRequestAction {
export class GetAppAutoscalerHealthAction implements EntityRequestAction {
constructor(
public guid: string,
public endpointGuid: string,
Expand All @@ -62,7 +62,7 @@ export class GetAppAutoscalerHealthAction implements IRequestAction {
endpointType = AUTOSCALER_ENDPOINT_TYPE;
}

export class GetAppAutoscalerPolicyAction implements IRequestAction {
export class GetAppAutoscalerPolicyAction implements EntityRequestAction {
constructor(
public guid: string,
public endpointGuid: string,
Expand All @@ -73,7 +73,7 @@ export class GetAppAutoscalerPolicyAction implements IRequestAction {
endpointType = AUTOSCALER_ENDPOINT_TYPE;
}

export class UpdateAppAutoscalerPolicyAction implements IRequestAction {
export class UpdateAppAutoscalerPolicyAction implements EntityRequestAction {
static updateKey = 'Updating-Existing-Application-Policy';
constructor(
public guid: string,
Expand All @@ -86,7 +86,8 @@ export class UpdateAppAutoscalerPolicyAction implements IRequestAction {
endpointType = AUTOSCALER_ENDPOINT_TYPE;
}

export class DetachAppAutoscalerPolicyAction implements IRequestAction {
export class DetachAppAutoscalerPolicyAction implements EntityRequestAction {
static updateKey = 'Detaching-Existing-Application-Policy';
constructor(
public guid: string,
public endpointGuid: string,
Expand Down Expand Up @@ -122,7 +123,7 @@ export class GetAppAutoscalerPolicyTriggerAction implements PaginatedAction {
windowValue: string;
}

export interface AutoscalerPaginationParams {
export interface AutoscalerPaginationParams extends PaginationParam {
'order-direction-field'?: string;
'order-direction': 'asc' | 'desc';
'results-per-page': string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ export function generateASEntities(): StratosBaseCatalogueEntity[] {
iconFont: 'stratos-icons',
logoUrl: '/core/assets/endpoint-icons/cloudfoundry.png',
authTypes: [],
} as IStratosEndpointDefinition;
schema: undefined
};
return [
generatePolicyEntity(endpointDefinition),
generatePolicyTriggerEntity(endpointDefinition),
Expand Down
26 changes: 12 additions & 14 deletions src/frontend/packages/cf-autoscaler/src/store/autoscaler.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Action, Store } from '@ngrx/store';
import { Observable } from 'rxjs';
import { catchError, mergeMap, withLatestFrom } from 'rxjs/operators';

import { PaginationResponse } from '../../../cloud-foundry/src/store/types/cf-api.types';
import { entityCatalogue } from '../../../core/src/core/entity-catalogue/entity-catalogue.service';
import { environment } from '../../../core/src/environments/environment';
import { AppState } from '../../../store/src/app-state';
Expand Down Expand Up @@ -52,7 +53,6 @@ import {
AppAutoscalerPolicyLocal,
AppScalingTrigger,
} from './app-autoscaler.types';
import { PaginationResponse } from '../../../cloud-foundry/src/store/types/cf-api.types';

const { proxyAPIVersion } = environment;
const commonPrefix = `/pp/${proxyAPIVersion}/autoscaler`;
Expand Down Expand Up @@ -205,13 +205,14 @@ export class AutoscalerEffects {
options.params.set('order', options.params.get('order-direction'));
options.params.delete('order-direction');
}
if (metricConfig && metricConfig.params) {
options.params.set('start-time', metricConfig.params.start + '000000000');
options.params.set('end-time', metricConfig.params.end + '000000000');
} else if (action.query && action.query.params) {
options.params.set('start-time', action.query.params.start + '000000000');
options.params.set('end-time', action.query.params.end + '000000000');
}
// TODO this needs to be changed into a string key-value
// if (metricConfig && metricConfig.params) {
// options.params.set('start-time', metricConfig.params.start + '000000000');
// options.params.set('end-time', metricConfig.params.end + '000000000');
// } else if (action.query && action.query.params) {
// options.params.set('start-time', action.query.params.start + '000000000');
// options.params.set('end-time', action.query.params.end + '000000000');
// }
return this.http
.request(new Request(options)).pipe(
mergeMap(response => {
Expand Down Expand Up @@ -410,17 +411,17 @@ export class AutoscalerEffects {
const searchParams = new URLSearchParams();
if (initialParams) {
Object.keys(initialParams).forEach((key) => {
searchParams.set(key, initialParams[key]);
searchParams.set(key, initialParams[key].toString());
});
}
if (params) {
Object.keys(params).forEach((key) => {
searchParams.set(key, params[key]);
searchParams.set(key, params[key].toString());
});
}
if (paginationParams) {
Object.keys(paginationParams).forEach((key) => {
searchParams.set(key, paginationParams[key]);
searchParams.set(key, paginationParams[key].toString());
});
}
return searchParams;
Expand All @@ -430,9 +431,6 @@ export class AutoscalerEffects {
return paginationState
? {
...paginationState.params,
q: [
...(paginationState.params.q || [])
],
page: paginationState.currentPage.toString(),
}
: {};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { RequestOptions, URLSearchParams } from '@angular/http';

import { PaginatedAction, QParam } from '../../../store/src/types/pagination.types';
import { PaginatedAction } from '../../../store/src/types/pagination.types';
import { appEventEntityType, cfEntityFactory } from '../cf-entity-factory';
import { CFStartAction } from './cf-action.types';
import { QParam, QParamJoiners } from '../../../store/src/q-param';

export const AppGetAllEvents = {
GET_ALL: '[Application Event] Get all',
Expand Down Expand Up @@ -34,7 +35,7 @@ export class GetAllAppEvents extends CFStartAction implements PaginatedAction {
'order-direction': 'desc',
'order-direction-field': GetAllAppEvents.sortField,
q: [
new QParam('actee', this.appGuid),
new QParam('actee', this.appGuid, QParamJoiners.colon).toString(),
]
};
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { RequestOptions } from '@angular/http';

import { createEntityRelationPaginationKey } from '../../../store/src/helpers/entity-relations/entity-relations.types';
import { PaginatedAction } from '../../../store/src/types/pagination.types';
import { ICFAction, RequestEntityLocation } from '../../../store/src/types/request.types';
import {
Expand All @@ -11,6 +10,7 @@ import {
cfEntityFactory,
} from '../cf-entity-factory';
import { CFStartAction } from './cf-action.types';
import { createEntityRelationPaginationKey } from '../entity-relations/entity-relations.types';

export enum AppMetadataTypes {
STATS,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import { RequestOptions, URLSearchParams } from '@angular/http';

import { getActions } from '../../../store/src/actions/action.helper';
import {
createEntityRelationKey,
createEntityRelationPaginationKey,
EntityInlineChildAction,
EntityInlineParentAction,
} from '../../../store/src/helpers/entity-relations/entity-relations.types';

import { ICFAction } from '../../../store/src/types/request.types';
import { CFEntityConfig } from '../../cf-types';
import {
Expand All @@ -18,6 +13,12 @@ import {
serviceInstancesEntityType,
} from '../cf-entity-factory';
import { CFStartAction } from './cf-action.types';
import {
createEntityRelationKey,
EntityInlineParentAction,
EntityInlineChildAction,
createEntityRelationPaginationKey
} from '../entity-relations/entity-relations.types';

export const ASSIGN_ROUTE = '[Application] Assign route';
export const ASSIGN_ROUTE_SUCCESS = '[Application] Assign route success';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Headers, RequestOptions, URLSearchParams } from '@angular/http';

import { IApp } from '../../../core/src/core/cf-api.types';
import { EntityInlineParentAction } from '../../../store/src/helpers/entity-relations/entity-relations.types';
import { pick } from '../../../store/src/helpers/reducer.helper';
import { ActionMergeFunction } from '../../../store/src/types/api.types';
import { PaginatedAction, PaginationParam } from '../../../store/src/types/pagination.types';
import { ICFAction } from '../../../store/src/types/request.types';
import { CF_ENDPOINT_TYPE } from '../../cf-types';
import { applicationEntityType, appStatsEntityType, cfEntityFactory } from '../cf-entity-factory';
import { EntityInlineParentAction } from '../entity-relations/entity-relations.types';
import { AppMetadataTypes } from './app-metadata.actions';
import { CFStartAction } from './cf-action.types';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { IRequestAction } from '../../../store/src/types/request.types';
import { CF_ENDPOINT_TYPE } from '../../cf-types';
import { cfInfoEntityType } from '../cf-entity-factory';
import { EntityRequestAction } from '../../../store/src/types/request.types';

export const GET_CF_INFO = '[CF Endpoint] Get Info';

export class GetCFInfo implements IRequestAction {
export class GetCFInfo implements EntityRequestAction {
constructor(public cfGuid: string) { }
type = GET_CF_INFO;
endpointType = CF_ENDPOINT_TYPE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { GitSCM } from '../../../core/src/shared/data-services/scm/scm';
import { GitAppDetails, OverrideAppDetails, SourceType } from '../store/types/deploy-application.types';
import { GitBranch, GitCommit } from '../store/types/git.types';
import { PaginatedAction } from '../../../store/src/types/pagination.types';
import { IRequestAction } from '../../../store/src/types/request.types';
import { EntityRequestAction } from '../../../store/src/types/request.types';

export const SET_APP_SOURCE_DETAILS = '[Deploy App] Application Source';
export const CHECK_PROJECT_EXISTS = '[Deploy App] Check Projet exists';
Expand Down Expand Up @@ -77,7 +77,7 @@ export class SaveAppOverrides implements Action {
type = SAVE_APP_OVERRIDE_DETAILS;
}

export class FetchCommit implements IRequestAction {
export class FetchCommit implements EntityRequestAction {
commit: GitCommit;
public endpointType = CF_ENDPOINT_TYPE;
constructor(public scm: GitSCM, public commitSha: string, public projectName: string) { }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { RequestOptions, URLSearchParams } from '@angular/http';

import { endpointSchemaKey } from '../../../store/src/helpers/entity-factory';
import { createEntityRelationPaginationKey } from '../../../store/src/helpers/entity-relations/entity-relations.types';
import { createEntityRelationPaginationKey } from '../entity-relations/entity-relations.types';
import { PaginatedAction } from '../../../store/src/types/pagination.types';
import { ICFAction } from '../../../store/src/types/request.types';
import { cfEntityFactory, domainEntityType } from '../cf-entity-factory';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { IRequestAction } from '../../../store/src/types/request.types';
import { CF_ENDPOINT_TYPE } from '../../cf-types';
import { gitRepoEntityType } from '../cf-entity-factory';
import {
EnvVarStratosProject,
} from '../features/applications/application/application-tabs-base/tabs/build-tab/application-env-vars.service';
import { EntityRequestAction } from '../../../store/src/types/request.types';

export const FETCH_GITHUB_REPO = '[Github] Fetch Github repo details';

export class FetchGitHubRepoInfo implements IRequestAction {
export class FetchGitHubRepoInfo implements EntityRequestAction {
constructor(public stProject: EnvVarStratosProject) { }
type = FETCH_GITHUB_REPO;
endpointType = CF_ENDPOINT_TYPE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ import { RequestMethod, RequestOptions, URLSearchParams } from '@angular/http';

import { IUpdateOrganization } from '../../../core/src/core/cf-api.types';
import { getActions } from '../../../store/src/actions/action.helper';
import {
createEntityRelationPaginationKey,
EntityInlineChildAction,
EntityInlineParentAction,
} from '../../../store/src/helpers/entity-relations/entity-relations.types';

import { PaginatedAction } from '../../../store/src/types/pagination.types';
import { ICFAction } from '../../../store/src/types/request.types';
import { CFEntityConfig } from '../../cf-types';
Expand All @@ -20,6 +16,11 @@ import {
} from '../cf-entity-factory';
import { CFStartAction } from './cf-action.types';
import { createDefaultUserRelations } from './user.actions.helpers';
import {
EntityInlineParentAction,
EntityInlineChildAction,
createEntityRelationPaginationKey
} from '../entity-relations/entity-relations.types';

export const GET_ORGANIZATION = '[Organization] Get one';
export const GET_ORGANIZATION_SUCCESS = '[Organization] Get one success';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ import { IQuotaDefinition } from '../../../core/src/core/cf-api.types';
import {
QuotaFormValues,
} from '../../../core/src/features/cloud-foundry/quota-definition-form/quota-definition-form.component';
import {
EntityInlineChildAction,
EntityInlineParentAction,
} from '../../../store/src/helpers/entity-relations/entity-relations.types';

import { PaginatedAction } from '../../../store/src/types/pagination.types';
import { ICFAction } from '../../../store/src/types/request.types';
import { CFEntityConfig } from '../../cf-types';
Expand All @@ -18,6 +15,7 @@ import {
spaceQuotaEntityType,
} from '../cf-entity-factory';
import { CFStartAction } from './cf-action.types';
import { EntityInlineChildAction, EntityInlineParentAction } from '../entity-relations/entity-relations.types';

export const GET_QUOTA_DEFINITION = '[QuotaDefinition] Get one';
export const GET_QUOTA_DEFINITION_SUCCESS = '[QuotaDefinition] Get one success';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { RequestOptions, URLSearchParams } from '@angular/http';

import { EntityCatalogueEntityConfig } from '../../../core/src/core/entity-catalogue/entity-catalogue.types';
import { EntityTreeRelation } from '../../../store/src/helpers/entity-relations/entity-relation-tree';
import {
EntityInlineChildAction,
EntityInlineParentAction,
} from '../../../store/src/helpers/entity-relations/entity-relations.types';
} from '../entity-relations/entity-relations.types';
import { PaginatedAction } from '../../../store/src/types/pagination.types';
import { IRequestActionEntity, RequestEntityLocation } from '../../../store/src/types/request.types';
import { RequestEntityLocation, RequestActionEntity } from '../../../store/src/types/request.types';
import { CFStartAction } from './cf-action.types';
import { EntityTreeRelation } from '../entity-relations/entity-relation-tree';

const relationActionId = 'FetchRelationAction';

Expand All @@ -30,7 +30,7 @@ export abstract class FetchRelationAction extends CFStartAction implements Entit
this.options.params = new URLSearchParams();
this.parentEntityConfig = parent.entity;
}
entity: IRequestActionEntity;
entity: RequestActionEntity;
entityType: string;
isId = relationActionId;
actions = [
Expand Down
Loading

0 comments on commit 307d71a

Please sign in to comment.