Skip to content

Commit

Permalink
Integrate Authenticator API into v2 Client (#311)
Browse files Browse the repository at this point in the history
integrate Authenticator API into v2 client
  • Loading branch information
oleksandrpravosudko-okta committed May 30, 2022
1 parent b305cf4 commit 946eccd
Show file tree
Hide file tree
Showing 56 changed files with 2,055 additions and 199 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ src/v3/.swagger-codegen-ignore
src/v3/git_push.sh
src/v3/README.md
src/v3/tsconfig.json
src/v3/package.json

src/types/v3/.swagger-codegen/
src/types/v3/.gitignore
src/types/v3/.npmignore
src/types/v3/.swagger-codegen-ignore
src/types/v3/git_push.sh
src/types/v3/README.md
src/types/v3/tsconfig.json
src/types/v3/tsconfig.json
src/types/v3/package.json
4 changes: 4 additions & 0 deletions src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ const DEFAULT_USER_AGENT = `${packageJson.name}/${packageJson.version} node/${pr
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');



/**
Expand Down Expand Up @@ -91,6 +93,8 @@ class Client extends GeneratedApiClient {
this.http.defaultHeaders['User-Agent'] = parsedConfig.client.userAgent ? parsedConfig.client.userAgent + ' ' + DEFAULT_USER_AGENT : DEFAULT_USER_AGENT;

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

}
}

Expand Down
13 changes: 13 additions & 0 deletions src/configuration.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,15 @@
/*!
* Copyright (c) 2017-present, Okta, Inc. and/or its affiliates. All rights reserved.
* The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
*
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
* See the License for the specific language governing permissions and limitations under the License.
*/


// no js code for V2Configuration, it is only used as a type in TypeScript modules
module.exports = {};
62 changes: 5 additions & 57 deletions src/generated-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -1413,13 +1413,7 @@ class GeneratedApiClient {
* @returns {Collection} A collection that will yield {@link Authenticator} instances.
*/
listAuthenticators() {
let url = `${this.baseUrl}/api/v1/authenticators`;

return new Collection(
this,
url,
new ModelFactory(models.Authenticator),
);
return this.authenticatorApi.listAuthenticators();
}

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

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

const request = this.http.getJson(
url,
null,
{ resources }
);
return request.then(jsonRes => new models.Authenticator(jsonRes, this));
return this.authenticatorApi.getAuthenticator(authenticatorId);
}

/**
Expand All @@ -1462,20 +1445,7 @@ class GeneratedApiClient {
if (!authenticator) {
return Promise.reject(new Error('OKTA API updateAuthenticator parameter authenticator is required.'));
}
let url = `${this.baseUrl}/api/v1/authenticators/${authenticatorId}`;

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

const request = this.http.putJson(
url,
{
body: authenticator
},
{ resources }
);
return request.then(jsonRes => new models.Authenticator(jsonRes, this));
return this.authenticatorApi.updateAuthenticator(authenticator, authenticatorId);
}

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

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

const request = this.http.postJson(
url,
null,
{ resources }
);
return request.then(jsonRes => new models.Authenticator(jsonRes, this));
return this.authenticatorApi.activateAuthenticator(authenticatorId);
}

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

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

const request = this.http.postJson(
url,
null,
{ resources }
);
return request.then(jsonRes => new models.Authenticator(jsonRes, this));
return this.authenticatorApi.deactivateAuthenticator(authenticatorId);
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/types/client.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { Http } from './http';
import { RequestExecutor } from './request-executor';
import { V2Configuration } from './configuration';
import { UserTypeApi } from './v3/apis/user-type-api';
import { AuthenticatorApi } from './v3/apis/authenticator-api';

export declare class Client extends ParameterizedOperationsClient {
constructor(config?: {
Expand Down Expand Up @@ -44,4 +45,5 @@ export declare class Client extends ParameterizedOperationsClient {
http: Http;

userTypeApi: UserTypeApi;
authenticatorApi: AuthenticatorApi;
}
13 changes: 13 additions & 0 deletions src/types/configuration.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
/*!
* Copyright (c) 2017-present, Okta, Inc. and/or its affiliates. All rights reserved.
* The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
*
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
* See the License for the specific language governing permissions and limitations under the License.
*/


import { CacheStorage } from './memory-store.d';
import { defaultCacheMiddleware } from './default-cache-middleware';
import { RequestExecutor } from './request-executor';
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 @@ -32,7 +32,7 @@ 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 { Authenticator } from './v3/models';
import { AuthenticatorOptions } from './models/Authenticator';
import { AuthorizationServer } from './models/AuthorizationServer';
import { AuthorizationServerOptions } from './models/AuthorizationServer';
Expand Down Expand Up @@ -91,7 +91,7 @@ import { GroupSchema } from './models/GroupSchema';
import { GroupSchemaOptions } from './models/GroupSchema';
import { LinkedObject } from './models/LinkedObject';
import { LinkedObjectOptions } from './models/LinkedObject';
import { UserType } from './models/UserType';
import { UserType } from './v3/models';
import { UserTypeOptions } from './models/UserType';
import { OrgSetting } from './models/OrgSetting';
import { OrgSettingOptions } from './models/OrgSetting';
Expand Down
11 changes: 11 additions & 0 deletions src/types/v3/api.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
/**
* Copyright (c) 2022-present, Okta, Inc. and/or its affiliates. All rights reserved.
* The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
*
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
* See the License for the specific language governing permissions and limitations under the License.
*
* Okta API
* Allows customers to easily access the Okta API
*
Expand All @@ -9,4 +19,5 @@
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
export * from './apis/authenticator-api';
export * from './apis/user-type-api';
Loading

0 comments on commit 946eccd

Please sign in to comment.