예제 #1
0
 public EnableModel(
     TeamDirectoryClient teamDirectoryClient,
     SettingsStorage settingsStorage,
     ILogger <EnableModel> logger)
 {
     _teamDirectoryClient = teamDirectoryClient;
     _settingsStorage     = settingsStorage;
     _logger = logger;
 }
 public IndexModel(
     ILogger <IndexModel> logger,
     ProjectClient projectClient,
     ToDoItemClient todoClient,
     TeamDirectoryClient teamDirectoryClient,
     CalendarClient calendarClient)
 {
     _logger              = logger;
     _projectClient       = projectClient;
     _todoClient          = todoClient;
     _teamDirectoryClient = teamDirectoryClient;
     _calendarClient      = calendarClient;
 }
예제 #3
0
 public IndexModel(
     TeamDirectoryClient teamDirectoryClient,
     AbsenceClient absenceClient,
     CalendarClient calendarClient,
     ChatClient chatClient,
     SettingsStorage settingsStorage,
     IConfiguration configuration,
     ILogger <IndexModel> logger)
 {
     _teamDirectoryClient = teamDirectoryClient;
     _absenceClient       = absenceClient;
     _calendarClient      = calendarClient;
     _chatClient          = chatClient;
     _settingsStorage     = settingsStorage;
     _meetingUrlTemplate  = configuration["Space:ServerUrl"].TrimEnd('/') + "/meetings/{0}";
     _logger = logger;
 }
예제 #4
0
        public async Task UnusedTestAsync()
        {
            var connection = new ClientCredentialsConnection(
                new Uri("TODO"),
                "TODO",
                "TODO",
                new HttpClient());

            var teamDirectoryClient = new TeamDirectoryClient(connection);

            // ReSharper disable once UnusedVariable
            var memberProfile = await teamDirectoryClient.Profiles
                                .GetProfileAsync(ProfileIdentifier.Username("Heather.Stewart"), partial => partial
                                                 .WithAllFieldsWildcard() // Include all first-level fields
                                                 .WithManagers(manager => manager
                                                               .WithId()
                                                               .WithUsername()
                                                               .WithName(name => name
                                                                         .WithFirstName()
                                                                         .WithLastName())));
        }
예제 #5
0
        // ReSharper disable once UnusedParameter.Local
        static async Task Main(string[] args)
        {
            // Create a connection using a service account.
            // NOTE: Service accounts do not have access to all operations in Space!
            var connection = new ClientCredentialsConnection(
                new Uri(Environment.GetEnvironmentVariable("JB_SPACE_API_URL") !),
                Environment.GetEnvironmentVariable("JB_SPACE_CLIENT_ID") !,
                Environment.GetEnvironmentVariable("JB_SPACE_CLIENT_SECRET") !,
                new HttpClient());

            var teamDirectoryClient = new TeamDirectoryClient(connection);

            // User to add to chat later on
            var chatChannelName = "SpaceDotNet";

            // Get all profiles with their names
            await foreach (var profile in teamDirectoryClient.Profiles.GetAllProfilesAsyncEnumerable("", false, false, partial: _ => _
                                                                                                     .WithId()
                                                                                                     .WithName()))
            {
                Console.WriteLine($"{profile.Name.FirstName} {profile.Name.LastName}");
            }

            // Get profiles with their Id. Accessing another property (such as name) will throw.
            var firstProfile = await teamDirectoryClient.Profiles.GetAllProfilesAsyncEnumerable("", false, false, partial : _ => _
                                                                                                .WithId()).FirstAsync();

            try
            {
                // This will fail...
                Console.WriteLine($"{firstProfile.Name.FirstName} {firstProfile.Name.LastName}");
            }
            catch (PropertyNotRequestedException e)
            {
                Console.WriteLine($"The Space API client tells us which partial query should be added to access {e.PropertyName}:");
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(e.Message);
                Console.ResetColor();
            }

            // Send chat message?
            var chatClient        = new ChatClient(connection);
            var chatChannelExists = !await chatClient.Channels.IsNameFreeAsync(chatChannelName);

            if (!chatChannelExists)
            {
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine($"Skipped sending chat message example. Create a channel named \"{chatChannelName}\" in your Space organization and try again.");
                Console.ResetColor();
            }
            else
            {
                await chatClient.Messages.SendMessageAsync(
                    recipient : MessageRecipient.Channel(ChatChannel.FromName(chatChannelName)),
                    content : ChatMessage.Block(
                        outline: new MessageOutline("Have you tried JetBrains Space?"),
                        messageData: "Have you tried JetBrains Space? See https://www.jetbrains.com/space/ for more information.",
                        sections: new List <MessageSectionElement>
                {
                    new MessageSection
                    {
                        Header   = "JetBrains Space",
                        Elements = new List <MessageElement>
                        {
                            MessageElement.MessageText("JetBrains Space is an Integrated Team Environment.",
                                                       MessageAccessoryElement.MessageIcon(new ApiIcon("space"), MessageStyle.SUCCESS)),
                            MessageElement.MessageText("Have you tried JetBrains Space?"),
                            MessageElement.MessageDivider(),
                            MessageElement.MessageText("Get access at https://www.jetbrains.com/space/")
                        },
                        Footer = "Check it out at https://www.jetbrains.com/space/"
                    }
                },
                        style: MessageStyle.SUCCESS),
                    unfurlLinks : false);

                Console.WriteLine($"A chat message has been sent to the channel named \"{chatChannelName}\" in your Space organization.");
            }
        }