0.14.1 • Published 5 months ago

@resolution/organizations-api-client v0.14.1

Weekly downloads
-
License
MIT
Repository
bitbucket
Last release
5 months ago

Atlassian Organizations API Client

TypeScript/JavaScript client for the Atlassian Organizations API, generated from the Atlassian OpenAPI schema.

Installation

npm install @resolution/organizations-api-client

or

yarn add @resolution/organizations-api-client

Usage

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 management
  • domains - Domain management
  • events - Event management
  • groups - Group management
  • orgs - Organization management
  • policies - Policy management
  • users - User management
  • validate - Validation
  • workspaces - 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

0.14.1

5 months ago

0.14.0

6 months ago