Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate Schema API into v2 Client #312

Merged
merged 8 commits into from
Mar 31, 2022
5 changes: 2 additions & 3 deletions src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ const { Http } = require('./http');
const DEFAULT_USER_AGENT = `${packageJson.name}/${packageJson.version} node/${process.versions.node} ${os.platform()}/${os.release()}`;
const repoUrl = 'https://github.com/okta/okta-sdk-nodejs';
const { OAuth } = require('./oauth');
const { UserTypeApi } = require('./v3/apis/user-type-api');
const { AuthenticatorApi } = require('./v3/apis/authenticator-api');
const { AuthenticatorApi, SchemaApi, UserTypeApi } = require('./v3/api');



Expand Down Expand Up @@ -94,7 +93,7 @@ class Client extends GeneratedApiClient {

this.userTypeApi = new UserTypeApi(config, parsedConfig.client.orgUrl, this.http);
this.authenticatorApi = new AuthenticatorApi(config, parsedConfig.client.orgUrl, this.http);

this.schemaApi = new SchemaApi(config, parsedConfig.client.orgUrl, this.http);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class Collection {
const item = self.currentItems.length && self.currentItems.shift();
const done = !self.currentItems.length && !self.nextUri && !item;
const result = {
value: item ? self.factory.createInstance(item, self.client) : null,
value: item ? (self.factory ? self.factory.createInstance(item, self.client) : item) : null,
done,
};
resolve(result);
Expand Down
80 changes: 6 additions & 74 deletions src/generated-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -5831,18 +5831,7 @@ class GeneratedApiClient {
if (!appInstanceId) {
return Promise.reject(new Error('OKTA API getApplicationUserSchema parameter appInstanceId is required.'));
}
let url = `${this.baseUrl}/api/v1/meta/schemas/apps/${appInstanceId}/default`;

const resources = [
`${this.baseUrl}/api/v1/meta/schemas/apps/${appInstanceId}`
];

const request = this.http.getJson(
url,
null,
{ resources }
);
return request.then(jsonRes => new models.UserSchema(jsonRes, this));
return this.schemaApi.getApplicationUserSchema(appInstanceId);
}

/**
Expand All @@ -5857,20 +5846,7 @@ class GeneratedApiClient {
if (!appInstanceId) {
return Promise.reject(new Error('OKTA API updateApplicationUserProfile parameter appInstanceId is required.'));
}
let url = `${this.baseUrl}/api/v1/meta/schemas/apps/${appInstanceId}/default`;

const resources = [
`${this.baseUrl}/api/v1/meta/schemas/apps/${appInstanceId}`
];

const request = this.http.postJson(
url,
{
body: userSchema
},
{ resources }
);
return request.then(jsonRes => new models.UserSchema(jsonRes, this));
return this.schemaApi.updateApplicationUserProfile(appInstanceId, userSchema);
}

/**
Expand All @@ -5880,16 +5856,7 @@ class GeneratedApiClient {
* @returns {Promise<GroupSchema>}
*/
getGroupSchema() {
let url = `${this.baseUrl}/api/v1/meta/schemas/group/default`;

const resources = [];

const request = this.http.getJson(
url,
null,
{ resources }
);
return request.then(jsonRes => new models.GroupSchema(jsonRes, this));
return this.schemaApi.getGroupSchema();
}

/**
Expand All @@ -5900,18 +5867,7 @@ class GeneratedApiClient {
* @returns {Promise<GroupSchema>}
*/
updateGroupSchema(groupSchema) {
let url = `${this.baseUrl}/api/v1/meta/schemas/group/default`;

const resources = [];

const request = this.http.postJson(
url,
{
body: groupSchema
},
{ resources }
);
return request.then(jsonRes => new models.GroupSchema(jsonRes, this));
return this.schemaApi.updateGroupSchema(groupSchema);
}

/**
Expand Down Expand Up @@ -6015,18 +5971,7 @@ class GeneratedApiClient {
if (!schemaId) {
return Promise.reject(new Error('OKTA API getUserSchema parameter schemaId is required.'));
}
let url = `${this.baseUrl}/api/v1/meta/schemas/user/${schemaId}`;

const resources = [
`${this.baseUrl}/api/v1/meta/schemas/user/${schemaId}`
];

const request = this.http.getJson(
url,
null,
{ resources }
);
return request.then(jsonRes => new models.UserSchema(jsonRes, this));
return this.schemaApi.getUserSchema(schemaId);
}

/**
Expand All @@ -6044,20 +5989,7 @@ class GeneratedApiClient {
if (!userSchema) {
return Promise.reject(new Error('OKTA API updateUserProfile parameter userSchema is required.'));
}
let url = `${this.baseUrl}/api/v1/meta/schemas/user/${schemaId}`;

const resources = [
`${this.baseUrl}/api/v1/meta/schemas/user/${schemaId}`
];

const request = this.http.postJson(
url,
{
body: userSchema
},
{ resources }
);
return request.then(jsonRes => new models.UserSchema(jsonRes, this));
return this.schemaApi.updateUserProfile(userSchema, schemaId);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/types/collection.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { ModelResolutionFactory } from './resolution-factory';
import { Client } from './client';

export declare class Collection<T> {
constructor(client: Client, uri: string, factory: ModelFactory | ModelResolutionFactory, request?: RequestOptions);
constructor(client: Client, uri: string, factory?: ModelFactory | ModelResolutionFactory, request?: RequestOptions);

nextUri: string;
client: Client;
Expand Down
4 changes: 2 additions & 2 deletions src/types/generated-client.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ import { InlineHookResponse } from './models/InlineHookResponse';
import { LogEvent } from './models/LogEvent';
import { ProfileMapping } from './models/ProfileMapping';
import { ProfileMappingOptions } from './models/ProfileMapping';
import { UserSchema } from './models/UserSchema';
import { UserSchema } from './v3/models';
import { UserSchemaOptions } from './models/UserSchema';
import { GroupSchema } from './models/GroupSchema';
import { GroupSchema } from './v3/models';
import { GroupSchemaOptions } from './models/GroupSchema';
import { LinkedObject } from './models/LinkedObject';
import { LinkedObjectOptions } from './models/LinkedObject';
Expand Down
Loading