示例#1
0
        /// <summary>
        /// Gets an archive of the users openvpn configs
        /// </summary>
        /// <param name="organization">the organization to fetch configs from</param>
        /// <param name="name">the name of the user to fetch configs from</param>
        /// <param name="type">the archive type the config should be in</param>
        /// <returns>A byte array of the config data</returns>
        /// <exception cref="PritunlException"></exception>
        /// <remarks>Throws a <see cref="PritunlException"/> if it could't find the organization or the user</remarks>
        public static async Task <byte[]> GetKeys(string organization, string name, KeyType type)
        {
            var org = await Organizations.GetOrganization(organization);

            var user = await GetUserAsync(organization, name);

            var key = await PritunlRequest.GetAsync <Key>($"key/{org.Id}/{user.Id}");

            switch (type)
            {
            case KeyType.Tar:
                return(await PritunlRequest.GetAsync <byte[]>(key.KeyUrl));

            case KeyType.Zip:
                return(await PritunlRequest.GetAsync <byte[]>(key.KeyZipUrl));

            case KeyType.Onc:
                return(await PritunlRequest.GetAsync <byte[]>(key.KeyOncUrl));

            default:
                return(null);
            }
        }
 /// <summary>
 /// Gets a list of the organizations on the pritunl server
 /// </summary>
 /// <returns>List of Organizations</returns>
 public static async Task <List <Organization> > GetOrganizations()
 {
     return(await PritunlRequest.GetAsync <List <Organization> >("organization"));
 }
示例#3
0
        /// <summary>
        /// Gets a list of users from the organization
        /// </summary>
        /// <param name="organization">The organization to fetch users from</param>
        /// <returns>List of users in the org</returns>
        /// <exception cref="PritunlException"></exception>
        /// <remarks>Throws a <see cref="PritunlException"/> if it could't find the organization</remarks>
        public static async Task <List <User> > GetUsersAsync(string organization)
        {
            var org = await Organizations.GetOrganization(organization);

            return(await PritunlRequest.GetAsync <List <User> >($"user/{org.Id}"));
        }/// <summary>
示例#4
0
 /// <summary>
 /// Gets the servers on the pritunl server
 /// </summary>
 /// <returns>The list of servers</returns>
 public static async Task <List <Server> > GetServersAsync()
 {
     return(await PritunlRequest.GetAsync <List <Server> >("server"));
 }