Package com.structurizr.api
Class StructurizrClient
- java.lang.Object
-
- com.structurizr.api.StructurizrClient
-
public final class StructurizrClient extends java.lang.ObjectA client for the Structurizr API (https://api.structurizr.com) that allows you to get and put Structurizr workspaces in a JSON format.
-
-
Constructor Summary
Constructors Constructor Description 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.secretStructurizrClient(java.lang.String apiKey, java.lang.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(java.lang.String url, java.lang.String apiKey, java.lang.String apiSecret)Creates a new Structurizr client with the specified API URL, key and secret.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetAgent()Gets the agent string used to identify this client instance.java.lang.StringgetUrl()Gets the API URL that this client is for.com.structurizr.WorkspacegetWorkspace(long workspaceId)Gets the workspace with the given ID.java.io.FilegetWorkspaceArchiveLocation()Gets the location where a copy of the workspace is archived when it is retrieved from the server.booleanlockWorkspace(long workspaceId)Locks the workspace with the given ID.voidputWorkspace(long workspaceId, com.structurizr.Workspace workspace)Updates the given workspace.voidsetAgent(java.lang.String agent)Sets the agent string used to identify this client instance.voidsetEncryptionStrategy(EncryptionStrategy encryptionStrategy)Sets the encryption strategy for use when getting or putting workspaces.voidsetIdGenerator(com.structurizr.model.IdGenerator idGenerator)Sets the ID generator to use when parsing a JSON workspace definition.voidsetMergeFromRemote(boolean mergeFromRemote)Specifies whether the layout of diagrams from a remote workspace should be retained when putting a new version of the workspace.voidsetUser(java.lang.String user)voidsetWorkspaceArchiveLocation(java.io.File workspaceArchiveLocation)Sets the location where a copy of the workspace will be archived whenever it is retrieved from the server.booleanunlockWorkspace(long workspaceId)Unlocks the workspace with the given ID.
-
-
-
Constructor Detail
-
StructurizrClient
public StructurizrClient() throws StructurizrClientExceptionCreates 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
public StructurizrClient(java.lang.String apiKey, java.lang.String apiSecret)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
public StructurizrClient(java.lang.String url, java.lang.String apiKey, java.lang.String apiSecret)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 Detail
-
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
public java.lang.String getAgent()
Gets the agent string used to identify this client instance.- Returns:
- "structurizr-java/{version}", unless overridden
-
setAgent
public void setAgent(java.lang.String agent)
Sets the agent string used to identify this client instance.- Parameters:
agent- the agent string
-
getUrl
public java.lang.String getUrl()
Gets the API URL that this client is for.- Returns:
- the API URL, as a String
-
getWorkspaceArchiveLocation
public java.io.File 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
public void setWorkspaceArchiveLocation(java.io.File workspaceArchiveLocation)
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
public void setEncryptionStrategy(EncryptionStrategy encryptionStrategy)
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
public boolean lockWorkspace(long workspaceId) throws StructurizrClientExceptionLocks 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
public boolean unlockWorkspace(long workspaceId) throws StructurizrClientExceptionUnlocks 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
public com.structurizr.Workspace getWorkspace(long workspaceId) throws StructurizrClientExceptionGets 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 StructurizrClientExceptionUpdates 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
public void setUser(java.lang.String user)
-
-