0.1.0-preview.2 • Published 4 years ago

@aws-sdk/client-codecommit-node v0.1.0-preview.2

Weekly downloads
12
License
Apache-2.0
Repository
-
Last release
4 years ago

@aws-sdk/client-codecommit-node

Description

AWS CodeCommit This is the AWS CodeCommit API Reference. This reference provides descriptions of the operations and data types for AWS CodeCommit API along with usage examples. You can use the AWS 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 AWS account. CreateRepository, which creates an AWS CodeCommit repository. DeleteRepository, which deletes an AWS CodeCommit repository. GetRepository, which returns information about a specified repository. ListRepositories, which lists all AWS CodeCommit repositories associated with your AWS account. UpdateRepositoryDescription, which sets or updates the description of the repository. UpdateRepositoryName, which changes the name of the repository. If you change the name of a repository, no other users of that repository will be able to access it until you send them the new HTTPS or SSH URL to use. Branches, by calling the following: CreateBranch, which creates a new 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. GetFile, which returns the base-64 encoded content of a specified file. GetFolder, which returns the contents of a specified folder or directory. PutFile, which adds or modifies a file in a specified repository and branch. Information about committed code in a repository, by calling the following: GetBlob, which returns the base-64 encoded content of an individual Git blob object within 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). Pull requests, by calling the following: CreatePullRequest, which creates a pull request in a specified repository. DescribePullRequestEvents, which returns information about one or more pull request events. GetCommentsForPullRequest, which returns information about comments on a specified pull request. GetMergeConflicts, which returns information about merge conflicts between the source and destination branch in a pull request. GetPullRequest, which returns information about a specified pull request. ListPullRequests, which lists all pull requests for a repository. MergePullRequestByFastForward, which merges the source destination branch of a pull request into the specified destination branch for that pull request using the fast-forward merge option. PostCommentForPullRequest, which posts a comment to a pull request at the specified line, file, or request. UpdatePullRequestDescription, which updates the description of a pull request. UpdatePullRequestStatus, which updates the status of a pull request. UpdatePullRequestTitle, which updates the title of a pull request. Information about comments in a repository, by calling the following: DeleteCommentContent, which deletes the content of a comment on a commit in a repository. GetComment, which returns information about a comment on a commit. GetCommentsForComparedCommit, which returns information about comments on the comparison between two commit specifiers in a repository. PostCommentForComparedCommit, which creates a comment on the comparison between two commit specifiers in a repository. PostCommentReply, which creates a reply to a comment. UpdateComment, which updates the content of a comment on a commit in a repository. 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 AWS CodeCommit, see the AWS CodeCommit User Guide.

Installing

To install the this package using NPM, simply type the following into a terminal window:

npm install @aws-sdk/client-codecommit-node

Getting Started

Import

The AWS SDK is modulized by clients and commends in CommonJS modules. To send a request, you only need to import the client(CodeCommitClient) and the commands you need, for example BatchGetRepositoriesCommand:

//javascript
const { CodeCommitClient } = require('@aws-sdk/client-codecommit-node/CodeCommitClient');
const { BatchGetRepositoriesCommand } = require('@aws-sdk/client-codecommit-node/commands/BatchGetRepositoriesCommand');
//typescript
const { CodeCommitClient } = import '@aws-sdk/client-codecommit-node/CodeCommitClient';
const { BatchGetRepositoriesCommand } = import '@aws-sdk/client-codecommit-node/commands/BatchGetRepositoriesCommand';

Usage

To send a request, you:

  • Initiate client with configurations.(credentials, region). For more information you can refer to the API reference.
  • Initiate command with input parameters.
  • Call send operation of client with command object as input.
  • If you are using a custom http handler, you may call destroy() to close open connections.
const codeCommit = new CodeCommitClient({region: 'region'});
//clients can be shared by different commands
const params = {
    repositoryNames: [ /**a list of string*/ ],
};
const batchGetRepositoriesCommand = new BatchGetRepositoriesCommand(params);
codeCommit.send(batchGetRepositoriesCommand).then(data => {
    // do something
}).catch(error => {
    // error handling
})

Besides using promise style, there are 2 other ways to send a request:

// async/await
try {
    const data = await codeCommit.send(batchGetRepositoriesCommand);
    // do something
} catch(error) {
    // error handling
}
// callback
codeCommit.send(batchGetRepositoriesCommand, (err, data) => {
    //do something
})

Besides using send(), the SDK can also send requests using the simplified callback style in version 2 of the SDK.

import * as AWS from '@aws-sdk/@aws-sdk/client-codecommit-node/CodeCommit';
const codeCommit = new AWS.CodeCommit({region: 'region'})
codeCommit.batchGetRepositories(params, (err, data) => {
    //do something
})

Troubleshooting

When the service returns an exception, inpecting the exceptions is always helpful. You can not only access the exception information but also response metadata(i.e request id).

try {
    const data = await codeCommit.send(batchGetRepositoriesCommand);
    // do something
} catch(error) {
    const metadata = error.$metadata;
    console.log(
`requestId: ${metadata.requestId}
cfId: ${metadata.cfId}
extendedRequestId: ${metadata.extendedRequestId}`
    );
/*
The keys within exceptions are also parsed, you can access them by specifying exception names like below:
    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 and have limited bandwidth to address them.

  • Ask a question on StackOverflow and tag it with aws-sdk-js
  • Come join the AWS JavaScript community on gitter
  • If it turns out that you may have found a bug, please open an issue

Contributing

This client code is generated automatically. Any modifications will be overwritten the next time the `@aws-sdk/@aws-sdk/client-codecommit-node' package is updated. To contribute to SDK you can checkout our code generator package.

License

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