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.
- 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):
For example,apic identity-providers:list --scope provider --server platform_api_endpoint_url --fields title,realm
Theapic 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
title
value should enable you to determine which identity provider to use; you can then copy the corresponding--realm
parameter directly from the displayedrealm
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 isdefault-idp-2
.For full details of the
apic login
command, see Logging in to a management server. - Create a new Drupal state key, or update an existing key, and set the
value.
Where: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
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 bestring
,integer
,float
,boolean
,json
, oryaml
. Defaults toauto
, 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 examplesystem.cron_last
(required).state_value
is the value to assign to the state key (required).--format
is the output format. Can bejson
,yaml
,go-template=...
,go-template-file=...
. Defaults toyaml
.
For example, to create a new key calledtestKey
, and set the value to123
: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
- 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 keytestKey
:apic --mode portaladmin drupal-state:get -s my.management.server.com -c dev-catalog -o myorg --format yaml --state_key testKey testKey: 123
- 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 keytestKey
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.