Class WorkspaceApiClient

java.lang.Object
com.structurizr.api.AbstractApiClient
com.structurizr.api.WorkspaceApiClient

public class WorkspaceApiClient extends AbstractApiClient
A client for the Structurizr workspace API that allows you to get and put Structurizr workspaces in a JSON format.
  • Constructor Details

    • WorkspaceApiClient

      protected WorkspaceApiClient()
    • WorkspaceApiClient

      public WorkspaceApiClient(String apiKey, String apiSecret)
      Creates a new Structurizr API client with the specified API key and secret, for the Structurizr cloud service.
      Parameters:
      apiKey - the API key of your workspace
      apiSecret - the API secret of your workspace
    • WorkspaceApiClient

      public WorkspaceApiClient(String url, String apiKey, String apiSecret)
      Creates a new Structurizr client with the specified API URL, key and secret.
      Parameters:
      url - the URL of your Structurizr instance
      apiKey - the API key of your workspace
      apiSecret - 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
    • setApiKey

      protected void setApiKey(String apiKey)
    • setApiSecret

      protected void setApiSecret(String apiSecret)
    • getWorkspaceArchiveLocation

      public 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(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 StructurizrClientException
      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

      public boolean unlockWorkspace(long workspaceId) throws StructurizrClientException
      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

      public com.structurizr.Workspace getWorkspace(long workspaceId) throws StructurizrClientException
      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 ID
      workspace - the workspace instance to update
      Throws:
      StructurizrClientException - if there are problems related to the network, authorization, JSON serialization, etc
    • setUser

      public void setUser(String user)