本文へスキップ

トラブルチケットAPIテスト

このガイドでは、一般的なAPIテストの原則に基づき、Equinix Trouble Ticket APIの具体的なテストアプローチと例を示します。

トラブルチケットAPIの概要

Trouble Ticket APIを利用すると、お客様はエクイニクスのサポートとプログラム上でやり取りし、さまざまなカテゴリーのサービスに影響を与える問題のサポートチケットを作成できます:

  • クロスコネクトの課題
  • ネットワーク接続の問題
  • 電力関連インシデント
  • 環境への配慮
  • ハードウェア障害
  • セキュリティインシデント
  • マネージドソリューションのサポート

トラブルチケット問題の種類

Trouble Ticket API は、それぞれ特定の問題コードを持つ、さまざまな問題カテゴリをサポートしています:

Problem CategoryDescriptionExample Codes
Cross ConnectPhysical cable connection issuescc01, cc02, cc03
NetworkNetwork connectivity problemsnet01, net02
EnvironmentHVAC, cooling, environmental issuesenv01, env02, env03, env04
HardwareEquipment and hardware failureshdw01
PowerPower-related incidentspwr01, pwr02
SecuritySecurity access and badge issuessec01, sec02
Managed ServicesManaged service support requestsms01-ms13
SmartViewSmartView monitoring issuessv01-sv05

トラブルチケットテストワークフロー

Trouble Ticket API をテストする前に、以下を確認してください:

  • エクイニクスの開発者アカウント(トラブルチケット権限付き
  • 有効なAPI認証情報(クライアントIDとクライアントシークレット)
  • 適切なIBXロケーションとケージへのアクセス
  • API認証の理解

トラブルチケットオーダーの作成

import requests
import json
from datetime import datetime, timedelta

# Setup authentication
auth_url = "https://api.equinix.com/oauth2/v1/token"
auth_payload = {
"grant_type": "client_credentials",
"client_id": "YOUR_CLIENT_ID",
"client_secret": "YOUR_CLIENT_SECRET"
}

auth_response = requests.post(auth_url, data=auth_payload)
token = auth_response.json()["access_token"]

# Test creating a trouble ticket order
base_url = "https://api.equinix.com"
headers = {
"Authorization": f"Bearer {token}",
"Content-Type": "application/json"
}

# Example: Create a network connectivity trouble ticket
request_payload = {
"customerReferenceNumber": "TT-TEST-001",
"ibxLocation": {
"ibx": "CH1",
"cages": [
{
"cage": "CH1:05:000750",
"accountNumber": "12345",
"cabinets": [
"CH1:05:000750:01"
]
}
]
},
"serviceDetails": {
"incidentDateTime": (datetime.utcnow() - timedelta(hours=1)).isoformat() + "Z",
"problemCode": "net01", # Network connectivity issue
"additionalDetails": "TEST: Network connectivity issue - API testing"
},
"contacts": [
{
"contactType": "ORDERING",
"userName": "test_ordering_user"
},
{
"contactType": "NOTIFICATION",
"userName": "test_notification_user"
},
{
"contactType": "TECHNICAL",
"userName": "test_technical_user",
"workPhone": "555-0123",
"workPhonePrefToCall": "ANYTIME"
}
]
}

create_response = requests.post(
f"{base_url}/v1/orders/troubleticket",
headers=headers,
data=json.dumps(request_payload)
)

# Verify response
assert create_response.status_code == 201, f"Failed to create trouble ticket: {create_response.text}"
order_number = create_response.json()["OrderNumber"]

print(f"Successfully created trouble ticket order: {order_number}")

テスト場所と問題タイプの検証

# Test retrieving available locations
locations_response = requests.get(
f"{base_url}/v1/orders/troubleticket/locations",
headers=headers
)

assert locations_response.status_code == 200, f"Failed to retrieve locations: {locations_response.text}"
locations = locations_response.json()["locations"]

print(f"Available locations: {len(locations)}")

# Test retrieving problem types
types_response = requests.get(
f"{base_url}/v1/orders/troubleticket/types",
headers=headers
)

assert types_response.status_code == 200, f"Failed to retrieve problem types: {types_response.text}"
problem_types = types_response.json()["troubleTicketTypes"]

print(f"Available problem types: {len(problem_types)}")

エラーシナリオのテスト

API実装のエラー処理は必ずテストしてください:

import requests
import json
from datetime import datetime, timedelta

# Setup authentication
auth_url = "https://api.equinix.com/oauth2/v1/token"
auth_payload = {
"grant_type": "client_credentials",
"client_id": "YOUR_CLIENT_ID",
"client_secret": "YOUR_CLIENT_SECRET"
}

auth_response = requests.post(auth_url, data=auth_payload)
token = auth_response.json()["access_token"]

# Prepare request
base_url = "https://api.equinix.com"
headers = {
"Authorization": f"Bearer {token}",
"Content-Type": "application/json"
}

# Test with invalid problem code
invalid_payload = {
"customerReferenceNumber": "TT-ERROR-TEST-001",
"ibxLocation": {
"ibx": "CH1",
"cages": [{"cage": "CH1:05:000750", "accountNumber": "12345"}]
},
"serviceDetails": {
"incidentDateTime": (datetime.utcnow() - timedelta(hours=1)).isoformat() + "Z",
"problemCode": "INVALID_CODE", # Invalid problem code
"additionalDetails": "TEST: Invalid problem code test"
},
"contacts": [
{"contactType": "ORDERING", "userName": "test_user"},
{"contactType": "NOTIFICATION", "userName": "test_user"}
]
}

error_response = requests.post(
f"{base_url}/v1/orders/troubleticket",
headers=headers,
data=json.dumps(invalid_payload)
)

# Verify error response
assert error_response.status_code == 400, f"Expected error but got: {error_response.status_code}"
error_data = error_response.json()
assert "errors" in error_data, "Error response format not as expected"

print("Successfully validated error handling for invalid problem code")
print(json.dumps(error_data, indent=2))

トラブルチケットAPIテストのベストプラクティス

**重要:**Equinix Trouble Ticket APIは、実際のサポートチケットを作成するプロダクションシステムです。意図しない運用作業が発生しないよう、常に以下のテストのベストプラクティスに従ってください。

  1. テスト専用アカウントの設定 :可能であれば、テスト用に別のアカウントをリクエストしてください。
  2. テスト依頼には、 :サポートスタッフがテスト依頼を識別しやすくするため、説明の前に必ず「TEST:」を付けてください。
  3. 有効なインシデント時刻の使用 :インシデントの日付/時刻が適切にフォーマットされ、未来でないことを確認します。
  4. ロケーション・アクセスの検証 :チケットを作成する前に、ロケーションエンドポイントを使用して、アクセス可能なIBXロケーションを確認します。
  5. 有効な問題コードでのテスト :タイプ・エンドポイントを使用して、常に問題コードを検証してください。
  6. 完全な連絡先情報を含める :必要な連絡先(注文、通知)がすべて提供されていることを確認します。
  7. テストリソースのクリーンアップ :サポートと協力して、テストチケットを作成後すぐにクローズします。
  8. エラー処理のテスト :適切なエラー処理とレスポンスコードの検証

自動化に関する考察

Trouble Ticket API を中心に自動化を構築する場合:

  • API失敗時の適切なエラー処理とリトライの実装
  • 必須フィールドとデータ形式の検証を構築
  • すべてのチケット作成アクティビティの監査ロギングの追加
  • インシデント発生時刻の正確な把握とフォーマット化
  • 提出前に場所と問題コードの情報を確認
  • 本番チケット作成時の承認ワークフローの導入を検討
  • 迅速な解決のための包括的な連絡先情報の記載

その他のリソース

このページは役に立ちましたか?