0.14.1 • Published 5 months ago
@resolution/organizations-api-client v0.14.1
Atlassian Organizations API Client
TypeScript/JavaScript client for the Atlassian Organizations API, generated from the Atlassian OpenAPI schema.
Installation
npm install @resolution/organizations-api-clientor
yarn add @resolution/organizations-api-clientUsage
import { OrganizationsApiClient } from '@resolution/organizations-api-client';
// Initialize the client with your API key
const organizationsClient = new OrganizationsApiClient({
apiKey: 'your-api-key-here'
});
// Example: Get organizations
async function getOrganizations() {
try {
const response = await organizationsClient.orgs.getOrgs();
console.log('Organizations:', response.data);
} catch (error) {
console.error('Error fetching organizations:', error);
}
}Authentication
This client only supports API key authentication. You need to provide an API key when initializing the client:
const client = new OrganizationsApiClient({
apiKey: 'your-api-key-here'
});Available Services
The client provides access to the following services:
directory- Directory managementdomains- Domain managementevents- Event managementgroups- Group managementorgs- Organization managementpolicies- Policy managementusers- User managementvalidate- Validationworkspaces- Workspace management
Error Handling
The client uses the ApiError class for error handling:
import { OrganizationsApiClient, ApiError } from '@resolution/organizations-api-client';
const organizationsClient = new OrganizationsApiClient({
apiKey: 'your-api-key-here'
});
try {
await organizationsClient.orgs.getOrgs();
} catch (error) {
if (error instanceof ApiError) {
console.error('API Error:', error.message);
console.error('Status:', error.statusCode);
console.error('Details:', error.details);
} else {
console.error('Unknown error:', error);
}
}Advanced Configuration
You can customize client behavior with additional options:
const client = new OrganizationsApiClient({
apiKey: 'your-api-key-here',
// Custom validation error handler
handleValidationError: (error) => {
console.error('Validation error:', error);
},
// Custom deprecation warning logger
logDeprecationWarning: ({ operationName, path, method }) => {
console.warn(`Deprecated operation used: ${operationName} (${method} ${path})`);
},
// Custom retry logic
shouldRetryOnError: (error, attemptNumber) => {
return attemptNumber < 3 && (error.statusCode === 429 || error.statusCode >= 500);
}
});License
MIT