Skip to content

Commit d47cf4f

Browse files
authored
release-for-synapse-access-control-rlc (Azure#23250)
* release-for-synapse-access-control-rlc * update samples to use isUnexpected * remove unused imports * update version
1 parent 81cad53 commit d47cf4f

File tree

19 files changed

+542
-250
lines changed

19 files changed

+542
-250
lines changed

sdk/synapse/synapse-access-control-rest/review/synapse-access-control.api.md

Lines changed: 104 additions & 57 deletions
Large diffs are not rendered by default.

sdk/synapse/synapse-access-control-rest/samples-dev/createRoleAssignment.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* @azsdk-weight 10
99
*/
1010

11-
import AccessControl from "@azure-rest/synapse-access-control";
11+
import AccessControl, { isUnexpected } from "@azure-rest/synapse-access-control";
1212
import { DefaultAzureCredential } from "@azure/identity";
1313
import { v4 } from "uuid";
1414
import dotenv from "dotenv";
@@ -31,7 +31,7 @@ async function main() {
3131
.path("/roleAssignments/{roleAssignmentId}", roleAssignmentId)
3232
.put({ body: { principalId, roleId, scope } });
3333

34-
if (result.status !== "200") {
34+
if (isUnexpected(result)) {
3535
throw result.body.error;
3636
}
3737

sdk/synapse/synapse-access-control-rest/samples-dev/listRoleAssignments.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* @azsdk-weight 20
99
*/
1010

11-
import AccessControl, { paginate } from "@azure-rest/synapse-access-control";
11+
import AccessControl, { isUnexpected, paginate } from "@azure-rest/synapse-access-control";
1212
import { DefaultAzureCredential } from "@azure/identity";
1313
import dotenv from "dotenv";
1414

@@ -20,7 +20,7 @@ async function main() {
2020
const client = AccessControl(endpoint, new DefaultAzureCredential());
2121
const initialResponse = await client.path("/roleAssignments").get();
2222

23-
if (initialResponse.status !== "200") {
23+
if (isUnexpected(initialResponse)) {
2424
throw initialResponse.body.error;
2525
}
2626

sdk/synapse/synapse-access-control-rest/samples/v1-beta/javascript/createRoleAssignment.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
* @summary creates a role assignment
88
*/
99

10-
const AccessControl = require("@azure-rest/synapse-access-control").default;
10+
const AccessControl = require("@azure-rest/synapse-access-control").default,
11+
{ isUnexpected } = require("@azure-rest/synapse-access-control");
1112
const { DefaultAzureCredential } = require("@azure/identity");
1213
const { v4 } = require("uuid");
1314
require("dotenv").config();
@@ -28,7 +29,7 @@ async function main() {
2829
.path("/roleAssignments/{roleAssignmentId}", roleAssignmentId)
2930
.put({ body: { principalId, roleId, scope } });
3031

31-
if (result.status !== "200") {
32+
if (isUnexpected(result)) {
3233
throw result.body.error;
3334
}
3435

sdk/synapse/synapse-access-control-rest/samples/v1-beta/javascript/listRoleAssignments.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*/
99

1010
const AccessControl = require("@azure-rest/synapse-access-control").default,
11-
{ paginate } = require("@azure-rest/synapse-access-control");
11+
{ isUnexpected, paginate } = require("@azure-rest/synapse-access-control");
1212
const { DefaultAzureCredential } = require("@azure/identity");
1313
require("dotenv").config();
1414

@@ -18,7 +18,7 @@ async function main() {
1818
const client = AccessControl(endpoint, new DefaultAzureCredential());
1919
const initialResponse = await client.path("/roleAssignments").get();
2020

21-
if (initialResponse.status !== "200") {
21+
if (isUnexpected(initialResponse)) {
2222
throw initialResponse.body.error;
2323
}
2424

sdk/synapse/synapse-access-control-rest/samples/v1-beta/typescript/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"devDependencies": {
3939
"@types/uuid": "^8.0.0",
4040
"@types/node": "^12.0.0",
41-
"typescript": "~4.4.0",
41+
"typescript": "~4.6.0",
4242
"rimraf": "latest"
4343
}
4444
}

sdk/synapse/synapse-access-control-rest/samples/v1-beta/typescript/src/createRoleAssignment.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @summary creates a role assignment
88
*/
99

10-
import AccessControl from "@azure-rest/synapse-access-control";
10+
import AccessControl, { isUnexpected } from "@azure-rest/synapse-access-control";
1111
import { DefaultAzureCredential } from "@azure/identity";
1212
import { v4 } from "uuid";
1313
import dotenv from "dotenv";
@@ -30,7 +30,7 @@ async function main() {
3030
.path("/roleAssignments/{roleAssignmentId}", roleAssignmentId)
3131
.put({ body: { principalId, roleId, scope } });
3232

33-
if (result.status !== "200") {
33+
if (isUnexpected(result)) {
3434
throw result.body.error;
3535
}
3636

sdk/synapse/synapse-access-control-rest/samples/v1-beta/typescript/src/listRoleAssignments.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @summary list role assignments
88
*/
99

10-
import AccessControl, { paginate } from "@azure-rest/synapse-access-control";
10+
import AccessControl, { isUnexpected, paginate } from "@azure-rest/synapse-access-control";
1111
import { DefaultAzureCredential } from "@azure/identity";
1212
import dotenv from "dotenv";
1313

@@ -19,7 +19,7 @@ async function main() {
1919
const client = AccessControl(endpoint, new DefaultAzureCredential());
2020
const initialResponse = await client.path("/roleAssignments").get();
2121

22-
if (initialResponse.status !== "200") {
22+
if (isUnexpected(initialResponse)) {
2323
throw initialResponse.body.error;
2424
}
2525

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT license.
3+
4+
import { getClient, ClientOptions } from "@azure-rest/core-client";
5+
import { TokenCredential } from "@azure/core-auth";
6+
import { AccessControlRestClient } from "./clientDefinitions";
7+
8+
export default function createClient(
9+
endpoint: string,
10+
credentials: TokenCredential,
11+
options: ClientOptions = {}
12+
): AccessControlRestClient {
13+
const baseUrl = options.baseUrl ?? `${endpoint}`;
14+
options.apiVersion = options.apiVersion ?? "2020-12-01";
15+
options = {
16+
...options,
17+
credentials: {
18+
scopes: ["https://dev.azuresynapse.net/.default"]
19+
}
20+
};
21+
22+
const userAgentInfo = `azsdk-js-synapse-access-control-rest/1.0.0-beta.1`;
23+
const userAgentPrefix =
24+
options.userAgentOptions && options.userAgentOptions.userAgentPrefix
25+
? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`
26+
: `${userAgentInfo}`;
27+
options = {
28+
...options,
29+
userAgentOptions: {
30+
userAgentPrefix
31+
}
32+
};
33+
34+
const client = getClient(
35+
baseUrl,
36+
credentials,
37+
options
38+
) as AccessControlRestClient;
39+
40+
return client;
41+
}

sdk/synapse/synapse-access-control-rest/src/accessControl.ts renamed to sdk/synapse/synapse-access-control-rest/src/clientDefinitions.ts

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,13 @@ import {
3030
RoleDefinitionsListScopes200Response,
3131
RoleDefinitionsListScopesdefaultResponse
3232
} from "./responses";
33-
import { getClient, ClientOptions, Client } from "@azure-rest/core-client";
34-
import { TokenCredential } from "@azure/core-auth";
33+
import { Client, StreamableMethod } from "@azure-rest/core-client";
3534

3635
export interface RoleAssignmentsCheckPrincipalAccess {
3736
/** Check if the given principalId has access to perform list of actions at a given scope. */
3837
post(
3938
options: RoleAssignmentsCheckPrincipalAccessParameters
40-
): Promise<
39+
): StreamableMethod<
4140
| RoleAssignmentsCheckPrincipalAccess200Response
4241
| RoleAssignmentsCheckPrincipalAccessdefaultResponse
4342
>;
@@ -47,7 +46,7 @@ export interface RoleAssignmentsListRoleAssignments {
4746
/** List role assignments. */
4847
get(
4948
options?: RoleAssignmentsListRoleAssignmentsParameters
50-
): Promise<
49+
): StreamableMethod<
5150
| RoleAssignmentsListRoleAssignments200Response
5251
| RoleAssignmentsListRoleAssignmentsdefaultResponse
5352
>;
@@ -57,21 +56,21 @@ export interface RoleAssignmentsCreateRoleAssignment {
5756
/** Create role assignment. */
5857
put(
5958
options: RoleAssignmentsCreateRoleAssignmentParameters
60-
): Promise<
59+
): StreamableMethod<
6160
| RoleAssignmentsCreateRoleAssignment200Response
6261
| RoleAssignmentsCreateRoleAssignmentdefaultResponse
6362
>;
6463
/** Get role assignment by role assignment Id. */
6564
get(
6665
options?: RoleAssignmentsGetRoleAssignmentByIdParameters
67-
): Promise<
66+
): StreamableMethod<
6867
| RoleAssignmentsGetRoleAssignmentById200Response
6968
| RoleAssignmentsGetRoleAssignmentByIddefaultResponse
7069
>;
7170
/** Delete role assignment by role assignment Id. */
7271
delete(
7372
options?: RoleAssignmentsDeleteRoleAssignmentByIdParameters
74-
): Promise<
73+
): StreamableMethod<
7574
| RoleAssignmentsDeleteRoleAssignmentById200Response
7675
| RoleAssignmentsDeleteRoleAssignmentById204Response
7776
| RoleAssignmentsDeleteRoleAssignmentByIddefaultResponse
@@ -82,7 +81,7 @@ export interface RoleDefinitionsListRoleDefinitions {
8281
/** List role definitions. */
8382
get(
8483
options?: RoleDefinitionsListRoleDefinitionsParameters
85-
): Promise<
84+
): StreamableMethod<
8685
| RoleDefinitionsListRoleDefinitions200Response
8786
| RoleDefinitionsListRoleDefinitionsdefaultResponse
8887
>;
@@ -92,7 +91,7 @@ export interface RoleDefinitionsGetRoleDefinitionById {
9291
/** Get role definition by role definition Id. */
9392
get(
9493
options?: RoleDefinitionsGetRoleDefinitionByIdParameters
95-
): Promise<
94+
): StreamableMethod<
9695
| RoleDefinitionsGetRoleDefinitionById200Response
9796
| RoleDefinitionsGetRoleDefinitionByIddefaultResponse
9897
>;
@@ -102,7 +101,7 @@ export interface RoleDefinitionsListScopes {
102101
/** List rbac scopes. */
103102
get(
104103
options?: RoleDefinitionsListScopesParameters
105-
): Promise<
104+
): StreamableMethod<
106105
| RoleDefinitionsListScopes200Response
107106
| RoleDefinitionsListScopesdefaultResponse
108107
>;
@@ -132,20 +131,3 @@ export interface Routes {
132131
export type AccessControlRestClient = Client & {
133132
path: Routes;
134133
};
135-
136-
export default function AccessControl(
137-
endpoint: string,
138-
credentials: TokenCredential,
139-
options: ClientOptions = {}
140-
): AccessControlRestClient {
141-
const baseUrl = options.baseUrl ?? `${endpoint}`;
142-
options.apiVersion = options.apiVersion ?? "2020-12-01";
143-
options = {
144-
...options,
145-
credentials: {
146-
scopes: ["https://dev.azuresynapse.net/.default"]
147-
}
148-
};
149-
150-
return getClient(baseUrl, credentials, options) as AccessControlRestClient;
151-
}

0 commit comments

Comments
 (0)