ticket-system.md 5.24 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# GitHub-Ticketsystem

This documents GitHub specific things for the integration to this library.
For the global parts, see in the [core sections Ticketsystem site][core-ts].

## create new instance

A `GithubTicketSystem` object is always referencing a specific GitHub project.
Mandatory information to instantiate it, are the GitHub instances base url, the project owner and project.

For public accessible actions, it can be used anonymously.
Other operations have to be authenticated using an username and a personal access token.

For all calls the `accept` header will be set to `application/vnd.github.v3+json`.
If not configured otherwise, connections will use `https`.

### by URI

```java
// recommended option
GithubTicketSystem ts = (GithubTicketSystem) TicketSystem.fromUri("<uri>");

// second possible declaration
TicketSystem<
    GithubTicket,
    GithubTicketSystem,
    GithubTicketBuilder,
    GithubFilter
    > gl = TicketSystem.fromUri("<uri>");
```

The first declaration option uses the child-class from the GitHub implementation directly.
The second option uses the parent-class instead,
defining the different implementations with Generics.

Use the first option, if you're sure you want to use GitHub no matter what.
This way you can see GitHub specific methods,
whereas the second option keeps you limited on the global defined ones.
If you may switch ticket systems in the future,
the second option forces you to not use system specific stuff, making a transition easier.

The URI to pass has to match this format:
```
unifiedticketing:github:[http://|https://]<base url>::<owner>:<repo>[:<username>:<apikey>]
```

- protocol for http/https is optional. If not given, https is used
- base url can contain also non-standard port hosted github instances
- username and api key if authentication needed, otherwise anonymous access is used

??? example "URI examples"
    - non-https anonymous, owner me, project hello-world, public gitlab  
        `unifiedticketing:github:http://api.github.com::me:hello-world`
    - implicit https authenticated, owner me, project hello-world, public gitlab  
        `unifiedticketing:github:api.github.com::me:hello-world:me:1234896102765abcddbda324bb3a3`
    - explicit https authenticated, owner me, project hello-world, fictional github, non-standard port  
        `unifiedticketing:github:https://api.github.example.org:8080::me:hello-world:me:1234896102765abcddbda324bb3a3`

### by builder

For instantiation from the builder,
mostly the same like building by URI applies.

!!! warning
    Passing the base url ensure the protocol (http or https) is removed

??? example "builder examples"
    - non-https anonymous, owner me, repo hello-world, public github  
        ```java
        GithubTicketSystem ts = TicketSystem.fromBuilder()
            .github()
            .withBaseUrl("api.github.com")
            .withHttp()
            .withOwner("me")
            .withRepo("hello-world")
            .build();
        ```
    - implicit https authenticated, owner me, repo hello-world, public github  
        ```java
        GithubTicketSystem ts = TicketSystem.fromBuilder()
            .github()
            .withBaseUrl("api.github.com")
            .withOwner("me")
            .withRepo("hello-world")
            .withAuthentication("me", "1234896102765abcddbda324bb3a3")
            .build();
        ```
    - explicit https authenticated, owner me, repo hello-world, fictional github, non-standard port  
        ```java
        GithubTicketSystem ts = TicketSystem.fromBuilder()
            .github()
            .withBaseUrl("api.github.example.org:8080")
            .withHttps()
            .withOwner("me")
            .withRepo("hello-world")
            .withAuthentication("me", "1234896102765abcddbda324bb3a3")
            .build();
        ```

## list tickets

!!! warning "default pagination"
    GitHub has a default pagination on _30_ elements per page.
    Highest possible value is _100_ elements. [[Link]][api-docs-pagination]

!!! info "assignees"
    GitHub implementation supports the fields `id` and `username`.
    If ticket has no assignees, assignee field stays `null`.

From the filters shown on the global `TicketSystem` docs,
the ones for title, description filter and ticket id's are not natively supported by the GitHub API.
If such a filter is used,
this get's done locally after receiving the response from GitHub,
before handing it to the user.

## get single ticket

As the GitHub API doesn't support a ticket-id filter on the list endpoint,
the method for getting a single ticket by it's id uses the single ticket endpoint.

If you use the Filter class with a single ticket id as only filter,
you end up fetching all tickets of that repo, filtering out all non matching ones locally.

## create new ticket

For a new GitHub ticket a title is mandatory.
Everything else is optional.

!!! example "minimal example"
    ```java
    GithubTicket = ts.createTicket()
        .title("my new ticket")
        .create();
    ```

Setting an assignee, has to be by user login name.

[core-ts]: ../../core/ticket-system.md
[api-docs-issues-list]: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues#list-repository-issues
[api-docs-pagination]: https://docs.github.com/en/free-pro-team@latest/rest/overview/resources-in-the-rest-api#pagination