Ansys Instance Management gRPC API

1.1.3 · active · verified Thu Apr 16

This library provides the autogenerated Python gRPC interface for the Ansys Platform Instance Management service. It allows Python applications to interact with the Ansys Platform to manage instances of Ansys products and services. The current version is 1.1.3, and it follows a release cadence tied to updates in the underlying gRPC API definition.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to establish an insecure gRPC connection to a local Ansys Platform Instance Management service endpoint and call the `ListInstances` method. For production environments, secure channels (e.g., `grpc.secure_channel`) and robust authentication (e.g., API keys, JWT tokens via call credentials) are mandatory. The `GRPC_TARGET` can be configured via an environment variable.

import grpc
import os
from ansys.api.platform.instancemanagement.v1 import instance_management_pb2_grpc
from ansys.api.platform.instancemanagement.v1 import instance_management_pb2

# For local testing without authentication
# For production, use secure channels and proper authentication (e.g., API key, JWT).
# Example with an insecure channel, replace with your gRPC endpoint.
GRPC_TARGET = os.environ.get('ANSYS_PLATFORM_GRPC_TARGET', 'localhost:50051')

try:
    # Establish a gRPC channel
    channel = grpc.insecure_channel(GRPC_TARGET)

    # Create a gRPC client stub
    client = instance_management_pb2_grpc.InstanceManagementServiceStub(channel)

    # Call a sample method (e.g., ListInstances)
    # Note: This operation might require specific permissions or an actual running service
    #       that supports insecure connections or has no instances to list.
    request = instance_management_pb2.ListInstancesRequest()
    response = client.ListInstances(request)

    print(f"Successfully called ListInstances. Found {len(response.instances)} instances.")
    for instance in response.instances:
        print(f"  - Instance ID: {instance.id}, Name: {instance.name}, State: {instance.state}")

except grpc.RpcError as e:
    print(f"gRPC Error: {e.code()} - {e.details()}")
except Exception as e:
    print(f"An unexpected error occurred: {e}")
finally:
    if 'channel' in locals() and channel:
        channel.close()

view raw JSON →