|
1 | | -// Edit a Mobile test returns "OK" response |
| 1 | +// Edit a mobile test returns "OK" response |
2 | 2 |
|
3 | 3 | import com.datadog.api.client.ApiClient; |
4 | 4 | import com.datadog.api.client.ApiException; |
5 | 5 | import com.datadog.api.client.v1.api.SyntheticsApi; |
| 6 | +import com.datadog.api.client.v1.model.SyntheticsCheckType; |
| 7 | +import com.datadog.api.client.v1.model.SyntheticsConfigVariable; |
| 8 | +import com.datadog.api.client.v1.model.SyntheticsConfigVariableType; |
| 9 | +import com.datadog.api.client.v1.model.SyntheticsMobileStep; |
| 10 | +import com.datadog.api.client.v1.model.SyntheticsMobileStepParams; |
| 11 | +import com.datadog.api.client.v1.model.SyntheticsMobileStepParamsDirection; |
| 12 | +import com.datadog.api.client.v1.model.SyntheticsMobileStepParamsElement; |
| 13 | +import com.datadog.api.client.v1.model.SyntheticsMobileStepParamsElementContextType; |
| 14 | +import com.datadog.api.client.v1.model.SyntheticsMobileStepParamsElementRelativePosition; |
| 15 | +import com.datadog.api.client.v1.model.SyntheticsMobileStepParamsElementUserLocator; |
| 16 | +import com.datadog.api.client.v1.model.SyntheticsMobileStepParamsElementUserLocatorValuesItems; |
| 17 | +import com.datadog.api.client.v1.model.SyntheticsMobileStepParamsElementUserLocatorValuesItemsType; |
| 18 | +import com.datadog.api.client.v1.model.SyntheticsMobileStepParamsPositionsItems; |
| 19 | +import com.datadog.api.client.v1.model.SyntheticsMobileStepParamsVariable; |
| 20 | +import com.datadog.api.client.v1.model.SyntheticsMobileStepType; |
6 | 21 | import com.datadog.api.client.v1.model.SyntheticsMobileTest; |
7 | 22 | import com.datadog.api.client.v1.model.SyntheticsMobileTestConfig; |
8 | 23 | import com.datadog.api.client.v1.model.SyntheticsMobileTestOptions; |
9 | 24 | import com.datadog.api.client.v1.model.SyntheticsMobileTestType; |
10 | 25 | import com.datadog.api.client.v1.model.SyntheticsMobileTestsMobileApplication; |
11 | 26 | import com.datadog.api.client.v1.model.SyntheticsMobileTestsMobileApplicationReferenceType; |
| 27 | +import com.datadog.api.client.v1.model.SyntheticsTestCiOptions; |
| 28 | +import com.datadog.api.client.v1.model.SyntheticsTestExecutionRule; |
| 29 | +import com.datadog.api.client.v1.model.SyntheticsTestOptionsMonitorOptions; |
| 30 | +import com.datadog.api.client.v1.model.SyntheticsTestOptionsMonitorOptionsNotificationPresetName; |
| 31 | +import com.datadog.api.client.v1.model.SyntheticsTestOptionsRetry; |
| 32 | +import com.datadog.api.client.v1.model.SyntheticsTestOptionsScheduling; |
| 33 | +import com.datadog.api.client.v1.model.SyntheticsTestOptionsSchedulingTimeframe; |
12 | 34 | import com.datadog.api.client.v1.model.SyntheticsTestPauseStatus; |
| 35 | +import com.datadog.api.client.v1.model.SyntheticsTestRestrictionPolicyBinding; |
| 36 | +import com.datadog.api.client.v1.model.SyntheticsTestRestrictionPolicyBindingRelation; |
| 37 | +import java.util.Arrays; |
13 | 38 | import java.util.Collections; |
14 | 39 |
|
15 | 40 | public class Example { |
16 | 41 | public static void main(String[] args) { |
17 | 42 | ApiClient defaultClient = ApiClient.getDefaultApiClient(); |
18 | 43 | SyntheticsApi apiInstance = new SyntheticsApi(defaultClient); |
19 | 44 |
|
20 | | - // there is a valid "synthetics_mobile_test" in the system |
21 | | - String SYNTHETICS_MOBILE_TEST_PUBLIC_ID = System.getenv("SYNTHETICS_MOBILE_TEST_PUBLIC_ID"); |
22 | | - |
23 | 45 | SyntheticsMobileTest body = |
24 | 46 | new SyntheticsMobileTest() |
25 | | - .name("Example-Synthetic-updated") |
26 | | - .status(SyntheticsTestPauseStatus.PAUSED) |
27 | | - .type(SyntheticsMobileTestType.MOBILE) |
28 | | - .config(new SyntheticsMobileTestConfig()) |
29 | | - .message("") |
| 47 | + .config( |
| 48 | + new SyntheticsMobileTestConfig() |
| 49 | + .variables( |
| 50 | + Collections.singletonList( |
| 51 | + new SyntheticsConfigVariable() |
| 52 | + .name("VARIABLE_NAME") |
| 53 | + .secure(false) |
| 54 | + .type(SyntheticsConfigVariableType.TEXT)))) |
| 55 | + .deviceIds(Collections.singletonList("chrome.laptop_large")) |
| 56 | + .message("Notification message") |
| 57 | + .name("Example test name") |
30 | 58 | .options( |
31 | 59 | new SyntheticsMobileTestOptions() |
| 60 | + .bindings( |
| 61 | + Collections.singletonList( |
| 62 | + new SyntheticsTestRestrictionPolicyBinding() |
| 63 | + .relation(SyntheticsTestRestrictionPolicyBindingRelation.EDITOR))) |
| 64 | + .ci( |
| 65 | + new SyntheticsTestCiOptions() |
| 66 | + .executionRule(SyntheticsTestExecutionRule.BLOCKING)) |
32 | 67 | .deviceIds( |
33 | | - Collections.singletonList("synthetics:mobile:device:iphone_15_ios_17")) |
| 68 | + Collections.singletonList( |
| 69 | + "synthetics:mobile:device:apple_ipad_10th_gen_2022_ios_16")) |
34 | 70 | .mobileApplication( |
35 | 71 | new SyntheticsMobileTestsMobileApplication() |
36 | | - .applicationId("ab0e0aed-536d-411a-9a99-5428c27d8f8e") |
37 | | - .referenceId("6115922a-5f5d-455e-bc7e-7955a57f3815") |
| 72 | + .applicationId("00000000-0000-0000-0000-aaaaaaaaaaaa") |
| 73 | + .referenceId("00000000-0000-0000-0000-aaaaaaaaaaab") |
38 | 74 | .referenceType( |
39 | | - SyntheticsMobileTestsMobileApplicationReferenceType.VERSION)) |
40 | | - .tickEvery(3600L)); |
| 75 | + SyntheticsMobileTestsMobileApplicationReferenceType.LATEST)) |
| 76 | + .monitorOptions( |
| 77 | + new SyntheticsTestOptionsMonitorOptions() |
| 78 | + .notificationPresetName( |
| 79 | + SyntheticsTestOptionsMonitorOptionsNotificationPresetName.SHOW_ALL)) |
| 80 | + .restrictedRoles( |
| 81 | + Collections.singletonList("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")) |
| 82 | + .retry(new SyntheticsTestOptionsRetry()) |
| 83 | + .scheduling( |
| 84 | + new SyntheticsTestOptionsScheduling() |
| 85 | + .timeframes( |
| 86 | + Arrays.asList( |
| 87 | + new SyntheticsTestOptionsSchedulingTimeframe() |
| 88 | + .day(1) |
| 89 | + .from("07:00") |
| 90 | + .to("16:00"), |
| 91 | + new SyntheticsTestOptionsSchedulingTimeframe() |
| 92 | + .day(3) |
| 93 | + .from("07:00") |
| 94 | + .to("16:00"))) |
| 95 | + .timezone("America/New_York")) |
| 96 | + .tickEvery(300L)) |
| 97 | + .status(SyntheticsTestPauseStatus.LIVE) |
| 98 | + .steps( |
| 99 | + Collections.singletonList( |
| 100 | + new SyntheticsMobileStep() |
| 101 | + .name("") |
| 102 | + .params( |
| 103 | + new SyntheticsMobileStepParams() |
| 104 | + .check(SyntheticsCheckType.EQUALS) |
| 105 | + .direction(SyntheticsMobileStepParamsDirection.UP) |
| 106 | + .element( |
| 107 | + new SyntheticsMobileStepParamsElement() |
| 108 | + .contextType( |
| 109 | + SyntheticsMobileStepParamsElementContextType.NATIVE) |
| 110 | + .relativePosition( |
| 111 | + new SyntheticsMobileStepParamsElementRelativePosition()) |
| 112 | + .userLocator( |
| 113 | + new SyntheticsMobileStepParamsElementUserLocator() |
| 114 | + .values( |
| 115 | + Collections.singletonList( |
| 116 | + new SyntheticsMobileStepParamsElementUserLocatorValuesItems() |
| 117 | + .type( |
| 118 | + SyntheticsMobileStepParamsElementUserLocatorValuesItemsType |
| 119 | + .ACCESSIBILITY_ID))))) |
| 120 | + .positions( |
| 121 | + Collections.singletonList( |
| 122 | + new SyntheticsMobileStepParamsPositionsItems())) |
| 123 | + .variable( |
| 124 | + new SyntheticsMobileStepParamsVariable() |
| 125 | + .example("") |
| 126 | + .name("VAR_NAME"))) |
| 127 | + .publicId("pub-lic-id0") |
| 128 | + .type(SyntheticsMobileStepType.ASSERTELEMENTCONTENT))) |
| 129 | + .tags(Collections.singletonList("env:production")) |
| 130 | + .type(SyntheticsMobileTestType.MOBILE); |
41 | 131 |
|
42 | 132 | try { |
43 | | - SyntheticsMobileTest result = |
44 | | - apiInstance.updateMobileTest(SYNTHETICS_MOBILE_TEST_PUBLIC_ID, body); |
| 133 | + SyntheticsMobileTest result = apiInstance.updateMobileTest("public_id", body); |
45 | 134 | System.out.println(result); |
46 | 135 | } catch (ApiException e) { |
47 | 136 | System.err.println("Exception when calling SyntheticsApi#updateMobileTest"); |
|
0 commit comments