atlassian_apis 0.1.1 atlassian_apis: ^0.1.1 copied to clipboard
A client to access the Atlassian REST APIs (Jira Cloud platform, Service Desk, Confluence)
A client for the Atlassian REST APIs in Dart #
This is a Dart client for the APIs of:
All the client are generated from the OpenAPI definition files provided by Atlassian See Atlassian documentation of the APIs
Usage #
Authentication #
import 'dart:io';
import 'package:atlassian_apis/jira_platform.dart';
import 'package:atlassian_apis/service_management.dart';
void main() async {
// This example uses API Token authentication.
// Alternatively, you can use OAuth1 with RSA.
var user = Platform.environment['ATLASSIAN_USER']!;
var apiToken = Platform.environment['ATLASSIAN_API_TOKEN']!;
// Create an authenticated http client.
var client = ApiClient.basicAuthentication(
Uri.https('<your-account>.atlassian.net', ''),
user: user,
apiToken: apiToken);
// Create the API wrapper from the http client
var jira = JiraPlatformApi(client);
// Communicate with the APIs..
await jira.projects.searchProjects();
// Close the client to quickly terminate the process
client.close();
}
Jira #
import 'dart:convert';
import 'package:atlassian_apis/jira_platform.dart';
import 'package:atlassian_apis/service_management.dart';
void main() async {
// Create Jira API from an authenticated client
var jira = JiraPlatformApi(apiClient);
// Create a comment
var info = await jira.issueComments
.addComment(issueIdOrKey: 'BR-123', body: Comment(body: 'A comment'));
printJson(info);
}
Service desk #
import 'dart:convert';
import 'dart:io';
import 'package:atlassian_apis/service_management.dart';
import 'package:http/http.dart';
void main() async {
// Create the API for Service Desk
var serviceManagement = ServiceManagementApi(apiClient);
// Fetch some data
var desks = await serviceManagement.servicedesk.getServiceDesks();
printJson(desks);
// Create a new customer
var newCustomer = await serviceManagement.customer
.createCustomer(body: CustomerCreateDTO(email: '..', displayName: '...'));
printJson(newCustomer);
// Upload a file
var file = File('some_file.png');
var attachment = await serviceManagement.servicedesk.attachTemporaryFile(
serviceDeskId: 1,
file: MultipartFile('file', file.openRead(), file.lengthSync()));
// Create a new customer request with attachment
await serviceManagement.request.createCustomerRequest(
body: RequestCreateDTO(requestFieldValues: {
'summary': 'The issue summary',
'attachment': attachment.temporaryAttachments.map((e) => {'id': e}).toList()
}));
}