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 Policy API #349

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const {
IdentityProviderApi,
SessionApi,
TemplateApi,
PolicyApi,
} = require('./generated');
const { createConfiguration } = require('./generated/configuration');
const { ServerConfiguration } = require('./generated/servers');
Expand Down Expand Up @@ -143,6 +144,7 @@ class Client extends GeneratedApiClient {
this.identityProviderApi = new IdentityProviderApi(configuration);
this.sessionApi = new SessionApi(configuration);
this.templateApi = new TemplateApi(configuration);
this.policyApi = new PolicyApi(configuration);
}
}

Expand Down
225 changes: 30 additions & 195 deletions src/generated-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ const qs = require('querystring');

const { Collection } = require('./collection');
const models = require('./models');
const factories = require('./factories');
const { ModelFactory } = require('./model-factory');

/**
Expand Down Expand Up @@ -4322,16 +4321,15 @@ class GeneratedApiClient {
if (!queryParameters) {
return Promise.reject(new Error('OKTA API listPolicies parameter queryParameters is required.'));
}
let url = `${this.baseUrl}/api/v1/policies`;
const queryString = qs.stringify(queryParameters || {});

url += queryString ? ('?' + queryString) : '';

return new Collection(
this.http,
url,
new factories.Policy(this),
);
let type;
let status;
let expand;
if (queryParameters) {
type = queryParameters.type;
status = queryParameters.status;
expand = queryParameters.expand;
}
return this.policyApi.listPolicies(type, status, expand);
}

/**
Expand All @@ -4347,21 +4345,11 @@ class GeneratedApiClient {
if (!policy) {
return Promise.reject(new Error('OKTA API createPolicy parameter policy is required.'));
}
let url = `${this.baseUrl}/api/v1/policies`;
const queryString = qs.stringify(queryParameters || {});

url += queryString ? ('?' + queryString) : '';

const resources = [];

const request = this.http.postJson(
url,
{
body: policy
},
{ resources }
);
return request.then(jsonRes => new factories.Policy(this).createInstance(jsonRes));
let activate;
if (queryParameters) {
activate = queryParameters.activate;
}
return this.policyApi.createPolicy(policy, activate);
}

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

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

const request = this.http.delete(
url,
null,
{ resources }
);
return request;
return this.policyApi.deletePolicy(policyId);
}

/**
Expand All @@ -4401,21 +4378,11 @@ class GeneratedApiClient {
if (!policyId) {
return Promise.reject(new Error('OKTA API getPolicy parameter policyId is required.'));
}
let url = `${this.baseUrl}/api/v1/policies/${policyId}`;
const queryString = qs.stringify(queryParameters || {});

url += queryString ? ('?' + queryString) : '';

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

const request = this.http.getJson(
url,
null,
{ resources }
);
return request.then(jsonRes => new factories.Policy(this).createInstance(jsonRes));
let expand;
if (queryParameters) {
expand = queryParameters.expand;
}
return this.policyApi.getPolicy(policyId, expand);
}

/**
Expand All @@ -4433,20 +4400,7 @@ class GeneratedApiClient {
if (!policy) {
return Promise.reject(new Error('OKTA API updatePolicy parameter policy is required.'));
}
let url = `${this.baseUrl}/api/v1/policies/${policyId}`;

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

const request = this.http.putJson(
url,
{
body: policy
},
{ resources }
);
return request.then(jsonRes => new factories.Policy(this).createInstance(jsonRes));
return this.policyApi.updatePolicy(policyId, policy);
}

/**
Expand All @@ -4459,22 +4413,7 @@ class GeneratedApiClient {
if (!policyId) {
return Promise.reject(new Error('OKTA API activatePolicy parameter policyId is required.'));
}
let url = `${this.baseUrl}/api/v1/policies/${policyId}/lifecycle/activate`;

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

const request = this.http.post(
url,
{
headers: {
'Content-Type': 'application/json', 'Accept': 'application/json',
},
},
{ resources }
);
return request;
return this.policyApi.activatePolicy(policyId);
}

/**
Expand All @@ -4487,22 +4426,7 @@ class GeneratedApiClient {
if (!policyId) {
return Promise.reject(new Error('OKTA API deactivatePolicy parameter policyId is required.'));
}
let url = `${this.baseUrl}/api/v1/policies/${policyId}/lifecycle/deactivate`;

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

const request = this.http.post(
url,
{
headers: {
'Content-Type': 'application/json', 'Accept': 'application/json',
},
},
{ resources }
);
return request;
return this.policyApi.deactivatePolicy(policyId);
}

/**
Expand All @@ -4516,13 +4440,7 @@ class GeneratedApiClient {
if (!policyId) {
return Promise.reject(new Error('OKTA API listPolicyRules parameter policyId is required.'));
}
let url = `${this.baseUrl}/api/v1/policies/${policyId}/rules`;

return new Collection(
this.http,
url,
new factories.PolicyRule(this),
);
return this.policyApi.listPolicyRules(policyId);
}

/**
Expand All @@ -4540,20 +4458,7 @@ class GeneratedApiClient {
if (!policyRule) {
return Promise.reject(new Error('OKTA API createPolicyRule parameter policyRule is required.'));
}
let url = `${this.baseUrl}/api/v1/policies/${policyId}/rules`;

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

const request = this.http.postJson(
url,
{
body: policyRule
},
{ resources }
);
return request.then(jsonRes => new factories.PolicyRule(this).createInstance(jsonRes));
return this.policyApi.createPolicyRule(policyId, policyRule);
}

/**
Expand All @@ -4570,19 +4475,7 @@ class GeneratedApiClient {
if (!ruleId) {
return Promise.reject(new Error('OKTA API deletePolicyRule parameter ruleId is required.'));
}
let url = `${this.baseUrl}/api/v1/policies/${policyId}/rules/${ruleId}`;

const resources = [
`${this.baseUrl}/api/v1/policies/${policyId}/rules/${ruleId}`,
`${this.baseUrl}/api/v1/policies/${policyId}`
];

const request = this.http.delete(
url,
null,
{ resources }
);
return request;
return this.policyApi.deletePolicyRule(policyId, ruleId);
}

/**
Expand All @@ -4600,19 +4493,7 @@ class GeneratedApiClient {
if (!ruleId) {
return Promise.reject(new Error('OKTA API getPolicyRule parameter ruleId is required.'));
}
let url = `${this.baseUrl}/api/v1/policies/${policyId}/rules/${ruleId}`;

const resources = [
`${this.baseUrl}/api/v1/policies/${policyId}/rules/${ruleId}`,
`${this.baseUrl}/api/v1/policies/${policyId}`
];

const request = this.http.getJson(
url,
null,
{ resources }
);
return request.then(jsonRes => new factories.PolicyRule(this).createInstance(jsonRes));
return this.policyApi.getPolicyRule(policyId, ruleId);
}

/**
Expand All @@ -4634,21 +4515,7 @@ class GeneratedApiClient {
if (!policyRule) {
return Promise.reject(new Error('OKTA API updatePolicyRule parameter policyRule is required.'));
}
let url = `${this.baseUrl}/api/v1/policies/${policyId}/rules/${ruleId}`;

const resources = [
`${this.baseUrl}/api/v1/policies/${policyId}/rules/${ruleId}`,
`${this.baseUrl}/api/v1/policies/${policyId}`
];

const request = this.http.putJson(
url,
{
body: policyRule
},
{ resources }
);
return request.then(jsonRes => new factories.PolicyRule(this).createInstance(jsonRes));
return this.policyApi.updatePolicyRule(policyId, ruleId, policyRule);
}

/**
Expand All @@ -4665,23 +4532,7 @@ class GeneratedApiClient {
if (!ruleId) {
return Promise.reject(new Error('OKTA API activatePolicyRule parameter ruleId is required.'));
}
let url = `${this.baseUrl}/api/v1/policies/${policyId}/rules/${ruleId}/lifecycle/activate`;

const resources = [
`${this.baseUrl}/api/v1/policies/${policyId}/rules/${ruleId}`,
`${this.baseUrl}/api/v1/policies/${policyId}`
];

const request = this.http.post(
url,
{
headers: {
'Content-Type': 'application/json', 'Accept': 'application/json',
},
},
{ resources }
);
return request;
return this.policyApi.activatePolicyRule(policyId, ruleId);
}

/**
Expand All @@ -4698,23 +4549,7 @@ class GeneratedApiClient {
if (!ruleId) {
return Promise.reject(new Error('OKTA API deactivatePolicyRule parameter ruleId is required.'));
}
let url = `${this.baseUrl}/api/v1/policies/${policyId}/rules/${ruleId}/lifecycle/deactivate`;

const resources = [
`${this.baseUrl}/api/v1/policies/${policyId}/rules/${ruleId}`,
`${this.baseUrl}/api/v1/policies/${policyId}`
];

const request = this.http.post(
url,
{
headers: {
'Content-Type': 'application/json', 'Accept': 'application/json',
},
},
{ resources }
);
return request;
return this.policyApi.deactivatePolicyRule(policyId, ruleId);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/generated/apis/PolicyApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ class PolicyApiResponseProcessor {
*/
async activatePolicyRule(response) {
const contentType = ObjectSerializer_1.ObjectSerializer.normalizeMediaType(response.headers['content-type']);
if ((0, util_1.isCodeInRange)('200', response.httpStatusCode)) {
if ((0, util_1.isCodeInRange)('204', response.httpStatusCode)) {
return;
}
if ((0, util_1.isCodeInRange)('403', response.httpStatusCode)) {
Expand Down Expand Up @@ -899,7 +899,7 @@ class PolicyApiResponseProcessor {
*/
async deletePolicy(response) {
const contentType = ObjectSerializer_1.ObjectSerializer.normalizeMediaType(response.headers['content-type']);
if ((0, util_1.isCodeInRange)('200', response.httpStatusCode)) {
if ((0, util_1.isCodeInRange)('204', response.httpStatusCode)) {
return;
}
if ((0, util_1.isCodeInRange)('403', response.httpStatusCode)) {
Expand Down
Loading