Package com.structurizr.api
Class StructurizrClient
java.lang.Object
com.structurizr.api.StructurizrClient
A client for the Structurizr API (https://api.structurizr.com)
that allows you to get and put Structurizr workspaces in a JSON format.
-
Constructor Summary
ConstructorDescriptionCreates a new Structurizr client based upon configuration in a structurizr.properties file on the classpath with the following name-value pairs: - structurizr.api.url - structurizr.api.key - structurizr.api.secretStructurizrClient
(String apiKey, String apiSecret) Creates a new Structurizr API client with the specified API key and secret, for the default API URL (https://api.structurizr.com).StructurizrClient
(String url, String apiKey, String apiSecret) Creates a new Structurizr client with the specified API URL, key and secret. -
Method Summary
Modifier and TypeMethodDescriptiongetAgent()
Gets the agent string used to identify this client instance.getUrl()
Gets the API URL that this client is for.com.structurizr.Workspace
getWorkspace
(long workspaceId) Gets the workspace with the given ID.Gets the location where a copy of the workspace is archived when it is retrieved from the server.boolean
lockWorkspace
(long workspaceId) Locks the workspace with the given ID.void
putWorkspace
(long workspaceId, com.structurizr.Workspace workspace) Updates the given workspace.void
Sets the agent string used to identify this client instance.void
setEncryptionStrategy
(EncryptionStrategy encryptionStrategy) Sets the encryption strategy for use when getting or putting workspaces.void
setIdGenerator
(com.structurizr.model.IdGenerator idGenerator) Sets the ID generator to use when parsing a JSON workspace definition.void
setMergeFromRemote
(boolean mergeFromRemote) Specifies whether the layout of diagrams from a remote workspace should be retained when putting a new version of the workspace.void
void
setWorkspaceArchiveLocation
(File workspaceArchiveLocation) Sets the location where a copy of the workspace will be archived whenever it is retrieved from the server.boolean
unlockWorkspace
(long workspaceId) Unlocks the workspace with the given ID.
-
Constructor Details
-
StructurizrClient
Creates a new Structurizr client based upon configuration in a structurizr.properties file on the classpath with the following name-value pairs: - structurizr.api.url - structurizr.api.key - structurizr.api.secret- Throws:
StructurizrClientException
- if something goes wrong
-
StructurizrClient
Creates a new Structurizr API client with the specified API key and secret, for the default API URL (https://api.structurizr.com).- Parameters:
apiKey
- the API key of your workspaceapiSecret
- the API secret of your workspace
-
StructurizrClient
Creates a new Structurizr client with the specified API URL, key and secret.- Parameters:
url
- the URL of your Structurizr instanceapiKey
- the API key of your workspaceapiSecret
- the API secret of your workspace
-
-
Method Details
-
setIdGenerator
public void setIdGenerator(com.structurizr.model.IdGenerator idGenerator) Sets the ID generator to use when parsing a JSON workspace definition.- Parameters:
idGenerator
- an IdGenerator implementation
-
getAgent
Gets the agent string used to identify this client instance.- Returns:
- "structurizr-java/{version}", unless overridden
-
setAgent
Sets the agent string used to identify this client instance.- Parameters:
agent
- the agent string
-
getUrl
Gets the API URL that this client is for.- Returns:
- the API URL, as a String
-
getWorkspaceArchiveLocation
Gets the location where a copy of the workspace is archived when it is retrieved from the server.- Returns:
- a File instance representing a directory, or null if this client instance is not archiving
-
setWorkspaceArchiveLocation
Sets the location where a copy of the workspace will be archived whenever it is retrieved from the server. Set this to null if you don't want archiving.- Parameters:
workspaceArchiveLocation
- a File instance representing a directory, or null if you don't want archiving
-
setEncryptionStrategy
Sets the encryption strategy for use when getting or putting workspaces.- Parameters:
encryptionStrategy
- an EncryptionStrategy implementation
-
setMergeFromRemote
public void setMergeFromRemote(boolean mergeFromRemote) Specifies whether the layout of diagrams from a remote workspace should be retained when putting a new version of the workspace.- Parameters:
mergeFromRemote
- true if layout information should be merged from the remote workspace, false otherwise
-
lockWorkspace
Locks the workspace with the given ID.- Parameters:
workspaceId
- the ID of your workspace- Returns:
- true if the workspace could be locked, false otherwise
- Throws:
StructurizrClientException
- if there are problems related to the network, authorization, etc
-
unlockWorkspace
Unlocks the workspace with the given ID.- Parameters:
workspaceId
- the ID of your workspace- Returns:
- true if the workspace could be unlocked, false otherwise
- Throws:
StructurizrClientException
- if there are problems related to the network, authorization, etc
-
getWorkspace
Gets the workspace with the given ID.- Parameters:
workspaceId
- the workspace ID- Returns:
- a Workspace instance
- Throws:
StructurizrClientException
- if there are problems related to the network, authorization, JSON deserialization, etc
-
putWorkspace
public void putWorkspace(long workspaceId, com.structurizr.Workspace workspace) throws StructurizrClientException Updates the given workspace.- Parameters:
workspaceId
- the workspace IDworkspace
- the workspace instance to update- Throws:
StructurizrClientException
- if there are problems related to the network, authorization, JSON serialization, etc
-
setUser
-