API Reference

Complete API documentation for the Slingshot SDK.

Client

class slingshot.client.SlingshotClient(api_key: str | None = None, api_url: str = 'https://slingshot.capitalone.com/prod/api/gradient/v1')[source]

Bases: object

SlingshotClient is a client for interacting with the Slingshot API.

__init__(api_key: str | None = None, api_url: str = 'https://slingshot.capitalone.com/prod/api/gradient/v1')[source]

Initialize the Slingshot client.

Parameters:
  • api_key (str) – The API key for authentication. If not provided, it will look for the environment variable SLINGSHOT_API_KEY.

  • api_url (str) – The base URL for the Slingshot API. Defaults to DEFAULT API_URL.

Raises:

ValueError – If the API key is not provided and not found in the environment.

Example

>>> from slingshot.client import SlingshotClient
>>> client = SlingshotClient(api_key="your_api_key")
property projects: ProjectAPI

Get the projects API client.

API Schema Types

These are the data types returned by the API methods that match the Slingshot API schema.

class slingshot.types.ProjectSchema(_typename, _fields=None, /, **kwargs)[source]

Bases: dict

Schema for a project in Slingshot.

created_at: str | None
updated_at: str | None
id: str | None
name: str | None
app_id: str | None
cluster_path: str | None
job_id: str | None
workspace_id: str | None
creator_id: str | None
product_code: str | None
description: str | None
settings: ProjectSettingsSchema | None
metrics: ProjectMetricsSchema | None
creator: ProjectCreatorSchema | None
phase: str | None
product_name: str | None

API Modules

Projects API

class slingshot.api.projects.ProjectAPI(client: SlingshotClient)[source]

Bases: object

API for managing projects in Slingshot.

__init__(client: SlingshotClient)[source]

Initialize the ProjectAPI.

create(name: str, product_code: str, app_id: str | None = Ellipsis, cluster_path: str | None = Ellipsis, job_id: str | None = Ellipsis, workspaceId: str | None = Ellipsis, subscriptionId: str | None = Ellipsis, description: str | None = Ellipsis, cluster_log_url: str | None = Ellipsis, settings: AssignSettingsSchema | None = Ellipsis) ProjectSchema[source]

Create a new project.

Note: See API documentation for default values of parameters.

Parameters:
  • name (str) – The name of the project.

  • product_code (str) – The product code associated with the project.

  • settings (AssignSettingsSchema, optional) – A object for

  • settings. (additional)

  • app_id (Optional[str], optional) – The application ID.

  • cluster_path (Optional[str], optional) – The path to the cluster.

  • job_id (Optional[str], optional) – The job ID.

  • workspaceId (Optional[str], optional) – The workspace ID.

  • subscriptionId (Optional[str], optional) – The subscription ID.

  • description (Optional[str], optional) – A description for the project.

  • cluster_log_url (Optional[str], optional) – The URL for cluster logs.

  • settings – An object that specifies options. sla_minutes (Optional[int], optional): Option to set the SLA minutes. fix_scaling_type (Optional[bool], optional): Option to fix the scaling type. auto_apply_recs (Optional[bool], optional): Option to auto apply recommendations. optimize_instance_size (Optional[bool], optional): Option to optimize the instance size.

Returns:

The details of the newly created project.

Return type:

ProjectSchema

update(project_id: str, name: str | None = Ellipsis, cluster_path: str | None = Ellipsis, job_id: str | None = Ellipsis, workspaceId: str | None = Ellipsis, subscriptionId: str | None = Ellipsis, description: str | None = Ellipsis, cluster_log_url: str | None = Ellipsis, settings: AssignSettingsSchema | None = Ellipsis) ProjectSchema[source]

Update an existing project’s attributes.

Note: See API documentation for default values of parameters.

Parameters:
  • project_id (str) – The ID of the project to update.

  • name (Optional[str], optional) – The new name for the project.

  • cluster_path (Optional[str], optional) – The new path to the cluster.

  • job_id (Optional[str], optional) – The new job ID.

  • workspaceId (Optional[str], optional) – The new workspace ID.

  • subscriptionId (Optional[str], optional) – The new subscription ID.

  • description (Optional[str], optional) – The new description for the

  • project.

  • cluster_log_url (Optional[str], optional) – The new URL for cluster logs.

  • settings (AssignSettingsSchema, optional) – An object that specifies options. sla_minutes (Optional[int], optional): Option to set the SLA minutes. fix_scaling_type (Optional[bool], optional): Option to fix the scaling type. auto_apply_recs (Optional[bool], optional): Option to auto apply recommendations. optimize_instance_size (Optional[bool], optional): Option to optimize the instance size.

Returns:

The details of the updated project.

Return type:

ProjectSchema

get_projects(include: list[str], creator_id: str | None = None, app_id: str | None = None, job_id: str | None = None, page: int = 1, size: int = 50) Page[ProjectSchema][source]

Retrieve a paginated list of projects based on filter criteria.

Parameters:
  • include (list[str]) – Specifies related resources to include the

  • response.

  • creator_id (Optional[str], optional) – The ID of the creator to

  • None. (Defaults to)

  • app_id (Optional[str], optional) – The application ID to filter

  • None.

  • job_id (Optional[str], optional) – The job ID to filter projects by.

  • None.

  • page (int, optional) – The page number to retrieve. Defaults to 1.

  • size (int, optional) – The number of projects to retrieve per page.

  • 50. (Defaults to)

Returns:

A list of project details for the requested page.

Return type:

Page[ProjectSchema]

iterate_projects(include: list[str], creator_id: str | None = None, app_id: str | None = None, job_id: str | None = None, size: int = 50, max_pages: int = 1000) Iterator[ProjectSchema][source]

A memory-efficient generator that fetches all projects page by page.

Parameters:
  • include (list[str]) – Specifies related resources to include the

  • response.

  • creator_id (Optional[str], optional) – The ID of the creator to

  • None. (Defaults to)

  • app_id (Optional[str], optional) – The application ID to filter

  • None.

  • job_id (Optional[str], optional) – The job ID to filter projects by.

  • None.

  • size (int, optional) – The number of projects to retrieve per page.

  • 50. (Defaults to)

  • max_pages (int, optional) – The maximum number of pages allowed to

  • 1000. (traverse. Defaults to)

Yields:

Iterator[ProjectSchema] – A project object, one at a time.

get_project(project_id: str, include: list[str]) ProjectSchema[source]

Fetch a project by its ID.

Parameters:
  • project_id (str) – The ID of the project to fetch.

  • include (list[str]) – Specifies related resources to include the

  • response.

Returns:

The project details.

Return type:

ProjectSchema

create_project_recommendation(project_id: str) RecommendationDetailsSchema[source]

Create a new recommendation for a given project.

Parameters:
  • project_id (str) – The ID of the project to create a recommendation

  • for.

Returns:

The recommendation creation status object.

Return type:

RecommendationDetailsSchema

get_project_recommendation(recommendation_id: str, project_id: str) RecommendationDetailsSchema[source]

Fetch a specific recommendation for a project.

Parameters:
  • recommendation_id (str) – The ID of the recommendation to fetch.

  • project_id (str) – The ID of the project that the recommendation

  • to. (belongs)

Returns:

The details of the specific recommendation.

Return type:

RecommendationDetailsSchema