Using the drupal-state commands

You can use the drupal-state commands to store and retrieve information about the state of your Developer Portal system.

Information about the state of your Developer Portal system is stored in the Developer Portal database, and therefore this information is lost if the database is dropped, or the Developer Portal site is re-installed from configuration.

The drupal-state commands can be used to set, update, get, or delete a state key value. For example, you can use the drupal-state commands to enable and disable maintenance mode for your Developer Portal; for more information, see the scenario How to enable and disable maintenance mode on your Developer Portal.

Warning: Use the drupal-state command with caution. This command enables you to modify keys for your Developer Portal site state. Incorrect usage of this command can bring down your Developer Portal, and then require restoring it from a backup.
  1. Log in as Provider org:
    apic login --server management_server --realm provider/identity_provider --username provider_username --password provider_password
    You can determine which identity provider to use in the --realm parameter by entering the following command to see a list of all available identity providers (you do not need to be logged in to use this command):
    apic identity-providers:list --scope provider --server platform_api_endpoint_url --fields title,realm
    For example,
    apic identity-providers:list --scope provider --server platform_api_endpoint_url --fields title,realm 
    total_results: 2
    results:
      - title: API Manager User Registry
        realm: provider/default-idp-2
      - title: Corporate LDAP user registry
        realm: provider/corporate-ldap
    The title value should enable you to determine which identity provider to use; you can then copy the corresponding --realm parameter directly from the displayed realm value. For any identity providers that were created by your administrator after API Connect was installed, the names will have been determined at creation time. The default API Manager Local User Registry for login as a member of a provider organization is default-idp-2.

    For full details of the apic login command, see Logging in to a management server.

  2. Create a new Drupal state key, or update an existing key, and set the value.
    apic --mode portaladmin drupal-state:set -server management_server --catalog catalogid/name --org orgid/name  --input_format input_format_type --state_key state_key_name --state_value state_value
    Where:
    • management_server is the endpoint URL of the management server (required).
    • catalogid/name is the ID or name of the catalog that the site belongs to (required).
    • orgid/name is the ID or name of the provider organization that the catalog belongs to (required).
    • input_format_type is the input format of the value for the state key. Can be string, integer, float, boolean, json, or yaml. Defaults to auto, which means that you can omit this parameter, and the toolkit CLI will decide which format to use.
    • state_key_name is the name of the state key, for example system.cron_last (required).
    • state_value is the value to assign to the state key (required).
    • --format is the output format. Can be json, yaml, go-template=..., go-template-file=.... Defaults to yaml.
    For example, to create a new key called testKey, and set the value to 123:
    apic --mode portaladmin drupal-state:set -s my.management.server.com -o myorg -c dev-catalog --input_format yaml --state_key testKey --state_value 123
    Successfully set state testKey to the value of 123
  3. Get the value for a particular Drupal state key.
    apic --mode portaladmin drupal-state:get --server management_server --catalog catalogid/name --org orgid/name  --format format_type --state_key state_key_name
    For example, to get the value of the state key testKey:
    apic --mode portaladmin drupal-state:get -s my.management.server.com -c dev-catalog -o myorg --format yaml --state_key testKey
    testKey: 123
  4. Delete a specific Drupal state key and its value.
    apic --mode portaladmin drupal-state:delete --server management_server --catalog catalogid/name --org orgid/name --state_key state_key_name
    For example, to delete the state key testKey and its value:
    apic --mode portaladmin drupal-state:delete -s my.management.server.com -c dev-catalog -o myorg --state_key testKey
    The key/value was successfully deleted.