using System;
using System.Collections.Generic;
using Google.Apis.Auth.OAuth2;
using Google.Apis.Iam.v1;
using Google.Apis.Iam.v1.Data;
public partial class CustomRoles
{
public static Role CreateRole(string name, string projectId, string title,
string description, IList<string> permissions, string stage)
{
var credential = GoogleCredential.GetApplicationDefault()
.CreateScoped(IamService.Scope.CloudPlatform);
var service = new IamService(new IamService.Initializer
{
HttpClientInitializer = credential
});
var role = new Role
{
Title = title,
Description = description,
IncludedPermissions = permissions,
Stage = stage
};
var request = new CreateRoleRequest
{
Role = role,
RoleId = name
};
role = service.Projects.Roles.Create(request,
"projects/" + projectId).Execute();
Console.WriteLine("Created role: " + role.Name);
return role;
}
}