Beispiel #1
0
        /// <summary>
        /// Creates a JIRA client configured to use the REST API.
        /// </summary>
        /// <param name="url">Url to the JIRA server.</param>
        /// <param name="username">Username used to authenticate.</param>
        /// <param name="password">Password used to authenticate.</param>
        /// <param name="settings">Settings to configure the rest client.</param>
        /// <returns>Jira object configured to use REST API.</returns>
        public static Jira CreateRestClient(string url, string username = null, string password = null, JiraRestClientSettings settings = null)
        {
            Jira jira    = null;
            var  options = new JiraRestClient.Options()
            {
                Url                = url,
                Username           = username,
                Password           = password,
                RestClientSettings = settings ?? new JiraRestClientSettings(),
                GetCurrentJiraFunc = () => jira
            };

            var restClient = new JiraRestClient(options);

            jira = CreateRestClient(restClient, new JiraCredentials(username, password), options.RestClientSettings.Cache);

            return(jira);
        }
Beispiel #2
0
        /// <summary>
        /// Create a client that connects with a JIRA server with specified dependencies.
        /// </summary>
        public Jira(IJqlExpressionVisitor translator,
                    IJiraSoapClient jiraService,
                    IFileSystem fileSystem,
                    JiraCredentials credentials = null,
                    string accessToken          = null,
                    JiraCache cache             = null)
        {
            _provider    = new JiraQueryProvider(translator, this);
            _jiraService = jiraService;
            _fileSystem  = fileSystem;
            _token       = accessToken;
            _credentials = credentials;
            _restClient  = jiraService as IJiraRestClient;
            _cache       = cache ?? new JiraCache();

            this.MaxIssuesPerRequest = DEFAULT_MAX_ISSUES_PER_REQUEST;
            this.Debug = false;

            if (_restClient == null && !String.IsNullOrEmpty(jiraService.Url))
            {
                var options = new JiraRestClient.Options()
                {
                    Url = jiraService.Url,
                    RestClientSettings = new JiraRestClientSettings(),
                    GetCurrentJiraFunc = () => this
                };

                if (this._credentials != null)
                {
                    options.Username = _credentials.UserName;
                    options.Password = _credentials.Password;
                }

                this._restClient = new JiraRestClient(options);
            }
        }