Example #1
0
 private object ResolveTests(ApiCall apiCall)
 {
     return(Resolve <TestOccurrenceDto, TestOccurrenceListDto>(apiCall, TestOccurrences));
 }
Example #2
0
 private object ResolveProblems(ApiCall apiCall)
 {
     return(Resolve <BuildProblemOccurrenceDto, BuildProblemOccurrenceListDto>(apiCall, ProblemOccurrences));
 }
Example #3
0
        private object ResolveBuildTypes(ApiCall apiCall)
        {
            var id = apiCall.GetLocatorOrDefault();

            if (apiCall.Method == HttpMethod.Post)
            {
                // [Headers("Accept: application/json", "Content-Type: application/xml")]
                // [Post("/app/rest/buildTypes")]
                // Task<BuildTypeDto> CreateBuildType([Body] string buildTypeXml);
                return(BuildTypes.Create(apiCall.Content));
            }
            else if (apiCall.Method == HttpMethod.Get)
            {
                if (!apiCall.HasLocatorSegment)
                {
                    // [Headers("Accept: application/json")]
                    // [Get("/app/rest/buildTypes")]
                    // Task<BuildTypeListDto> BuildTypes();
                    return(BuildTypes.All());
                }
                if (String.IsNullOrEmpty(apiCall.PropertySegment))
                {
                    // [Headers("Accept: application/json")]
                    // [Get("/app/rest/buildTypes/{id}")]
                    // Task<BuildTypeDto> BuildType([AliasAs("id")] string buildTypeId);
                    return(BuildTypes.ById(id));
                }
                else if (apiCall.PropertySegment == "buildTags")
                {
                    // [Headers("Accept: application/json")]
                    // [Get("/app/rest/buildTypes/{id}/buildTags")]
                    // Task<TagsDto> BuildTypeTags([AliasAs("id")] string buildTypeId);
                    return(BuildTypes.Tags(Builds, id));
                }
                else if (apiCall.PropertySegment == "triggers")
                {
                    // [Headers("Accept: application/json")]
                    // [Get("/app/rest/buildTypes/{id}/triggers")]
                    // Task<TriggersDto> BuildTypeTriggers([AliasAs("id")] string buildTypeId);
                    return(BuildTypes.Triggers(id));
                }
                else if (apiCall.PropertySegment == "artifact-dependencies")
                {
                    // [Headers("Accept: application/json")]
                    // [Get("/app/rest/buildTypes/{id}/artifact-dependencies")]
                    // Task<ArtifactDependenciesDto> BuildTypeArtifactDependencies([AliasAs("id")] string buildTypeId);
                    return(BuildTypes.ArtifactDependencies(id));
                }
            }
            else if (apiCall.Method == HttpMethod.Put)
            {
                if (apiCall.PropertySegment == "parameters")
                {
                    // [Put("/app/rest/buildTypes/{id}/parameters/{name}")]
                    // Task SetBuildTypeParameter([AliasAs("id")] string buildTypeId, string name, [Body] string value);
                    BuildTypes.SetParameters(id, apiCall.DescriptorSegment, apiCall.Content);
                    return(id);
                }
                else if (apiCall.PropertySegment == "settings")
                {
                    // [Put("/app/rest/buildTypes/{id}/settings/{name}")]
                    // Task SetBuildTypeSettings([AliasAs("id")] string buildTypeId, string name, [Body] string value);
                    BuildTypes.SetSetting(id, apiCall.DescriptorSegment, apiCall.Content);
                    return(id);
                }
            }
            else if (apiCall.Method == HttpMethod.Delete)
            {
                BuildTypes.Delete(id);
                return(id);
            }

            throw new NotImplementedException($"End-point {apiCall.Method} : {apiCall.RequestPath} not implemented.");
        }
Example #4
0
 private object ResolveInvestigations(ApiCall apiCall)
 {
     return(Resolve <InvestigationDto, InvestigationListDto>(apiCall, Investigations));
 }
Example #5
0
        private object ResolveBuilds(ApiCall apiCall)
        {
            var id = apiCall.GetLocatorOrDefault();

            if (apiCall.Method == HttpMethod.Post)
            {
                if (String.IsNullOrEmpty(apiCall.PropertySegment))
                {
                    // [Headers("Accept: application/json")]
                    // [Post("/app/rest/builds/{id}")]
                    // Task CancelBuild([AliasAs("id")] string buildId, [Body] BuildCancelRequestDto value);
                    Builds.CancelBuild(id);
                    return(id);
                }
                else
                {
                    // [Headers("Accept: application/json")]
                    // [Post("/app/rest/builds/{id}/tags/")]
                    // Task AddTag([AliasAs("id")] string buildId, [Body] string tag);
                    Builds.AddTag(id, apiCall.Content);
                    return(id);
                }
            }
            else if (apiCall.Method == HttpMethod.Get)
            {
                if (!apiCall.HasLocatorSegment)
                {
                    // [Headers("Accept: application/json")]
                    // [Get("/app/rest/builds")]
                    // Task<BuildListDto> Builds([AliasAs("locator")] string buildLocator);
                    return(Builds.All());
                }

                if (String.IsNullOrEmpty(apiCall.PropertySegment))
                {
                    // [Headers("Accept: application/json")]
                    // [Get("/app/rest/builds/{id}")]
                    // Task<BuildDto> Build(string id);
                    return(Builds.ById(apiCall.GetLocator()));
                }
                else if (apiCall.PropertySegment == "resulting-properties")
                {
                    // [Headers("Accept: application/json")]
                    // [Get("/app/rest/builds/{id}/resulting-properties")]
                    // Task<ParametersDto> ResultingProperties([AliasAs("id")] string buildId);
                    return(Builds.ResultingProperties(id));
                }
                else if (apiCall.PropertySegment == "artifacts" && apiCall.DescriptorSegment == "children")
                {
                    // [Headers("Accept: application/json")]
                    // [Get("/app/rest/builds/{id}/artifacts/children/{**path}")]
                    // Task<ArtifactFileListDto> ArtifactChildren([AliasAs("id")] string buildId, [AliasAs("path")] string artifactPath, string locator, string fields);
                    return(Builds.Artifacts(id));
                }
                else if (apiCall.PropertySegment == "artifacts" && apiCall.DescriptorSegment == "content")
                {
                    // [Get("/app/rest/builds/{id}/artifacts/content/{**path}")]
                    // Task<Stream> ArtifactContent( [AliasAs("id")] string buildId, [AliasAs("path")] string artifactPath);
                    return(Builds.Content(id));
                }
            }
            else if (apiCall.Method == HttpMethod.Put)
            {
                if (apiCall.PropertySegment == "comment")
                {
                    // [Put("/app/rest/builds/{id}/comment/")]
                    // Task SetComment([AliasAs("id")] string buildId, [Body] string comment);
                    Builds.SetComment(id, apiCall.Content);
                    return(id);
                }
                else if (apiCall.PropertySegment == "tags")
                {
                    // [Put("/app/rest/builds/{id}/tags/")]
                    // Task ReplaceTags([AliasAs("id")] string buildId, [Body] TagsDto tags);
                    Builds.ReplaceTags(id, apiCall.JsonContentAs <TagsDto>());
                    return(id);
                }
                else if (apiCall.PropertySegment == "pin")
                {
                    // [Put("/app/rest/builds/{id}/pin/")]
                    // Task Pin([AliasAs("id")] string buildId, [Body] string comment);
                    Builds.Pin(id, apiCall.Content);
                    return(id);
                }
            }
            else if (apiCall.Method == HttpMethod.Delete)
            {
                // //The standard DELETE annotation doesn't allow to include a body, so we need to use our own.
                // //Probably it would be better to change Rest API here (https://youtrack.jetbrains.com/issue/TW-49178).
                // // @DELETE_WITH_BODY("/app/rest/builds/{id}/pin/")
                // [Delete("/app/rest/builds/{id}/pin/")]
                // Task Unpin([AliasAs("id")] string buildId, [Body] string comment);
                Builds.Unpin(id);
                return(id);
            }

            throw new NotImplementedException($"End-point {apiCall.Method} : {apiCall.RequestPath} not implemented.");
        }