@azure-rest/onlineexperimentation 1.0.0-alpha.20250613.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/LICENSE +21 -0
- package/README.md +98 -0
- package/dist/browser/clientDefinitions.d.ts +30 -0
- package/dist/browser/clientDefinitions.js +3 -0
- package/dist/browser/extensibleEnums.d.ts +99 -0
- package/dist/browser/extensibleEnums.js +106 -0
- package/dist/browser/index.d.ts +11 -0
- package/dist/browser/index.js +13 -0
- package/dist/browser/isUnexpected.d.ts +6 -0
- package/dist/browser/isUnexpected.js +72 -0
- package/dist/browser/logger.d.ts +1 -0
- package/dist/browser/logger.js +4 -0
- package/dist/browser/models.d.ts +104 -0
- package/dist/browser/models.js +3 -0
- package/dist/browser/onlineExperimentationClient.d.ts +15 -0
- package/dist/browser/onlineExperimentationClient.js +45 -0
- package/dist/browser/outputModels.d.ts +137 -0
- package/dist/browser/outputModels.js +3 -0
- package/dist/browser/package.json +3 -0
- package/dist/browser/paginateHelper.d.ts +67 -0
- package/dist/browser/paginateHelper.js +136 -0
- package/dist/browser/parameters.d.ts +92 -0
- package/dist/browser/parameters.js +3 -0
- package/dist/browser/responses.d.ts +113 -0
- package/dist/browser/responses.js +3 -0
- package/dist/commonjs/clientDefinitions.d.ts +30 -0
- package/dist/commonjs/clientDefinitions.js +4 -0
- package/dist/commonjs/extensibleEnums.d.ts +99 -0
- package/dist/commonjs/extensibleEnums.js +109 -0
- package/dist/commonjs/index.d.ts +11 -0
- package/dist/commonjs/index.js +33 -0
- package/dist/commonjs/isUnexpected.d.ts +6 -0
- package/dist/commonjs/isUnexpected.js +75 -0
- package/dist/commonjs/logger.d.ts +1 -0
- package/dist/commonjs/logger.js +7 -0
- package/dist/commonjs/models.d.ts +104 -0
- package/dist/commonjs/models.js +4 -0
- package/dist/commonjs/onlineExperimentationClient.d.ts +15 -0
- package/dist/commonjs/onlineExperimentationClient.js +48 -0
- package/dist/commonjs/outputModels.d.ts +137 -0
- package/dist/commonjs/outputModels.js +4 -0
- package/dist/commonjs/package.json +3 -0
- package/dist/commonjs/paginateHelper.d.ts +67 -0
- package/dist/commonjs/paginateHelper.js +139 -0
- package/dist/commonjs/parameters.d.ts +92 -0
- package/dist/commonjs/parameters.js +4 -0
- package/dist/commonjs/responses.d.ts +113 -0
- package/dist/commonjs/responses.js +4 -0
- package/dist/commonjs/tsdoc-metadata.json +11 -0
- package/dist/esm/clientDefinitions.d.ts +30 -0
- package/dist/esm/clientDefinitions.js +3 -0
- package/dist/esm/extensibleEnums.d.ts +99 -0
- package/dist/esm/extensibleEnums.js +106 -0
- package/dist/esm/index.d.ts +11 -0
- package/dist/esm/index.js +13 -0
- package/dist/esm/isUnexpected.d.ts +6 -0
- package/dist/esm/isUnexpected.js +72 -0
- package/dist/esm/logger.d.ts +1 -0
- package/dist/esm/logger.js +4 -0
- package/dist/esm/models.d.ts +104 -0
- package/dist/esm/models.js +3 -0
- package/dist/esm/onlineExperimentationClient.d.ts +15 -0
- package/dist/esm/onlineExperimentationClient.js +45 -0
- package/dist/esm/outputModels.d.ts +137 -0
- package/dist/esm/outputModels.js +3 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/paginateHelper.d.ts +67 -0
- package/dist/esm/paginateHelper.js +136 -0
- package/dist/esm/parameters.d.ts +92 -0
- package/dist/esm/parameters.js +3 -0
- package/dist/esm/responses.d.ts +113 -0
- package/dist/esm/responses.js +3 -0
- package/dist/react-native/clientDefinitions.d.ts +30 -0
- package/dist/react-native/clientDefinitions.js +3 -0
- package/dist/react-native/extensibleEnums.d.ts +99 -0
- package/dist/react-native/extensibleEnums.js +106 -0
- package/dist/react-native/index.d.ts +11 -0
- package/dist/react-native/index.js +13 -0
- package/dist/react-native/isUnexpected.d.ts +6 -0
- package/dist/react-native/isUnexpected.js +72 -0
- package/dist/react-native/logger.d.ts +1 -0
- package/dist/react-native/logger.js +4 -0
- package/dist/react-native/models.d.ts +104 -0
- package/dist/react-native/models.js +3 -0
- package/dist/react-native/onlineExperimentationClient.d.ts +15 -0
- package/dist/react-native/onlineExperimentationClient.js +45 -0
- package/dist/react-native/outputModels.d.ts +137 -0
- package/dist/react-native/outputModels.js +3 -0
- package/dist/react-native/package.json +3 -0
- package/dist/react-native/paginateHelper.d.ts +67 -0
- package/dist/react-native/paginateHelper.js +136 -0
- package/dist/react-native/parameters.d.ts +92 -0
- package/dist/react-native/parameters.js +3 -0
- package/dist/react-native/responses.d.ts +113 -0
- package/dist/react-native/responses.js +3 -0
- package/package.json +138 -0
- package/review/onlineexperimentation.api.md +612 -0
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/** Defines experiment metric metadata and computation details. */
|
|
2
|
+
export interface ExperimentMetricOutput {
|
|
3
|
+
/** Identifier for this experiment metric. Must start with a lowercase letter and contain only lowercase letters, numbers, and underscores. */
|
|
4
|
+
readonly id: string;
|
|
5
|
+
/**
|
|
6
|
+
* Determines whether it is included in experiment analysis.
|
|
7
|
+
*
|
|
8
|
+
* Possible values: "Active", "Inactive"
|
|
9
|
+
*/
|
|
10
|
+
lifecycle: LifecycleStageOutput;
|
|
11
|
+
/** A user-friendly display name for the experiment metric shown in reports and dashboards. */
|
|
12
|
+
displayName: string;
|
|
13
|
+
/** A detailed description of the experiment metric. */
|
|
14
|
+
description: string;
|
|
15
|
+
/** Categories associated with the experiment metric. Used for organizing and filtering metrics. */
|
|
16
|
+
categories: string[];
|
|
17
|
+
/**
|
|
18
|
+
* The desired direction for changes in the metric value.
|
|
19
|
+
*
|
|
20
|
+
* Possible values: "Increase", "Decrease", "Neutral"
|
|
21
|
+
*/
|
|
22
|
+
desiredDirection: DesiredDirectionOutput;
|
|
23
|
+
/** The metric definition specifying how the metric value is calculated from event data. */
|
|
24
|
+
definition: ExperimentMetricDefinitionOutput;
|
|
25
|
+
/** ETag of the experiment metric. */
|
|
26
|
+
readonly eTag: string;
|
|
27
|
+
/** The timestamp (UTC) of the last modification to the experiment metric resource. */
|
|
28
|
+
readonly lastModifiedAt: string;
|
|
29
|
+
}
|
|
30
|
+
/** The metric definition, which determines how the metric value is calculated from event data. */
|
|
31
|
+
export interface ExperimentMetricDefinitionOutputParent {
|
|
32
|
+
type: string;
|
|
33
|
+
}
|
|
34
|
+
/** The definition of an EventCount metric definition. Counts the occurrences of a specified event. */
|
|
35
|
+
export interface EventCountMetricDefinitionOutput extends ExperimentMetricDefinitionOutputParent {
|
|
36
|
+
/** The type of metric. */
|
|
37
|
+
type: "EventCount";
|
|
38
|
+
/** Event to observe. */
|
|
39
|
+
event: ObservedEventOutput;
|
|
40
|
+
}
|
|
41
|
+
/** An event observed by a metric. */
|
|
42
|
+
export interface ObservedEventOutput {
|
|
43
|
+
/** The name of the event. */
|
|
44
|
+
eventName: string;
|
|
45
|
+
/** [Optional] A condition to filter events. */
|
|
46
|
+
filter?: string;
|
|
47
|
+
}
|
|
48
|
+
/** The definition of a UserCount metric definition. Counts unique users who encounter a specified event. */
|
|
49
|
+
export interface UserCountMetricDefinitionOutput extends ExperimentMetricDefinitionOutputParent {
|
|
50
|
+
/** The type of metric. */
|
|
51
|
+
type: "UserCount";
|
|
52
|
+
/** Event to observe. */
|
|
53
|
+
event: ObservedEventOutput;
|
|
54
|
+
}
|
|
55
|
+
/** The definition of an EventRate metric definition. Calculates the percentage of events satisfying a specified condition. */
|
|
56
|
+
export interface EventRateMetricDefinitionOutput extends ExperimentMetricDefinitionOutputParent {
|
|
57
|
+
/** The type of metric. */
|
|
58
|
+
type: "EventRate";
|
|
59
|
+
/** Event to observe as the rate denominator. */
|
|
60
|
+
event: ObservedEventOutput;
|
|
61
|
+
/** The event contributes to the rate numerator if it satisfies this condition. */
|
|
62
|
+
rateCondition: string;
|
|
63
|
+
}
|
|
64
|
+
/** The definition of a UserRate metric definition. Calculates the percentage of users who encounter a start event and subsequently an end event. Users must encounter events in the specified order. */
|
|
65
|
+
export interface UserRateMetricDefinitionOutput extends ExperimentMetricDefinitionOutputParent {
|
|
66
|
+
/** The type of metric. */
|
|
67
|
+
type: "UserRate";
|
|
68
|
+
/** The start event to observe as the rate denominator. */
|
|
69
|
+
startEvent: ObservedEventOutput;
|
|
70
|
+
/** The end event to observe, which is a condition for the rate numerator. */
|
|
71
|
+
endEvent: ObservedEventOutput;
|
|
72
|
+
}
|
|
73
|
+
/** The definition of a Sum metric definition. Calculates the sum of a specified event property. Experiment analysis accounts for unequal traffic allocation. */
|
|
74
|
+
export interface SumMetricDefinitionOutput extends ExperimentMetricDefinitionOutputParent {
|
|
75
|
+
/** The type of metric. */
|
|
76
|
+
type: "Sum";
|
|
77
|
+
/** The value to aggregate. */
|
|
78
|
+
value: AggregatedValueOutput;
|
|
79
|
+
}
|
|
80
|
+
/** An event property value aggregated by a metric. */
|
|
81
|
+
export interface AggregatedValueOutput {
|
|
82
|
+
/** The name of the event. */
|
|
83
|
+
eventName: string;
|
|
84
|
+
/** [Optional] A condition to filter events. */
|
|
85
|
+
filter?: string;
|
|
86
|
+
/** The key of the event property to aggregate. */
|
|
87
|
+
eventProperty: string;
|
|
88
|
+
}
|
|
89
|
+
/** The definition of an Average metric definition. Calculates the average value of a specified event property. */
|
|
90
|
+
export interface AverageMetricDefinitionOutput extends ExperimentMetricDefinitionOutputParent {
|
|
91
|
+
/** The type of metric. */
|
|
92
|
+
type: "Average";
|
|
93
|
+
/** The value to aggregate. */
|
|
94
|
+
value: AggregatedValueOutput;
|
|
95
|
+
}
|
|
96
|
+
/** The definition of a Percentile metric definition. Calculates a specified percentile of an event property. */
|
|
97
|
+
export interface PercentileMetricDefinitionOutput extends ExperimentMetricDefinitionOutputParent {
|
|
98
|
+
/** The type of metric. */
|
|
99
|
+
type: "Percentile";
|
|
100
|
+
/** The value to aggregate, including the event name and property to measure. */
|
|
101
|
+
value: AggregatedValueOutput;
|
|
102
|
+
/** The percentile to measure. */
|
|
103
|
+
percentile: number;
|
|
104
|
+
}
|
|
105
|
+
/** The result of validating an experiment metric. */
|
|
106
|
+
export interface ExperimentMetricValidationResultOutput {
|
|
107
|
+
/** Indicates whether the experiment metric is valid. */
|
|
108
|
+
isValid: boolean;
|
|
109
|
+
/** Diagnostic details from the validation process. */
|
|
110
|
+
readonly diagnostics: Array<DiagnosticDetailOutput>;
|
|
111
|
+
}
|
|
112
|
+
/** Diagnostic details for validation errors. */
|
|
113
|
+
export interface DiagnosticDetailOutput {
|
|
114
|
+
/** A human-readable error message. */
|
|
115
|
+
readonly message: string;
|
|
116
|
+
/**
|
|
117
|
+
* The diagnostic error code.
|
|
118
|
+
*
|
|
119
|
+
* Possible values: "FailedSchemaValidation", "InvalidEventCondition", "UnsupportedEventCondition", "InvalidExperimentMetricDefinition"
|
|
120
|
+
*/
|
|
121
|
+
readonly code: DiagnosticCodeOutput;
|
|
122
|
+
}
|
|
123
|
+
/** Paged collection of ExperimentMetric items */
|
|
124
|
+
export interface PagedExperimentMetricOutput {
|
|
125
|
+
/** The ExperimentMetric items on this page */
|
|
126
|
+
value: Array<ExperimentMetricOutput>;
|
|
127
|
+
/** The link to the next page of items */
|
|
128
|
+
nextLink?: string;
|
|
129
|
+
}
|
|
130
|
+
/** The metric definition, which determines how the metric value is calculated from event data. */
|
|
131
|
+
export type ExperimentMetricDefinitionOutput = ExperimentMetricDefinitionOutputParent | EventCountMetricDefinitionOutput | UserCountMetricDefinitionOutput | EventRateMetricDefinitionOutput | UserRateMetricDefinitionOutput | SumMetricDefinitionOutput | AverageMetricDefinitionOutput | PercentileMetricDefinitionOutput;
|
|
132
|
+
/** Alias for LifecycleStageOutput */
|
|
133
|
+
export type LifecycleStageOutput = string;
|
|
134
|
+
/** Alias for DesiredDirectionOutput */
|
|
135
|
+
export type DesiredDirectionOutput = string;
|
|
136
|
+
/** Alias for DiagnosticCodeOutput */
|
|
137
|
+
export type DiagnosticCodeOutput = string;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { Client, PathUncheckedResponse } from "@azure-rest/core-client";
|
|
2
|
+
/**
|
|
3
|
+
* An interface that tracks the settings for paged iteration
|
|
4
|
+
*/
|
|
5
|
+
export interface PageSettings {
|
|
6
|
+
/**
|
|
7
|
+
* The token that keeps track of where to continue the iterator
|
|
8
|
+
*/
|
|
9
|
+
continuationToken?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* An interface that allows async iterable iteration both to completion and by page.
|
|
13
|
+
*/
|
|
14
|
+
export interface PagedAsyncIterableIterator<TElement, TPage = TElement[], TPageSettings = PageSettings> {
|
|
15
|
+
/**
|
|
16
|
+
* The next method, part of the iteration protocol
|
|
17
|
+
*/
|
|
18
|
+
next(): Promise<IteratorResult<TElement>>;
|
|
19
|
+
/**
|
|
20
|
+
* The connection to the async iterator, part of the iteration protocol
|
|
21
|
+
*/
|
|
22
|
+
[Symbol.asyncIterator](): PagedAsyncIterableIterator<TElement, TPage, TPageSettings>;
|
|
23
|
+
/**
|
|
24
|
+
* Return an AsyncIterableIterator that works a page at a time
|
|
25
|
+
*/
|
|
26
|
+
byPage: (settings?: TPageSettings) => AsyncIterableIterator<TPage>;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Helper type to extract the type of an array
|
|
30
|
+
*/
|
|
31
|
+
export type GetArrayType<T> = T extends Array<infer TData> ? TData : never;
|
|
32
|
+
/**
|
|
33
|
+
* The type of a custom function that defines how to get a page and a link to the next one if any.
|
|
34
|
+
*/
|
|
35
|
+
export type GetPage<TPage> = (pageLink: string) => Promise<{
|
|
36
|
+
page: TPage;
|
|
37
|
+
nextPageLink?: string;
|
|
38
|
+
}>;
|
|
39
|
+
/**
|
|
40
|
+
* Options for the paging helper
|
|
41
|
+
*/
|
|
42
|
+
export interface PagingOptions<TResponse> {
|
|
43
|
+
/**
|
|
44
|
+
* Custom function to extract pagination details for crating the PagedAsyncIterableIterator
|
|
45
|
+
*/
|
|
46
|
+
customGetPage?: GetPage<PaginateReturn<TResponse>[]>;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Helper type to infer the Type of the paged elements from the response type
|
|
50
|
+
* This type is generated based on the swagger information for x-ms-pageable
|
|
51
|
+
* specifically on the itemName property which indicates the property of the response
|
|
52
|
+
* where the page items are found. The default value is `value`.
|
|
53
|
+
* This type will allow us to provide strongly typed Iterator based on the response we get as second parameter
|
|
54
|
+
*/
|
|
55
|
+
export type PaginateReturn<TResult> = TResult extends {
|
|
56
|
+
body: {
|
|
57
|
+
value?: infer TPage;
|
|
58
|
+
};
|
|
59
|
+
} ? GetArrayType<TPage> : Array<unknown>;
|
|
60
|
+
/**
|
|
61
|
+
* Helper to paginate results from an initial response that follows the specification of Autorest `x-ms-pageable` extension
|
|
62
|
+
* @param client - Client to use for sending the next page requests
|
|
63
|
+
* @param initialResponse - Initial response containing the nextLink and current page of elements
|
|
64
|
+
* @param customGetPage - Optional - Function to define how to extract the page and next link to be used to paginate the results
|
|
65
|
+
* @returns - PagedAsyncIterableIterator to iterate the elements
|
|
66
|
+
*/
|
|
67
|
+
export declare function paginate<TResponse extends PathUncheckedResponse>(client: Client, initialResponse: TResponse, options?: PagingOptions<TResponse>): PagedAsyncIterableIterator<PaginateReturn<TResponse>>;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
import { createRestError } from "@azure-rest/core-client";
|
|
4
|
+
/**
|
|
5
|
+
* returns an async iterator that iterates over results. It also has a `byPage`
|
|
6
|
+
* method that returns pages of items at once.
|
|
7
|
+
*
|
|
8
|
+
* @param pagedResult - an object that specifies how to get pages.
|
|
9
|
+
* @returns a paged async iterator that iterates over results.
|
|
10
|
+
*/
|
|
11
|
+
function getPagedAsyncIterator(pagedResult) {
|
|
12
|
+
const iter = getItemAsyncIterator(pagedResult);
|
|
13
|
+
return {
|
|
14
|
+
next() {
|
|
15
|
+
return iter.next();
|
|
16
|
+
},
|
|
17
|
+
[Symbol.asyncIterator]() {
|
|
18
|
+
return this;
|
|
19
|
+
},
|
|
20
|
+
byPage: pagedResult?.byPage ??
|
|
21
|
+
((settings) => {
|
|
22
|
+
const { continuationToken } = settings ?? {};
|
|
23
|
+
return getPageAsyncIterator(pagedResult, {
|
|
24
|
+
pageLink: continuationToken,
|
|
25
|
+
});
|
|
26
|
+
}),
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
async function* getItemAsyncIterator(pagedResult) {
|
|
30
|
+
const pages = getPageAsyncIterator(pagedResult);
|
|
31
|
+
const firstVal = await pages.next();
|
|
32
|
+
// if the result does not have an array shape, i.e. TPage = TElement, then we return it as is
|
|
33
|
+
if (!Array.isArray(firstVal.value)) {
|
|
34
|
+
// can extract elements from this page
|
|
35
|
+
const { toElements } = pagedResult;
|
|
36
|
+
if (toElements) {
|
|
37
|
+
yield* toElements(firstVal.value);
|
|
38
|
+
for await (const page of pages) {
|
|
39
|
+
yield* toElements(page);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
yield firstVal.value;
|
|
44
|
+
// `pages` is of type `AsyncIterableIterator<TPage>` but TPage = TElement in this case
|
|
45
|
+
yield* pages;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
yield* firstVal.value;
|
|
50
|
+
for await (const page of pages) {
|
|
51
|
+
// pages is of type `AsyncIterableIterator<TPage>` so `page` is of type `TPage`. In this branch,
|
|
52
|
+
// it must be the case that `TPage = TElement[]`
|
|
53
|
+
yield* page;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
async function* getPageAsyncIterator(pagedResult, options = {}) {
|
|
58
|
+
const { pageLink } = options;
|
|
59
|
+
let response = await pagedResult.getPage(pageLink ?? pagedResult.firstPageLink);
|
|
60
|
+
if (!response) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
yield response.page;
|
|
64
|
+
while (response.nextPageLink) {
|
|
65
|
+
response = await pagedResult.getPage(response.nextPageLink);
|
|
66
|
+
if (!response) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
yield response.page;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Helper to paginate results from an initial response that follows the specification of Autorest `x-ms-pageable` extension
|
|
74
|
+
* @param client - Client to use for sending the next page requests
|
|
75
|
+
* @param initialResponse - Initial response containing the nextLink and current page of elements
|
|
76
|
+
* @param customGetPage - Optional - Function to define how to extract the page and next link to be used to paginate the results
|
|
77
|
+
* @returns - PagedAsyncIterableIterator to iterate the elements
|
|
78
|
+
*/
|
|
79
|
+
export function paginate(client, initialResponse, options = {}) {
|
|
80
|
+
let firstRun = true;
|
|
81
|
+
const itemName = "value";
|
|
82
|
+
const nextLinkName = "nextLink";
|
|
83
|
+
const { customGetPage } = options;
|
|
84
|
+
const pagedResult = {
|
|
85
|
+
firstPageLink: "",
|
|
86
|
+
getPage: typeof customGetPage === "function"
|
|
87
|
+
? customGetPage
|
|
88
|
+
: async (pageLink) => {
|
|
89
|
+
const result = firstRun ? initialResponse : await client.pathUnchecked(pageLink).get();
|
|
90
|
+
firstRun = false;
|
|
91
|
+
checkPagingRequest(result);
|
|
92
|
+
const nextLink = getNextLink(result.body, nextLinkName);
|
|
93
|
+
const values = getElements(result.body, itemName);
|
|
94
|
+
return {
|
|
95
|
+
page: values,
|
|
96
|
+
nextPageLink: nextLink,
|
|
97
|
+
};
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
return getPagedAsyncIterator(pagedResult);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Gets for the value of nextLink in the body
|
|
104
|
+
*/
|
|
105
|
+
function getNextLink(body, nextLinkName) {
|
|
106
|
+
if (!nextLinkName) {
|
|
107
|
+
return undefined;
|
|
108
|
+
}
|
|
109
|
+
const nextLink = body[nextLinkName];
|
|
110
|
+
if (typeof nextLink !== "string" && typeof nextLink !== "undefined") {
|
|
111
|
+
throw new Error(`Body Property ${nextLinkName} should be a string or undefined`);
|
|
112
|
+
}
|
|
113
|
+
return nextLink;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Gets the elements of the current request in the body.
|
|
117
|
+
*/
|
|
118
|
+
function getElements(body, itemName) {
|
|
119
|
+
const value = body[itemName];
|
|
120
|
+
// value has to be an array according to the x-ms-pageable extension.
|
|
121
|
+
// The fact that this must be an array is used above to calculate the
|
|
122
|
+
// type of elements in the page in PaginateReturn
|
|
123
|
+
if (!Array.isArray(value)) {
|
|
124
|
+
throw new Error(`Couldn't paginate response\n Body doesn't contain an array property with name: ${itemName}`);
|
|
125
|
+
}
|
|
126
|
+
return value ?? [];
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Checks if a request failed
|
|
130
|
+
*/
|
|
131
|
+
function checkPagingRequest(response) {
|
|
132
|
+
const Http2xxStatusCodes = ["200", "201", "202", "203", "204", "205", "206", "207", "208", "226"];
|
|
133
|
+
if (!Http2xxStatusCodes.includes(response.status)) {
|
|
134
|
+
throw createRestError(`Pagination failed with unexpected statusCode ${response.status}`, response);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import type { RawHttpHeadersInput } from "@azure/core-rest-pipeline";
|
|
2
|
+
import type { RequestParameters } from "@azure-rest/core-client";
|
|
3
|
+
import type { ExperimentMetric } from "./models.js";
|
|
4
|
+
export interface GetMetricHeaders {
|
|
5
|
+
/** The request should only proceed if an entity matches this string. */
|
|
6
|
+
"If-Match"?: string;
|
|
7
|
+
/** The request should only proceed if no entity matches this string. */
|
|
8
|
+
"If-None-Match"?: string;
|
|
9
|
+
/** The request should only proceed if the entity was not modified after this time. */
|
|
10
|
+
"If-Unmodified-Since"?: string;
|
|
11
|
+
/** The request should only proceed if the entity was modified after this time. */
|
|
12
|
+
"If-Modified-Since"?: string;
|
|
13
|
+
/** An opaque, globally-unique, client-generated string identifier for the request. */
|
|
14
|
+
"x-ms-client-request-id"?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface GetMetricHeaderParam {
|
|
17
|
+
headers?: RawHttpHeadersInput & GetMetricHeaders;
|
|
18
|
+
}
|
|
19
|
+
export type GetMetricParameters = GetMetricHeaderParam & RequestParameters;
|
|
20
|
+
export interface CreateOrUpdateMetricHeaders {
|
|
21
|
+
/** The request should only proceed if an entity matches this string. */
|
|
22
|
+
"If-Match"?: string;
|
|
23
|
+
/** The request should only proceed if no entity matches this string. */
|
|
24
|
+
"If-None-Match"?: string;
|
|
25
|
+
/** The request should only proceed if the entity was not modified after this time. */
|
|
26
|
+
"If-Unmodified-Since"?: string;
|
|
27
|
+
/** The request should only proceed if the entity was modified after this time. */
|
|
28
|
+
"If-Modified-Since"?: string;
|
|
29
|
+
/** An opaque, globally-unique, client-generated string identifier for the request. */
|
|
30
|
+
"x-ms-client-request-id"?: string;
|
|
31
|
+
}
|
|
32
|
+
/** The resource instance. */
|
|
33
|
+
export type ExperimentMetricResourceMergeAndPatch = Partial<ExperimentMetric>;
|
|
34
|
+
export interface CreateOrUpdateMetricBodyParam {
|
|
35
|
+
/** The resource instance. */
|
|
36
|
+
body: ExperimentMetricResourceMergeAndPatch;
|
|
37
|
+
}
|
|
38
|
+
export interface CreateOrUpdateMetricHeaderParam {
|
|
39
|
+
headers?: RawHttpHeadersInput & CreateOrUpdateMetricHeaders;
|
|
40
|
+
}
|
|
41
|
+
export interface CreateOrUpdateMetricMediaTypesParam {
|
|
42
|
+
/** This request has a JSON Merge Patch body. */
|
|
43
|
+
contentType: "application/merge-patch+json";
|
|
44
|
+
}
|
|
45
|
+
export type CreateOrUpdateMetricParameters = CreateOrUpdateMetricHeaderParam & CreateOrUpdateMetricMediaTypesParam & CreateOrUpdateMetricBodyParam & RequestParameters;
|
|
46
|
+
export interface ValidateMetricHeaders {
|
|
47
|
+
/** An opaque, globally-unique, client-generated string identifier for the request. */
|
|
48
|
+
"x-ms-client-request-id"?: string;
|
|
49
|
+
}
|
|
50
|
+
export interface ValidateMetricBodyParam {
|
|
51
|
+
/** Experiment metric input to validate */
|
|
52
|
+
body: ExperimentMetric;
|
|
53
|
+
}
|
|
54
|
+
export interface ValidateMetricHeaderParam {
|
|
55
|
+
headers?: RawHttpHeadersInput & ValidateMetricHeaders;
|
|
56
|
+
}
|
|
57
|
+
export type ValidateMetricParameters = ValidateMetricHeaderParam & ValidateMetricBodyParam & RequestParameters;
|
|
58
|
+
export interface DeleteMetricHeaders {
|
|
59
|
+
/** The request should only proceed if an entity matches this string. */
|
|
60
|
+
"If-Match"?: string;
|
|
61
|
+
/** The request should only proceed if no entity matches this string. */
|
|
62
|
+
"If-None-Match"?: string;
|
|
63
|
+
/** The request should only proceed if the entity was not modified after this time. */
|
|
64
|
+
"If-Unmodified-Since"?: string;
|
|
65
|
+
/** The request should only proceed if the entity was modified after this time. */
|
|
66
|
+
"If-Modified-Since"?: string;
|
|
67
|
+
/** An opaque, globally-unique, client-generated string identifier for the request. */
|
|
68
|
+
"x-ms-client-request-id"?: string;
|
|
69
|
+
}
|
|
70
|
+
export interface DeleteMetricHeaderParam {
|
|
71
|
+
headers?: RawHttpHeadersInput & DeleteMetricHeaders;
|
|
72
|
+
}
|
|
73
|
+
export type DeleteMetricParameters = DeleteMetricHeaderParam & RequestParameters;
|
|
74
|
+
export interface ListMetricsHeaders {
|
|
75
|
+
/** An opaque, globally-unique, client-generated string identifier for the request. */
|
|
76
|
+
"x-ms-client-request-id"?: string;
|
|
77
|
+
}
|
|
78
|
+
export interface ListMetricsQueryParamProperties {
|
|
79
|
+
/** The number of result items to return. */
|
|
80
|
+
top?: number;
|
|
81
|
+
/** The number of result items to skip. */
|
|
82
|
+
skip?: number;
|
|
83
|
+
/** The maximum number of result items per page. */
|
|
84
|
+
maxpagesize?: number;
|
|
85
|
+
}
|
|
86
|
+
export interface ListMetricsQueryParam {
|
|
87
|
+
queryParameters?: ListMetricsQueryParamProperties;
|
|
88
|
+
}
|
|
89
|
+
export interface ListMetricsHeaderParam {
|
|
90
|
+
headers?: RawHttpHeadersInput & ListMetricsHeaders;
|
|
91
|
+
}
|
|
92
|
+
export type ListMetricsParameters = ListMetricsQueryParam & ListMetricsHeaderParam & RequestParameters;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import type { RawHttpHeaders } from "@azure/core-rest-pipeline";
|
|
2
|
+
import type { HttpResponse, ErrorResponse } from "@azure-rest/core-client";
|
|
3
|
+
import type { ExperimentMetricOutput, ExperimentMetricValidationResultOutput, PagedExperimentMetricOutput } from "./outputModels.js";
|
|
4
|
+
export interface GetMetric200Headers {
|
|
5
|
+
/** The entity tag for the response. */
|
|
6
|
+
etag?: string;
|
|
7
|
+
/** An opaque, globally-unique, client-generated string identifier for the request. */
|
|
8
|
+
"x-ms-client-request-id"?: string;
|
|
9
|
+
}
|
|
10
|
+
/** The request has succeeded. */
|
|
11
|
+
export interface GetMetric200Response extends HttpResponse {
|
|
12
|
+
status: "200";
|
|
13
|
+
body: ExperimentMetricOutput;
|
|
14
|
+
headers: RawHttpHeaders & GetMetric200Headers;
|
|
15
|
+
}
|
|
16
|
+
export interface GetMetricDefaultHeaders {
|
|
17
|
+
/** String error code indicating what went wrong. */
|
|
18
|
+
"x-ms-error-code"?: string;
|
|
19
|
+
}
|
|
20
|
+
export interface GetMetricDefaultResponse extends HttpResponse {
|
|
21
|
+
status: string;
|
|
22
|
+
body: ErrorResponse;
|
|
23
|
+
headers: RawHttpHeaders & GetMetricDefaultHeaders;
|
|
24
|
+
}
|
|
25
|
+
export interface CreateOrUpdateMetric200Headers {
|
|
26
|
+
/** The entity tag for the response. */
|
|
27
|
+
etag?: string;
|
|
28
|
+
/** An opaque, globally-unique, client-generated string identifier for the request. */
|
|
29
|
+
"x-ms-client-request-id"?: string;
|
|
30
|
+
}
|
|
31
|
+
/** The request has succeeded. */
|
|
32
|
+
export interface CreateOrUpdateMetric200Response extends HttpResponse {
|
|
33
|
+
status: "200";
|
|
34
|
+
body: ExperimentMetricOutput;
|
|
35
|
+
headers: RawHttpHeaders & CreateOrUpdateMetric200Headers;
|
|
36
|
+
}
|
|
37
|
+
export interface CreateOrUpdateMetric201Headers {
|
|
38
|
+
/** The entity tag for the response. */
|
|
39
|
+
etag?: string;
|
|
40
|
+
/** An opaque, globally-unique, client-generated string identifier for the request. */
|
|
41
|
+
"x-ms-client-request-id"?: string;
|
|
42
|
+
}
|
|
43
|
+
/** The request has succeeded and a new resource has been created as a result. */
|
|
44
|
+
export interface CreateOrUpdateMetric201Response extends HttpResponse {
|
|
45
|
+
status: "201";
|
|
46
|
+
body: ExperimentMetricOutput;
|
|
47
|
+
headers: RawHttpHeaders & CreateOrUpdateMetric201Headers;
|
|
48
|
+
}
|
|
49
|
+
export interface CreateOrUpdateMetricDefaultHeaders {
|
|
50
|
+
/** String error code indicating what went wrong. */
|
|
51
|
+
"x-ms-error-code"?: string;
|
|
52
|
+
}
|
|
53
|
+
export interface CreateOrUpdateMetricDefaultResponse extends HttpResponse {
|
|
54
|
+
status: string;
|
|
55
|
+
body: ErrorResponse;
|
|
56
|
+
headers: RawHttpHeaders & CreateOrUpdateMetricDefaultHeaders;
|
|
57
|
+
}
|
|
58
|
+
export interface ValidateMetric200Headers {
|
|
59
|
+
/** An opaque, globally-unique, client-generated string identifier for the request. */
|
|
60
|
+
"x-ms-client-request-id"?: string;
|
|
61
|
+
}
|
|
62
|
+
/** The request has succeeded. */
|
|
63
|
+
export interface ValidateMetric200Response extends HttpResponse {
|
|
64
|
+
status: "200";
|
|
65
|
+
body: ExperimentMetricValidationResultOutput;
|
|
66
|
+
headers: RawHttpHeaders & ValidateMetric200Headers;
|
|
67
|
+
}
|
|
68
|
+
export interface ValidateMetricDefaultHeaders {
|
|
69
|
+
/** String error code indicating what went wrong. */
|
|
70
|
+
"x-ms-error-code"?: string;
|
|
71
|
+
}
|
|
72
|
+
export interface ValidateMetricDefaultResponse extends HttpResponse {
|
|
73
|
+
status: string;
|
|
74
|
+
body: ErrorResponse;
|
|
75
|
+
headers: RawHttpHeaders & ValidateMetricDefaultHeaders;
|
|
76
|
+
}
|
|
77
|
+
export interface DeleteMetric204Headers {
|
|
78
|
+
/** An opaque, globally-unique, client-generated string identifier for the request. */
|
|
79
|
+
"x-ms-client-request-id"?: string;
|
|
80
|
+
}
|
|
81
|
+
/** There is no content to send for this request, but the headers may be useful. */
|
|
82
|
+
export interface DeleteMetric204Response extends HttpResponse {
|
|
83
|
+
status: "204";
|
|
84
|
+
headers: RawHttpHeaders & DeleteMetric204Headers;
|
|
85
|
+
}
|
|
86
|
+
export interface DeleteMetricDefaultHeaders {
|
|
87
|
+
/** String error code indicating what went wrong. */
|
|
88
|
+
"x-ms-error-code"?: string;
|
|
89
|
+
}
|
|
90
|
+
export interface DeleteMetricDefaultResponse extends HttpResponse {
|
|
91
|
+
status: string;
|
|
92
|
+
body: ErrorResponse;
|
|
93
|
+
headers: RawHttpHeaders & DeleteMetricDefaultHeaders;
|
|
94
|
+
}
|
|
95
|
+
export interface ListMetrics200Headers {
|
|
96
|
+
/** An opaque, globally-unique, client-generated string identifier for the request. */
|
|
97
|
+
"x-ms-client-request-id"?: string;
|
|
98
|
+
}
|
|
99
|
+
/** The request has succeeded. */
|
|
100
|
+
export interface ListMetrics200Response extends HttpResponse {
|
|
101
|
+
status: "200";
|
|
102
|
+
body: PagedExperimentMetricOutput;
|
|
103
|
+
headers: RawHttpHeaders & ListMetrics200Headers;
|
|
104
|
+
}
|
|
105
|
+
export interface ListMetricsDefaultHeaders {
|
|
106
|
+
/** String error code indicating what went wrong. */
|
|
107
|
+
"x-ms-error-code"?: string;
|
|
108
|
+
}
|
|
109
|
+
export interface ListMetricsDefaultResponse extends HttpResponse {
|
|
110
|
+
status: string;
|
|
111
|
+
body: ErrorResponse;
|
|
112
|
+
headers: RawHttpHeaders & ListMetricsDefaultHeaders;
|
|
113
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { GetMetricParameters, CreateOrUpdateMetricParameters, DeleteMetricParameters, ValidateMetricParameters, ListMetricsParameters } from "./parameters.js";
|
|
2
|
+
import type { GetMetric200Response, GetMetricDefaultResponse, CreateOrUpdateMetric200Response, CreateOrUpdateMetric201Response, CreateOrUpdateMetricDefaultResponse, DeleteMetric204Response, DeleteMetricDefaultResponse, ValidateMetric200Response, ValidateMetricDefaultResponse, ListMetrics200Response, ListMetricsDefaultResponse } from "./responses.js";
|
|
3
|
+
import type { Client, StreamableMethod } from "@azure-rest/core-client";
|
|
4
|
+
export interface GetMetric {
|
|
5
|
+
/** Fetches an experiment metric by ID. */
|
|
6
|
+
get(options?: GetMetricParameters): StreamableMethod<GetMetric200Response | GetMetricDefaultResponse>;
|
|
7
|
+
/** Creates or updates an experiment metric. */
|
|
8
|
+
patch(options: CreateOrUpdateMetricParameters): StreamableMethod<CreateOrUpdateMetric200Response | CreateOrUpdateMetric201Response | CreateOrUpdateMetricDefaultResponse>;
|
|
9
|
+
/** Deletes an experiment metric. */
|
|
10
|
+
delete(options?: DeleteMetricParameters): StreamableMethod<DeleteMetric204Response | DeleteMetricDefaultResponse>;
|
|
11
|
+
}
|
|
12
|
+
export interface ValidateMetric {
|
|
13
|
+
/** Validates an experiment metric definition. */
|
|
14
|
+
post(options: ValidateMetricParameters): StreamableMethod<ValidateMetric200Response | ValidateMetricDefaultResponse>;
|
|
15
|
+
}
|
|
16
|
+
export interface ListMetrics {
|
|
17
|
+
/** Lists experiment metrics. */
|
|
18
|
+
get(options?: ListMetricsParameters): StreamableMethod<ListMetrics200Response | ListMetricsDefaultResponse>;
|
|
19
|
+
}
|
|
20
|
+
export interface Routes {
|
|
21
|
+
/** Resource for '/experiment-metrics/\{experimentMetricId\}' has methods for the following verbs: get, patch, delete */
|
|
22
|
+
(path: "/experiment-metrics/{experimentMetricId}", experimentMetricId: string): GetMetric;
|
|
23
|
+
/** Resource for '/experiment-metrics:validate' has methods for the following verbs: post */
|
|
24
|
+
(path: "/experiment-metrics:validate"): ValidateMetric;
|
|
25
|
+
/** Resource for '/experiment-metrics' has methods for the following verbs: get */
|
|
26
|
+
(path: "/experiment-metrics"): ListMetrics;
|
|
27
|
+
}
|
|
28
|
+
export type OnlineExperimentationClient = Client & {
|
|
29
|
+
path: Routes;
|
|
30
|
+
};
|