Skip to content

Commit

Permalink
integrate EventHook API into v2 client
Browse files Browse the repository at this point in the history
  • Loading branch information
oleksandrpravosudko-okta committed Jun 10, 2022
1 parent 2993c1d commit c046df2
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 147 deletions.
3 changes: 2 additions & 1 deletion src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const DEFAULT_USER_AGENT = `${packageJson.name}/${packageJson.version} node/${pr
const repoUrl = 'https://github.com/okta/okta-sdk-nodejs';
const { OAuth } = require('./oauth');
const { getAffectedResources } = require('./request-middleware');
const { AuthenticatorApi, SchemaApi, UserTypeApi, InlineHookApi, ProfileMappingApi, DomainApi, LinkedObjectApi, SystemLogApi, FeatureApi, GroupApi } = require('./generated');
const { AuthenticatorApi, SchemaApi, UserTypeApi, InlineHookApi, ProfileMappingApi, DomainApi, LinkedObjectApi, SystemLogApi, FeatureApi, GroupApi, EventHookApi } = require('./generated');
const { createConfiguration } = require('./generated/configuration');
const { ServerConfiguration } = require('./generated/servers');
const { Observable } = require('./generated/rxjsStub');
Expand Down Expand Up @@ -117,6 +117,7 @@ class Client extends GeneratedApiClient {
this.systemLogApi = new SystemLogApi(configuration);
this.featureApi = new FeatureApi(configuration);
this.groupApi = new GroupApi(configuration);
this.eventHookApi = new EventHookApi(configuration);
}
}

Expand Down
101 changes: 8 additions & 93 deletions src/generated-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -3450,13 +3450,7 @@ class GeneratedApiClient {
* @returns {Collection} A collection that will yield {@link EventHook} instances.
*/
listEventHooks() {
let url = `${this.baseUrl}/api/v1/eventHooks`;

return new Collection(
this.http,
url,
new ModelFactory(models.EventHook, this),
);
return this.eventHookApi.listEventHooks();
}

/**
Expand All @@ -3470,18 +3464,7 @@ class GeneratedApiClient {
if (!eventHook) {
return Promise.reject(new Error('OKTA API createEventHook parameter eventHook is required.'));
}
let url = `${this.baseUrl}/api/v1/eventHooks`;

const resources = [];

const request = this.http.postJson(
url,
{
body: eventHook
},
{ resources }
);
return request.then(jsonRes => new models.EventHook(jsonRes, this));
return this.eventHookApi.createEventHook(eventHook);
}

/**
Expand All @@ -3494,18 +3477,7 @@ class GeneratedApiClient {
if (!eventHookId) {
return Promise.reject(new Error('OKTA API deleteEventHook parameter eventHookId is required.'));
}
let url = `${this.baseUrl}/api/v1/eventHooks/${eventHookId}`;

const resources = [
`${this.baseUrl}/api/v1/eventHooks/${eventHookId}`
];

const request = this.http.delete(
url,
null,
{ resources }
);
return request;
return this.eventHookApi.deleteEventHook(eventHookId);
}

/**
Expand All @@ -3519,18 +3491,7 @@ class GeneratedApiClient {
if (!eventHookId) {
return Promise.reject(new Error('OKTA API getEventHook parameter eventHookId is required.'));
}
let url = `${this.baseUrl}/api/v1/eventHooks/${eventHookId}`;

const resources = [
`${this.baseUrl}/api/v1/eventHooks/${eventHookId}`
];

const request = this.http.getJson(
url,
null,
{ resources }
);
return request.then(jsonRes => new models.EventHook(jsonRes, this));
return this.eventHookApi.getEventHook(eventHookId);
}

/**
Expand All @@ -3548,20 +3509,7 @@ class GeneratedApiClient {
if (!eventHook) {
return Promise.reject(new Error('OKTA API updateEventHook parameter eventHook is required.'));
}
let url = `${this.baseUrl}/api/v1/eventHooks/${eventHookId}`;

const resources = [
`${this.baseUrl}/api/v1/eventHooks/${eventHookId}`
];

const request = this.http.putJson(
url,
{
body: eventHook
},
{ resources }
);
return request.then(jsonRes => new models.EventHook(jsonRes, this));
return this.eventHookApi.updateEventHook(eventHookId, eventHook);
}

/**
Expand All @@ -3575,18 +3523,7 @@ class GeneratedApiClient {
if (!eventHookId) {
return Promise.reject(new Error('OKTA API activateEventHook parameter eventHookId is required.'));
}
let url = `${this.baseUrl}/api/v1/eventHooks/${eventHookId}/lifecycle/activate`;

const resources = [
`${this.baseUrl}/api/v1/eventHooks/${eventHookId}`
];

const request = this.http.postJson(
url,
null,
{ resources }
);
return request.then(jsonRes => new models.EventHook(jsonRes, this));
return this.eventHookApi.activateEventHook(eventHookId);
}

/**
Expand All @@ -3600,18 +3537,7 @@ class GeneratedApiClient {
if (!eventHookId) {
return Promise.reject(new Error('OKTA API deactivateEventHook parameter eventHookId is required.'));
}
let url = `${this.baseUrl}/api/v1/eventHooks/${eventHookId}/lifecycle/deactivate`;

const resources = [
`${this.baseUrl}/api/v1/eventHooks/${eventHookId}`
];

const request = this.http.postJson(
url,
null,
{ resources }
);
return request.then(jsonRes => new models.EventHook(jsonRes, this));
return this.eventHookApi.deactivateEventHook(eventHookId);
}

/**
Expand All @@ -3625,18 +3551,7 @@ class GeneratedApiClient {
if (!eventHookId) {
return Promise.reject(new Error('OKTA API verifyEventHook parameter eventHookId is required.'));
}
let url = `${this.baseUrl}/api/v1/eventHooks/${eventHookId}/lifecycle/verify`;

const resources = [
`${this.baseUrl}/api/v1/eventHooks/${eventHookId}`
];

const request = this.http.postJson(
url,
null,
{ resources }
);
return request.then(jsonRes => new models.EventHook(jsonRes, this));
return this.eventHookApi.verifyEventHook(eventHookId);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/types/client.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { OAuth } from './oauth';
import { Http } from './http';
import { RequestExecutor } from './request-executor';
import { V2Configuration } from './configuration';
import { AuthenticatorApi, SchemaApi, UserTypeApi, InlineHookApi, ProfileMappingApi, DomainApi, LinkedObjectApi, SystemLogApi, FeatureApi, GroupApi } from './generated';
import { AuthenticatorApi, SchemaApi, UserTypeApi, InlineHookApi, ProfileMappingApi, DomainApi, LinkedObjectApi, SystemLogApi, FeatureApi, GroupApi, EventHookApi } from './generated';
export declare class Client extends ParameterizedOperationsClient {
constructor(config?: V2Configuration);

Expand All @@ -39,4 +39,5 @@ export declare class Client extends ParameterizedOperationsClient {
systemLogApi: SystemLogApi;
featureApi: FeatureApi;
groupApi: GroupApi;
eventHookApi: EventHookApi;
}
42 changes: 12 additions & 30 deletions src/types/generated-client.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import { ReadStream } from 'fs';
import { OAuth2Token } from './models/OAuth2Token';
import { AppUser } from './models/AppUser';
import { AppUserOptions } from './models/AppUser';
import { Authenticator } from './models/Authenticator';
import { AuthorizationServer } from './models/AuthorizationServer';
import { AuthorizationServerOptions } from './models/AuthorizationServer';
import { OAuth2Claim } from './models/OAuth2Claim';
Expand All @@ -57,33 +56,12 @@ import { EmailTemplateTestRequestOptions } from './models/EmailTemplateTestReque
import { ThemeResponse } from './models/ThemeResponse';
import { ThemeOptions } from './models/Theme';
import { ImageUploadResponse } from './models/ImageUploadResponse';
import { DomainListResponse } from './models/DomainListResponse';
import { Domain } from './models/Domain';
import { DomainCertificate } from './models/DomainCertificate';
import { EventHook } from './models/EventHook';
import { EventHookOptions } from './models/EventHook';
import { Feature } from './models/Feature';
import { Group } from './models/Group';
import { GroupRule } from './models/GroupRule';
import { Role } from './models/Role';
import { AssignRoleRequest } from './models/AssignRoleRequest';
import { CatalogApplication } from './models/CatalogApplication';
import { User } from './models/User';
import { IdentityProvider } from './models/IdentityProvider';
import { IdentityProviderOptions } from './models/IdentityProvider';
import { JsonWebKeyOptions } from './models/JsonWebKey';
import { IdentityProviderApplicationUser } from './models/IdentityProviderApplicationUser';
import { UserIdentityProviderLinkRequestOptions } from './models/UserIdentityProviderLinkRequest';
import { SocialAuthToken } from './models/SocialAuthToken';
import { InlineHook } from './models/InlineHook';
import { InlineHookPayload } from './models/InlineHookPayload';
import { InlineHookResponse } from './models/InlineHookResponse';
import { LogEvent } from './models/LogEvent';
import { ProfileMapping } from './models/ProfileMapping';
import { UserSchema } from './models/UserSchema';
import { GroupSchema } from './models/GroupSchema';
import { LinkedObject } from './models/LinkedObject';
import { UserType } from './models/UserType';
import { OrgSetting } from './models/OrgSetting';
import { OrgSettingOptions } from './models/OrgSetting';
import { OrgContactTypeObj } from './models/OrgContactTypeObj';
Expand All @@ -105,6 +83,7 @@ import { ThreatInsightConfiguration } from './models/ThreatInsightConfiguration'
import { ThreatInsightConfigurationOptions } from './models/ThreatInsightConfiguration';
import { TrustedOrigin } from './models/TrustedOrigin';
import { TrustedOriginOptions } from './models/TrustedOrigin';
import { User } from './models/User';
import { CreateUserRequestOptions } from './models/CreateUserRequest';
import { UserOptions } from './models/User';
import { AppLink } from './models/AppLink';
Expand All @@ -118,11 +97,14 @@ import { SecurityQuestion } from './models/SecurityQuestion';
import { ActivateFactorRequestOptions } from './models/ActivateFactorRequest';
import { VerifyUserFactorResponse } from './models/VerifyUserFactorResponse';
import { VerifyFactorRequestOptions } from './models/VerifyFactorRequest';
import { Group } from './models/Group';
import { UserActivationToken } from './models/UserActivationToken';
import { TempPassword } from './models/TempPassword';
import { ResetPasswordToken } from './models/ResetPasswordToken';
import { ResponseLinks } from './models/ResponseLinks';
import { Role } from './models/Role';
import { AssignRoleRequestOptions } from './models/AssignRoleRequest';
import { CatalogApplication } from './models/CatalogApplication';
import { NetworkZone } from './models/NetworkZone';
import { NetworkZoneOptions } from './models/NetworkZone';

Expand Down Expand Up @@ -308,14 +290,14 @@ export declare class GeneratedApiClient {
getDomain(domainId: string): Promise<v3.Domain>;
createCertificate(domainId: string, domainCertificate: v3.DomainCertificate): Promise<void>;
verifyDomain(domainId: string): Promise<v3.Domain>;
listEventHooks(): Collection<EventHook>;
createEventHook(eventHook: EventHookOptions): Promise<EventHook>;
deleteEventHook(eventHookId: string): Promise<Response>;
getEventHook(eventHookId: string): Promise<EventHook>;
updateEventHook(eventHookId: string, eventHook: EventHookOptions): Promise<EventHook>;
activateEventHook(eventHookId: string): Promise<EventHook>;
deactivateEventHook(eventHookId: string): Promise<EventHook>;
verifyEventHook(eventHookId: string): Promise<EventHook>;
listEventHooks(): Promise<Collection<v3.EventHook>>;
createEventHook(eventHook: v3.EventHook): Promise<v3.EventHook>;
deleteEventHook(eventHookId: string): Promise<void>;
getEventHook(eventHookId: string): Promise<v3.EventHook>;
updateEventHook(eventHookId: string, eventHook: v3.EventHook): Promise<v3.EventHook>;
activateEventHook(eventHookId: string): Promise<v3.EventHook>;
deactivateEventHook(eventHookId: string): Promise<v3.EventHook>;
verifyEventHook(eventHookId: string): Promise<v3.EventHook>;
listFeatures(): Promise<Collection<v3.Feature>>;
getFeature(featureId: string): Promise<v3.Feature>;
listFeatureDependencies(featureId: string): Promise<Collection<v3.Feature>>;
Expand Down
10 changes: 10 additions & 0 deletions templates/helpers/operation-v3.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,16 @@ const V3ApiOperations = {
'removeUserFromGroup',
'updateGroup',
'updateGroupRule',
],
EventHookApi: [
'activateEventHook',
'createEventHook',
'deactivateEventHook',
'deleteEventHook',
'getEventHook',
'listEventHooks',
'updateEventHook',
'verifyEventHook',
]
};

Expand Down
6 changes: 5 additions & 1 deletion templates/helpers/operation.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,11 @@ const typeScriptClientImportBuilder = operations => {
const [args, returnType] = getOperationArgumentsAndReturnType(operation, { tagV3Methods: true });
const typeNames = convertTypeObjectsToTypeNames(args, returnType);
const importableTypes = typeNames.filter(isImportableType);
return acc.concat(importableTypes);
if (!isV3Api(operation.operationId)) {
return acc.concat(importableTypes);
} else {
return acc;
}
}, []);

const uniqueImportTypes = new Set([...operationsImportTypes]);
Expand Down
Loading

0 comments on commit c046df2

Please sign in to comment.