Beanstalk

File Edit Resource

File Edit allows you to change contents of files in your repository.

Readable attributes

id integer Unique ID of the FileEdit.
account_id integer ID of the associated Account.
repository_id integer ID of the associated Repository.
user_id integer ID of the User who initiated the edit.
type string Type of the edit based on repository’s version control system.
file_path string Full path to a file that should be updated.
branch_name string Name of a branch where the file is stored. Git and Mercurial only.
content string Text that should replace file’s current content.
commit_message string Message that should be used for a commit that will be created.
revision_before_commit string Revision (or hash ID) at which repository was before edit was applied.
committed_revision string Revision (or hash ID) of a commit that applied the edit.
updated_at datetime Time when the edit was last updated.
created_at datetime Time when the edit was first added to the system.
applied_at datetime Time when the edit was applied by the system.

Writable attributes

file_path string Required. Existing files only. Full path from repository root.
branch_name string Required. Name of branch where file is located. Git and Mercurial only.
content string Required.
commit_message string Required.

Find File Edit

Use this method to get information about a File Edit that you created. Check applied_at and committed_revision attributes to check if it was applied by the system already or not.

json http-request
GET /api/repositories/{REPOSITORY_ID}/file_edits/{EDIT_ID}.json

Click to expand…

json http-response
STATUS: 200

{
  "file_edit": {
    "commit_message": "bla",
    "revision_before_commit": null,
    "file_path": "README",
    "created_at": "2012/06/05 21:43:50 -0400",
    "committed_revision": null,
    "updated_at": "2012/06/05 21:43:50 -0400",
    "account_id": 2,
    "id": 8,
    "user_id": 2,
    "content": "old file is back!\nbla",
    "applied_at": null,
    "repository_id": 20,
    "branch_name": "third-branch"
  }
}
xml http-request
GET /api/repositories/{REPOSITORY_ID}/file_edits/{EDIT_ID}.xml

Click to expand…

xml http-response
STATUS: 200

<?xml version="1.0" encoding="UTF-8"?>
<file-edit>
  <account-id type="integer">2</account-id>
  <applied-at type="datetime" nil="true"/>
  <branch-name>third-branch</branch-name>
  <commit-message>bla</commit-message>
  <committed-revision nil="true"/>
  <content type="binary" encoding="base64">b2xkIGZpbGUgaXMgYmFjayEKYmxh</content>
  <created-at type="datetime">2012-06-05T21:43:50-04:00</created-at>
  <file-path>README</file-path>
  <id type="integer">8</id>
  <repository-id type="integer">20</repository-id>
  <revision-before-commit nil="true"/>
  <updated-at type="datetime">2012-06-05T21:43:50-04:00</updated-at>
  <user-id type="integer">2</user-id>
</file-edit>

Create File Edit

New File Edits are added to queue and processed in background on one of our servers. It can take a few minutes for your edit to be applied, depending on the size of the repository.

json http-request
POST /api/repositories/{REPOSITORY_ID}/file_edits.json

{
  "file_edit": {
    "file_path": "trunk/app/controllers/application_controller.rb",
    "content": "this is not your regular controller",
    "commit_message": "Replaced controller with some weird stuff"
  }
}

Click to expand…

json http-response
STATUS: 201

{
  "file_edit": {
    "commit_message": "Replaced controller with some weird stuff",
    "revision_before_commit": null,
    "file_path": "trunk/app/controllers/application_controller.rb",
    "created_at": "2012/06/05 21:43:50 -0400",
    "committed_revision": null,
    "updated_at": "2012/06/05 21:43:50 -0400",
    "account_id": 2,
    "id": 9,
    "user_id": 2,
    "content": "this is not your regular controller",
    "applied_at": null,
    "repository_id": 20,
    "branch_name": null
  }
}
xml http-request
POST /api/repositories/{REPOSITORY_ID}/file_edits.xml

<file-edit>
  <file-path>trunk/app/controllers/application_controller.rb</file-path>
  <content>this is not your regular controller</content>
  <commit-message>Replaced controller with some weird stuff</commit-message>
</file-edit>

Click to expand…

xml http-response
STATUS: 201

<?xml version="1.0" encoding="UTF-8"?>
<file-edit>
  <account-id type="integer">2</account-id>
  <applied-at type="datetime" nil="true"/>
  <branch-name nil="true"/>
  <commit-message>Replaced controller with some weird stuff</commit-message>
  <committed-revision nil="true"/>
  <content type="binary" encoding="base64">b2xkIGZpbGUgaXMgYmFjayEKYmxh</content>
  <created-at type="datetime">2012-06-05T21:43:50-04:00</created-at>
  <file-path>trunk/app/controllers/application_controller.rb</file-path>
  <id type="integer">8</id>
  <repository-id type="integer">20</repository-id>
  <revision-before-commit nil="true"/>
  <updated-at type="datetime">2012-06-05T21:43:50-04:00</updated-at>
  <user-id type="integer">2</user-id>
</file-edit>