예제 #1
0
        public ValidationFailure TestConnection(ReadarrIndexer indexer, ReadarrSettings settings)
        {
            var request = BuildRequest(settings, $"/api/v1/indexer/test", HttpMethod.Post);

            request.SetContent(indexer.ToJson());

            try
            {
                Execute <ReadarrIndexer>(request);
            }
            catch (HttpException ex)
            {
                if (ex.Response.StatusCode == HttpStatusCode.Unauthorized)
                {
                    _logger.Error(ex, "API Key is invalid");
                    return(new ValidationFailure("ApiKey", "API Key is invalid"));
                }

                if (ex.Response.StatusCode == HttpStatusCode.BadRequest)
                {
                    _logger.Error(ex, "Prowlarr URL is invalid");
                    return(new ValidationFailure("ProwlarrUrl", "Prowlarr url is invalid, Readarr cannot connect to Prowlarr"));
                }

                _logger.Error(ex, "Unable to send test message");
                return(new ValidationFailure("BaseUrl", "Unable to complete application test"));
            }
            catch (Exception ex)
            {
                _logger.Error(ex, "Unable to send test message");
                return(new ValidationFailure("", "Unable to send test message"));
            }

            return(null);
        }
예제 #2
0
        public ReadarrIndexer UpdateIndexer(ReadarrIndexer indexer, ReadarrSettings settings)
        {
            var request = BuildRequest(settings, $"/api/v1/indexer/{indexer.Id}", HttpMethod.Put);

            request.SetContent(indexer.ToJson());

            return(Execute <ReadarrIndexer>(request));
        }
예제 #3
0
        public ReadarrIndexer AddIndexer(ReadarrIndexer indexer, ReadarrSettings settings)
        {
            var request = BuildRequest(settings, "/api/v1/indexer", HttpMethod.Post);

            request.SetContent(indexer.ToJson());

            return(Execute <ReadarrIndexer>(request));
        }