本文へスキップ

Smarthands API テスト

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

Smarthands API の概要

Smarthands APIを使用すると、Equinix IBXデータセンター内のさまざまなリモートハンズサービスをプログラムでリクエストおよび管理できます:

Smarthands TypeDescriptionECP API Mapping
Request photos/documentationRequest cage-related photos or documentationhttps://api.equinix.com/v1/orders/smarthands/pictures
SmartHand OtherRequest a Smart Hands order not listed abovehttps://api.equinix.com/v1/orders/smarthands/other
SmartHand Cage Clean upRequest a cage clean uphttps://api.equinix.com/v1/orders/smarthands/cageCleanup
SmartHand Shipment UnpackUnpack inbound shipment and dispose packaginghttps://api.equinix.com/v1/orders/smarthands/shipmentUnpack
SmartHand Cage EscortRequest IBX security escorthttps://api.equinix.com/v1/orders/smarthands/cageEscort
Equipment InstallRequest equipment installationhttps://api.equinix.com/v1/orders/smarthands/equipmentInstall
Request CablesRequest cableshttps://api.equinix.com/v1/orders/smarthands/cableRequest
Locate PackagesRequest package locationhttps://api.equinix.com/v1/orders/smarthands/locatePackage
Run Patch CablesRequest cables run between deviceshttps://api.equinix.com/v1/orders/smarthands/runJumperCable
Patch Cable InstallRequest patch cable installationhttps://api.equinix.com/v1/orders/smarthands/patchCableInstall
Move Patch CableMove patch cables between deviceshttps://api.equinix.com/v1/orders/smarthands/moveJumperCable
Patch Cable RemovalRemove patch cableshttps://api.equinix.com/v1/orders/smarthands/patchCableRemoval
Large SmartHands OrderLarge cable/equipment requestshttps://api.equinix.com/v1/orders/smarthands/largeOrder

Smarthands のテスト ワークフロー

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

  • 適切な権限を持つ有効なAPI認証情報
  • お客様の設備があるエクイニクスIBX拠点へのアクセス
  • サービスチケットのワークフローに精通していること

Smarthands サービス リクエストの作成

import requests
import json

# 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 Smarthands request
base_url = "https://api.equinix.com/v1"
headers = {
"Authorization": f"Bearer {token}",
"Content-Type": "application/json"
}

# Example: Create a cage escort request
request_payload = {
"customerReferenceNumber": "RSS41244",
"purchaseOrder": {
"number": "123455",
"purchaseOrderType": "EXISTING"
},
"ibxLocation": {
"ibx": "AM1",
"cages": [
{
"cage": "AM1:01:001MC3",
"accountNumber": "12345",
"cabinets": [
"AM1:01:001MC3:0102"
]
}
]
},
"contacts": [
{
"contactType": "ORDERING",
"userName": "jondoe@test.com"
},
{
"contactType": "NOTIFICATION",
"userName": "jondoe@test.com"
},
{
"contactType": "TECHNICAL",
"name": "John Doe",
"workPhone": "1111111",
"workPhonePrefToCall": "ANYTIME",
"mobilePhone": "1111111",
"mobilePhonePrefToCall": "ANYTIME"
}
],
"schedule": {
"scheduleType": "STANDARD",
"requestedStartDate": "2017-04-05T12:00:00Z",
"requestedCompletionDate": "2017-04-05T12:00:00Z"
},
"attachments": [
{
"id": "eb9ab7e9-3785-41e4-af24-112dff",
"name": "eb9ab7e9-3785-41e4-af24-asfsa5424"
}
],
"serviceDetails": {
"durationVisit": "30 Minutes",
"openCabinetForVisitor": false,
"scopeOfWork": "Scope of work",
"supervisionReqForVisitor": false,
"workVisitOrderNumber": "1-108050984499"
}
}

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

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

print(f"Successfully created Smarthands request with order number: {order_number}")

リクエストステータスの確認

# Test retrieving request status
status_response = requests.get(
f"https://api.equinix.com/colocations/v2/orders/{order_number}",
headers=headers
)

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

print(f"Current request status: {status}")

エラーシナリオのテスト

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

# Test with invalid location
invalid_payload = {
"customerReferenceNumber": "RSS41244",
"purchaseOrder": {
"number": "123455",
"purchaseOrderType": "EXISTING"
},
"ibxLocation": {
"ibx": "INVALID", # Invalid IBX code
"cages": [
{
"cage": "INVALID:01:001MC3",
"accountNumber": "12345",
"cabinets": [
"INVALID:01:001MC3:0102"
]
}
]
},
"contacts": [
{
"contactType": "ORDERING",
"userName": "jondoe@test.com"
}
],
"schedule": {
"scheduleType": "STANDARD",
"requestedStartDate": "2025-08-01T10:00:00Z",
"requestedCompletionDate": "2025-08-01T12:00:00Z"
},
"serviceDetails": {
"durationVisit": "30 Minutes",
"openCabinetForVisitor": false,
"scopeOfWork": "Test invalid IBX location",
"supervisionReqForVisitor": false
}
}

error_response = requests.post(
f"{base_url}/orders/smarthands/cageEscort",
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}"
assert "Invalid IBX location" in error_response.text, "Error message not as expected"

Smarthands API テストのベストプラクティス

重要な注意事項: Equinix APIは、実際の出荷リクエストを作成するプロダクションシステムです。意図しない運用作業が発生しないよう、常に以下のテストのベストプラクティスに従ってください。

  1. テスト専用アカウントの設定 :可能であれば、テスト用に別のアカウントをリクエストしてください。
  2. 読み取り専用操作から始める :リソースを作成/変更する前に、まずGETエンドポイントをテストしてください。
  3. テスト依頼には、 :オペレータがテストリクエストを識別しやすくするため、説明の前に必ず「TEST:」を付けます。
  4. テストリソースのクリーンアップ :作成に成功した後、テスト出荷を直ちにキャンセルします。
  5. 完全な詳細を含める :リクエストには包括的な情報を提供しましょう。
  6. 追跡番号 :適切な取り扱いを保証するため、インバウンド貨物の正確な追跡番号を常にご提供ください。
  7. 連絡先情報 :連絡先情報が最新であり、予定されたサービス時間内に担当者が対応可能であることを確認してください。
  8. 説明の詳細 :施設担当者が効率的にリクエストを完了できるよう、要件は詳細に、しかし簡潔に記述してください。

自動化に関する考察

Smarthands API を中心にオートメーションを構築する場合:

  • 適切なエラー処理と再試行の実装
  • ステータス更新のためのWebhookレシーバーの実装を検討
  • タイムウィンドウとサービス可用性の検証をビルトイン
  • すべてのAPIインタラクションの監査ロギングを含みます。
  • すべての出荷関連リクエストに追跡情報が自動的に含まれるようにします。
  • スケジュールされたサービス窓口の可用性を確認

その他のリソース

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