Initializing help system before first use

Insight Scenario REST API client

Topics covered in this chapter:

Introduction

The subpackage xpressinsight.scenario can be used to interact with an Insight v5 server using the REST web service interface. You can use the xpressinsight.scenario package to create, update and delete apps, folders and scenarios; to read and write entity data; to access and update scenario and app attachments, and to execute scenarios.

xpressinsight.scenario can be used both inside and outside Insight apps. When used within an Insight app, there is no relationship between the calls made through xpressinsight.scenario and the currently running scenario (any reads or writes behave as though they came from outside the scenario).

Your Python script file should import the xpressinsight.scenario package in the usual way:

import xpressinsight.scenario as ins

Thereafter, all xpressinsight.scenario types can be accessed by prepending "ins.". This is the standard way of importing the xpressinsight.scenario package. Many example fragments given in this document will assume that the package has been imported in this way.

After importing, you must instantiate an ins.InsightRestClient object, passing in the URL of the Insight server. Authentication information (client-id and secret values, generated from the Insight UI) are read from the Windows credential manager or Mac keychain entry named "ficoxpress:<insight_server_url>" (where <insight_server_url> is the URL of the Insight server); consult the Insight 5 documentation for detailed instructions on how to configure this. For example:

client = ins.InsightRestClient('http://localhost:8080/')

When running on Mac, the client ID must be passed to the InsightRestClient constructor to enable the keychain entry to be found:

client = ins.InsightRestClient('http://localhost:8080/',
    client_id='<replace-this-with-client-id>')

Alternately, on any platform, the credentials can be passed explicitly as arguments in the Python script:

client = ins.InsightRestClient('http://localhost:8080/',
    client_id='<replace-this-with-client-id>',
    secret='<replace-this-with-secret>')

The client ID and secret are credentials giving access to your Insight 5 account - you should never hard-code the secret in a Python source file. Requests you make through the InsightRestClient are performed as the user that generated the client ID and secret, and the operations that can be performed are restricted by the authorities granted to that account.

When you want to use the InsightRestClient from within an Insight app, you can instantiate it from the AppInterface.get_rest_client function, which avoids passing the insight URL, e.g.:

client = self.insight.get_rest_client(
    client_id='<replace-this-with-client-id>',
    secret='<replace-this-with-secret>')

Finally, if your Insight app is running within DMP, you can omit the client_id and secret entirely. When you do this, InsightRestClient automatically makes requests under an Insight user named "solutionclient", and must add this user to any apps you want to access, using the Insight administration UI. Depending on which actions you want to perform, you might also need to grant additional authorities to the "solutionclient" user.

client = self.insight.get_rest_client()
#  client authorized using 'solutionclient' user

By whatever method you create your InsightRestClient instance, you can then use it to perform operations using the Insight 5 REST API. For example, to create a new scenario within an app:

my_scenario = client.create_scenario(
    name='My New Scenario',
    parent=ins.reference.to_app('570b9100-46e3-4643-baee--2e24aa538f25'))

Or to read the 'factories' frame from a scenario:

@xi.ScenarioData()
class FactoriesInfo:
    factories: xi.data.DataFrame(columns=[
        xi.data.Column('costs'),
        xi.data.Column('units_manufactured')
    ])

my_factories_info = client.get_scenario_data(
    scenario_id='bfc697fb-53e7-435b-ade0-0b4b632134b4',
    scenario_data_class=FactoryInfo)

Full details on the functions supported can be found in xpressinsight.scenario.InsightRestClient.

The InsightRestClient classes

xpressinsight.scenario.InsightRestClient

Allows interaction with an Insight v5 server through its REST API.
Creates a new InsightRestApi instance, which can be used to interact with an Insight v5 server through its REST API.
Instructs Insight server to cancel any execution of the given scenario.
Create a copy of an existing scenario within an app.
Create a new app.
Create a new folder within an app.
Create a new scenario within an app.
Delete an existing app and all scenarios within it.
Delete the specified app attachment.
Delete an existing folder, including any subfolders and scenarios within it.
Delete an existing scenario within an app.
Delete the specified scenario attachment.
Execute the scenario, optionally waiting for the job to complete.
Get information about all the attachments on the given app.
Get the app records for all apps that the REST API client credentials have permission to access.
Get information about all the attachments on the given scenario.
Get the app record for the app with the given ID.
Download the indicated app attachment.
Get information about a given app attachment.
Get information about the users who can access the given app.
Get information about all the tags defined for the given app.
Get the folders and scenarios that are the immediate children of the given folder or app.
Get the scenario record for the folder with the given ID.
Get the scenario, folder, or app record for the given repository path.
Get the scenario record for the scenario with the given ID.
Download the indicated scenario attachment.
Get information about a given scenario attachment.
Loads the entities described in annotations on the given class, from the given scenario, into an instance of the given class.
Get the run log captured during the completed scenario execution.
Get the user record with the specified ID.
Check whether a scenario is currently executing or about to execute.
Move a folder to a different parent folder or to the app root.
Move a scenario to a different folder or the app root.
Upload an app attachment, either creating a new attachment or overwriting an existing one of the same name.
Upload a scenario attachment, either creating a new attachment or overwriting an existing one of the same name.
Rename an existing folder.
Rename an existing scenario
Update the filename, description, tags or 'hidden' flag for the given app attachment.
Update folder owner and (optionally) share status.
Update folder share status.
Updates the filename, description, tags or 'hidden' flag for the given scenario attachment.
Update scenario owner and (optionally) share status.
Update scenario share status.
Update the values of one or more entities in an Insight scenario.
Upgrade an existing app.
Wait until any queued or in-progress scenario execution has completed.

xpressinsight.scenario.App

Information about a single app.

xpressinsight.scenario.AppCreationResponse

Information about an app creation.

xpressinsight.scenario.AppMember

Information about a user who has access to an app.

xpressinsight.scenario.AppUpgradeResponse

Information about an app upgrade.

xpressinsight.scenario.ArrayUpdate

Representation of an update to the applied to the value of an array entity.

xpressinsight.scenario.Attachment

Information about a single scenario or app attachment.

xpressinsight.scenario.AttachmentTag

Information about a single attachment tag.

xpressinsight.scenario.AttachmentUpdate

Information about an update to apply to the metadata of a scenario or app attachment.

xpressinsight.scenario.BearerToken

Class containing a bearer token that can be used to authorize a request to the Insight 5 REST API, and the date/time after which the token is no longer valid.

xpressinsight.scenario.EntityUpdate

Abstract superclass representing an update to be applied to the value of an entity in a scenario.

xpressinsight.scenario.Folder

Information about a single folder.

xpressinsight.scenario.IndexUpdate

Representation of an update to the value of an index entity (also known as a set entity).

xpressinsight.scenario.ModelStatus

Enumeration of the possible states a scenario can have after execution.

xpressinsight.scenario.ObjectType

Enumeration of the different types of object that can be returned by the Insight server.

xpressinsight.scenario.ProblemStatus

Enumeration of the possible states an optimization problem can have.

xpressinsight.scenario.Reference

Class containing an ID and object type; used to refer to other objects in the Insight data model where the type cannot be inferred from the context.
Shorthand for creating a Reference to an app of the given ID.
Shorthand for creating a Reference to a folder of the given ID.
Shorthand for creating a Reference to a folder of the given ID.

xpressinsight.scenario.ScalarUpdate

Representation of an update to be applied to the value of a scalar entity.

xpressinsight.scenario.Scenario

Information about a single scenario.

xpressinsight.scenario.ScenarioDataState

Enumeration of the possible states that a scenario's entity data can be in.

xpressinsight.scenario.ScenarioSummary

Summary of the state of a scenario, its data, and the most recent job that executed it.

xpressinsight.scenario.ShareStatus

Enumeration of the different ways a scenario or folder can be shared with other users.

xpressinsight.scenario.User

Information about a user account.

xpressinsight.scenario.UserStatus

Enumeration of the different possible states of a user's account.

© 2001-2024 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.