From ffee4bf8e5c6ef0aa487cdf3af850a15bccfac12 Mon Sep 17 00:00:00 2001 From: Jay Sharma <42339291+Jayssgss@users.noreply.github.com> Date: Tue, 17 Mar 2026 17:54:07 +0530 Subject: [PATCH 1/6] Automate SDK Updation and PyPI publishing --- automation/publish_pypi.sh | 280 ++++++++++++++++++++++++++++ automation/update_sdk.sh | 363 +++++++++++++++++++++++++++++++++++++ 2 files changed, 643 insertions(+) create mode 100755 automation/publish_pypi.sh create mode 100755 automation/update_sdk.sh diff --git a/automation/publish_pypi.sh b/automation/publish_pypi.sh new file mode 100755 index 0000000..f328036 --- /dev/null +++ b/automation/publish_pypi.sh @@ -0,0 +1,280 @@ +#!/bin/bash + +# ============================================================================= +# INSTANA PYTHON SDK PYPI PUBLISHING SCRIPT +# ============================================================================= +# This script handles publishing the SDK to PyPI +# ============================================================================= + +set -e # Exit on any error + +# Colors for output +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +CYAN='\033[0;36m' +NC='\033[0m' # No Color + +# Configuration +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +PROJECT_ROOT="$(dirname "$SCRIPT_DIR")" +PYPI_USERNAME="${PYPI_USERNAME:-__token__}" +PYPI_PASSWORD="${PYPI_PASSWORD:-}" +PYPI_REPOSITORY="${PYPI_REPOSITORY:-pypi}" +DRY_RUN="${DRY_RUN:-false}" + +# Function to print colored output +print_header() { + echo -e "\n${CYAN}========================================${NC}" + echo -e "${CYAN}$1${NC}" + echo -e "${CYAN}========================================${NC}\n" +} + +print_status() { + echo -e "${BLUE}[INFO]${NC} $1" +} + +print_success() { + echo -e "${GREEN}[SUCCESS]${NC} $1" +} + +print_warning() { + echo -e "${YELLOW}[WARNING]${NC} $1" +} + +print_error() { + echo -e "${RED}[ERROR]${NC} $1" +} + +# Function to show usage +show_usage() { + cat << EOF +Usage: $0 [OPTIONS] + +Publish Instana Python SDK to PyPI + +OPTIONS: + -u, --username USER PyPI username (default: __token__) + -p, --password PASS PyPI password/token (required) + -r, --repository REPO PyPI repository (default: pypi, use testpypi for testing) + -d, --dry-run Check packages without uploading + -h, --help Show this help message + +EXAMPLES: + # Publish to PyPI with token + $0 --password YOUR_PYPI_TOKEN + + # Publish to Test PyPI + $0 --password YOUR_TEST_TOKEN --repository testpypi + + # Dry run to check packages + $0 --dry-run + + # Publish with username/password (legacy) + $0 --username myuser --password mypassword + +ENVIRONMENT VARIABLES: + PYPI_USERNAME PyPI username (default: __token__) + PYPI_PASSWORD PyPI password/token + PYPI_REPOSITORY PyPI repository (default: pypi) + +NOTES: + - For PyPI API tokens, use username: __token__ + - Get tokens at: https://pypi.org/manage/account/token/ + - Test PyPI: https://test.pypi.org/manage/account/token/ + +EOF +} + +# Parse command line arguments +while [[ $# -gt 0 ]]; do + case $1 in + -u|--username) + PYPI_USERNAME="$2" + shift 2 + ;; + -p|--password) + PYPI_PASSWORD="$2" + shift 2 + ;; + -r|--repository) + PYPI_REPOSITORY="$2" + shift 2 + ;; + -d|--dry-run) + DRY_RUN=true + shift + ;; + -h|--help) + show_usage + exit 0 + ;; + *) + print_error "Unknown option: $1" + show_usage + exit 1 + ;; + esac +done + +# Change to project root +cd "$PROJECT_ROOT" + +print_header "Instana Python SDK PyPI Publishing" +print_status "Project root: $PROJECT_ROOT" +print_status "Repository: $PYPI_REPOSITORY" +print_status "Username: $PYPI_USERNAME" +print_status "Dry run: $DRY_RUN" + +# ============================================================================= +# STEP 1: Validate prerequisites +# ============================================================================= +print_header "Step 1: Validating prerequisites" + +# Check if dist directory exists +if [ ! -d "dist" ]; then + print_error "dist/ directory not found" + print_status "Run './automation/update_sdk.sh' first to build packages" + exit 1 +fi + +# Check if packages exist +PACKAGE_COUNT=$(ls -1 dist/*.whl dist/*.tar.gz 2>/dev/null | wc -l) +if [ "$PACKAGE_COUNT" -eq 0 ]; then + print_error "No distribution packages found in dist/" + print_status "Run './automation/update_sdk.sh' first to build packages" + exit 1 +fi + +print_success "Found $PACKAGE_COUNT distribution package(s)" +ls -lh dist/ + +# Get version from package +CURRENT_VERSION=$(grep "^VERSION = " setup.py | sed 's/VERSION = "\(.*\)"/\1/') +print_status "SDK version: $CURRENT_VERSION" + +# ============================================================================= +# STEP 2: Setup publishing environment +# ============================================================================= +print_header "Step 2: Setting up publishing environment" + +if [ "$DRY_RUN" = false ]; then + # Create virtual environment for publishing + print_status "Creating virtual environment..." + python3 -m venv .venv-publish + source .venv-publish/bin/activate + + # Install twine + print_status "Installing twine..." + pip install --upgrade twine + + print_success "Publishing environment ready" +else + print_status "DRY RUN: Would create virtual environment and install twine" +fi + +# ============================================================================= +# STEP 3: Check packages +# ============================================================================= +print_header "Step 3: Checking packages" + +if [ "$DRY_RUN" = false ]; then + source .venv-publish/bin/activate + + print_status "Running twine check..." + if twine check dist/*; then + print_success "Package check passed" + else + print_error "Package check failed" + deactivate + rm -rf .venv-publish + exit 1 + fi +else + print_status "DRY RUN: Would run twine check on packages" +fi + +# ============================================================================= +# STEP 4: Upload to PyPI +# ============================================================================= +if [ "$DRY_RUN" = false ]; then + print_header "Step 4: Uploading to PyPI" + + # Validate credentials + if [ -z "$PYPI_PASSWORD" ]; then + print_error "PyPI password/token is required" + print_status "Use --password option or set PYPI_PASSWORD environment variable" + deactivate + rm -rf .venv-publish + exit 1 + fi + + source .venv-publish/bin/activate + + print_status "Uploading packages to $PYPI_REPOSITORY..." + print_status "This may take a moment..." + + # Upload to PyPI + if [ "$PYPI_REPOSITORY" = "pypi" ]; then + twine upload dist/* -u "$PYPI_USERNAME" -p "$PYPI_PASSWORD" + PACKAGE_URL="https://pypi.org/project/instana-client/$CURRENT_VERSION/" + elif [ "$PYPI_REPOSITORY" = "testpypi" ]; then + twine upload --repository testpypi dist/* -u "$PYPI_USERNAME" -p "$PYPI_PASSWORD" + PACKAGE_URL="https://test.pypi.org/project/instana-client/$CURRENT_VERSION/" + else + twine upload --repository "$PYPI_REPOSITORY" dist/* -u "$PYPI_USERNAME" -p "$PYPI_PASSWORD" + PACKAGE_URL="Custom repository: $PYPI_REPOSITORY" + fi + + print_success "Successfully uploaded to $PYPI_REPOSITORY" + + deactivate +else + print_header "Step 4: Upload Preview (Dry Run)" + print_status "Would upload the following packages:" + ls -1 dist/ + print_status "To repository: $PYPI_REPOSITORY" + print_status "With username: $PYPI_USERNAME" +fi + +# ============================================================================= +# STEP 5: Cleanup +# ============================================================================= +print_header "Step 5: Cleanup" + +if [ "$DRY_RUN" = false ]; then + rm -rf .venv-publish + print_success "Cleanup complete" +else + print_status "DRY RUN: Would cleanup virtual environment" +fi + +# ============================================================================= +# Summary +# ============================================================================= +print_header "Publishing Summary" + +if [ "$DRY_RUN" = false ]; then + echo -e "${GREEN}✅ Publishing Complete!${NC}\n" + echo "Package: instana-client" + echo "Version: $CURRENT_VERSION" + echo "Repository: $PYPI_REPOSITORY" + echo "" + echo "Package URL: $PACKAGE_URL" + echo "" + echo "Next steps:" + echo "1. Verify package on PyPI" + echo "2. Test installation: pip install instana-client==$CURRENT_VERSION" + echo "3. Create git tag: git tag v$CURRENT_VERSION" + echo "4. Push tag: git push origin v$CURRENT_VERSION" + echo "5. Create GitHub release" +else + echo "This was a DRY RUN - no packages were uploaded" + echo "Run without --dry-run to publish to PyPI" + echo "" + echo "Packages ready for upload:" + ls -1 dist/ +fi + +print_success "Publishing process complete! 🎉" diff --git a/automation/update_sdk.sh b/automation/update_sdk.sh new file mode 100755 index 0000000..12e62ca --- /dev/null +++ b/automation/update_sdk.sh @@ -0,0 +1,363 @@ +#!/bin/bash + +# ============================================================================= +# INSTANA PYTHON SDK UPDATE SCRIPT +# ============================================================================= +# This script automates the SDK update process including: +# - Regenerating SDK code from OpenAPI spec +# - Running tests +# - Version bumping +# - Building distribution packages +# ============================================================================= + +set -e # Exit on any error + +# Colors for output +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +CYAN='\033[0;36m' +NC='\033[0m' # No Color + +# Configuration +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +PROJECT_ROOT="$(dirname "$SCRIPT_DIR")" +OPENAPI_SPEC_PATH="${OPENAPI_SPEC_PATH:-}" +NEW_VERSION="${NEW_VERSION:-}" +SKIP_TESTS="${SKIP_TESTS:-false}" +SKIP_BUILD="${SKIP_BUILD:-false}" +DRY_RUN="${DRY_RUN:-false}" + +# Function to print colored output +print_header() { + echo -e "\n${CYAN}========================================${NC}" + echo -e "${CYAN}$1${NC}" + echo -e "${CYAN}========================================${NC}\n" +} + +print_status() { + echo -e "${BLUE}[INFO]${NC} $1" +} + +print_success() { + echo -e "${GREEN}[SUCCESS]${NC} $1" +} + +print_warning() { + echo -e "${YELLOW}[WARNING]${NC} $1" +} + +print_error() { + echo -e "${RED}[ERROR]${NC} $1" +} + +# Function to show usage +show_usage() { + cat << EOF +Usage: $0 [OPTIONS] + +Automate Instana Python SDK updates + +OPTIONS: + -s, --spec-path PATH Path to OpenAPI spec file (required) + -v, --version VERSION New SDK version (e.g., 1.0.5) + -t, --skip-tests Skip running tests + -b, --skip-build Skip building distribution packages + -d, --dry-run Perform dry run (no actual changes) + -h, --help Show this help message + +EXAMPLES: + # Update with new spec and auto-increment version + $0 --spec-path ./openapi.yaml + + # Update with specific version + $0 --spec-path ./openapi-1.316.yaml --version 1.0.5 + + # Dry run to see what would happen + $0 --spec-path ./openapi.yaml --dry-run + + # Update without building packages + $0 --spec-path ./openapi.yaml --skip-build + +ENVIRONMENT VARIABLES: + OPENAPI_SPEC_PATH Default OpenAPI spec path + NEW_VERSION Default new version + +EOF +} + +# Parse command line arguments +while [[ $# -gt 0 ]]; do + case $1 in + -s|--spec-path) + OPENAPI_SPEC_PATH="$2" + shift 2 + ;; + -v|--version) + NEW_VERSION="$2" + shift 2 + ;; + -t|--skip-tests) + SKIP_TESTS=true + shift + ;; + -b|--skip-build) + SKIP_BUILD=true + shift + ;; + -d|--dry-run) + DRY_RUN=true + shift + ;; + -h|--help) + show_usage + exit 0 + ;; + *) + print_error "Unknown option: $1" + show_usage + exit 1 + ;; + esac +done + +# Validate required parameters +if [ -z "$OPENAPI_SPEC_PATH" ]; then + print_error "OpenAPI spec path is required" + show_usage + exit 1 +fi + +# Validate spec file exists +if [ ! -f "$OPENAPI_SPEC_PATH" ]; then + print_error "OpenAPI spec file not found: $OPENAPI_SPEC_PATH" + exit 1 +fi + +# Change to project root +cd "$PROJECT_ROOT" + +print_header "Instana Python SDK Update" +print_status "Project root: $PROJECT_ROOT" +print_status "OpenAPI spec: $OPENAPI_SPEC_PATH" +print_status "Dry run: $DRY_RUN" + +# ============================================================================= +# STEP 1: Backup current state +# ============================================================================= +print_header "Step 1: Backing up current state" + +BACKUP_DIR="$PROJECT_ROOT/.backup_$(date +%Y%m%d_%H%M%S)" +if [ "$DRY_RUN" = false ]; then + mkdir -p "$BACKUP_DIR" + cp -r instana_client "$BACKUP_DIR/" + cp setup.py pyproject.toml "$BACKUP_DIR/" + print_success "Backup created at: $BACKUP_DIR" +else + print_status "DRY RUN: Would create backup at $BACKUP_DIR" +fi + +# ============================================================================= +# STEP 2: Copy OpenAPI spec to project root +# ============================================================================= +print_header "Step 2: Preparing OpenAPI specification" + +print_status "Using spec file: $OPENAPI_SPEC_PATH" +if [ "$DRY_RUN" = false ]; then + # Copy to project root as openapi.yaml + cp "$OPENAPI_SPEC_PATH" openapi.yaml + print_success "Copied OpenAPI spec to project root" +else + print_status "DRY RUN: Would copy from $OPENAPI_SPEC_PATH" +fi + +# Extract version from OpenAPI spec +SPEC_VERSION=$(grep -m 1 "version:" openapi.yaml | sed 's/.*version: *//;s/"//g;s/'\''//g' | tr -d ' ') +print_status "OpenAPI spec version: $SPEC_VERSION" + +# ============================================================================= +# STEP 3: Determine new SDK version +# ============================================================================= +print_header "Step 3: Determining SDK version" + +CURRENT_VERSION=$(grep "^VERSION = " setup.py | sed 's/VERSION = "\(.*\)"/\1/') +print_status "Current SDK version: $CURRENT_VERSION" + +if [ -z "$NEW_VERSION" ]; then + # Auto-increment patch version + IFS='.' read -ra VERSION_PARTS <<< "$CURRENT_VERSION" + MAJOR="${VERSION_PARTS[0]}" + MINOR="${VERSION_PARTS[1]}" + PATCH="${VERSION_PARTS[2]}" + NEW_PATCH=$((PATCH + 1)) + NEW_VERSION="$MAJOR.$MINOR.$NEW_PATCH" + print_status "Auto-incremented version to: $NEW_VERSION" +else + print_status "Using specified version: $NEW_VERSION" +fi + +# ============================================================================= +# STEP 4: Generate SDK code +# ============================================================================= +print_header "Step 4: Generating SDK code" + +if [ "$DRY_RUN" = false ]; then + print_status "Running OpenAPI generator..." + + # Check if openapi-generator-cli is available + if ! command -v openapi-generator-cli &> /dev/null; then + print_error "openapi-generator-cli not found. Please install it first." + print_status "Install with: npm install -g @openapitools/openapi-generator-cli" + exit 1 + fi + + openapi-generator-cli generate \ + -i openapi.yaml \ + -g python \ + -o . \ + --config openapi-generator-config.json \ + --skip-validate-spec + + print_success "SDK code generated" +else + print_status "DRY RUN: Would generate SDK code" +fi + +# ============================================================================= +# STEP 5: Update version numbers +# ============================================================================= +print_header "Step 5: Updating version numbers" + +if [ "$DRY_RUN" = false ]; then + # Update setup.py + sed -i.bak "s/VERSION = \"$CURRENT_VERSION\"/VERSION = \"$NEW_VERSION\"/" setup.py + + # Update pyproject.toml + sed -i.bak "s/version = \"$CURRENT_VERSION\"/version = \"$NEW_VERSION\"/" pyproject.toml + + # Update __init__.py + sed -i.bak "s/__version__ = \"$CURRENT_VERSION\"/__version__ = \"$NEW_VERSION\"/" instana_client/__init__.py + + # Update api_client.py + sed -i.bak "s/OpenAPI-Generator\/$CURRENT_VERSION/OpenAPI-Generator\/$NEW_VERSION/" instana_client/api_client.py + + # Update configuration.py + sed -i.bak "s/SDK Package Version: $CURRENT_VERSION/SDK Package Version: $NEW_VERSION/" instana_client/configuration.py + + # Clean up backup files + rm -f setup.py.bak pyproject.toml.bak instana_client/__init__.py.bak \ + instana_client/api_client.py.bak instana_client/configuration.py.bak + + print_success "Version updated to $NEW_VERSION" +else + print_status "DRY RUN: Would update version from $CURRENT_VERSION to $NEW_VERSION" +fi + +# ============================================================================= +# STEP 6: Run tests +# ============================================================================= +if [ "$SKIP_TESTS" = false ]; then + print_header "Step 6: Running tests" + + if [ "$DRY_RUN" = false ]; then + # Run sanity tests + print_status "Running sanity tests..." + if ./sanity_test.sh; then + print_success "Sanity tests passed" + else + print_error "Sanity tests failed" + print_warning "Restoring from backup..." + rm -rf instana_client setup.py pyproject.toml + cp -r "$BACKUP_DIR"/* . + exit 1 + fi + + # Run unit tests + print_status "Running unit tests..." + if python3 -m pytest test/ -v --tb=short --maxfail=5; then + print_success "Unit tests passed" + else + print_warning "Some unit tests failed (this is expected for stub tests)" + fi + else + print_status "DRY RUN: Would run sanity and unit tests" + fi +else + print_warning "Skipping tests (--skip-tests flag set)" +fi + +# ============================================================================= +# STEP 7: Build distribution packages +# ============================================================================= +if [ "$SKIP_BUILD" = false ]; then + print_header "Step 7: Building distribution packages" + + if [ "$DRY_RUN" = false ]; then + # Clean previous builds + rm -rf dist/ build/ *.egg-info + + # Create virtual environment for build + python3 -m venv .venv-build + source .venv-build/bin/activate + pip install --upgrade build + + # Build packages + python -m build + + print_success "Distribution packages built" + ls -lh dist/ + + deactivate + rm -rf .venv-build + else + print_status "DRY RUN: Would build distribution packages" + fi +else + print_warning "Skipping build (--skip-build flag set)" +fi + +# ============================================================================= +# STEP 8: Cleanup +# ============================================================================= +print_header "Step 8: Cleanup" + +if [ "$DRY_RUN" = false ]; then + rm -rf build/ *.egg-info + print_success "Cleanup complete" + + # Keep backup for safety + print_status "Backup preserved at: $BACKUP_DIR" + print_status "Remove manually if update is successful" +else + print_status "DRY RUN: Would cleanup build artifacts" +fi + +# ============================================================================= +# Summary +# ============================================================================= +print_header "Update Summary" + +echo -e "${GREEN}✅ SDK Update Complete!${NC}\n" +echo "Previous version: $CURRENT_VERSION" +echo "New version: $NEW_VERSION" +echo "OpenAPI spec version: $SPEC_VERSION" +echo "" + +if [ "$DRY_RUN" = false ]; then + echo "Next steps:" + echo "1. Review the changes: git diff" + echo "2. Test the updated SDK" + if [ "$SKIP_BUILD" = false ]; then + echo "3. Publish to PyPI: ./automation/publish_pypi.sh" + fi + echo "4. Commit changes: git add . && git commit -m 'Update SDK to version $NEW_VERSION'" + echo "5. Push to repository: git push" + echo "" + echo "Backup location: $BACKUP_DIR" +else + echo "This was a DRY RUN - no actual changes were made" + echo "Run without --dry-run to perform the actual update" +fi + +print_success "SDK update complete! 🎉" From ffda73592a7d3000ef348aadb5f72bb52231345e Mon Sep 17 00:00:00 2001 From: Jay Sharma <42339291+Jayssgss@users.noreply.github.com> Date: Wed, 18 Mar 2026 16:37:35 +0530 Subject: [PATCH 2/6] Update the python-sdk to 1.0.5 and fix the service.py --- .openapi-generator-ignore | 1 + instana_client/__init__.py | 2 +- instana_client/api_client.py | 2 +- instana_client/configuration.py | 2 +- instana_client/models/service.py | 3 +-- pyproject.toml | 2 +- setup.py | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.openapi-generator-ignore b/.openapi-generator-ignore index bbc5673..dd177d7 100644 --- a/.openapi-generator-ignore +++ b/.openapi-generator-ignore @@ -31,3 +31,4 @@ openapi-generator-config.json # application_resources_api.py - No longer needed, new spec fixes the API design # tag_filter.py - STILL NEEDED: New spec uses Dict[str, Any] which doesn't support string/int/bool values instana_client/models/tag_filter.py +instana_client/models/service.py diff --git a/instana_client/__init__.py b/instana_client/__init__.py index a51e911..de35958 100644 --- a/instana_client/__init__.py +++ b/instana_client/__init__.py @@ -15,7 +15,7 @@ """ # noqa: E501 -__version__ = "1.0.4" +__version__ = "1.0.5" # Define package exports __all__ = [ diff --git a/instana_client/api_client.py b/instana_client/api_client.py index acb09e5..3cae3f8 100644 --- a/instana_client/api_client.py +++ b/instana_client/api_client.py @@ -92,7 +92,7 @@ def __init__( self.default_headers[header_name] = header_value self.cookie = cookie # Set default User-Agent. - self.user_agent = 'OpenAPI-Generator/1.0.4/python' + self.user_agent = 'OpenAPI-Generator/1.0.5/python' self.client_side_validation = configuration.client_side_validation def __enter__(self): diff --git a/instana_client/configuration.py b/instana_client/configuration.py index 696fa64..bb63a33 100644 --- a/instana_client/configuration.py +++ b/instana_client/configuration.py @@ -536,7 +536,7 @@ def to_debug_report(self) -> str: "OS: {env}\n"\ "Python Version: {pyversion}\n"\ "Version of the API: 1.315.1425\n"\ - "SDK Package Version: 1.0.4".\ + "SDK Package Version: 1.0.5".\ format(env=sys.platform, pyversion=sys.version) def get_host_settings(self) -> List[HostSetting]: diff --git a/instana_client/models/service.py b/instana_client/models/service.py index b7c45b5..cac4080 100644 --- a/instana_client/models/service.py +++ b/instana_client/models/service.py @@ -32,8 +32,7 @@ class Service(BaseModel): id: Annotated[str, Field(min_length=1, strict=True)] = Field(description="Unique ID of the Service. Eg: `3feb3dcd206c166ef2b41c707e0cd38d7cd325aa`.") label: Annotated[str, Field(min_length=1, strict=True)] = Field(description="Name of the Service. Eg: `payment`.") snapshot_ids: List[StrictStr] = Field(description="A unique identifier the metrics are assigned to.", alias="snapshotIds") - technologies: List[StrictStr] = Field(description="List of technologies: `Eg:[\"springbootApplicationContainer\"]`") - types: List[StrictStr] = Field(description="Shows types of Endpoints a Service can consist of. It may be one or more. Eg: `HTTP` `OPENTELEMETRY` can be in 1 Service.") + technologies: Optional[List[StrictStr]] = Field(default=None, description="List of technologies: `Eg:[\"springbootApplicationContainer\"]`") types: List[StrictStr] = Field(description="Shows types of Endpoints a Service can consist of. It may be one or more. Eg: `HTTP` `OPENTELEMETRY` can be in 1 Service.") __properties: ClassVar[List[str]] = ["entityType", "id", "label", "snapshotIds", "technologies", "types"] @field_validator('entity_type') diff --git a/pyproject.toml b/pyproject.toml index db7c146..d9490ec 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "instana_client" -version = "1.0.4" +version = "1.0.5" description = "Instana REST API documentation" authors = [ {name = "© Instana",email = "support@instana.com"}, diff --git a/setup.py b/setup.py index f73a51a..c3094a5 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ # prerequisite: setuptools # http://pypi.python.org/pypi/setuptools NAME = "instana-client" -VERSION = "1.0.4" +VERSION = "1.0.5" PYTHON_REQUIRES = ">= 3.9" REQUIRES = [ "urllib3 >= 2.1.0, < 3.0.0", From ff07d35b0c0d9681f3e8b220efc526afe6bc2c40 Mon Sep 17 00:00:00 2001 From: Jay Sharma <42339291+Jayssgss@users.noreply.github.com> Date: Wed, 18 Mar 2026 16:51:10 +0530 Subject: [PATCH 3/6] fix: sanity test --- instana_client/models/service.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/instana_client/models/service.py b/instana_client/models/service.py index cac4080..1d81418 100644 --- a/instana_client/models/service.py +++ b/instana_client/models/service.py @@ -32,7 +32,8 @@ class Service(BaseModel): id: Annotated[str, Field(min_length=1, strict=True)] = Field(description="Unique ID of the Service. Eg: `3feb3dcd206c166ef2b41c707e0cd38d7cd325aa`.") label: Annotated[str, Field(min_length=1, strict=True)] = Field(description="Name of the Service. Eg: `payment`.") snapshot_ids: List[StrictStr] = Field(description="A unique identifier the metrics are assigned to.", alias="snapshotIds") - technologies: Optional[List[StrictStr]] = Field(default=None, description="List of technologies: `Eg:[\"springbootApplicationContainer\"]`") types: List[StrictStr] = Field(description="Shows types of Endpoints a Service can consist of. It may be one or more. Eg: `HTTP` `OPENTELEMETRY` can be in 1 Service.") + technologies: Optional[List[StrictStr]] = Field(default=None, description="List of technologies: `Eg:[\"springbootApplicationContainer\"]`") + types: List[StrictStr] = Field(description="Shows types of Endpoints a Service can consist of. It may be one or more. Eg: `HTTP` `OPENTELEMETRY` can be in 1 Service.") __properties: ClassVar[List[str]] = ["entityType", "id", "label", "snapshotIds", "technologies", "types"] @field_validator('entity_type') From 3af598711b3ea87b6ef5c2a1192e583fcb5aff37 Mon Sep 17 00:00:00 2001 From: Jay Sharma <42339291+Jayssgss@users.noreply.github.com> Date: Wed, 18 Mar 2026 17:28:16 +0530 Subject: [PATCH 4/6] Update PyPI version to 1.0.6 --- instana_client/__init__.py | 2 +- instana_client/api_client.py | 2 +- instana_client/configuration.py | 2 +- pyproject.toml | 2 +- setup.py | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/instana_client/__init__.py b/instana_client/__init__.py index de35958..7b742fa 100644 --- a/instana_client/__init__.py +++ b/instana_client/__init__.py @@ -15,7 +15,7 @@ """ # noqa: E501 -__version__ = "1.0.5" +__version__ = "1.0.6" # Define package exports __all__ = [ diff --git a/instana_client/api_client.py b/instana_client/api_client.py index 3cae3f8..3a58010 100644 --- a/instana_client/api_client.py +++ b/instana_client/api_client.py @@ -92,7 +92,7 @@ def __init__( self.default_headers[header_name] = header_value self.cookie = cookie # Set default User-Agent. - self.user_agent = 'OpenAPI-Generator/1.0.5/python' + self.user_agent = 'OpenAPI-Generator/1.0.6/python' self.client_side_validation = configuration.client_side_validation def __enter__(self): diff --git a/instana_client/configuration.py b/instana_client/configuration.py index bb63a33..23b7683 100644 --- a/instana_client/configuration.py +++ b/instana_client/configuration.py @@ -536,7 +536,7 @@ def to_debug_report(self) -> str: "OS: {env}\n"\ "Python Version: {pyversion}\n"\ "Version of the API: 1.315.1425\n"\ - "SDK Package Version: 1.0.5".\ + "SDK Package Version: 1.0.6".\ format(env=sys.platform, pyversion=sys.version) def get_host_settings(self) -> List[HostSetting]: diff --git a/pyproject.toml b/pyproject.toml index d9490ec..3b8e371 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "instana_client" -version = "1.0.5" +version = "1.0.6" description = "Instana REST API documentation" authors = [ {name = "© Instana",email = "support@instana.com"}, diff --git a/setup.py b/setup.py index c3094a5..6761a07 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ # prerequisite: setuptools # http://pypi.python.org/pypi/setuptools NAME = "instana-client" -VERSION = "1.0.5" +VERSION = "1.0.6" PYTHON_REQUIRES = ">= 3.9" REQUIRES = [ "urllib3 >= 2.1.0, < 3.0.0", From 26fc6b43a478bee3d8b434d8332996dcda118c29 Mon Sep 17 00:00:00 2001 From: Jay Sharma <42339291+Jayssgss@users.noreply.github.com> Date: Wed, 18 Mar 2026 21:25:22 +0530 Subject: [PATCH 5/6] Remove the emojis provided by Bob --- automation/publish_pypi.sh | 4 +- automation/update_sdk.sh | 4 +- sanity_test.sh | 381 ------------------------------------- 3 files changed, 4 insertions(+), 385 deletions(-) delete mode 100755 sanity_test.sh diff --git a/automation/publish_pypi.sh b/automation/publish_pypi.sh index f328036..13bdefa 100755 --- a/automation/publish_pypi.sh +++ b/automation/publish_pypi.sh @@ -256,7 +256,7 @@ fi print_header "Publishing Summary" if [ "$DRY_RUN" = false ]; then - echo -e "${GREEN}✅ Publishing Complete!${NC}\n" + echo -e "Publishing Complete!${NC}\n" echo "Package: instana-client" echo "Version: $CURRENT_VERSION" echo "Repository: $PYPI_REPOSITORY" @@ -277,4 +277,4 @@ else ls -1 dist/ fi -print_success "Publishing process complete! 🎉" +print_success "Publishing process complete!" diff --git a/automation/update_sdk.sh b/automation/update_sdk.sh index 12e62ca..1667a14 100755 --- a/automation/update_sdk.sh +++ b/automation/update_sdk.sh @@ -338,7 +338,7 @@ fi # ============================================================================= print_header "Update Summary" -echo -e "${GREEN}✅ SDK Update Complete!${NC}\n" +echo -e "SDK Update Complete!${NC}\n" echo "Previous version: $CURRENT_VERSION" echo "New version: $NEW_VERSION" echo "OpenAPI spec version: $SPEC_VERSION" @@ -360,4 +360,4 @@ else echo "Run without --dry-run to perform the actual update" fi -print_success "SDK update complete! 🎉" +print_success "SDK update complete!" diff --git a/sanity_test.sh b/sanity_test.sh deleted file mode 100755 index 074e4c6..0000000 --- a/sanity_test.sh +++ /dev/null @@ -1,381 +0,0 @@ -#!/bin/bash - -# ============================================================================= -# INSTANA PYTHON SDK SANITY TESTING SCRIPT -# ============================================================================= -# This script performs comprehensive sanity testing for the Instana Python SDK -# Run this after any SDK update to ensure everything works correctly -# ============================================================================= - -set -e # Exit on any error - -# Colors for output -RED='\033[0;31m' -GREEN='\033[0;32m' -YELLOW='\033[1;33m' -BLUE='\033[0;34m' -NC='\033[0m' # No Color - -# Function to print colored output -print_status() { - echo -e "${BLUE}[INFO]${NC} $1" -} - -print_success() { - echo -e "${GREEN}[SUCCESS]${NC} $1" -} - -print_warning() { - echo -e "${YELLOW}[WARNING]${NC} $1" -} - -print_error() { - echo -e "${RED}[ERROR]${NC} $1" -} - -# Function to check if command exists -command_exists() { - command -v "$1" >/dev/null 2>&1 -} - -# ============================================================================= -# PHASE 1: ENVIRONMENT SETUP -# ============================================================================= - -print_status "Starting Instana Python SDK Sanity Testing..." -echo "==================================================" - -# Check Python version -print_status "Checking Python version..." -python3 --version -if [ $? -eq 0 ]; then - print_success "Python3 is available" -else - print_error "Python3 is not available" - exit 1 -fi - -# Check if we're in the right directory -if [ ! -f "setup.py" ]; then - print_error "setup.py not found. Please run this script from the project root directory." - exit 1 -fi - -print_success "Running from correct directory" - -# ============================================================================= -# PHASE 2: DEPENDENCY CHECK -# ============================================================================= - -print_status "Checking dependencies..." - -# Install required packages if not present -REQUIRED_PACKAGES=("setuptools" "pydantic" "python-dateutil" "urllib3") - -for package in "${REQUIRED_PACKAGES[@]}"; do - if ! python3 -c "import $package" 2>/dev/null; then - print_warning "$package not found, installing..." - # Try with --break-system-packages first (for Homebrew Python), fall back to regular install - if python3 -m pip install --break-system-packages "$package" >/dev/null 2>&1; then - print_success "$package installed successfully" - elif python3 -m pip install "$package" >/dev/null 2>&1; then - print_success "$package installed successfully" - else - print_error "Failed to install $package" - exit 1 - fi - else - print_success "$package is available" - fi -done - -# ============================================================================= -# PHASE 3: PACKAGE VALIDATION -# ============================================================================= - -print_status "Phase 1: Package Configuration Validation" -echo "--------------------------------------------------" - -# Test 1: Check package configuration -print_status "Testing package configuration..." -if python3 setup.py check >/dev/null 2>&1; then - print_success "Package configuration is valid" -else - print_error "Package configuration failed" - exit 1 -fi - -# Test 2: Build package -print_status "Testing package build..." -if python3 setup.py build >/dev/null 2>&1; then - print_success "Package builds successfully" -else - print_error "Package build failed" - exit 1 -fi - -# Test 3: Install package -print_status "Testing package installation..." -# Use pip install instead of setup.py install (modern approach) -if python3 -m pip install --break-system-packages -e . >/dev/null 2>&1; then - print_success "Package installs successfully" -elif python3 -m pip install -e . >/dev/null 2>&1; then - print_success "Package installs successfully" -else - print_error "Package installation failed" - exit 1 -fi - -# ============================================================================= -# PHASE 4: IMPORT TESTING -# ============================================================================= - -print_status "Phase 2: Import and Basic Functionality Testing" -echo "------------------------------------------------------" - -# Test 4: Basic import -print_status "Testing basic package import..." -if python3 -c "import instana_client; print('Basic import: SUCCESS')" 2>&1; then - print_success "Basic package import works" -else - print_error "Basic package import failed" - print_error "Attempting to show import error details..." - python3 -c "import instana_client" 2>&1 || true - exit 1 -fi - -# Test 5: Version check -print_status "Testing version information..." -VERSION=$(python3 -c "import instana_client; print(instana_client.__version__)" 2>/dev/null) -if [ $? -eq 0 ]; then - print_success "SDK Version: $VERSION" -else - print_error "Version check failed" - exit 1 -fi - -# Test 6: Core modules import -print_status "Testing core module imports..." -CORE_MODULES=("api_client" "configuration" "exceptions" "rest" "api_response") - -for module in "${CORE_MODULES[@]}"; do - if python3 -c "from instana_client import $module; print('$module: SUCCESS')" 2>/dev/null; then - print_success "Core module '$module' imports correctly" - else - print_error "Core module '$module' import failed" - exit 1 - fi -done - -# ============================================================================= -# PHASE 5: API MODULE TESTING -# ============================================================================= - -print_status "Phase 3: API Module Testing" -echo "---------------------------------" - -# Test 7: New API modules (v304 specific) -print_status "Testing new API modules..." -NEW_API_MODULES=("ai_management_api" "teams_api" "custom_entities_api" "end_user_monitoring_api" "logging_analyze_api" "roles_api" "slo_correction_configurations_api" "slo_correction_windows_api") - -for api in "${NEW_API_MODULES[@]}"; do - if python3 -c "from instana_client.api import $api; print('$api: SUCCESS')" 2>/dev/null; then - print_success "New API '$api' imports correctly" - else - print_error "New API '$api' import failed" - exit 1 - fi -done - -# Test 8: Legacy API modules (ensure backward compatibility) -print_status "Testing legacy API modules..." -LEGACY_API_MODULES=("application_api" "infrastructure_api" "events_api" "health_api") - -for api in "${LEGACY_API_MODULES[@]}"; do - if python3 -c "from instana_client.api import $api; print('$api: SUCCESS')" 2>/dev/null; then - print_success "Legacy API '$api' imports correctly" - else - print_warning "Legacy API '$api' not found (may be renamed in v304)" - fi -done - -# ============================================================================= -# PHASE 6: MODEL TESTING -# ============================================================================= - -print_status "Phase 4: Model Testing" -echo "---------------------------" - -# Test 9: Key model imports -print_status "Testing key model imports..." -KEY_MODELS=("application" "service" "event" "trace" "metric" "alert") - -for model in "${KEY_MODELS[@]}"; do - if python3 -c "from instana_client.models import $model; print('$model: SUCCESS')" 2>/dev/null; then - print_success "Model '$model' imports correctly" - else - print_warning "Model '$model' not found (may be renamed in v304)" - fi -done - -# ============================================================================= -# PHASE 7: CONFIGURATION TESTING -# ============================================================================= - -print_status "Phase 5: Configuration Testing" -echo "------------------------------------" - -# Test 10: Configuration object creation -print_status "Testing configuration object creation..." -if python3 -c " -from instana_client.configuration import Configuration -config = Configuration() -print('Configuration object created successfully') -" 2>/dev/null; then - print_success "Configuration object creation works" -else - print_error "Configuration object creation failed" - exit 1 -fi - -# Test 11: API client creation -print_status "Testing API client creation..." -if python3 -c " -from instana_client.api_client import ApiClient -from instana_client.configuration import Configuration -config = Configuration() -client = ApiClient(config) -print('API client created successfully') -" 2>/dev/null; then - print_success "API client creation works" -else - print_error "API client creation failed" - exit 1 -fi - -# ============================================================================= -# PHASE 8: FILE STRUCTURE VALIDATION -# ============================================================================= - -print_status "Phase 6: File Structure Validation" -echo "----------------------------------------" - -# Test 12: Check file counts -print_status "Validating file structure..." - -MODEL_COUNT=$(find instana_client/models -name "*.py" | wc -l) -API_COUNT=$(find instana_client/api -name "*.py" | wc -l) -TOTAL_PYTHON_FILES=$(find instana_client -name "*.py" | wc -l) - -print_success "File structure validation:" -print_success " - Model files: $MODEL_COUNT" -print_success " - API files: $API_COUNT" -print_success " - Total Python files: $TOTAL_PYTHON_FILES" - -# ============================================================================= -# PHASE 9: FINAL VALIDATION -# ============================================================================= - -print_status "Phase 7: Final Integration Test" -echo "------------------------------------" - -# Test 13: Complete integration test -print_status "Running complete integration test..." -if python3 -c " -import instana_client -print('✅ 1. Basic import: SUCCESS') -print(f' SDK Version: {instana_client.__version__}') - -from instana_client.api.ai_management_api import AIManagementApi -from instana_client.api.teams_api import TeamsApi -print('✅ 2. New APIs: SUCCESS') - -from instana_client.models.application import Application -print('✅ 3. Models: SUCCESS') - -from instana_client.configuration import Configuration -print('✅ 4. Configuration: SUCCESS') - -print('🎉 ALL SYSTEMS GO!') -" 2>/dev/null; then - print_success "Complete integration test passed" -else - print_error "Complete integration test failed" - exit 1 -fi - -# ============================================================================= -# PHASE 8: CLEANUP -# ============================================================================= - -print_status "Phase 8: Cleanup" -echo "-------------------" - -# Clean up build artifacts -print_status "Cleaning up build artifacts..." -if [ -d "build" ]; then - rm -rf build/ - print_success "Removed build/ directory" -fi - -if [ -d "instana_client.egg-info" ]; then - rm -rf instana_client.egg-info/ - print_success "Removed instana_client.egg-info/ directory" -fi - -if [ -d "dist" ]; then - rm -rf dist/ - print_success "Removed dist/ directory" -fi - -# Clean up test reports -print_status "Cleaning up test reports..." -if ls sanity_test_report_*.txt >/dev/null 2>&1; then - rm -f sanity_test_report_*.txt - print_success "Removed test report files" -fi - -# ============================================================================= -# PHASE 9: SUMMARY -# ============================================================================= - -echo "" -echo "==================================================" -print_success "SANITY TESTING COMPLETED SUCCESSFULLY! 🎉" -echo "==================================================" -echo "" -print_success "All tests passed:" -print_success " ✅ Package configuration valid" -print_success " ✅ Package builds successfully" -print_success " ✅ Package installs successfully" -print_success " ✅ All imports work correctly" -print_success " ✅ New APIs functional" -print_success " ✅ Models accessible" -print_success " ✅ Configuration works" -print_success " ✅ File structure valid" -print_success " ✅ Integration test passed" -echo "" -print_success "The Instana Python SDK is ready for production! 🚀" -echo "" - -# Optional: Generate test report -if [ "$1" = "--report" ]; then - REPORT_FILE="sanity_test_report_$(date +%Y%m%d_%H%M%S).txt" - echo "Generating test report: $REPORT_FILE" - { - echo "Instana Python SDK Sanity Test Report" - echo "Generated: $(date)" - echo "======================================" - echo "" - echo "Test Results: ALL PASSED" - echo "SDK Version: $VERSION" - echo "Model Files: $MODEL_COUNT" - echo "API Files: $API_COUNT" - echo "Total Python Files: $TOTAL_PYTHON_FILES" - echo "" - echo "All sanity tests completed successfully." - } > "$REPORT_FILE" - print_success "Test report saved to: $REPORT_FILE" -fi - -exit 0 From f12f19df8a3c559a911e439e433b4c54eb67a990 Mon Sep 17 00:00:00 2001 From: Jay Sharma <42339291+Jayssgss@users.noreply.github.com> Date: Wed, 18 Mar 2026 21:33:56 +0530 Subject: [PATCH 6/6] Update Sanity Tests --- sanity_test.sh | 381 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 381 insertions(+) create mode 100755 sanity_test.sh diff --git a/sanity_test.sh b/sanity_test.sh new file mode 100755 index 0000000..2e87d11 --- /dev/null +++ b/sanity_test.sh @@ -0,0 +1,381 @@ +#!/bin/bash + +# ============================================================================= +# INSTANA PYTHON SDK SANITY TESTING SCRIPT +# ============================================================================= +# This script performs comprehensive sanity testing for the Instana Python SDK +# Run this after any SDK update to ensure everything works correctly +# ============================================================================= + +set -e # Exit on any error + +# Colors for output +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +NC='\033[0m' # No Color + +# Function to print colored output +print_status() { + echo -e "${BLUE}[INFO]${NC} $1" +} + +print_success() { + echo -e "${GREEN}[SUCCESS]${NC} $1" +} + +print_warning() { + echo -e "${YELLOW}[WARNING]${NC} $1" +} + +print_error() { + echo -e "${RED}[ERROR]${NC} $1" +} + +# Function to check if command exists +command_exists() { + command -v "$1" >/dev/null 2>&1 +} + +# ============================================================================= +# PHASE 1: ENVIRONMENT SETUP +# ============================================================================= + +print_status "Starting Instana Python SDK Sanity Testing..." +echo "==================================================" + +# Check Python version +print_status "Checking Python version..." +python3 --version +if [ $? -eq 0 ]; then + print_success "Python3 is available" +else + print_error "Python3 is not available" + exit 1 +fi + +# Check if we're in the right directory +if [ ! -f "setup.py" ]; then + print_error "setup.py not found. Please run this script from the project root directory." + exit 1 +fi + +print_success "Running from correct directory" + +# ============================================================================= +# PHASE 2: DEPENDENCY CHECK +# ============================================================================= + +print_status "Checking dependencies..." + +# Install required packages if not present +REQUIRED_PACKAGES=("setuptools" "pydantic" "python-dateutil" "urllib3") + +for package in "${REQUIRED_PACKAGES[@]}"; do + if ! python3 -c "import $package" 2>/dev/null; then + print_warning "$package not found, installing..." + # Try with --break-system-packages first (for Homebrew Python), fall back to regular install + if python3 -m pip install --break-system-packages "$package" >/dev/null 2>&1; then + print_success "$package installed successfully" + elif python3 -m pip install "$package" >/dev/null 2>&1; then + print_success "$package installed successfully" + else + print_error "Failed to install $package" + exit 1 + fi + else + print_success "$package is available" + fi +done + +# ============================================================================= +# PHASE 3: PACKAGE VALIDATION +# ============================================================================= + +print_status "Phase 1: Package Configuration Validation" +echo "--------------------------------------------------" + +# Test 1: Check package configuration +print_status "Testing package configuration..." +if python3 setup.py check >/dev/null 2>&1; then + print_success "Package configuration is valid" +else + print_error "Package configuration failed" + exit 1 +fi + +# Test 2: Build package +print_status "Testing package build..." +if python3 setup.py build >/dev/null 2>&1; then + print_success "Package builds successfully" +else + print_error "Package build failed" + exit 1 +fi + +# Test 3: Install package +print_status "Testing package installation..." +# Use pip install instead of setup.py install (modern approach) +if python3 -m pip install --break-system-packages -e . >/dev/null 2>&1; then + print_success "Package installs successfully" +elif python3 -m pip install -e . >/dev/null 2>&1; then + print_success "Package installs successfully" +else + print_error "Package installation failed" + exit 1 +fi + +# ============================================================================= +# PHASE 4: IMPORT TESTING +# ============================================================================= + +print_status "Phase 2: Import and Basic Functionality Testing" +echo "------------------------------------------------------" + +# Test 4: Basic import +print_status "Testing basic package import..." +if python3 -c "import instana_client; print('Basic import: SUCCESS')" 2>&1; then + print_success "Basic package import works" +else + print_error "Basic package import failed" + print_error "Attempting to show import error details..." + python3 -c "import instana_client" 2>&1 || true + exit 1 +fi + +# Test 5: Version check +print_status "Testing version information..." +VERSION=$(python3 -c "import instana_client; print(instana_client.__version__)" 2>/dev/null) +if [ $? -eq 0 ]; then + print_success "SDK Version: $VERSION" +else + print_error "Version check failed" + exit 1 +fi + +# Test 6: Core modules import +print_status "Testing core module imports..." +CORE_MODULES=("api_client" "configuration" "exceptions" "rest" "api_response") + +for module in "${CORE_MODULES[@]}"; do + if python3 -c "from instana_client import $module; print('$module: SUCCESS')" 2>/dev/null; then + print_success "Core module '$module' imports correctly" + else + print_error "Core module '$module' import failed" + exit 1 + fi +done + +# ============================================================================= +# PHASE 5: API MODULE TESTING +# ============================================================================= + +print_status "Phase 3: API Module Testing" +echo "---------------------------------" + +# Test 7: New API modules (v304 specific) +print_status "Testing new API modules..." +NEW_API_MODULES=("ai_management_api" "teams_api" "custom_entities_api" "end_user_monitoring_api" "logging_analyze_api" "roles_api" "slo_correction_configurations_api" "slo_correction_windows_api") + +for api in "${NEW_API_MODULES[@]}"; do + if python3 -c "from instana_client.api import $api; print('$api: SUCCESS')" 2>/dev/null; then + print_success "New API '$api' imports correctly" + else + print_error "New API '$api' import failed" + exit 1 + fi +done + +# Test 8: Legacy API modules (ensure backward compatibility) +print_status "Testing legacy API modules..." +LEGACY_API_MODULES=("application_api" "infrastructure_api" "events_api" "health_api") + +for api in "${LEGACY_API_MODULES[@]}"; do + if python3 -c "from instana_client.api import $api; print('$api: SUCCESS')" 2>/dev/null; then + print_success "Legacy API '$api' imports correctly" + else + print_warning "Legacy API '$api' not found (may be renamed in v304)" + fi +done + +# ============================================================================= +# PHASE 6: MODEL TESTING +# ============================================================================= + +print_status "Phase 4: Model Testing" +echo "---------------------------" + +# Test 9: Key model imports +print_status "Testing key model imports..." +KEY_MODELS=("application" "service" "event" "trace" "metric" "alert") + +for model in "${KEY_MODELS[@]}"; do + if python3 -c "from instana_client.models import $model; print('$model: SUCCESS')" 2>/dev/null; then + print_success "Model '$model' imports correctly" + else + print_warning "Model '$model' not found (may be renamed in v304)" + fi +done + +# ============================================================================= +# PHASE 7: CONFIGURATION TESTING +# ============================================================================= + +print_status "Phase 5: Configuration Testing" +echo "------------------------------------" + +# Test 10: Configuration object creation +print_status "Testing configuration object creation..." +if python3 -c " +from instana_client.configuration import Configuration +config = Configuration() +print('Configuration object created successfully') +" 2>/dev/null; then + print_success "Configuration object creation works" +else + print_error "Configuration object creation failed" + exit 1 +fi + +# Test 11: API client creation +print_status "Testing API client creation..." +if python3 -c " +from instana_client.api_client import ApiClient +from instana_client.configuration import Configuration +config = Configuration() +client = ApiClient(config) +print('API client created successfully') +" 2>/dev/null; then + print_success "API client creation works" +else + print_error "API client creation failed" + exit 1 +fi + +# ============================================================================= +# PHASE 8: FILE STRUCTURE VALIDATION +# ============================================================================= + +print_status "Phase 6: File Structure Validation" +echo "----------------------------------------" + +# Test 12: Check file counts +print_status "Validating file structure..." + +MODEL_COUNT=$(find instana_client/models -name "*.py" | wc -l) +API_COUNT=$(find instana_client/api -name "*.py" | wc -l) +TOTAL_PYTHON_FILES=$(find instana_client -name "*.py" | wc -l) + +print_success "File structure validation:" +print_success " - Model files: $MODEL_COUNT" +print_success " - API files: $API_COUNT" +print_success " - Total Python files: $TOTAL_PYTHON_FILES" + +# ============================================================================= +# PHASE 9: FINAL VALIDATION +# ============================================================================= + +print_status "Phase 7: Final Integration Test" +echo "------------------------------------" + +# Test 13: Complete integration test +print_status "Running complete integration test..." +if python3 -c " +import instana_client +print('1. Basic import: SUCCESS') +print(f' SDK Version: {instana_client.__version__}') + +from instana_client.api.ai_management_api import AIManagementApi +from instana_client.api.teams_api import TeamsApi +print('2. New APIs: SUCCESS') + +from instana_client.models.application import Application +print('3. Models: SUCCESS') + +from instana_client.configuration import Configuration +print('4. Configuration: SUCCESS') + +print(' ALL SYSTEMS GO!') +" 2>/dev/null; then + print_success "Complete integration test passed" +else + print_error "Complete integration test failed" + exit 1 +fi + +# ============================================================================= +# PHASE 8: CLEANUP +# ============================================================================= + +print_status "Phase 8: Cleanup" +echo "-------------------" + +# Clean up build artifacts +print_status "Cleaning up build artifacts..." +if [ -d "build" ]; then + rm -rf build/ + print_success "Removed build/ directory" +fi + +if [ -d "instana_client.egg-info" ]; then + rm -rf instana_client.egg-info/ + print_success "Removed instana_client.egg-info/ directory" +fi + +if [ -d "dist" ]; then + rm -rf dist/ + print_success "Removed dist/ directory" +fi + +# Clean up test reports +print_status "Cleaning up test reports..." +if ls sanity_test_report_*.txt >/dev/null 2>&1; then + rm -f sanity_test_report_*.txt + print_success "Removed test report files" +fi + +# ============================================================================= +# PHASE 9: SUMMARY +# ============================================================================= + +echo "" +echo "==================================================" +print_success "SANITY TESTING COMPLETED SUCCESSFULLY! 🎉" +echo "==================================================" +echo "" +print_success "All tests passed:" +print_success " Package configuration valid" +print_success " Package builds successfully" +print_success " Package installs successfully" +print_success " All imports work correctly" +print_success " New APIs functional" +print_success " Models accessible" +print_success " Configuration works" +print_success " File structure valid" +print_success " Integration test passed" +echo "" +print_success "The Instana Python SDK is ready for production! 🚀" +echo "" + +# Optional: Generate test report +if [ "$1" = "--report" ]; then + REPORT_FILE="sanity_test_report_$(date +%Y%m%d_%H%M%S).txt" + echo "Generating test report: $REPORT_FILE" + { + echo "Instana Python SDK Sanity Test Report" + echo "Generated: $(date)" + echo "======================================" + echo "" + echo "Test Results: ALL PASSED" + echo "SDK Version: $VERSION" + echo "Model Files: $MODEL_COUNT" + echo "API Files: $API_COUNT" + echo "Total Python Files: $TOTAL_PYTHON_FILES" + echo "" + echo "All sanity tests completed successfully." + } > "$REPORT_FILE" + print_success "Test report saved to: $REPORT_FILE" +fi + +exit 0