Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Synapse] Update swagger to aa19725fe79aea2a9dc580f3c66f77f89cc34563, bump to newest AccessControl API, add new Artifacts.Library API #18343

Merged
merged 14 commits into from
Feb 5, 2021
29 changes: 17 additions & 12 deletions sdk/synapse/Azure.Analytics.Synapse.AccessControl/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,27 +73,32 @@ To interact with Azure Synapse, you need to instantiate a `AccessControlClient`.
// Replace the string below with your actual endpoint url.
string endpoint = "<my-endpoint-url>";

AccessControlClient client = new AccessControlClient(new Uri(endpoint), new DefaultAzureCredential());
RoleAssignmentsClient roleAssignmentsClient = new RoleAssignmentsClient(new Uri(endpoint), new DefaultAzureCredential());
RoleDefinitionsClient definitionsClient = new RoleDefinitionsClient(new Uri(endpoint), new DefaultAzureCredential());
```

### Create a role assignment

First, you need to the determine the ID of the role you wish to assign, along with the ID of the principal you wish to assign that role.

```C# Snippet:PrepCreateRoleAssignment
Pageable<SynapseRole> roles = client.GetRoleDefinitions();
SynapseRole role = roles.Single(role => role.Name == "Workspace Admin");
string roleID = role.Id;
Response<IReadOnlyList<SynapseRoleDefinition>> roles = definitionsClient.ListRoleDefinitions();
SynapseRoleDefinition role = roles.Value.Single(role => role.Name == "Workspace Admin");
Guid roleId = role.Id.Value;

string assignedScope = "workspaces/workspacechhamosynapse";

// Replace the string below with the ID you'd like to assign the role.
string principalId = "<my-principal-id>";
Guid principalId = Guid.Parse("<my-principal-id>");

// Replace the string below with the ID of the assignment you'd like to use.
string assignmentId = "<my-assignment-id>";
```

Then create an instance of `RoleAssignmentOptions` with the requested values. Finally call `CreateRoleAssignment` with the options to create the role assignment.

```C# Snippet:CreateRoleAssignment
RoleAssignmentOptions request = new RoleAssignmentOptions(roleID, principalId);
Response<RoleAssignmentDetails> response = client.CreateRoleAssignment(request);
Response<RoleAssignmentDetails> response = roleAssignmentsClient.CreateRoleAssignment (assignmentId, roleId, principalId, assignedScope);
RoleAssignmentDetails roleAssignmentAdded = response.Value;
```

Expand All @@ -102,17 +107,17 @@ RoleAssignmentDetails roleAssignmentAdded = response.Value;
You can retrieve the details of a role assignment by calling `GetRoleAssignmentById`, passing in the assignment ID.

```C# Snippet:RetrieveRoleAssignment
RoleAssignmentDetails roleAssignment = client.GetRoleAssignmentById(roleAssignmentAdded.Id);
Console.WriteLine($"Role {roleAssignment.RoleId} is assigned to {roleAssignment.PrincipalId}.");
RoleAssignmentDetails roleAssignment = roleAssignmentsClient.GetRoleAssignmentById(roleAssignmentAdded.Id);
Console.WriteLine($"Role {roleAssignment.RoleDefinitionId} is assigned to {roleAssignment.PrincipalId}.");
```

### List role assignments

To enumerate all role assignments in the Synapse workspace you can call `GetRoleAssignments`.

```C# Snippet:ListRoleAssignments
Response<IReadOnlyList<RoleAssignmentDetails>> roleAssignments = client.GetRoleAssignments();
foreach (RoleAssignmentDetails assignment in roleAssignments.Value)
Response<IReadOnlyList<SynapseRoleDefinition>> roleAssignments = definitionsClient.ListRoleDefinitions();
foreach (SynapseRoleDefinition assignment in roleAssignments.Value)
{
Console.WriteLine(assignment.Id);
}
Expand All @@ -123,7 +128,7 @@ foreach (RoleAssignmentDetails assignment in roleAssignments.Value)
To delete a role assignment no longer needed you can call `DeleteRoleAssignmentById`, passing in the assignment ID.

```C# Snippet:DeleteRoleAssignment
client.DeleteRoleAssignmentById(roleAssignment.Id);
roleAssignmentsClient.DeleteRoleAssignmentById(roleAssignment.Id);
```

## To build
Expand Down
Original file line number Diff line number Diff line change
@@ -1,60 +1,108 @@
namespace Azure.Analytics.Synapse.AccessControl
{
public partial class AccessControlClient
{
protected AccessControlClient() { }
public AccessControlClient(System.Uri endpoint, Azure.Core.TokenCredential credential) { }
public AccessControlClient(System.Uri endpoint, Azure.Core.TokenCredential credential, Azure.Analytics.Synapse.AccessControl.AccessControlClientOptions options) { }
public virtual Azure.Response<Azure.Analytics.Synapse.AccessControl.Models.RoleAssignmentDetails> CreateRoleAssignment(Azure.Analytics.Synapse.AccessControl.Models.RoleAssignmentOptions createRoleAssignmentOptions, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Analytics.Synapse.AccessControl.Models.RoleAssignmentDetails>> CreateRoleAssignmentAsync(Azure.Analytics.Synapse.AccessControl.Models.RoleAssignmentOptions createRoleAssignmentOptions, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual Azure.Response DeleteRoleAssignmentById(string roleAssignmentId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response> DeleteRoleAssignmentByIdAsync(string roleAssignmentId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual Azure.Response<System.Collections.Generic.IReadOnlyList<string>> GetCallerRoleAssignments(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response<System.Collections.Generic.IReadOnlyList<string>>> GetCallerRoleAssignmentsAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public partial class RoleAssignmentsClient
{
protected RoleAssignmentsClient() { }
public RoleAssignmentsClient(System.Uri endpoint, Azure.Core.TokenCredential credential) { }
public RoleAssignmentsClient(System.Uri endpoint, Azure.Core.TokenCredential credential, Azure.Analytics.Synapse.AccessControl.RoleAssignmentsClientOptions options) { }
public virtual Azure.Response<Azure.Analytics.Synapse.AccessControl.Models.CheckPrincipalAccessResponse> CheckPrincipalAccess(Azure.Analytics.Synapse.AccessControl.Models.SubjectInfo subject, System.Collections.Generic.IEnumerable<Azure.Analytics.Synapse.AccessControl.Models.RequiredAction> actions, string scope, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Analytics.Synapse.AccessControl.Models.CheckPrincipalAccessResponse>> CheckPrincipalAccessAsync(Azure.Analytics.Synapse.AccessControl.Models.SubjectInfo subject, System.Collections.Generic.IEnumerable<Azure.Analytics.Synapse.AccessControl.Models.RequiredAction> actions, string scope, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual Azure.Response<Azure.Analytics.Synapse.AccessControl.Models.RoleAssignmentDetails> CreateRoleAssignment(string roleAssignmentId, System.Guid roleId, System.Guid principalId, string scope, string principalType = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Analytics.Synapse.AccessControl.Models.RoleAssignmentDetails>> CreateRoleAssignmentAsync(string roleAssignmentId, System.Guid roleId, System.Guid principalId, string scope, string principalType = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual Azure.Response DeleteRoleAssignmentById(string roleAssignmentId, string scope = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response> DeleteRoleAssignmentByIdAsync(string roleAssignmentId, string scope = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual Azure.Response<Azure.Analytics.Synapse.AccessControl.Models.RoleAssignmentDetails> GetRoleAssignmentById(string roleAssignmentId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Analytics.Synapse.AccessControl.Models.RoleAssignmentDetails>> GetRoleAssignmentByIdAsync(string roleAssignmentId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual Azure.Response<System.Collections.Generic.IReadOnlyList<Azure.Analytics.Synapse.AccessControl.Models.RoleAssignmentDetails>> GetRoleAssignments(string roleId = null, string principalId = null, string continuationToken = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response<System.Collections.Generic.IReadOnlyList<Azure.Analytics.Synapse.AccessControl.Models.RoleAssignmentDetails>>> GetRoleAssignmentsAsync(string roleId = null, string principalId = null, string continuationToken = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual Azure.Response<Azure.Analytics.Synapse.AccessControl.Models.SynapseRole> GetRoleDefinitionById(string roleId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Analytics.Synapse.AccessControl.Models.SynapseRole>> GetRoleDefinitionByIdAsync(string roleId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual Azure.Pageable<Azure.Analytics.Synapse.AccessControl.Models.SynapseRole> GetRoleDefinitions(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual Azure.AsyncPageable<Azure.Analytics.Synapse.AccessControl.Models.SynapseRole> GetRoleDefinitionsAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual Azure.Response<Azure.Analytics.Synapse.AccessControl.Models.RoleAssignmentDetailsList> ListRoleAssignments(string roleId = null, string principalId = null, string scope = null, string continuationToken = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Analytics.Synapse.AccessControl.Models.RoleAssignmentDetailsList>> ListRoleAssignmentsAsync(string roleId = null, string principalId = null, string scope = null, string continuationToken = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
}
public partial class AccessControlClientOptions : Azure.Core.ClientOptions
public partial class RoleAssignmentsClientOptions : Azure.Core.ClientOptions
{
public AccessControlClientOptions(Azure.Analytics.Synapse.AccessControl.AccessControlClientOptions.ServiceVersion serviceVersion = Azure.Analytics.Synapse.AccessControl.AccessControlClientOptions.ServiceVersion.V2020_02_01_preview) { }
public RoleAssignmentsClientOptions(Azure.Analytics.Synapse.AccessControl.RoleAssignmentsClientOptions.ServiceVersion serviceVersion = Azure.Analytics.Synapse.AccessControl.RoleAssignmentsClientOptions.ServiceVersion.V2020_08_01_preview) { }
public enum ServiceVersion
{
V2020_02_01_preview = 1,
V2020_08_01_preview = 1,
}
}
public partial class RoleDefinitionsClient
{
protected RoleDefinitionsClient() { }
public RoleDefinitionsClient(System.Uri endpoint, Azure.Core.TokenCredential credential) { }
public RoleDefinitionsClient(System.Uri endpoint, Azure.Core.TokenCredential credential, Azure.Analytics.Synapse.AccessControl.RoleDefinitionsClientOptions options) { }
public virtual Azure.Response<Azure.Analytics.Synapse.AccessControl.Models.SynapseRoleDefinition> GetRoleDefinitionById(string roleDefinitionId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Analytics.Synapse.AccessControl.Models.SynapseRoleDefinition>> GetRoleDefinitionByIdAsync(string roleDefinitionId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual Azure.Response<System.Collections.Generic.IReadOnlyList<Azure.Analytics.Synapse.AccessControl.Models.SynapseRoleDefinition>> ListRoleDefinitions(bool? isBuiltIn = default(bool?), string scope = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response<System.Collections.Generic.IReadOnlyList<Azure.Analytics.Synapse.AccessControl.Models.SynapseRoleDefinition>>> ListRoleDefinitionsAsync(bool? isBuiltIn = default(bool?), string scope = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual Azure.Response<System.Collections.Generic.IReadOnlyList<string>> ListScopes(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response<System.Collections.Generic.IReadOnlyList<string>>> ListScopesAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
}
public partial class RoleDefinitionsClientOptions : Azure.Core.ClientOptions
{
public RoleDefinitionsClientOptions(Azure.Analytics.Synapse.AccessControl.RoleDefinitionsClientOptions.ServiceVersion serviceVersion = Azure.Analytics.Synapse.AccessControl.RoleDefinitionsClientOptions.ServiceVersion.V2020_08_01_preview) { }
public enum ServiceVersion
{
V2020_08_01_preview = 1,
}
}
}
namespace Azure.Analytics.Synapse.AccessControl.Models
{
public partial class CheckAccessDecision
{
internal CheckAccessDecision() { }
public string AccessDecision { get { throw null; } }
public string ActionId { get { throw null; } }
public Azure.Analytics.Synapse.AccessControl.Models.RoleAssignmentDetails RoleAssignment { get { throw null; } }
}
public partial class CheckPrincipalAccessResponse
{
internal CheckPrincipalAccessResponse() { }
public System.Collections.Generic.IReadOnlyList<Azure.Analytics.Synapse.AccessControl.Models.CheckAccessDecision> AccessDecisions { get { throw null; } }
}
public partial class RequiredAction
{
public RequiredAction(string id, bool isDataAction) { }
public string Id { get { throw null; } }
public bool IsDataAction { get { throw null; } }
}
public partial class RoleAssignmentDetails
{
internal RoleAssignmentDetails() { }
public string Id { get { throw null; } }
public string PrincipalId { get { throw null; } }
public string RoleId { get { throw null; } }
public System.Guid? PrincipalId { get { throw null; } }
public string PrincipalType { get { throw null; } }
public System.Guid? RoleDefinitionId { get { throw null; } }
public string Scope { get { throw null; } }
}
public partial class RoleAssignmentOptions
public partial class RoleAssignmentDetailsList
{
public RoleAssignmentOptions(string roleId, string principalId) { }
public string PrincipalId { get { throw null; } }
public string RoleId { get { throw null; } }
internal RoleAssignmentDetailsList() { }
public int? Count { get { throw null; } }
public System.Collections.Generic.IReadOnlyList<Azure.Analytics.Synapse.AccessControl.Models.RoleAssignmentDetails> Value { get { throw null; } }
}
public partial class RolesListResponse
public partial class SubjectInfo
{
internal RolesListResponse() { }
public string NextLink { get { throw null; } }
public System.Collections.Generic.IReadOnlyList<Azure.Analytics.Synapse.AccessControl.Models.SynapseRole> Value { get { throw null; } }
public SubjectInfo(System.Guid principalId) { }
public System.Collections.Generic.IList<System.Guid> GroupIds { get { throw null; } }
public System.Guid PrincipalId { get { throw null; } }
}
public partial class SynapseRole
public partial class SynapseRbacPermission
{
internal SynapseRole() { }
public string Id { get { throw null; } }
public bool IsBuiltIn { get { throw null; } }
internal SynapseRbacPermission() { }
public System.Collections.Generic.IReadOnlyList<string> Actions { get { throw null; } }
public System.Collections.Generic.IReadOnlyList<string> DataActions { get { throw null; } }
public System.Collections.Generic.IReadOnlyList<string> NotActions { get { throw null; } }
public System.Collections.Generic.IReadOnlyList<string> NotDataActions { get { throw null; } }
}
public partial class SynapseRoleDefinition
{
internal SynapseRoleDefinition() { }
public string AvailabilityStatus { get { throw null; } }
public string Description { get { throw null; } }
public System.Guid? Id { get { throw null; } }
public bool? IsBuiltIn { get { throw null; } }
public string Name { get { throw null; } }
public System.Collections.Generic.IReadOnlyList<Azure.Analytics.Synapse.AccessControl.Models.SynapseRbacPermission> Permissions { get { throw null; } }
public System.Collections.Generic.IReadOnlyList<string> Scopes { get { throw null; } }
}
}
Loading