";let n=document.getElementById("TableOfContents");n&&(n.innerHTML=e)}rerender(){this.rerenderFilterMenu(),this.rerenderPageContent(),this.populateRightNav(),this.runHooks("afterRerender")}rerenderPageContent(){let e={};Object.keys(this.ifFunctionsByRef).forEach(t=>{let s=this.ifFunctionsByRef[t],o=s.value,n=(0,h.reresolveFunctionNode)(s,{variables:this.selectedValsByTraitId});this.ifFunctionsByRef[t]=n,o!==n.value&&(e[t]=n.value)});let t=document.getElementsByClassName("cdoc__toggleable");for(let n=0;n{this.fitCustomizationMenuToScreen()})}addDropdownEventListeners(){let e=document.getElementsByClassName("cdoc-dropdown");for(let t=0;t{let t=e.target;for(;!t.classList.contains("cdoc-dropdown")&&t.parentElement;)t=t.parentElement;let n=t.classList.toggle("cdoc-dropdown__expanded");t.setAttribute("aria-expanded",n.toString())});document.addEventListener("keydown",e=>{if(e.key==="Enter"){let t=e.target;t.classList.contains("cdoc-filter__option")&&t.click()}}),document.addEventListener("click",t=>{for(let n=0;nthis.handleFilterSelectionChange(e));this.addDropdownEventListeners()}locateFilterSelectorEl(){let e=document.getElementById("cdoc-selector");return!!e&&(this.filterSelectorEl=e,!0)}applyFilterSelectionOverrides(){let s=Object.keys(this.selectedValsByTraitId),e=!1,t=this.browserStorage.getTraitVals();Object.keys(t).forEach(n=>{s.includes(n)&&this.selectedValsByTraitId[n]!==t[n]&&(this.selectedValsByTraitId[n]=t[n],e=!0)});let n=(0,v.getTraitValsFromUrl)({url:new URL(window.location.href),traitIds:s});return Object.keys(n).forEach(t=>{this.selectedValsByTraitId[t]!==n[t]&&(this.selectedValsByTraitId[t]=n[t],e=!0)}),e}updateEditButton(){let t=document.getElementsByClassName("toc-edit-btn")[0];if(!t)return;let e=t.getElementsByTagName("a")[0];e&&(e.href=e.href.replace(/\.md\/$/,".mdoc.md/"))}revealPage(){this.runHooks("beforeReveal"),this.filterSelectorEl&&(this.filterSelectorEl.style.position="sticky",this.filterSelectorEl.style.backgroundColor="white",this.filterSelectorEl.style.paddingTop="10px",this.filterSelectorEl.style.visibility="visible",this.filterSelectorEl.style.zIndex="1000");let e=document.getElementById("cdoc-content");e&&(e.style.visibility="visible"),this.runHooks("afterReveal")}rerenderFilterMenu(){if(!this.filterSelectorEl||!this.filtersManifest)throw new Error("Cannot rerender filter selector without filtersManifest and filterSelectorEl");let e=(0,r.resolveFilters)({filtersManifest:this.filtersManifest,valsByTraitId:this.selectedValsByTraitId});Object.keys(e).forEach(t=>{let n=e[t];this.selectedValsByTraitId[t]=n.currentValue});let t=(0,b.buildCustomizationMenuUi)(e);this.filterSelectorEl.innerHTML=t,this.fitCustomizationMenuToScreen(),this.addFilterSelectorEventListeners()}fitCustomizationMenuToScreen(){let e=document.getElementById(f);if(!e)return;let s=e.classList.contains(n),t=document.getElementById(p);if(!t)throw new Error("Dropdown menu not found");let o=document.getElementById(g);if(!o)throw new Error("Menu wrapper not found");let i=e.scrollWidth>o.clientWidth;!s&&i?(e.classList.add(n),t.classList.remove(n)):s&&!i&&(e.classList.remove(n),t.classList.add(n))}get cdocsState(){return{selectedValsByTraitId:this.selectedValsByTraitId,ifFunctionsByRef:this.ifFunctionsByRef,filtersManifest:this.filtersManifest,browserStorage:this.browserStorage,filterSelectorEl:this.filterSelectorEl}}};e.ClientFiltersManager=a,t=a,s={value:void 0}}),j=e(e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=b();window.clientFiltersManager=t.ClientFiltersManager.instance}),j()})()Crear un test de API con la API
Esta guía contiene ejemplos de archivos de configuración y enlaces a recursos Terraform que puedes utilizar para crear tests de API, así como recursos sintéticos asociados, como variables globales.
importosfromdateutil.parserimportparseasdateutil_parserfromdatadog_api_client.v1importApiClient,ApiException,Configurationfromdatadog_api_client.v1.apiimportsynthetics_apifromdatadog_api_client.v1.modelsimport*frompprintimportpprint//Consultarconfiguración.pyparaverunalistadetodoslosparámetrosdeonfiguracióncompatiblesconfiguration=Configuration(host="https://api.datadoghq.com",api_key={"apiKeyAuth":"<YOUR_API_KEY>","appKeyAuth":"<YOUR_APPLICATION_KEY>"})//IngresaruncontextoconunainstanciadeclienteAPIdondelaconfiguracióndeApiClientestéconfiguradacomoapi_client://CrearunainstanciadelaclaseAPIapi_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 | Detalles del test a crear.//ejemplodetransferenciasólodelosvaloresrequeridosquenotienenvalorespredeterminadosdefinidostry://CrearuntestdeAPIapi_response=api_instance.create_synthetics_api_test(body)pprint(api_response)exceptApiExceptionase:print("Exception when calling SyntheticsApi->create_synthetics_api_test: %s\n"%e)
Terraform
Tests de API
El recurso de test Synthetic, con type configurado como api, se puede utilizar para crear y gestionar tus tests de API a través de Terraform.
Localizaciones privadas
Si necesitas ejecutar tests de Synthetic desde localizaciones personalizadas o protegidas, puedes utilizar el recurso de localización privada para crear y gestionar localizaciones privadas desde las que ejecutar tus tests. Para obtener más información, consulta la página de localizaciones privadas.