importosfromdateutil.parserimportparseasdateutil_parserfromdatadog_api_client.v1importApiClient,ApiException,Configurationfromdatadog_api_client.v1.apiimportsynthetics_apifromdatadog_api_client.v1.modelsimport*frompprintimportpprint//지원하는설정파라미터의모든목록을확인하려면configuration.py를참조하세요.configuration=Configuration(host="https://api.datadoghq.com",api_key={"apiKeyAuth":"<YOUR_API_KEY>","appKeyAuth":"<YOUR_APPLICATION_KEY>"})//API클라이언트인스턴스가있는컨텍스트에서ApiClient설정을api_client로설정합니다://API클래스인스턴스를생성합니다.api_instance=synthetics_api.SyntheticsApi(api_client)body=SyntheticsAPITest(config=SyntheticsAPITestConfig(assertions=[SyntheticsAssertion(operator="lessThan",type="responseTime",target=1000),],request=SyntheticsTestRequest(body="body_example",headers=SyntheticsTestHeaders(**{"User-Agent":"value"}),method=HTTPMethod("GET"),no_saving_response_body=True,query={},timeout=60.0,url="https://httpbin.org/get",),),locations=["aws:eu-west-2",],message="message_example",name="name_example",options=SyntheticsTestOptions(follow_redirects=True,min_failure_duration=1,min_location_failed=1,#monitor_name="monitor_name_example",monitor_options=SyntheticsTestOptionsMonitorOptions(renotify_interval=0,),monitor_priority=1,tick_every=30),status=SyntheticsTestPauseStatus("live"),subtype=SyntheticsTestDetailsSubType("http"),tags=["python-client",],type=SyntheticsAPITestType("api"),)# SyntheticsAPITest | 생성할 테스트 세부 정보.//기본값이설정되지않은필수값만전달하는예시try://API테스트생성api_response=api_instance.create_synthetics_api_test(body)pprint(api_response)exceptApiExceptionase:print("Exception when calling SyntheticsApi->create_synthetics_api_test: %s\n"%e)
사용자 지정 위치 또는 보안 위치에서 신서틱(Synthetic) 테스트를 실행해야 하는 경우, 비공개 위치 리소스를 사용하여 비공개 위치를 생성 및 관리하여 테스트를 실행할 수 있습니다. 자세한 내용을 확인하려면 비공개 위치 페이지를 참조하세요.
글로벌 및 로컬 변수
신서틱 글로벌 변수 리소스를 활용하여 테스트 간에 안전하게 공유할 수 있는 변수인 신서틱 글로벌 변수를 생성 및 관리할 수 있습니다. 신서틱(Synthetic) 테스트 리소스에서 config_variable 중첩 스키마를 type = "text"로 정의하여 테스트별 내장 로컬 변수를 생성할 수도 있습니다.