예제 #1
0
 /// <summary>
 /// Creates a new entry point using an OAuth token.
 /// </summary>
 /// <param name="uri">The base URI of the REST interface. Missing trailing slash will be appended automatically.</param>
 /// <param name="token">The OAuth token to present as a "Bearer" to the REST interface.</param>
 /// <param name="serializer">Controls the serialization of entities sent to and received from the server. Defaults to a JSON serializer if unset.</param>
 public EntryEndpoint(Uri uri, string token, MediaTypeFormatter serializer = null) : base(
     uri: uri.EnsureTrailingSlash(),
     httpClient: BuildHttpClient(uri),
     serializer: serializer ?? BuildSerializer())
 {
     HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
 }
예제 #2
0
 public void AddInstance(string displayName, Uri serverUrl, bool requiresAuthentication)
 {
     this.Instances.Add(new JenkinsInstance
     {
         DisplayName = displayName,
         Url = serverUrl.EnsureTrailingSlash().ToString(),
         RequiresAuthentication = requiresAuthentication,
         FavoriteJobs = new System.Collections.Generic.List<string>()
     });
 }
예제 #3
0
        public Uri GetUriForImage(string imageResourceName)
        {
            var uri = new Uri(_baseImageUri, new Uri(imageResourceName, UriKind.Relative));

            // we put a trailing slash here because the image resource names will contain at least one . about which the
            // mvc routing engine and IIS get confused.
            var uriWithTrailingSlash = uri.EnsureTrailingSlash();

            return uriWithTrailingSlash;
        }
        internal ConnectionInformation(Uri serverUri, string userName, SecureString password)
        {
            if (serverUri == null)
            {
                throw new ArgumentNullException(nameof(serverUri));
            }

            this.ServerUri = serverUri.EnsureTrailingSlash();
            this.UserName = userName;
            this.Password = password?.CopyAsReadOnly();
            this.Authentication = AuthenticationType.Basic; // Only one supported at this point
        }
예제 #5
0
 /// <summary>
 /// Creates a new entry point.
 /// </summary>
 /// <param name="uri">The base URI of the REST interface. Missing trailing slash will be appended automatically.</param>
 /// <param name="credentials">Optional HTTP Basic Auth credentials used to authenticate against the REST interface.</param>
 /// <param name="serializer">Controls the serialization of entities sent to and received from the server. Defaults to a JSON serializer if unset.</param>
 public EntryEndpoint(Uri uri, ICredentials credentials = null, MediaTypeFormatter serializer = null) : base(
     uri: uri.EnsureTrailingSlash(),
     httpClient: BuildHttpClient(uri, credentials),
     serializer: serializer ?? BuildSerializer())
 {
 }
예제 #6
0
 public PathFactory(Uri basePostUri, Uri baseImageUri)
 {
     _basePostUri = basePostUri.EnsureTrailingSlash();
     _baseImageUri = baseImageUri.EnsureTrailingSlash();
 }
예제 #7
0
        public async Task<IEnumerable<RawLogFileInfo>> GetRawLogFiles(Uri uri)
        {
            if (uri == null)
            {
                throw new ArgumentNullException("uri");
            }

            var uriString = uri.ToString();
            try
            {
                _jobEventSource.BeginningDirectoryListing(uriString);
                Trace.TraceInformation("Listing directory '{0}'.", uri);

                var request = CreateRequest(uri);
                request.Method = WebRequestMethods.Ftp.ListDirectory;
                var webResponse = (FtpWebResponse)await request.GetResponseAsync();

                string directoryList;
                using (var streamReader = new StreamReader(webResponse.GetResponseStream(), Encoding.ASCII))
                {
                    directoryList = await streamReader.ReadToEndAsync();
                }

                _jobEventSource.FinishingDirectoryListing(uriString);

                var fileNames = directoryList.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                var rawLogFiles = fileNames.Select(fn => new RawLogFileInfo(new Uri(uri.EnsureTrailingSlash(), fn)));

                return rawLogFiles;
            }
            catch (Exception e)
            {
                _jobEventSource.FailedToGetRawLogFiles(uriString, e.ToString());
                Trace.TraceError("Failed to get raw log files: {0}", e);
                return Enumerable.Empty<RawLogFileInfo>();
            }
        }
        private void Construct(string id, Uri urlBase, bool useMime = false, IDictionary<string, string> nameValues = null) {
            ParameterCheck.ParameterRequired(id, "id");
            ParameterCheck.ParameterRequired(urlBase, "uriBase");

            this.id = id;
            this.urlBase = urlBase.EnsureTrailingSlash();
            this.useMime = useMime;
            this.nameValues = new ReadOnlyDictionary<string, string>(nameValues ?? new Dictionary<string, string>());

            this.folderInfo = new List<FileTransmitterFolderInfo>();

            this.localPath = urlBase.EnsureTrailingSlash().GetLocalPath();
        }