Adaptavist Managed API for GitHub
npm install @managed-api/github-coreThis is a runtime agnostic version of the Managed API (with core suffix) that makes it easy to port it to any runtime you may want to use this Managed API on.
You can do so by extending the *Core Managed API class where you'll be asked to provide implementation for getPlatformImplementation function. In this implementation you have to specify how to perform buffer encoding/decoding operations and how to perform HTTP calls:
``typescript`
{
buffer: {
encode(input: string): ArrayBuffer;
decode(input: ArrayBuffer): string;
},
performHttpCall(request: Request): Promise
}
Here is an example how to create a Node port of the Managed API:
`typescript
import { GitHubApiCore } from "@managed-api/github-core";
import { PlatformImplementation, Request, Response, Headers } from "@managed-api/commons-core";
import fetch from "node-fetch";
export class GitHubApi extends GitHubApiCore {
constructor(private baseUrl: string, private authToken: string) {
super();
}
protected getPlatformImplementation(): PlatformImplementation {
return {
buffer: {
encode: (input) => Buffer.from(input, 'utf-8'),
decode: (input) => Buffer.from(input).toString('utf-8')
},
performHttpCall: (request) => this.performHttpCall(request)
};
}
private async performHttpCall(request: Request): Promise
const requestUrl = ${this.baseUrl}${request.url}; // Substitute base URLBasic ${this.authToken}
request.headers.set('Authorization', ); // Substitute auth token
const response = await fetch(requestUrl, {
method: request.method,
headers: request.headers as any,
body: request.method.toLowerCase() !== 'get' ? Buffer.from((await request.arrayBuffer()) ?? new ArrayBuffer(0)) : undefined
});
const apiHeaders = new Headers();
response.headers.forEach((value, key) => apiHeaders.append(key, value));
const body = await response.arrayBuffer();
return super.buildResponse(response.url, response.status, response.statusText, apiHeaders, body);
}
}
`
Please note that the authentication handling details may not be accurate and serve as an example. If you wish to use these Managed APIs without having to concern yourself how to deal with and secure authentication details when working with APIs, then feel free to evaluate ScriptRunner Connect platform.
# Changelog
- Removed non-empty body from HEAD requests.
- # Breaking change: URL and query string parameters are now URL encoded, meaning if you encoded them explicitly before you have to remove your own encoding, otherwise they will get double encoded.
- * Updated OpenApi Specification.
- * Fields sort and order are deprecated in Search.searchCode.
* List organization members that can be used as Organization.Member.getMembers or All.getOrganizationMembers.
* Check organization membership for a user that can be used as Organization.Member.checkMembershipForUser or All.checkOrganizationMembershipForUser.
* Remove an organization member that can be used as Organization.Member.removeMember or All.removeOrganizationMember.
* Get organization membership for a user that can be used as Organization.Member.getMembershipForUser or All.getOrganizationMembershipForUser.
* Set organization membership for a user that can be used as Organization.Member.setMembershipForUser or All.setOrganizationMembershipForUser.
* Remove organization membership for a user that can be used as Organization.Member.removeMembershipForUser or All.removeOrganzationMembershipForUser.
* List organization memberships for the authenticated user that can be used as Organization.Member.getMembershipsForAuthenticatedUser or All.getOrganizationMembershipsForAuthenticatedUser.
* Get an organization membership for the authenticated user that can be used as Organization.Member.getMembershipForAuthenticatedUser or All.getOrganizationMembershipForAuthenticatedUser.
* Update an organization membership for the authenticated user that can be used as Organization.Member.updateMembershipForAuthenticatedUser or All.updateOrganizationMembershipForAuthenticatedUser.
* List organizations that can be used as Organization.getOrganizations or All.getOrganizations.
* Get an organization that can be used as Organization.getOrganization or All.getOrganization.
* Update an organization that can be used as Organization.updateOrganization or All.updateOrganization.
* Get the audit log for an organization that can be used as Organization.getAuditLog or All.getAuditLogForOrganization.
* List app installations for an organization that can be used as Organization.getInstallations or All.getInstallationsForOrganization.
* List organizations for the authenticated user that can be used as Organization.getOrganizationsForAuthenticatedUser or All.getOrganizationsForAuthenticatedUser.
* List organizations for a user that can be used as Organization.getOrganizationsForUser or All.getOrganizationsForUser.
* Search code that can be used as Search.searchCode or All.searchCode.
* Search commits that can be used as Search.searchCommits or All.searchCommits.
* Search issues and pull requests that can be used as Search.searchIssuesAndPullRequests or All.searchIssuesAndPullRequests.
* Search labels that can be used as Search.searchLabels or All.searchLabels.
* Search repositories that can be used as Search.searchRepositories or All.searchRepositories.
* Search topics that can be used as Search.searchTopics or All.searchTopics.
* Search users that can be used as Search.searchUsers or All.searchUsers.
* List releases that can be used as Release.getReleases or All.getReleases.
* Create a release that can be used as Release.createRelease or All.createRelease.
* Generate release notes content for a release that can be used as Release.generateReleaseNotes or All.generateReleaseNotes.
* Get the latest release that can be used as Release.getLatestRelease or All.getLatestRelease.
* Get a release by tag name that can be used as Release.getReleaseByTagName or All.getReleaseByTagName.
* Get a release that can be used as Release.getRelease or All.getRelease.
* Update a release that can be used as Release.updateRelease or All.updateRelease.
* Delete a release that can be used as Release.deleteRelease or All.deleteRelease.
* List users blocked by the authenticated user that can be used as User.Block.getBlockedUsersByAuthenticatedUser or All.getBlockedUsersByAuthenticatedUser.
* Check if a user is blocked by the authenticated user that can be used as User.Block.checkIfUserIsBlockedByAuthenticatedUser or All.checkIfUserIsBlockedByAuthenticatedUser.
* Block a user that can be used as User.Block.blockUser or All.blockUser.
* Unblock a user that can be used as User.Block.unblockUser or All.unblockUser.
* Get the authenticated user that can be used as User.getAuthenticatedUser or All.getAuthenticatedUser.
* Update the authenticated user that can be used as User.updateAuthenticatedUser or All.updateAuthenticatedUser.
* List users that can be used as User.getUsers or All.getUsers.
* Get a user that can be used as User.getUser or All.getUser.
* Get contextual information for a user that can be used as User.getUserContext or All.getUserContext.
* Delete a file that can be used as Repository.Content.deleteFile or All.deleteFile.
* Get a repository README that can be used as Repository.Content.getRepositoryReadme or All.getRepositoryReadme.
* Get a repository README for a directory that can be used as Repository.Content.getRepositoryReadmeForDirectory or All.getRepositoryReadmeForDirectory.
* Get branch protection that can be used as Branch.Protection.getProtection or All.getBranchProtection.
* Update branch protection that can be used as Branch.Protection.updateProtection or All.updateBranchProtection.
* Delete branch protection that can be used as Branch.Protection.deleteProtection or All.deleteBranchProtection.
* Get admin branch protection that can be used as Branch.Protection.Admin.getProtection or All.getAdminBranchProtection.
* Set admin branch protection that can be used as Branch.Protection.Admin.setProtection or All.setAdminBranchProtection.
* Delete admin branch protection that can be used as Branch.Protection.Admin.deleteProtection or All.deleteAdminBranchProtection.
* Get pull request review protection that can be used as Branch.Protection.Pull.Review.getProtection or All.getBranchPullRequestReviewProtection.
* Update pull request review protection that can be used as Branch.Protection.Pull.Review.updateProtection or All.updateBranchPullRequestReviewProtection.
* Get commit signature protection that can be used as Branch.Protection.Commit.Signature.getProtection or All.getBranchCommitSignatureProtection.
* Create commit signature protection that can be used as Branch.Protection.Commit.Signature.createProtection or All.createBranchCommitSignatureProtection.
* Delete commit signature protection that can be used as Branch.Protection.Commit.Signature.deleteProtection or All.deleteBranchCommitSignatureProtection.
* Get status checks protection that can be used as Branch.Protection.Status.Check.getProtection or All.getBranchStatusCheckProtection.
* Update status checks protection that can be used as Branch.Protection.Status.Check.updateProtection or All.updateBranchStatusCheckProtection.
* Remove status checks protection that can be used as Branch.Protection.Status.Check.removeProtection or All.removeBranchStatusCheckProtection.
* Get all status check contexts that can be used as Branch.Protection.Status.Check.getContexts or All.getBranchStatusCheckContexts.
* Add status check contexts that can be used as Branch.Protection.Status.Check.addContexts or All.addBranchStatusCheckContexts.
* Set status check contexts that can be used as Branch.Protection.Status.Check.setContexts or All.setBranchStatusCheckContexts.
* List organization projects that can be used as Project.getOrganizationProjects or All.getOrganizationProjects.
* Create an organization project that can be used as Project.createOrganizationProject or All.createOrganizationProject.
* Get a project that can be used as Project.getProject or All.getProject.
* Update a project that can be used as Project.updateProject or All.updateProject.
* Delete a project that can be used as Project.deleteProject or All.deleteProject.
* List repository projects that can be used as Project.getRepositoryProjects or All.getRepositoryProjects.
* Create a repository project that can be used as Project.createRepositoryProject or All.createRepositoryProject.
* List user projects that can be used as Project.getUserProjects or All.getUserProjects.
* Create a user project that can be used as Project.createUserProject or All.createUserProject.
* Search code that can be used as Search.searchCode or All.searchCode.
* Search commits that can be used as Search.searchCommits or All.searchCommits.
* Search issues and pull requests that can be used as Search.searchIssuesAndPullRequests or All.searchIssuesAndPullRequests.
* Search labels that can be used as Search.searchLabels or All.searchLabels.
* Search repositories that can be used as Search.searchRepositories or All.searchRepositories.
* Search topics that can be used as Search.searchTopics or All.searchTopics.
* Search users that can be used as Search.searchUsers or All.searchUsers`.
Copyright Adaptavist 2025 (c) All rights reserved