Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mybee
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
mybee
Commits
dfeca7c2
Unverified
Commit
dfeca7c2
authored
Sep 07, 2020
by
Janoš Guljaš
Committed by
GitHub
Sep 07, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move chunks-pin endpoints from debugapi to api (#673)
parent
823f236d
Changes
9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
136 additions
and
161 deletions
+136
-161
Swarm.yaml
openapi/Swarm.yaml
+77
-2
SwarmDebug.yaml
openapi/SwarmDebug.yaml
+0
-75
export_test.go
pkg/api/export_test.go
+6
-4
pin.go
pkg/api/pin.go
+2
-2
pin_test.go
pkg/api/pin_test.go
+33
-37
router.go
pkg/api/router.go
+9
-0
debugapi_test.go
pkg/debugapi/debugapi_test.go
+0
-22
export_test.go
pkg/debugapi/export_test.go
+9
-11
router.go
pkg/debugapi/router.go
+0
-8
No files found.
openapi/Swarm.yaml
View file @
dfeca7c2
...
...
@@ -443,10 +443,85 @@ paths:
content
:
application/json
:
schema
:
$ref
:
'
SwarmCommon.yaml#/components/schemas/Status'
$ref
:
'
SwarmCommon.yaml#/components/schemas/Status'
'
404'
:
$ref
:
'
SwarmCommon.yaml#/components/responses/404'
'
500'
:
$ref
:
'
SwarmCommon.yaml#/components/responses/500'
default
:
description
:
Default response
\ No newline at end of file
description
:
Default response
'
/pinning/chunks/{address}'
:
parameters
:
-
in
:
path
name
:
address
schema
:
$ref
:
'
SwarmCommon.yaml#/components/schemas/SwarmAddress'
required
:
true
description
:
Swarm address of chunk
post
:
summary
:
Pin chunk with given address
tags
:
-
Chunk pinning
responses
:
'
200'
:
description
:
Pinning chunk with address
content
:
application/json
:
schema
:
$ref
:
'
SwarmCommon.yaml#/components/schemas/Response'
'
400'
:
$ref
:
'
SwarmCommon.yaml#/components/responses/400'
'
404'
:
$ref
:
'
SwarmCommon.yaml#/components/responses/404'
default
:
description
:
Default response
delete
:
summary
:
Unpin chunk with given address
tags
:
-
Chunk pinning
responses
:
'
200'
:
description
:
Unpinning chunk with address
content
:
application/json
:
schema
:
$ref
:
'
SwarmCommon.yaml#/components/schemas/Response'
'
400'
:
$ref
:
'
SwarmCommon.yaml#/components/responses/400'
'
404'
:
$ref
:
'
SwarmCommon.yaml#/components/responses/404'
default
:
description
:
Default response
get
:
summary
:
Get pinning status of chunk with given address
tags
:
-
Chunk pinning
responses
:
'
200'
:
description
:
Pinning state of chunk with address
content
:
application/json
:
schema
:
$ref
:
'
SwarmCommon.yaml#/components/schemas/PinningState'
'
500'
:
$ref
:
'
SwarmCommon.yaml#/components/responses/500'
default
:
description
:
Default response
'
/pinning/chunks/'
:
get
:
summary
:
Get list of pinned chunks
tags
:
-
Chunk pinning
responses
:
'
200'
:
description
:
List of pinned chunks
content
:
application/json
:
schema
:
$ref
:
'
SwarmCommon.yaml#/components/schemas/BzzChunksPinned'
'
500'
:
$ref
:
'
SwarmCommon.yaml#/components/responses/500'
default
:
description
:
Default response
openapi/SwarmDebug.yaml
View file @
dfeca7c2
...
...
@@ -134,81 +134,6 @@ paths:
default
:
description
:
Default response
'
/chunks-pin/{address}'
:
parameters
:
-
in
:
path
name
:
address
schema
:
$ref
:
'
SwarmCommon.yaml#/components/schemas/SwarmAddress'
required
:
true
description
:
Swarm address of chunk
post
:
summary
:
Pin chunk with given address
tags
:
-
Chunk pinning
responses
:
'
200'
:
description
:
Pinning chunk with address
content
:
application/json
:
schema
:
$ref
:
'
SwarmCommon.yaml#/components/schemas/Response'
'
400'
:
$ref
:
'
SwarmCommon.yaml#/components/responses/400'
'
404'
:
$ref
:
'
SwarmCommon.yaml#/components/responses/404'
default
:
description
:
Default response
delete
:
summary
:
Unpin chunk with given address
tags
:
-
Chunk pinning
responses
:
'
200'
:
description
:
Unpinning chunk with address
content
:
application/json
:
schema
:
$ref
:
'
SwarmCommon.yaml#/components/schemas/Response'
'
400'
:
$ref
:
'
SwarmCommon.yaml#/components/responses/400'
'
404'
:
$ref
:
'
SwarmCommon.yaml#/components/responses/404'
default
:
description
:
Default response
get
:
summary
:
Get pinning status of chunk with given address
tags
:
-
Chunk pinning
responses
:
'
200'
:
description
:
Pinning state of chunk with address
content
:
application/json
:
schema
:
$ref
:
'
SwarmCommon.yaml#/components/schemas/PinningState'
'
500'
:
$ref
:
'
SwarmCommon.yaml#/components/responses/500'
default
:
description
:
Default response
'
/chunks-pin/'
:
get
:
summary
:
Get list of pinned chunks
tags
:
-
Chunk pinning
responses
:
'
200'
:
description
:
List of pinned chunks
content
:
application/json
:
schema
:
$ref
:
'
SwarmCommon.yaml#/components/schemas/BzzChunksPinned'
'
500'
:
$ref
:
'
SwarmCommon.yaml#/components/responses/500'
default
:
description
:
Default response
'
/connect/{multiAddress}'
:
post
:
summary
:
Connect to address
...
...
pkg/api/export_test.go
View file @
dfeca7c2
...
...
@@ -9,10 +9,12 @@ import "github.com/ethersphere/bee/pkg/swarm"
type
Server
=
server
type
(
BytesPostResponse
=
bytesPostResponse
FileUploadResponse
=
fileUploadResponse
TagResponse
=
tagResponse
TagRequest
=
tagRequest
BytesPostResponse
=
bytesPostResponse
FileUploadResponse
=
fileUploadResponse
TagResponse
=
tagResponse
TagRequest
=
tagRequest
PinnedChunk
=
pinnedChunk
ListPinnedChunksResponse
=
listPinnedChunksResponse
)
var
(
...
...
pkg/
debug
api/pin.go
→
pkg/api/pin.go
View file @
dfeca7c2
...
...
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package
debug
api
package
api
import
(
"errors"
...
...
@@ -52,7 +52,7 @@ func (s *server) pinChunk(w http.ResponseWriter, r *http.Request) {
func
(
s
*
server
)
unpinChunk
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
addr
,
err
:=
swarm
.
ParseHexAddress
(
mux
.
Vars
(
r
)[
"address"
])
if
err
!=
nil
{
s
.
Logger
.
Debugf
(
"debug api: pin chunk: parse chunk ddress: %v"
,
err
)
s
.
Logger
.
Debugf
(
"debug api: pin chunk: parse chunk
a
ddress: %v"
,
err
)
jsonhttp
.
BadRequest
(
w
,
"bad address"
)
return
}
...
...
pkg/
debug
api/pin_test.go
→
pkg/api/pin_test.go
View file @
dfeca7c2
This diff is collapsed.
Click to expand it.
pkg/api/router.go
View file @
dfeca7c2
...
...
@@ -81,6 +81,15 @@ func (s *server) setupRouting() {
),
})
handle
(
router
,
"/pinning/chunks/{address}"
,
jsonhttp
.
MethodHandler
{
"GET"
:
http
.
HandlerFunc
(
s
.
getPinnedChunk
),
"POST"
:
http
.
HandlerFunc
(
s
.
pinChunk
),
"DELETE"
:
http
.
HandlerFunc
(
s
.
unpinChunk
),
})
handle
(
router
,
"/pinning/chunks"
,
jsonhttp
.
MethodHandler
{
"GET"
:
http
.
HandlerFunc
(
s
.
listPinnedChunks
),
})
s
.
Handler
=
web
.
ChainHandlers
(
logging
.
NewHTTPAccessLogHandler
(
s
.
Logger
,
logrus
.
InfoLevel
,
"api access"
),
handlers
.
CompressHandler
,
...
...
pkg/debugapi/debugapi_test.go
View file @
dfeca7c2
...
...
@@ -12,13 +12,11 @@ import (
"testing"
accountingmock
"github.com/ethersphere/bee/pkg/accounting/mock"
"github.com/ethersphere/bee/pkg/api"
"github.com/ethersphere/bee/pkg/debugapi"
"github.com/ethersphere/bee/pkg/logging"
p2pmock
"github.com/ethersphere/bee/pkg/p2p/mock"
"github.com/ethersphere/bee/pkg/pingpong"
"github.com/ethersphere/bee/pkg/resolver"
resolverMock
"github.com/ethersphere/bee/pkg/resolver/mock"
"github.com/ethersphere/bee/pkg/storage"
"github.com/ethersphere/bee/pkg/swarm"
"github.com/ethersphere/bee/pkg/tags"
...
...
@@ -67,26 +65,6 @@ func newTestServer(t *testing.T, o testServerOptions) *testServer {
}
}
func
newBZZTestServer
(
t
*
testing
.
T
,
o
testServerOptions
)
*
http
.
Client
{
if
o
.
Resolver
==
nil
{
o
.
Resolver
=
resolverMock
.
NewResolver
()
}
s
:=
api
.
New
(
o
.
Tags
,
o
.
Storer
,
o
.
Resolver
,
nil
,
logging
.
New
(
ioutil
.
Discard
,
0
),
nil
)
ts
:=
httptest
.
NewServer
(
s
)
t
.
Cleanup
(
ts
.
Close
)
return
&
http
.
Client
{
Transport
:
web
.
RoundTripperFunc
(
func
(
r
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
u
,
err
:=
url
.
Parse
(
ts
.
URL
+
r
.
URL
.
String
())
if
err
!=
nil
{
return
nil
,
err
}
r
.
URL
=
u
return
ts
.
Client
()
.
Transport
.
RoundTrip
(
r
)
}),
}
}
func
mustMultiaddr
(
t
*
testing
.
T
,
s
string
)
multiaddr
.
Multiaddr
{
t
.
Helper
()
...
...
pkg/debugapi/export_test.go
View file @
dfeca7c2
...
...
@@ -5,17 +5,15 @@
package
debugapi
type
(
StatusResponse
=
statusResponse
PingpongResponse
=
pingpongResponse
PeerConnectResponse
=
peerConnectResponse
PeersResponse
=
peersResponse
AddressesResponse
=
addressesResponse
PinnedChunk
=
pinnedChunk
ListPinnedChunksResponse
=
listPinnedChunksResponse
WelcomeMessageRequest
=
welcomeMessageRequest
WelcomeMessageResponse
=
welcomeMessageResponse
BalancesResponse
=
balancesResponse
BalanceResponse
=
balanceResponse
StatusResponse
=
statusResponse
PingpongResponse
=
pingpongResponse
PeerConnectResponse
=
peerConnectResponse
PeersResponse
=
peersResponse
AddressesResponse
=
addressesResponse
WelcomeMessageRequest
=
welcomeMessageRequest
WelcomeMessageResponse
=
welcomeMessageResponse
BalancesResponse
=
balancesResponse
BalanceResponse
=
balanceResponse
)
var
(
...
...
pkg/debugapi/router.go
View file @
dfeca7c2
...
...
@@ -70,14 +70,6 @@ func (s *server) setupRouting() {
"GET"
:
http
.
HandlerFunc
(
s
.
hasChunkHandler
),
"DELETE"
:
http
.
HandlerFunc
(
s
.
removeChunk
),
})
router
.
Handle
(
"/chunks-pin/{address}"
,
jsonhttp
.
MethodHandler
{
"GET"
:
http
.
HandlerFunc
(
s
.
getPinnedChunk
),
"POST"
:
http
.
HandlerFunc
(
s
.
pinChunk
),
"DELETE"
:
http
.
HandlerFunc
(
s
.
unpinChunk
),
})
router
.
Handle
(
"/chunks-pin"
,
jsonhttp
.
MethodHandler
{
"GET"
:
http
.
HandlerFunc
(
s
.
listPinnedChunks
),
})
router
.
Handle
(
"/topology"
,
jsonhttp
.
MethodHandler
{
"GET"
:
http
.
HandlerFunc
(
s
.
topologyHandler
),
})
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment