包详细信息

@aws-sdk/client-codecommit

aws1.4mApache-2.03.835.0

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

自述文件

@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

更新日志

Change Log

All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.

3.6.0 (2021-02-20)

Bug Fixes

  • revert publish v3.5.1-0 (#2058) (af25697)
  • client-kinesis-video-signaling: remove retry headers (#1963) (8b35943)
  • clients: remove unsupported CORS retry headers in new services (#2041) (82df9d3)
  • credential-provider-ini: refactor provider options interfaces (#2048) (34cecf1)
  • credential-provider-node: read config and credentials files only once (#2045) (7db14b1)
  • deps: add @aws-sdk/middleware-sdk-rds in DocDB and Neptune (#2042) (a0068f3)
  • lib-storage: fix typo in Upload.intialize (initialize) (#2025) (16214be)
  • middleware-sdk-ec2: add undeclared dependency @aws-sdk/protocol-http (#2043) (6e562ba)

Features

  • client-sso*: remove auth dependencies if client doesn't need (#2037) (f1e190c)
  • lib-storage: rewrite lib-storage upload (#2039) (2bd8f6a)

3.5.0 (2021-02-12)

Bug Fixes

  • util-dynamodb: state options.wrapNumbers on BigInt error in unmarshall (#2015) (d1c548e)
  • util-dynamodb: unmarshall small numbers or those in scientific notation (#2017) (80a8094)
  • util-user-agent-browser: use default import from bowser (#1991) (d2e8d4f)

Features

  • s3-request-presigner: automatically add host header (#1988) (cd50eeb)
  • util-dynamodb: marshall JavaScript Maps (#2010) (569b572)
  • util-dynamodb: support marshalling for Object.create (#1974) (a008d23)
  • add S3 and S3Control customizations for custom endpoints (#1993) (96c1b99)

3.4.1 (2021-01-29)

Bug Fixes

Features

  • use git-sync action to sync with private mirror (#1965) (10ab6a1)

3.4.0 (2021-01-28)

Bug Fixes

  • allow packages/types in gitignore (#1942) (b4b6fad)
  • credential-provider-cognito-identity: remove duplicate declarationDir (#1944) (d75488a)
  • generate-clients: call mergeManifest when constructor.name is Object (#1937) (601c03b)

Features

  • middleware-stack: allow adding middleware to override an existing one (#1964) (9c21f14), closes #1883
  • util-dynamodb: add option to convert class instance to map (#1969) (1783c69)
  • run prettier in parallel in generate-clients (#1949) (878617a)
  • use downlevel-dts to generate TS 3.4 compatible types (#1943) (63ad215)

3.3.0 (2021-01-14)

Bug Fixes

  • clients: export explicit dependencies on @aws-sdk/types (#1902) (96f1087)
  • clients: lowercase all header names in serializer (#1892) (1308721)
  • url-parser: merge browser and node url parser, add rn url parser (#1903) (99be092)
  • util-waiters: waiters should call operation once before entering waiting (#1915) (2a6ac11)

Features

  • clients: update README with documentation, usage and more (#1907) (03be111)

3.2.0 (2021-01-09)

Bug Fixes

  • lib-storage: chunk from readable only when defined (#1886) (4cdc08a)
  • s3-request-presigner: not to throw when get signed urls concurrently (#1884) (741bb99)
  • stop adding command mw repeatedly in resolveMiddleware() (#1883) (d4c302b)
  • readme: npm downloads tag (#1870) (1f8baf3)
  • readme: remove duplicate @aws-sdk (#1873) (85ae915)
  • readme: use latest for npm version badge in template (#1871) (80b57a7)
  • readme: use latest in npm version tag (#1872) (b8542d8)
  • util-user-agent-*: move @aws-sdk/types to devDependencies (#1879) (ea39ca6)
  • util-waiter: expose minDelay and maxDelay for waiters (#1839) (25cb359)

Features

  • use lock-threads GH action for inactive issues/PRs (#1881) (fc22682)
  • util-dynamodb: enable undefined values removal in marshall (#1840) (314d3b3)

3.1.0 (2020-12-23)

Bug Fixes

  • clients: default region and credential provider (#1834) (bc79ab5)
  • clients: populate sdkId in serviceId and default to use arnNamespace as signingName (#1786) (0011af2)
  • clients: remove retry headers for several services (#1789) (fc98d2d)
  • clients: update endpoint provider (#1824) (64d2210)
  • clients: use signing name from auth sigv4 trait (#1835) (e539302)
  • codegen: strip names from enums (#1837) (0711503)
  • lib-storage: cleanup stream listeners to prevent memory leak (3d36682)
  • middleware-user-agent: add middleware to final step of build (#1833) (e7dce39)
  • signature-v4: add secrets to signing key cache key (#1776) (8785ad4)
  • util-waiter: fix compiling error with waiter (#1812) (ca1f0d6), closes #1803
  • log requestId, extendedRequestId, cfId in $metadata (#1819) (f2a47e8)

Features

  • credential-provider-node: use credential_process from profile (#1773) (842e2a0), closes #1772
  • standardize user agent value (#1775) (388b180)
  • cucumber: use waiters in integration tests (#1792) (e151aee)
  • middleware-logger: log clientName, commandName, input, output (#1788) (4f9e56f)

3.0.0 (2020-12-15)

Features

1.0.0-rc.10 (2020-12-15)

Bug Fixes

Features

1.0.0-rc.9 (2020-12-11)

Bug Fixes

  • codegen: import SENSITIVE_STRING only when used (#1761) (9296283)
  • middleware-sdk-sqs: call next() exactly once in sendMessageMiddleware (#1752) (dc63e37)
  • shared-ini-file-loader: ignore prohibited profile name (#1764) (a209082)

Features

1.0.0-rc.8 (2020-12-05)

Bug Fixes

  • client-s3: fix union serialization (#1730) (6437e24)
  • client-sts: disable auth for public assumeRole commands (#1706) (891eae2)
  • codegen: checkstyle errors in AddBuiltinPlugins.java (#1731) (48c02f4)
  • middleware-sdk-sqs: Fix MD5 verification on SendMessageBatch. (#1666) (049f45e)
  • s3-request-presigner: skip hoisting SSE headers (#1701) (1ec70ff)

Features

  • update clients as of 11/20/2020 (#1711) (e932876)
  • update clients as of 11/30/2020 (#1734) (a1e8036)
  • update clients as of 12/3/2020 (#1741) (58383dc)
  • invalid-dependency: add invalidAsyncFunction which rejects with an Error (#1719) (c4c046e)

1.0.0-rc.7 (2020-11-20)

Bug Fixes

  • abort-controller: make AbortSignal WHATWG Spec compliant (#1699) (723ec4d)
  • codegen: add aws-iam-traits dependency (#1686) (d6fb1f6)
  • fetch-http-handler: omit body for HEAD/GET methods (#1698) (778b305)
  • node-http-handler: throw TimeoutError for Node.js timeouts (#1693) (96f61bb)
  • change paginators to export paginateOperationName (#1692) (6d02935)

Features

  • update clients as of 11/18/2020 (#1700) (8adfed1)
  • api-reference: add typedoc plugins for api reference (#1694) (2cb016f)
  • ci: add GitHub Action to test codegen (#1684) (41e9359)
  • node-http-handler: update timeout code and tests (#1691) (9e58bbb)
  • service-error-classification: add 429 response as Throttling (#1690) (9a62c0a)

BREAKING CHANGES

  • change paginators to export paginateOperationName to be consistent with verb nouns across AWS

1.0.0-rc.6 (2020-11-13)

Bug Fixes

Features

  • update clients as of 11/13 (#1676) (2d934c9)
  • codegen: add script to copy models from local directory (#1675) (028a362)

1.0.0-rc.5 (2020-11-09)

Bug Fixes

  • codegen for paginator send commands (#1667) (13f3347)
  • node-http-handler: set maxSockets above 0 in test (#1660) (706768d)
  • package.json: migrate @aws-sdk/types into devDependencies codegen (#1658) (eb50962)
  • migrate dev types for packages and lib into package.json devDeps (#1654) (16d7030)

Features

1.0.0-rc.4 (2020-10-31)

Bug Fixes

  • log requestId, extendedRequestId, cfId in metadata (#1640) (3a2f617)
  • client-timestream-*: use correct endpoint prefix (#1643) (f329821)
  • credential-provider-cognito-identity: return identityId as part of cognitoIdentityPool (#1635) (de75f7e)
  • util-format-url: remove headers or path from input (#1639) (db7aa08)

Features

1.0.0-rc.3 (2020-10-27)

Bug Fixes

  • client-cognito-identity: remove auth for UnlinkIdentity (#1621) (c32e5f3)
  • codegen: skip awsAuthPlugin when optionalAuth trait is set (#1622) (785272b)
  • generate-clients: Invoke prettier relative to client-generation (#1614) (a4136ab)

Features

  • polly-request-presigner: add presigned getSynthesizeSpeechUrl() (#1612) (2c9fd94)
  • update client description to add keywords (#1631) (93fc586)

1.0.0-rc.2 (2020-10-22)

Bug Fixes

  • storage: add version and downloads badges (#1599) (230d030)
  • throw 3XX redirection as errors explicitly (#1591) (76f83f1)

1.0.0-rc.1 (2020-10-19)

Bug Fixes

  • node-http-handler: fix type error sending Uint8Array as payload (#1561) (7bf03fc)

Features