You are viewing documentation for version 2 of the AWS SDK for Ruby. Version 3 documentation can be found here.

Class: Aws::CodeCommit::Client

Inherits:
Seahorse::Client::Base show all
Defined in:
(unknown)

Overview

An API client for AWS CodeCommit. To construct a client, you need to configure a :region and :credentials.

codecommit = Aws::CodeCommit::Client.new(
  region: region_name,
  credentials: credentials,
  # ...
)

See #initialize for a full list of supported configuration options.

Region

You can configure a default region in the following locations:

  • ENV['AWS_REGION']
  • Aws.config[:region]

Go here for a list of supported regions.

Credentials

Default credentials are loaded automatically from the following locations:

  • ENV['AWS_ACCESS_KEY_ID'] and ENV['AWS_SECRET_ACCESS_KEY']
  • Aws.config[:credentials]
  • The shared credentials ini file at ~/.aws/credentials (more information)
  • From an instance profile when running on EC2

You can also construct a credentials object from one of the following classes:

Alternatively, you configure credentials with :access_key_id and :secret_access_key:

# load credentials from disk
creds = YAML.load(File.read('/path/to/secrets'))

Aws::CodeCommit::Client.new(
  access_key_id: creds['access_key_id'],
  secret_access_key: creds['secret_access_key']
)

Always load your credentials from outside your application. Avoid configuring credentials statically and never commit them to source control.

Instance Attribute Summary

Attributes inherited from Seahorse::Client::Base

#config, #handlers

Constructor collapse

API Operations collapse

Instance Method Summary collapse

Methods inherited from Seahorse::Client::Base

add_plugin, api, #build_request, clear_plugins, define, new, #operation, #operation_names, plugins, remove_plugin, set_api, set_plugins

Methods included from Seahorse::Client::HandlerBuilder

#handle, #handle_request, #handle_response

Constructor Details

#initialize(options = {}) ⇒ Aws::CodeCommit::Client

Constructs an API client.

Options Hash (options):

  • :access_key_id (String)

    Used to set credentials statically. See Plugins::RequestSigner for more details.

  • :convert_params (Boolean) — default: true

    When true, an attempt is made to coerce request parameters into the required types. See Plugins::ParamConverter for more details.

  • :credentials (required, Credentials)

    Your AWS credentials. The following locations will be searched in order for credentials:

    • :access_key_id, :secret_access_key, and :session_token options
    • ENV['AWS_ACCESS_KEY_ID'], ENV['AWS_SECRET_ACCESS_KEY']
    • HOME/.aws/credentials shared credentials file
    • EC2 instance profile credentials See Plugins::RequestSigner for more details.
  • :endpoint (String)

    A default endpoint is constructed from the :region. See Plugins::RegionalEndpoint for more details.

  • :http_continue_timeout (Float) — default: 1

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :http_idle_timeout (Integer) — default: 5

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :http_open_timeout (Integer) — default: 15

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :http_proxy (String)

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :http_read_timeout (Integer) — default: 60

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :http_wire_trace (Boolean) — default: false

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :log_level (Symbol) — default: :info

    The log level to send messages to the logger at. See Plugins::Logging for more details.

  • :log_formatter (Logging::LogFormatter)

    The log formatter. Defaults to Seahorse::Client::Logging::Formatter.default. See Plugins::Logging for more details.

  • :logger (Logger) — default: nil

    The Logger instance to send log messages to. If this option is not set, logging will be disabled. See Plugins::Logging for more details.

  • :profile (String)

    Used when loading credentials from the shared credentials file at HOME/.aws/credentials. When not specified, 'default' is used. See Plugins::RequestSigner for more details.

  • :raise_response_errors (Boolean) — default: true

    When true, response errors are raised. See Seahorse::Client::Plugins::RaiseResponseErrors for more details.

  • :region (required, String)

    The AWS region to connect to. The region is used to construct the client endpoint. Defaults to ENV['AWS_REGION']. Also checks AMAZON_REGION and AWS_DEFAULT_REGION. See Plugins::RegionalEndpoint for more details.

  • :retry_limit (Integer) — default: 3

    The maximum number of times to retry failed requests. Only ~ 500 level server errors and certain ~ 400 level client errors are retried. Generally, these are throttling errors, data checksum errors, networking errors, timeout errors and auth errors from expired credentials. See Plugins::RetryErrors for more details.

  • :secret_access_key (String)

    Used to set credentials statically. See Plugins::RequestSigner for more details.

  • :session_token (String)

    Used to set credentials statically. See Plugins::RequestSigner for more details.

  • :simple_json (Boolean) — default: false

    Disables request parameter conversion, validation, and formatting. Also disable response data type conversions. This option is useful when you want to ensure the highest level of performance by avoiding overhead of walking request parameters and response data structures.

    When :simple_json is enabled, the request parameters hash must be formatted exactly as the DynamoDB API expects. See Plugins::Protocols::JsonRpc for more details.

  • :ssl_ca_bundle (String)

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :ssl_ca_directory (String)

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :ssl_ca_store (String)

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :ssl_verify_peer (Boolean) — default: true

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :stub_responses (Boolean) — default: false

    Causes the client to return stubbed responses. By default fake responses are generated and returned. You can specify the response data to return or errors to raise by calling Aws::ClientStubs#stub_responses. See Aws::ClientStubs for more information.

    Please note When response stubbing is enabled, no HTTP requests are made, and retries are disabled. See Plugins::StubResponses for more details.

  • :validate_params (Boolean) — default: true

    When true, request parameters are validated before sending the request. See Plugins::ParamValidator for more details.

Instance Method Details

#batch_get_repositories(options = {}) ⇒ Types::BatchGetRepositoriesOutput

Returns information about one or more repositories.

The description field for a repository accepts all HTML characters and all valid Unicode characters. Applications that do not HTML-encode the description and display it in a web page could expose users to potentially malicious code. Make sure that you HTML-encode the description field in any application that uses this API to display the repository description on a web page.

Examples:

Request syntax with placeholder values


resp = client.batch_get_repositories({
  repository_names: ["RepositoryName"], # required
})

Response structure


resp.repositories #=> Array
resp.repositories[0]. #=> String
resp.repositories[0].repository_id #=> String
resp.repositories[0].repository_name #=> String
resp.repositories[0].repository_description #=> String
resp.repositories[0].default_branch #=> String
resp.repositories[0].last_modified_date #=> Time
resp.repositories[0].creation_date #=> Time
resp.repositories[0].clone_url_http #=> String
resp.repositories[0].clone_url_ssh #=> String
resp.repositories[0].arn #=> String
resp.repositories_not_found #=> Array
resp.repositories_not_found[0] #=> String

Options Hash (options):

  • :repository_names (required, Array<String>)

    The names of the repositories to get information about.

Returns:

See Also:

#create_branch(options = {}) ⇒ Struct

Creates a new branch in a repository and points the branch to a commit.

Calling the create branch operation does not set a repository's default branch. To do this, call the update default branch operation.

Examples:

Request syntax with placeholder values


resp = client.create_branch({
  repository_name: "RepositoryName", # required
  branch_name: "BranchName", # required
  commit_id: "CommitId", # required
})

Options Hash (options):

  • :repository_name (required, String)

    The name of the repository in which you want to create the new branch.

  • :branch_name (required, String)

    The name of the new branch to create.

  • :commit_id (required, String)

    The ID of the commit to point the new branch to.

Returns:

  • (Struct)

    Returns an empty response.

See Also:

#create_repository(options = {}) ⇒ Types::CreateRepositoryOutput

Creates a new, empty repository.

Examples:

Request syntax with placeholder values


resp = client.create_repository({
  repository_name: "RepositoryName", # required
  repository_description: "RepositoryDescription",
})

Response structure


resp.. #=> String
resp..repository_id #=> String
resp..repository_name #=> String
resp..repository_description #=> String
resp..default_branch #=> String
resp..last_modified_date #=> Time
resp..creation_date #=> Time
resp..clone_url_http #=> String
resp..clone_url_ssh #=> String
resp..arn #=> String

Options Hash (options):

  • :repository_name (required, String)

    The name of the new repository to be created.

    The repository name must be unique across the calling AWS account. In addition, repository names are limited to 100 alphanumeric, dash, and underscore characters, and cannot include certain characters. For a full description of the limits on repository names, see Limits in the AWS CodeCommit User Guide. The suffix \".git\" is prohibited.

  • :repository_description (String)

    A comment or description about the new repository.

    The description field for a repository accepts all HTML characters and all valid Unicode characters. Applications that do not HTML-encode the description and display it in a web page could expose users to potentially malicious code. Make sure that you HTML-encode the description field in any application that uses this API to display the repository description on a web page.

Returns:

See Also:

#delete_branch(options = {}) ⇒ Types::DeleteBranchOutput

Deletes a branch from a repository, unless that branch is the default branch for the repository.

Examples:

Request syntax with placeholder values


resp = client.delete_branch({
  repository_name: "RepositoryName", # required
  branch_name: "BranchName", # required
})

Response structure


resp.deleted_branch.branch_name #=> String
resp.deleted_branch.commit_id #=> String

Options Hash (options):

  • :repository_name (required, String)

    The name of the repository that contains the branch to be deleted.

  • :branch_name (required, String)

    The name of the branch to delete.

Returns:

See Also:

#delete_repository(options = {}) ⇒ Types::DeleteRepositoryOutput

Deletes a repository. If a specified repository was already deleted, a null repository ID will be returned.

Deleting a repository also deletes all associated objects and metadata. After a repository is deleted, all future push calls to the deleted repository will fail.

Examples:

Request syntax with placeholder values


resp = client.delete_repository({
  repository_name: "RepositoryName", # required
})

Response structure


resp.repository_id #=> String

Options Hash (options):

  • :repository_name (required, String)

    The name of the repository to delete.

Returns:

See Also:

#get_blob(options = {}) ⇒ Types::GetBlobOutput

Returns the base-64 encoded content of an individual blob within a repository.

Examples:

Request syntax with placeholder values


resp = client.get_blob({
  repository_name: "RepositoryName", # required
  blob_id: "ObjectId", # required
})

Response structure


resp.content #=> IO

Options Hash (options):

  • :repository_name (required, String)

    The name of the repository that contains the blob.

  • :blob_id (required, String)

    The ID of the blob, which is its SHA-1 pointer.

Returns:

See Also:

#get_branch(options = {}) ⇒ Types::GetBranchOutput

Returns information about a repository branch, including its name and the last commit ID.

Examples:

Request syntax with placeholder values


resp = client.get_branch({
  repository_name: "RepositoryName",
  branch_name: "BranchName",
})

Response structure


resp.branch.branch_name #=> String
resp.branch.commit_id #=> String

Options Hash (options):

  • :repository_name (String)

    The name of the repository that contains the branch for which you want to retrieve information.

  • :branch_name (String)

    The name of the branch for which you want to retrieve information.

Returns:

See Also:

#get_commit(options = {}) ⇒ Types::GetCommitOutput

Returns information about a commit, including commit message and committer information.

Examples:

Request syntax with placeholder values


resp = client.get_commit({
  repository_name: "RepositoryName", # required
  commit_id: "ObjectId", # required
})

Response structure


resp.commit.commit_id #=> String
resp.commit.tree_id #=> String
resp.commit.parents #=> Array
resp.commit.parents[0] #=> String
resp.commit.message #=> String
resp.commit.author.name #=> String
resp.commit.author.email #=> String
resp.commit.author.date #=> String
resp.commit.committer.name #=> String
resp.commit.committer.email #=> String
resp.commit.committer.date #=> String
resp.commit.additional_data #=> String

Options Hash (options):

  • :repository_name (required, String)

    The name of the repository to which the commit was made.

  • :commit_id (required, String)

    The commit ID. Commit IDs are the full SHA of the commit.

Returns:

See Also:

#get_differences(options = {}) ⇒ Types::GetDifferencesOutput

Returns information about the differences in a valid commit specifier (such as a branch, tag, HEAD, commit ID or other fully qualified reference). Results can be limited to a specified path.

Examples:

Request syntax with placeholder values


resp = client.get_differences({
  repository_name: "RepositoryName", # required
  before_commit_specifier: "CommitName",
  after_commit_specifier: "CommitName", # required
  before_path: "Path",
  after_path: "Path",
  max_results: 1,
  next_token: "NextToken",
})

Response structure


resp.differences #=> Array
resp.differences[0].before_blob.blob_id #=> String
resp.differences[0].before_blob.path #=> String
resp.differences[0].before_blob.mode #=> String
resp.differences[0].after_blob.blob_id #=> String
resp.differences[0].after_blob.path #=> String
resp.differences[0].after_blob.mode #=> String
resp.differences[0].change_type #=> String, one of "A", "M", "D"
resp.next_token #=> String

Options Hash (options):

  • :repository_name (required, String)

    The name of the repository where you want to get differences.

  • :before_commit_specifier (String)

    The branch, tag, HEAD, or other fully qualified reference used to identify a commit. For example, the full commit ID. Optional. If not specified, all changes prior to the afterCommitSpecifier value will be shown. If you do not use beforeCommitSpecifier in your request, consider limiting the results with maxResults.

  • :after_commit_specifier (required, String)

    The branch, tag, HEAD, or other fully qualified reference used to identify a commit.

  • :before_path (String)

    The file path in which to check for differences. Limits the results to this path. Can also be used to specify the previous name of a directory or folder. If beforePath and afterPath are not specified, differences will be shown for all paths.

  • :after_path (String)

    The file path in which to check differences. Limits the results to this path. Can also be used to specify the changed name of a directory or folder, if it has changed. If not specified, differences will be shown for all paths.

  • :max_results (Integer)

    A non-negative integer used to limit the number of returned results.

  • :next_token (String)

    An enumeration token that when provided in a request, returns the next batch of the results.

Returns:

See Also:

#get_repository(options = {}) ⇒ Types::GetRepositoryOutput

Returns information about a repository.

The description field for a repository accepts all HTML characters and all valid Unicode characters. Applications that do not HTML-encode the description and display it in a web page could expose users to potentially malicious code. Make sure that you HTML-encode the description field in any application that uses this API to display the repository description on a web page.

Examples:

Request syntax with placeholder values


resp = client.get_repository({
  repository_name: "RepositoryName", # required
})

Response structure


resp.. #=> String
resp..repository_id #=> String
resp..repository_name #=> String
resp..repository_description #=> String
resp..default_branch #=> String
resp..last_modified_date #=> Time
resp..creation_date #=> Time
resp..clone_url_http #=> String
resp..clone_url_ssh #=> String
resp..arn #=> String

Options Hash (options):

  • :repository_name (required, String)

    The name of the repository to get information about.

Returns:

See Also:

#get_repository_triggers(options = {}) ⇒ Types::GetRepositoryTriggersOutput

Gets information about triggers configured for a repository.

Examples:

Request syntax with placeholder values


resp = client.get_repository_triggers({
  repository_name: "RepositoryName", # required
})

Response structure


resp.configuration_id #=> String
resp.triggers #=> Array
resp.triggers[0].name #=> String
resp.triggers[0].destination_arn #=> String
resp.triggers[0].custom_data #=> String
resp.triggers[0].branches #=> Array
resp.triggers[0].branches[0] #=> String
resp.triggers[0].events #=> Array
resp.triggers[0].events[0] #=> String, one of "all", "updateReference", "createReference", "deleteReference"

Options Hash (options):

  • :repository_name (required, String)

    The name of the repository for which the trigger is configured.

Returns:

See Also:

#list_branches(options = {}) ⇒ Types::ListBranchesOutput

Gets information about one or more branches in a repository.

Examples:

Request syntax with placeholder values


resp = client.list_branches({
  repository_name: "RepositoryName", # required
  next_token: "NextToken",
})

Response structure


resp.branches #=> Array
resp.branches[0] #=> String
resp.next_token #=> String

Options Hash (options):

  • :repository_name (required, String)

    The name of the repository that contains the branches.

  • :next_token (String)

    An enumeration token that allows the operation to batch the results.

Returns:

See Also:

#list_repositories(options = {}) ⇒ Types::ListRepositoriesOutput

Gets information about one or more repositories.

Examples:

Request syntax with placeholder values


resp = client.list_repositories({
  next_token: "NextToken",
  sort_by: "repositoryName", # accepts repositoryName, lastModifiedDate
  order: "ascending", # accepts ascending, descending
})

Response structure


resp.repositories #=> Array
resp.repositories[0].repository_name #=> String
resp.repositories[0].repository_id #=> String
resp.next_token #=> String

Options Hash (options):

  • :next_token (String)

    An enumeration token that allows the operation to batch the results of the operation. Batch sizes are 1,000 for list repository operations. When the client sends the token back to AWS CodeCommit, another page of 1,000 records is retrieved.

  • :sort_by (String)

    The criteria used to sort the results of a list repositories operation.

  • :order (String)

    The order in which to sort the results of a list repositories operation.

Returns:

See Also:

#put_repository_triggers(options = {}) ⇒ Types::PutRepositoryTriggersOutput

Replaces all triggers for a repository. This can be used to create or delete triggers.

Examples:

Request syntax with placeholder values


resp = client.put_repository_triggers({
  repository_name: "RepositoryName", # required
  triggers: [ # required
    {
      name: "RepositoryTriggerName", # required
      destination_arn: "Arn", # required
      custom_data: "RepositoryTriggerCustomData",
      branches: ["BranchName"],
      events: ["all"], # required, accepts all, updateReference, createReference, deleteReference
    },
  ],
})

Response structure


resp.configuration_id #=> String

Options Hash (options):

  • :repository_name (required, String)

    The name of the repository where you want to create or update the trigger.

  • :triggers (required, Array<Types::RepositoryTrigger>)

    The JSON block of configuration information for each trigger.

Returns:

See Also:

#test_repository_triggers(options = {}) ⇒ Types::TestRepositoryTriggersOutput

Tests the functionality of repository triggers by sending information to the trigger target. If real data is available in the repository, the test will send data from the last commit. If no data is available, sample data will be generated.

Examples:

Request syntax with placeholder values


resp = client.test_repository_triggers({
  repository_name: "RepositoryName", # required
  triggers: [ # required
    {
      name: "RepositoryTriggerName", # required
      destination_arn: "Arn", # required
      custom_data: "RepositoryTriggerCustomData",
      branches: ["BranchName"],
      events: ["all"], # required, accepts all, updateReference, createReference, deleteReference
    },
  ],
})

Response structure


resp.successful_executions #=> Array
resp.successful_executions[0] #=> String
resp.failed_executions #=> Array
resp.failed_executions[0].trigger #=> String
resp.failed_executions[0].failure_message #=> String

Options Hash (options):

  • :repository_name (required, String)

    The name of the repository in which to test the triggers.

  • :triggers (required, Array<Types::RepositoryTrigger>)

    The list of triggers to test.

Returns:

See Also:

#update_default_branch(options = {}) ⇒ Struct

Sets or changes the default branch name for the specified repository.

If you use this operation to change the default branch name to the current default branch name, a success message is returned even though the default branch did not change.

Examples:

Request syntax with placeholder values


resp = client.update_default_branch({
  repository_name: "RepositoryName", # required
  default_branch_name: "BranchName", # required
})

Options Hash (options):

  • :repository_name (required, String)

    The name of the repository to set or change the default branch for.

  • :default_branch_name (required, String)

    The name of the branch to set as the default.

Returns:

  • (Struct)

    Returns an empty response.

See Also:

#update_repository_description(options = {}) ⇒ Struct

Sets or changes the comment or description for a repository.

The description field for a repository accepts all HTML characters and all valid Unicode characters. Applications that do not HTML-encode the description and display it in a web page could expose users to potentially malicious code. Make sure that you HTML-encode the description field in any application that uses this API to display the repository description on a web page.

Examples:

Request syntax with placeholder values


resp = client.update_repository_description({
  repository_name: "RepositoryName", # required
  repository_description: "RepositoryDescription",
})

Options Hash (options):

  • :repository_name (required, String)

    The name of the repository to set or change the comment or description for.

  • :repository_description (String)

    The new comment or description for the specified repository. Repository descriptions are limited to 1,000 characters.

Returns:

  • (Struct)

    Returns an empty response.

See Also:

#update_repository_name(options = {}) ⇒ Struct

Renames a repository. The repository name must be unique across the calling AWS account. In addition, repository names are limited to 100 alphanumeric, dash, and underscore characters, and cannot include certain characters. The suffix ".git" is prohibited. For a full description of the limits on repository names, see Limits in the AWS CodeCommit User Guide.

Examples:

Request syntax with placeholder values


resp = client.update_repository_name({
  old_name: "RepositoryName", # required
  new_name: "RepositoryName", # required
})

Options Hash (options):

  • :old_name (required, String)

    The existing name of the repository.

  • :new_name (required, String)

    The new name for the repository.

Returns:

  • (Struct)

    Returns an empty response.

See Also:

#wait_until(waiter_name, params = {}) {|waiter| ... } ⇒ Boolean

Waiters polls an API operation until a resource enters a desired state.

Basic Usage

Waiters will poll until they are succesful, they fail by entering a terminal state, or until a maximum number of attempts are made.

# polls in a loop, sleeping between attempts client.waiter_until(waiter_name, params)

Configuration

You can configure the maximum number of polling attempts, and the delay (in seconds) between each polling attempt. You configure waiters by passing a block to #wait_until:

# poll for ~25 seconds
client.wait_until(...) do |w|
  w.max_attempts = 5
  w.delay = 5
end

Callbacks

You can be notified before each polling attempt and before each delay. If you throw :success or :failure from these callbacks, it will terminate the waiter.

started_at = Time.now
client.wait_until(...) do |w|

  # disable max attempts
  w.max_attempts = nil

  # poll for 1 hour, instead of a number of attempts
  w.before_wait do |attempts, response|
    throw :failure if Time.now - started_at > 3600
  end

end

Handling Errors

When a waiter is successful, it returns true. When a waiter fails, it raises an error. All errors raised extend from Waiters::Errors::WaiterFailed.

begin
  client.wait_until(...)
rescue Aws::Waiters::Errors::WaiterFailed
  # resource did not enter the desired state in time
end

Parameters:

  • waiter_name (Symbol)

    The name of the waiter. See #waiter_names for a full list of supported waiters.

  • params (Hash) (defaults to: {})

    Additional request parameters. See the #waiter_names for a list of supported waiters and what request they call. The called request determines the list of accepted parameters.

Yield Parameters:

Returns:

  • (Boolean)

    Returns true if the waiter was successful.

Raises:

  • (Errors::FailureStateError)

    Raised when the waiter terminates because the waiter has entered a state that it will not transition out of, preventing success.

  • (Errors::TooManyAttemptsError)

    Raised when the configured maximum number of attempts have been made, and the waiter is not yet successful.

  • (Errors::UnexpectedError)

    Raised when an error is encounted while polling for a resource that is not expected.

  • (Errors::NoSuchWaiterError)

    Raised when you request to wait for an unknown state.

#waiter_namesArray<Symbol>

Returns the list of supported waiters. The following table lists the supported waiters and the client method they call:

Waiter NameClient MethodDefault Delay:Default Max Attempts:

Returns:

  • (Array<Symbol>)

    the list of supported waiters.