Package com.linecorp.centraldogma.client
Interface CentralDogma
- All Known Implementing Classes:
AbstractCentralDogma
public interface CentralDogma
Central Dogma client.
-
Method Summary
Modifier and Type Method Description CompletableFuture<Void>
createProject(String projectName)
Creates a project.CompletableFuture<Void>
createRepository(String projectName, String repositoryName)
Creates a repository.default <T> Watcher<T>
fileWatcher(String projectName, String repositoryName, Query<T> query)
<T, U> Watcher<U>
fileWatcher(String projectName, String repositoryName, Query<T> query, Function<? super T,? extends U> function)
<T> CompletableFuture<Change<T>>
getDiff(String projectName, String repositoryName, Revision from, Revision to, Query<T> query)
Queries a file at two different revisions and returns the diff of the twoQuery
results.default CompletableFuture<Change<?>>
getDiff(String projectName, String repositoryName, Revision from, Revision to, String path)
Returns the diff of a file between twoRevision
s.CompletableFuture<List<Change<?>>>
getDiffs(String projectName, String repositoryName, Revision from, Revision to, String pathPattern)
Retrieves the diffs of the files matched by the given path pattern between twoRevision
s.<T> CompletableFuture<Entry<T>>
getFile(String projectName, String repositoryName, Revision revision, Query<T> query)
Queries a file at the specified revision and path with the specifiedQuery
.default CompletableFuture<Entry<?>>
getFile(String projectName, String repositoryName, Revision revision, String path)
Retrieves the file at the specified revision and path.CompletableFuture<Map<String,Entry<?>>>
getFiles(String projectName, String repositoryName, Revision revision, String pathPattern)
Retrieves the files matched by the path pattern.default CompletableFuture<List<Commit>>
getHistory(String projectName, String repositoryName, Revision from, Revision to)
Retrieves the history of the repository between twoRevision
s.CompletableFuture<List<Commit>>
getHistory(String projectName, String repositoryName, Revision from, Revision to, String pathPattern)
Retrieves the history of the files matched by the given path pattern between twoRevision
s.default CompletableFuture<List<Change<?>>>
getPreviewDiffs(String projectName, String repositoryName, Revision baseRevision, Change<?>... changes)
Retrieves the preview diffs, which are hypothetical diffs generated if the specifiedChange
s were successfully pushed to the specified repository.CompletableFuture<List<Change<?>>>
getPreviewDiffs(String projectName, String repositoryName, Revision baseRevision, Iterable<? extends Change<?>> changes)
Retrieves the preview diffs, which are hypothetical diffs generated if the specifiedChange
s were successfully pushed to the specified repository.CompletableFuture<Map<String,EntryType>>
listFiles(String projectName, String repositoryName, Revision revision, String pathPattern)
Retrieves the list of the files matched by the given path pattern.CompletableFuture<Set<String>>
listProjects()
Retrieves the list of the projects.CompletableFuture<Set<String>>
listRemovedProjects()
Retrieves the list of the removed projects, which can be unremoved.CompletableFuture<Set<String>>
listRemovedRepositories(String projectName)
Retrieves the list of the removed repositories, which can be unremoved.CompletableFuture<Map<String,RepositoryInfo>>
listRepositories(String projectName)
Retrieves the list of the repositories.<T> CompletableFuture<MergedEntry<T>>
mergeFiles(String projectName, String repositoryName, Revision revision, MergeQuery<T> mergeQuery)
Retrieves the merged entry of the specifiedMergeQuery
at the specified revision.default CompletableFuture<MergedEntry<?>>
mergeFiles(String projectName, String repositoryName, Revision revision, MergeSource... mergeSources)
Retrieves the merged entry of the specifiedMergeSource
s at the specified revision.default CompletableFuture<MergedEntry<?>>
mergeFiles(String projectName, String repositoryName, Revision revision, Iterable<MergeSource> mergeSources)
Retrieves the merged entry of the specifiedMergeSource
s at the specified revision.CompletableFuture<Revision>
normalizeRevision(String projectName, String repositoryName, Revision revision)
Converts the relative revision number to the absolute revision number. e.g.CompletableFuture<Void>
purgeProject(String projectName)
Purges a project that was removed before.CompletableFuture<Void>
purgeRepository(String projectName, String repositoryName)
Purges a repository that was removed before.default CompletableFuture<PushResult>
push(String projectName, String repositoryName, Revision baseRevision, Author author, String summary, Change<?>... changes)
Deprecated.default CompletableFuture<PushResult>
push(String projectName, String repositoryName, Revision baseRevision, Author author, String summary, Iterable<? extends Change<?>> changes)
Deprecated.default CompletableFuture<PushResult>
push(String projectName, String repositoryName, Revision baseRevision, Author author, String summary, String detail, Markup markup, Change<?>... changes)
Deprecated.CompletableFuture<PushResult>
push(String projectName, String repositoryName, Revision baseRevision, Author author, String summary, String detail, Markup markup, Iterable<? extends Change<?>> changes)
Deprecated.default CompletableFuture<PushResult>
push(String projectName, String repositoryName, Revision baseRevision, String summary, Change<?>... changes)
Pushes the specifiedChange
s to the repository.default CompletableFuture<PushResult>
push(String projectName, String repositoryName, Revision baseRevision, String summary, Iterable<? extends Change<?>> changes)
Pushes the specifiedChange
s to the repository.default CompletableFuture<PushResult>
push(String projectName, String repositoryName, Revision baseRevision, String summary, String detail, Markup markup, Change<?>... changes)
Pushes the specifiedChange
s to the repository.CompletableFuture<PushResult>
push(String projectName, String repositoryName, Revision baseRevision, String summary, String detail, Markup markup, Iterable<? extends Change<?>> changes)
Pushes the specifiedChange
s to the repository.CompletableFuture<Void>
removeProject(String projectName)
Removes a project.CompletableFuture<Void>
removeRepository(String projectName, String repositoryName)
Removes a repository.default Watcher<Revision>
repositoryWatcher(String projectName, String repositoryName, String pathPattern)
Returns aWatcher
which notifies its listeners when the specified repository has a new commit that contains the changes for the files matched by the givenpathPattern
. e.g:<T> Watcher<T>
repositoryWatcher(String projectName, String repositoryName, String pathPattern, Function<Revision,? extends T> function)
Returns aWatcher
which notifies its listeners when the specified repository has a new commit that contains the changes for the files matched by the givenpathPattern
. e.g:CompletableFuture<Void>
unremoveProject(String projectName)
Unremoves a project.CompletableFuture<Void>
unremoveRepository(String projectName, String repositoryName)
Unremoves a repository.default <T> CompletableFuture<Entry<T>>
watchFile(String projectName, String repositoryName, Revision lastKnownRevision, Query<T> query)
Waits for the file matched by the specifiedQuery
to be changed since the specifiedlastKnownRevision
.<T> CompletableFuture<Entry<T>>
watchFile(String projectName, String repositoryName, Revision lastKnownRevision, Query<T> query, long timeoutMillis)
Waits for the file matched by the specifiedQuery
to be changed since the specifiedlastKnownRevision
.default CompletableFuture<Revision>
watchRepository(String projectName, String repositoryName, Revision lastKnownRevision, String pathPattern)
Waits for the files matched by the specifiedpathPattern
to be changed since the specifiedlastKnownRevision
.CompletableFuture<Revision>
watchRepository(String projectName, String repositoryName, Revision lastKnownRevision, String pathPattern, long timeoutMillis)
Waits for the files matched by the specifiedpathPattern
to be changed since the specifiedlastKnownRevision
.
-
Method Details
-
createProject
Creates a project. -
removeProject
Removes a project. A removed project can be unremoved usingunremoveProject(String)
. -
purgeProject
Purges a project that was removed before. -
unremoveProject
Unremoves a project. -
listProjects
CompletableFuture<Set<String>> listProjects()Retrieves the list of the projects.- Returns:
- a
Set
that contains the names of the projects
-
listRemovedProjects
CompletableFuture<Set<String>> listRemovedProjects()Retrieves the list of the removed projects, which can be unremoved.- Returns:
- a
Set
that contains the names of the removed projects
-
createRepository
Creates a repository. -
removeRepository
Removes a repository. A removed repository can be unremoved usingunremoveRepository(String, String)
. -
purgeRepository
Purges a repository that was removed before. -
unremoveRepository
Unremoves a repository. -
listRepositories
Retrieves the list of the repositories.- Returns:
- a
Map
of repository name andRepositoryInfo
pairs
-
listRemovedRepositories
Retrieves the list of the removed repositories, which can be unremoved.- Returns:
- a
Set
that contains the names of the removed repositories
-
normalizeRevision
CompletableFuture<Revision> normalizeRevision(String projectName, String repositoryName, Revision revision)Converts the relative revision number to the absolute revision number. e.g.-1 -> 3
- Returns:
- the absolute
Revision
-
listFiles
CompletableFuture<Map<String,EntryType>> listFiles(String projectName, String repositoryName, Revision revision, String pathPattern)Retrieves the list of the files matched by the given path pattern. A path pattern is a variant of glob:"/**"
- find all files recursively"*.json"
- find all JSON files recursively"/foo/*.json"
- find all JSON files under the directory/foo
"/*/foo.txt"
- find all files namedfoo.txt
at the second depth level"*.json,/bar/*.txt"
- use comma to specify more than one pattern. A file will be matched if any pattern matches.
- Returns:
- a
Map
of file path and type pairs
-
getFile
default CompletableFuture<Entry<?>> getFile(String projectName, String repositoryName, Revision revision, String path)Retrieves the file at the specified revision and path. This method is a shortcut ofgetFile(projectName, repositoryName, revision, Query.identity(path)
. Consider usinggetFile(String, String, Revision, Query)
withQuery.ofText(String)
orQuery.ofJson(String)
if you already know the file type.- Returns:
- the
Entry
at the givenpath
-
getFile
<T> CompletableFuture<Entry<T>> getFile(String projectName, String repositoryName, Revision revision, Query<T> query)Queries a file at the specified revision and path with the specifiedQuery
. -
getFiles
CompletableFuture<Map<String,Entry<?>>> getFiles(String projectName, String repositoryName, Revision revision, String pathPattern)Retrieves the files matched by the path pattern. A path pattern is a variant of glob:"/**"
- find all files recursively"*.json"
- find all JSON files recursively"/foo/*.json"
- find all JSON files under the directory/foo
"/*/foo.txt"
- find all files namedfoo.txt
at the second depth level"*.json,/bar/*.txt"
- use comma to specify more than one pattern. A file will be matched if any pattern matches.
-
mergeFiles
default CompletableFuture<MergedEntry<?>> mergeFiles(String projectName, String repositoryName, Revision revision, MergeSource... mergeSources)Retrieves the merged entry of the specifiedMergeSource
s at the specified revision. Only JSON entry merge is currently supported. The JSON files are merged sequentially as specified in themergeSources
.Note that only
ObjectNode
is recursively merged traversing the children. Other node types are simply replaced.- Returns:
- the
MergedEntry
which contains the result of the merge
-
mergeFiles
default CompletableFuture<MergedEntry<?>> mergeFiles(String projectName, String repositoryName, Revision revision, Iterable<MergeSource> mergeSources)Retrieves the merged entry of the specifiedMergeSource
s at the specified revision. Only JSON entry merge is currently supported. The JSON files are merged sequentially as specified in themergeSources
.Note that only
ObjectNode
is recursively merged traversing the children. Other node types are simply replaced.- Returns:
- the
MergedEntry
which contains the result of the merge
-
mergeFiles
<T> CompletableFuture<MergedEntry<T>> mergeFiles(String projectName, String repositoryName, Revision revision, MergeQuery<T> mergeQuery)Retrieves the merged entry of the specifiedMergeQuery
at the specified revision. Only JSON entry merge is currently supported. The JSON files are merged sequentially as specified in theMergeQuery
.Note that only
ObjectNode
is recursively merged traversing the children. Other node types are simply replaced.- Returns:
- the
MergedEntry
which contains the result of the merge
-
getHistory
default CompletableFuture<List<Commit>> getHistory(String projectName, String repositoryName, Revision from, Revision to)Retrieves the history of the repository between twoRevision
s. This method is a shortcut ofgetHistory(projectName, repositoryName, from, to, "/**")
. Note that this method does not retrieve the diffs but only metadata about the changes. UsegetDiff(String, String, Revision, Revision, Query)
orgetDiffs(String, String, Revision, Revision, String)
to retrieve the diffs. -
getHistory
CompletableFuture<List<Commit>> getHistory(String projectName, String repositoryName, Revision from, Revision to, String pathPattern)Retrieves the history of the files matched by the given path pattern between twoRevision
s. A path pattern is a variant of glob:"/**"
- find all files recursively"*.json"
- find all JSON files recursively"/foo/*.json"
- find all JSON files under the directory/foo
"/*/foo.txt"
- find all files namedfoo.txt
at the second depth level"*.json,/bar/*.txt"
- use comma to specify more than one pattern. A file will be matched if any pattern matches.
Note that this method does not retrieve the diffs but only metadata about the changes. Use
getDiff(String, String, Revision, Revision, Query)
orgetDiffs(String, String, Revision, Revision, String)
to retrieve the diffs. -
getDiff
default CompletableFuture<Change<?>> getDiff(String projectName, String repositoryName, Revision from, Revision to, String path)Returns the diff of a file between twoRevision
s. This method is a shortcut ofgetDiff(projectName, repositoryName, from, to, Query.identity(path))
. Consider usinggetDiff(String, String, Revision, Revision, Query)
withQuery.ofText(String)
orQuery.ofJson(String)
if you already know the file type.- Returns:
- the
Change
that contains the diff of the givenpath
between the specified two revisions
-
getDiff
<T> CompletableFuture<Change<T>> getDiff(String projectName, String repositoryName, Revision from, Revision to, Query<T> query)Queries a file at two different revisions and returns the diff of the twoQuery
results.- Returns:
- the
Change
that contains the diff of the file matched by the givenquery
between the specified two revisions
-
getDiffs
CompletableFuture<List<Change<?>>> getDiffs(String projectName, String repositoryName, Revision from, Revision to, String pathPattern)Retrieves the diffs of the files matched by the given path pattern between twoRevision
s. A path pattern is a variant of glob:"/**"
- find all files recursively"*.json"
- find all JSON files recursively"/foo/*.json"
- find all JSON files under the directory/foo
"/*/foo.txt"
- find all files namedfoo.txt
at the second depth level"*.json,/bar/*.txt"
- use comma to specify more than one pattern. A file will be matched if any pattern matches.
-
getPreviewDiffs
default CompletableFuture<List<Change<?>>> getPreviewDiffs(String projectName, String repositoryName, Revision baseRevision, Change<?>... changes)Retrieves the preview diffs, which are hypothetical diffs generated if the specifiedChange
s were successfully pushed to the specified repository. This operation is useful for pre-checking if the specifiedChange
s will be applied as expected without any conflicts.- Returns:
- the diffs which would be committed if the specified
Change
s were pushed successfully
-
getPreviewDiffs
CompletableFuture<List<Change<?>>> getPreviewDiffs(String projectName, String repositoryName, Revision baseRevision, Iterable<? extends Change<?>> changes)Retrieves the preview diffs, which are hypothetical diffs generated if the specifiedChange
s were successfully pushed to the specified repository. This operation is useful for pre-checking if the specifiedChange
s will be applied as expected without any conflicts.- Returns:
- the diffs which would be committed if the specified
Change
s were pushed successfully
-
push
default CompletableFuture<PushResult> push(String projectName, String repositoryName, Revision baseRevision, String summary, Change<?>... changes)Pushes the specifiedChange
s to the repository.- Returns:
- the
PushResult
which tells theRevision
and timestamp of the newCommit
-
push
default CompletableFuture<PushResult> push(String projectName, String repositoryName, Revision baseRevision, String summary, Iterable<? extends Change<?>> changes)Pushes the specifiedChange
s to the repository.- Returns:
- the
PushResult
which tells theRevision
and timestamp of the newCommit
-
push
default CompletableFuture<PushResult> push(String projectName, String repositoryName, Revision baseRevision, String summary, String detail, Markup markup, Change<?>... changes)Pushes the specifiedChange
s to the repository.- Returns:
- the
PushResult
which tells theRevision
and timestamp of the newCommit
-
push
CompletableFuture<PushResult> push(String projectName, String repositoryName, Revision baseRevision, String summary, String detail, Markup markup, Iterable<? extends Change<?>> changes)Pushes the specifiedChange
s to the repository.- Returns:
- the
PushResult
which tells theRevision
and timestamp of the newCommit
-
push
@Deprecated default CompletableFuture<PushResult> push(String projectName, String repositoryName, Revision baseRevision, Author author, String summary, Change<?>... changes)Deprecated.Pushes the specifiedChange
s to the repository.- Returns:
- the
PushResult
which tells theRevision
and timestamp of the newCommit
-
push
@Deprecated default CompletableFuture<PushResult> push(String projectName, String repositoryName, Revision baseRevision, Author author, String summary, Iterable<? extends Change<?>> changes)Deprecated.Pushes the specifiedChange
s to the repository.- Returns:
- the
PushResult
which tells theRevision
and timestamp of the newCommit
-
push
@Deprecated default CompletableFuture<PushResult> push(String projectName, String repositoryName, Revision baseRevision, Author author, String summary, String detail, Markup markup, Change<?>... changes)Deprecated.Pushes the specifiedChange
s to the repository.- Returns:
- the
PushResult
which tells theRevision
and timestamp of the newCommit
-
push
@Deprecated CompletableFuture<PushResult> push(String projectName, String repositoryName, Revision baseRevision, Author author, String summary, String detail, Markup markup, Iterable<? extends Change<?>> changes)Deprecated.Pushes the specifiedChange
s to the repository.- Returns:
- the
PushResult
which tells theRevision
and timestamp of the newCommit
-
watchRepository
default CompletableFuture<Revision> watchRepository(String projectName, String repositoryName, Revision lastKnownRevision, String pathPattern)Waits for the files matched by the specifiedpathPattern
to be changed since the specifiedlastKnownRevision
. If no changes were made within 1 minute, the returnedCompletableFuture
will be completed withnull
.- Returns:
- the latest known
Revision
which contains the changes for the matched files.null
if the files were not changed for 1 minute since the invocation of this method.
-
watchRepository
CompletableFuture<Revision> watchRepository(String projectName, String repositoryName, Revision lastKnownRevision, String pathPattern, long timeoutMillis)Waits for the files matched by the specifiedpathPattern
to be changed since the specifiedlastKnownRevision
. If no changes were made within the specifiedtimeoutMillis
, the returnedCompletableFuture
will be completed withnull
. It is recommended to specify the largesttimeoutMillis
allowed by the server. If unsure, usewatchRepository(String, String, Revision, String)
.- Returns:
- the latest known
Revision
which contains the changes for the matched files.null
if the files were not changed fortimeoutMillis
milliseconds since the invocation of this method.
-
watchFile
default <T> CompletableFuture<Entry<T>> watchFile(String projectName, String repositoryName, Revision lastKnownRevision, Query<T> query)Waits for the file matched by the specifiedQuery
to be changed since the specifiedlastKnownRevision
. If no changes were made within 1 minute, the returnedCompletableFuture
will be completed withnull
. -
watchFile
<T> CompletableFuture<Entry<T>> watchFile(String projectName, String repositoryName, Revision lastKnownRevision, Query<T> query, long timeoutMillis)Waits for the file matched by the specifiedQuery
to be changed since the specifiedlastKnownRevision
. If no changes were made within the specifiedtimeoutMillis
, the returnedCompletableFuture
will be completed withnull
. It is recommended to specify the largesttimeoutMillis
allowed by the server. If unsure, usewatchFile(String, String, Revision, Query)
. -
fileWatcher
-
fileWatcher
<T, U> Watcher<U> fileWatcher(String projectName, String repositoryName, Query<T> query, Function<? super T,? extends U> function)Returns aWatcher
which notifies its listeners after applying the specifiedFunction
when the result of the givenQuery
becomes available or changes. e.g:Watcher<MyType> watcher = client.fileWatcher( "foo", "bar", Query.ofJson("/baz.json"), content -> new ObjectMapper().treeToValue(content, MyType.class)); watcher.watch((revision, myValue) -> { assert myValue instanceof MyType; ... });
-
repositoryWatcher
default Watcher<Revision> repositoryWatcher(String projectName, String repositoryName, String pathPattern)Returns aWatcher
which notifies its listeners when the specified repository has a new commit that contains the changes for the files matched by the givenpathPattern
. e.g:Watcher<Revision> watcher = client.repositoryWatcher("foo", "bar", "/*.json"); watcher.watch(revision -> { ... });
-
repositoryWatcher
<T> Watcher<T> repositoryWatcher(String projectName, String repositoryName, String pathPattern, Function<Revision,? extends T> function)Returns aWatcher
which notifies its listeners when the specified repository has a new commit that contains the changes for the files matched by the givenpathPattern
. e.g:
Note that you may getWatcher<Map<String, Entry<?>> watcher = client.repositoryWatcher( "foo", "bar", "/*.json", revision -> client.getFiles(revision).get()); watcher.watch((revision, contents) -> { ... });
RevisionNotFoundException
during thegetFiles()
call and may have to retry in the above example due to a known issue.
-