Creating and Updating Database Objects
You can create new, or update existing, database objects via methods in the Model Manager API. Such methods typically come in pairs: one simple variant that takes a few mandatory arguments and that relies heavily on defaults for most settings, and one advanced variant that enables you to fully specify all settings — see Advanced Database Operations Using Parameter Objects for further details.
Examples
Create a new repository in the database with name My Repository. The second argument is the comment for the first commit automatically saved to the new repository’s default branch.
Repository repository = database
  .createRepository("My Repository", "Created a new repository.");
The comment can always be skipped when saving a commit — in the previous example done by passing null for the second argument.
Create a new branch with name My Branch from the default branch. The third argument is the comment for the first commit automatically saved to the new branch.
BranchKey branchKey = repository.defaultBranch().branchKey();
Branch branch = repository
  .createBranch("My Branch", branchKey, "Created a new branch.");
Create a tag in the new branch with title My Tag. Assign the new tag to a model on the branch.
TagItemVersion version = branch
  .saveNewTag("My Tag", "Created a new tag.");
 
// The modelItemKey variable identifying the model item is
// assumed to be initialized elsewhere.
branch
  .modelByKey(modelItemKey)
  .assignTag(version.itemKey(), "Assigned a tag to the model.");
Update the title of the tag.
BranchTagItem branchTagItem = version.branchItem();
TagItemVersion secondVersion = branchTagItem
  .updateTitle("My Renamed Tag", "Renamed the newly created tag.");