Détail du package

@aws-sdk/client-codecommit

aws1.4mApache-2.03.840.0

AWS SDK for JavaScript Codecommit Client for Node.js, Browser and React Native

readme

@aws-sdk/client-codecommit

Description

AWS SDK for JavaScript CodeCommit Client for Node.js, Browser and React Native.

<fullname>CodeCommit</fullname>

This is the CodeCommit API Reference. This reference provides descriptions of the operations and data types for CodeCommit API along with usage examples.

You can use the CodeCommit API to work with the following objects:

Repositories, by calling the following:

  • BatchGetRepositories, which returns information about one or more repositories associated with your Amazon Web Services account.

  • CreateRepository, which creates an CodeCommit repository.

  • DeleteRepository, which deletes an CodeCommit repository.

  • GetRepository, which returns information about a specified repository.

  • ListRepositories, which lists all CodeCommit repositories associated with your Amazon Web Services account.

  • UpdateRepositoryDescription, which sets or updates the description of the repository.

  • UpdateRepositoryEncryptionKey, which updates the Key Management Service encryption key used to encrypt and decrypt a repository.

  • UpdateRepositoryName, which changes the name of the repository. If you change the name of a repository, no other users of that repository can access it until you send them the new HTTPS or SSH URL to use.

Branches, by calling the following:

  • CreateBranch, which creates a branch in a specified repository.

  • DeleteBranch, which deletes the specified branch in a repository unless it is the default branch.

  • GetBranch, which returns information about a specified branch.

  • ListBranches, which lists all branches for a specified repository.

  • UpdateDefaultBranch, which changes the default branch for a repository.

Files, by calling the following:

  • DeleteFile, which deletes the content of a specified file from a specified branch.

  • GetBlob, which returns the base-64 encoded content of an individual Git blob object in a repository.

  • GetFile, which returns the base-64 encoded content of a specified file.

  • GetFolder, which returns the contents of a specified folder or directory.

  • ListFileCommitHistory, which retrieves a list of commits and changes to a specified file.

  • PutFile, which adds or modifies a single file in a specified repository and branch.

Commits, by calling the following:

  • BatchGetCommits, which returns information about one or more commits in a repository.

  • CreateCommit, which creates a commit for changes to a repository.

  • GetCommit, which returns information about a commit, including commit messages and author and committer information.

  • GetDifferences, which returns information about the differences in a valid commit specifier (such as a branch, tag, HEAD, commit ID, or other fully qualified reference).

Merges, by calling the following:

  • BatchDescribeMergeConflicts, which returns information about conflicts in a merge between commits in a repository.

  • CreateUnreferencedMergeCommit, which creates an unreferenced commit between two branches or commits for the purpose of comparing them and identifying any potential conflicts.

  • DescribeMergeConflicts, which returns information about merge conflicts between the base, source, and destination versions of a file in a potential merge.

  • GetMergeCommit, which returns information about the merge between a source and destination commit.

  • GetMergeConflicts, which returns information about merge conflicts between the source and destination branch in a pull request.

  • GetMergeOptions, which returns information about the available merge options between two branches or commit specifiers.

  • MergeBranchesByFastForward, which merges two branches using the fast-forward merge option.

  • MergeBranchesBySquash, which merges two branches using the squash merge option.

  • MergeBranchesByThreeWay, which merges two branches using the three-way merge option.

Pull requests, by calling the following:

Approval rule templates, by calling the following:

Comments in a repository, by calling the following:

Tags used to tag resources in CodeCommit (not Git tags), by calling the following:

  • ListTagsForResource, which gets information about Amazon Web Servicestags for a specified Amazon Resource Name (ARN) in CodeCommit.

  • TagResource, which adds or updates tags for a resource in CodeCommit.

  • UntagResource, which removes tags for a resource in CodeCommit.

Triggers, by calling the following:

  • GetRepositoryTriggers, which returns information about triggers configured for a repository.

  • PutRepositoryTriggers, which replaces all triggers for a repository and can be used to create or delete triggers.

  • TestRepositoryTriggers, which tests the functionality of a repository trigger by sending data to the trigger target.

For information about how to use CodeCommit, see the CodeCommit User Guide.

Installing

To install this package, simply type add or install @aws-sdk/client-codecommit using your favorite package manager:

  • npm install @aws-sdk/client-codecommit
  • yarn add @aws-sdk/client-codecommit
  • pnpm add @aws-sdk/client-codecommit

Getting Started

Import

The AWS SDK is modulized by clients and commands. To send a request, you only need to import the CodeCommitClient and the commands you need, for example ListRepositoriesCommand:

// ES5 example
const { CodeCommitClient, ListRepositoriesCommand } = require("@aws-sdk/client-codecommit");
// ES6+ example
import { CodeCommitClient, ListRepositoriesCommand } from "@aws-sdk/client-codecommit";

Usage

To send a request, you:

  • Initiate client with configuration (e.g. credentials, region).
  • Initiate command with input parameters.
  • Call send operation on client with command object as input.
  • If you are using a custom http handler, you may call destroy() to close open connections.
// a client can be shared by different commands.
const client = new CodeCommitClient({ region: "REGION" });

const params = {
  /** input parameters */
};
const command = new ListRepositoriesCommand(params);

Async/await

We recommend using await operator to wait for the promise returned by send operation as follows:

// async/await.
try {
  const data = await client.send(command);
  // process data.
} catch (error) {
  // error handling.
} finally {
  // finally.
}

Async-await is clean, concise, intuitive, easy to debug and has better error handling as compared to using Promise chains or callbacks.

Promises

You can also use Promise chaining to execute send operation.

client.send(command).then(
  (data) => {
    // process data.
  },
  (error) => {
    // error handling.
  }
);

Promises can also be called using .catch() and .finally() as follows:

client
  .send(command)
  .then((data) => {
    // process data.
  })
  .catch((error) => {
    // error handling.
  })
  .finally(() => {
    // finally.
  });

Callbacks

We do not recommend using callbacks because of callback hell, but they are supported by the send operation.

// callbacks.
client.send(command, (err, data) => {
  // process err and data.
});

v2 compatible style

The client can also send requests using v2 compatible style. However, it results in a bigger bundle size and may be dropped in next major version. More details in the blog post on modular packages in AWS SDK for JavaScript

import * as AWS from "@aws-sdk/client-codecommit";
const client = new AWS.CodeCommit({ region: "REGION" });

// async/await.
try {
  const data = await client.listRepositories(params);
  // process data.
} catch (error) {
  // error handling.
}

// Promises.
client
  .listRepositories(params)
  .then((data) => {
    // process data.
  })
  .catch((error) => {
    // error handling.
  });

// callbacks.
client.listRepositories(params, (err, data) => {
  // process err and data.
});

Troubleshooting

When the service returns an exception, the error will include the exception information, as well as response metadata (e.g. request id).

try {
  const data = await client.send(command);
  // process data.
} catch (error) {
  const { requestId, cfId, extendedRequestId } = error.$metadata;
  console.log({ requestId, cfId, extendedRequestId });
  /**
   * The keys within exceptions are also parsed.
   * You can access them by specifying exception names:
   * if (error.name === 'SomeServiceException') {
   *     const value = error.specialKeyInException;
   * }
   */
}

Getting Help

Please use these community resources for getting help. We use the GitHub issues for tracking bugs and feature requests, but have limited bandwidth to address them.

To test your universal JavaScript code in Node.js, browser and react-native environments, visit our code samples repo.

Contributing

This client code is generated automatically. Any modifications will be overwritten the next time the @aws-sdk/client-codecommit package is updated. To contribute to client you can check our generate clients scripts.

License

This SDK is distributed under the Apache License, Version 2.0, see LICENSE for more information.

Client Commands (Operations List)

<summary> AssociateApprovalRuleTemplateWithRepository </summary> Command API Reference / Input / Output
<summary> BatchAssociateApprovalRuleTemplateWithRepositories </summary> Command API Reference / Input / Output
<summary> BatchDescribeMergeConflicts </summary> Command API Reference / Input / Output
<summary> BatchDisassociateApprovalRuleTemplateFromRepositories </summary> Command API Reference / Input / Output
<summary> BatchGetCommits </summary> Command API Reference / Input / Output
<summary> BatchGetRepositories </summary> Command API Reference / Input / Output
<summary> CreateApprovalRuleTemplate </summary> Command API Reference / Input / Output
<summary> CreateBranch </summary> Command API Reference / Input / Output
<summary> CreateCommit </summary> Command API Reference / Input / Output
<summary> CreatePullRequest </summary> Command API Reference / Input / Output
<summary> CreatePullRequestApprovalRule </summary> Command API Reference / Input / Output
<summary> CreateRepository </summary> Command API Reference / Input / Output
<summary> CreateUnreferencedMergeCommit </summary> Command API Reference / Input / Output
<summary> DeleteApprovalRuleTemplate </summary> Command API Reference / Input / Output
<summary> DeleteBranch </summary> Command API Reference / Input / Output
<summary> DeleteCommentContent </summary> Command API Reference / Input / Output
<summary> DeleteFile </summary> Command API Reference / Input / Output
<summary> DeletePullRequestApprovalRule </summary> Command API Reference / Input / Output
<summary> DeleteRepository </summary> Command API Reference / Input / Output
<summary> DescribeMergeConflicts </summary> Command API Reference / Input / Output
<summary> DescribePullRequestEvents </summary> Command API Reference / Input / Output
<summary> DisassociateApprovalRuleTemplateFromRepository </summary> Command API Reference / Input / Output
<summary> EvaluatePullRequestApprovalRules </summary> Command API Reference / Input / Output
<summary> GetApprovalRuleTemplate </summary> Command API Reference / Input / Output
<summary> GetBlob </summary> Command API Reference / Input / Output
<summary> GetBranch </summary> Command API Reference / Input / Output
<summary> GetComment </summary> Command API Reference / Input / Output
<summary> GetCommentReactions </summary> Command API Reference / Input / Output
<summary> GetCommentsForComparedCommit </summary> Command API Reference / Input / Output
<summary> GetCommentsForPullRequest </summary> Command API Reference / Input / Output
<summary> GetCommit </summary> Command API Reference / Input / Output
<summary> GetDifferences </summary> Command API Reference / Input / Output
<summary> GetFile </summary> Command API Reference / Input / Output
<summary> GetFolder </summary> Command API Reference / Input / Output
<summary> GetMergeCommit </summary> Command API Reference / Input / Output
<summary> GetMergeConflicts </summary> Command API Reference / Input / Output
<summary> GetMergeOptions </summary> Command API Reference / Input / Output
<summary> GetPullRequest </summary> Command API Reference / Input / Output
<summary> GetPullRequestApprovalStates </summary> Command API Reference / Input / Output
<summary> GetPullRequestOverrideState </summary> Command API Reference / Input / Output
<summary> GetRepository </summary> Command API Reference / Input / Output
<summary> GetRepositoryTriggers </summary> Command API Reference / Input / Output
<summary> ListApprovalRuleTemplates </summary> Command API Reference / Input / Output
<summary> ListAssociatedApprovalRuleTemplatesForRepository </summary> Command API Reference / Input / Output
<summary> ListBranches </summary> Command API Reference / Input / Output
<summary> ListFileCommitHistory </summary> Command API Reference / Input / Output
<summary> ListPullRequests </summary> Command API Reference / Input / Output
<summary> ListRepositories </summary> Command API Reference / Input / Output
<summary> ListRepositoriesForApprovalRuleTemplate </summary> Command API Reference / Input / Output
<summary> ListTagsForResource </summary> Command API Reference / Input / Output
<summary> MergeBranchesByFastForward </summary> Command API Reference / Input / Output
<summary> MergeBranchesBySquash </summary> Command API Reference / Input / Output
<summary> MergeBranchesByThreeWay </summary> Command API Reference / Input / Output
<summary> MergePullRequestByFastForward </summary> Command API Reference / Input / Output
<summary> MergePullRequestBySquash </summary> Command API Reference / Input / Output
<summary> MergePullRequestByThreeWay </summary> Command API Reference / Input / Output
<summary> OverridePullRequestApprovalRules </summary> Command API Reference / Input / Output
<summary> PostCommentForComparedCommit </summary> Command API Reference / Input / Output
<summary> PostCommentForPullRequest </summary> Command API Reference / Input / Output
<summary> PostCommentReply </summary> Command API Reference / Input / Output
<summary> PutCommentReaction </summary> Command API Reference / Input / Output
<summary> PutFile </summary> Command API Reference / Input / Output
<summary> PutRepositoryTriggers </summary> Command API Reference / Input / Output
<summary> TagResource </summary> Command API Reference / Input / Output
<summary> TestRepositoryTriggers </summary> Command API Reference / Input / Output
<summary> UntagResource </summary> Command API Reference / Input / Output
<summary> UpdateApprovalRuleTemplateContent </summary> Command API Reference / Input / Output
<summary> UpdateApprovalRuleTemplateDescription </summary> Command API Reference / Input / Output
<summary> UpdateApprovalRuleTemplateName </summary> Command API Reference / Input / Output
<summary> UpdateComment </summary> Command API Reference / Input / Output
<summary> UpdateDefaultBranch </summary> Command API Reference / Input / Output
<summary> UpdatePullRequestApprovalRuleContent </summary> Command API Reference / Input / Output
<summary> UpdatePullRequestApprovalState </summary> Command API Reference / Input / Output
<summary> UpdatePullRequestDescription </summary> Command API Reference / Input / Output
<summary> UpdatePullRequestStatus </summary> Command API Reference / Input / Output
<summary> UpdatePullRequestTitle </summary> Command API Reference / Input / Output
<summary> UpdateRepositoryDescription </summary> Command API Reference / Input / Output
<summary> UpdateRepositoryEncryptionKey </summary> Command API Reference / Input / Output
<summary> UpdateRepositoryName </summary> Command API Reference / Input / Output