Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NOTE] Notes on "GET /jobs/replication" API #28

Open
moooofly opened this issue Nov 7, 2018 · 0 comments
Open

[NOTE] Notes on "GET /jobs/replication" API #28

moooofly opened this issue Nov 7, 2018 · 0 comments
Assignees
Labels
note markdown some conclusions v1.6.0-66709daa

Comments

@moooofly
Copy link
Owner

moooofly commented Nov 7, 2018

by swagger file

image

but the format of start_time and end_time is just documented as Timestamp.

After some tests, I find what is the real meaning of Timestamp. Here is the output by harborctl

[#719#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$./harborctl job replication list -i 2 --startTime 20181104 --endTime 20181105
==> GET https://aa.bb.cc.dd/api/jobs/replication?policy_id=2&page=1&page_size=10&status=&start_time=1541289600&end_time=1541376000&repository=&num=1
<==
<== Rsp Status: 200 OK
<== Rsp Body: [
  {
    "id": 19925,
    "status": "finished",
    "repository": "backend-rls/cms",
    "policy_id": 2,
    "operation": "transfer",
    "tags": [
      "ci-612549"
    ],
    "creation_time": "2018-11-04T07:49:22Z",
    "update_time": "2018-11-04T07:49:29Z"
  },
  {
    "id": 19924,
    "status": "finished",
    "repository": "backend-rls/coursescript",
    "policy_id": 2,
    "operation": "transfer",
    "tags": [
      "latest"
    ],
    "creation_time": "2018-11-04T07:47:27Z",
    "update_time": "2018-11-04T07:47:32Z"
  },
  {
    "id": 19922,
    "status": "finished",
    "repository": "backend-rls/coursescript",
    "policy_id": 2,
    "operation": "transfer",
    "tags": [
      "v0.8.12"
    ],
    "creation_time": "2018-11-04T07:47:26Z",
    "update_time": "2018-11-04T07:47:32Z"
  },
  {
    "id": 19923,
    "status": "finished",
    "repository": "backend-rls/ccfakesrv",
    "policy_id": 2,
    "operation": "transfer",
    "tags": [
      "v0.8.12"
    ],
    "creation_time": "2018-11-04T07:47:27Z",
    "update_time": "2018-11-04T07:47:30Z"
  }
]
[#720#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$

Conclusion

  • the format of start_time and end_time is something like 1541289600, which is generated by codes as below
{
...
	st, err := time.Parse("20060102", rplistbyfilter.StartTime)
	if err != nil {
		fmt.Println("error:", err)
		os.Exit(1)
	}
	et, err := time.Parse("20060102", rplistbyfilter.EndTime)
	if err != nil {
		fmt.Println("error:", err)
		os.Exit(1)
	}
...
		"&start_time=" + strconv.FormatInt(st.Unix(), 10) +
		"&end_time=" + strconv.FormatInt(et.Unix(), 10) +
...
  • For human being, the format of start_time and end_time should not be defined as Timestamp (int64), so I provide the same functioning by changing the type of these two parameters to string, and you can specify start_time and end_time with something like "20181101", it is really useful.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
note markdown some conclusions v1.6.0-66709daa
Projects
None yet
Development

No branches or pull requests

1 participant