-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #61
- Loading branch information
Showing
15 changed files
with
659 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package drive | ||
|
||
import ( | ||
"github.com/yitsushi/go-misskey/core" | ||
) | ||
|
||
// CleanRequest represents a Clean request. | ||
type CleanRequest struct{} | ||
|
||
// Validate the request. | ||
func (r CleanRequest) Validate() error { | ||
return nil | ||
} | ||
|
||
// Clean local drive. | ||
func (s *Service) Clean() error { | ||
err := s.Call( | ||
&core.JSONRequest{Request: &CleanRequest{}, Path: "/admin/drive/cleanup"}, | ||
&core.EmptyResponse{}, | ||
) | ||
|
||
return err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package drive | ||
|
||
import ( | ||
"github.com/yitsushi/go-misskey/core" | ||
) | ||
|
||
// CleanRemoteRequest represents a CleanRemote request. | ||
type CleanRemoteRequest struct{} | ||
|
||
// Validate the request. | ||
func (r CleanRemoteRequest) Validate() error { | ||
return nil | ||
} | ||
|
||
// CleanRemote drive. | ||
func (s *Service) CleanRemote() error { | ||
err := s.Call( | ||
&core.JSONRequest{Request: &CleanRemoteRequest{}, Path: "/admin/drive/clean-remote-files"}, | ||
&core.EmptyResponse{}, | ||
) | ||
|
||
return err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package drive_test | ||
|
||
import ( | ||
"log" | ||
"net/http" | ||
"os" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/yitsushi/go-misskey" | ||
"github.com/yitsushi/go-misskey/core" | ||
"github.com/yitsushi/go-misskey/services/admin/drive" | ||
"github.com/yitsushi/go-misskey/test" | ||
) | ||
|
||
func TestService_CleanRemote(t *testing.T) { | ||
client := test.MakeMockClient(test.SimpleMockOptions{ | ||
Endpoint: "/api/admin/drive/clean-remote-files", | ||
RequestData: &drive.CleanRemoteRequest{}, | ||
ResponseFile: "empty", | ||
StatusCode: http.StatusNoContent, | ||
}) | ||
|
||
err := client.Admin().Drive().CleanRemote() | ||
|
||
if !assert.NoError(t, err) { | ||
return | ||
} | ||
} | ||
|
||
func TestCleanRemoteRequest_Validate(t *testing.T) { | ||
test.ValidateRequests( | ||
t, | ||
[]core.BaseRequest{}, | ||
[]core.BaseRequest{ | ||
drive.CleanRemoteRequest{}, | ||
}, | ||
) | ||
} | ||
|
||
func ExampleService_CleanRemote() { | ||
client := misskey.NewClient("https://slippy.xyz", os.Getenv("MISSKEY_TOKEN")) | ||
|
||
err := client.Admin().Drive().CleanRemote() | ||
if err != nil { | ||
log.Printf("[Admin/Drive/CleanRemote] %s", err) | ||
|
||
return | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package drive_test | ||
|
||
import ( | ||
"log" | ||
"net/http" | ||
"os" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/yitsushi/go-misskey" | ||
"github.com/yitsushi/go-misskey/core" | ||
"github.com/yitsushi/go-misskey/services/admin/drive" | ||
"github.com/yitsushi/go-misskey/test" | ||
) | ||
|
||
func TestService_Clean(t *testing.T) { | ||
client := test.MakeMockClient(test.SimpleMockOptions{ | ||
Endpoint: "/api/admin/drive/cleanup", | ||
RequestData: &drive.CleanRequest{}, | ||
ResponseFile: "empty", | ||
StatusCode: http.StatusNoContent, | ||
}) | ||
|
||
err := client.Admin().Drive().Clean() | ||
|
||
if !assert.NoError(t, err) { | ||
return | ||
} | ||
} | ||
|
||
func TestCleanRequest_Validate(t *testing.T) { | ||
test.ValidateRequests( | ||
t, | ||
[]core.BaseRequest{}, | ||
[]core.BaseRequest{ | ||
drive.CleanRequest{}, | ||
}, | ||
) | ||
} | ||
|
||
func ExampleService_Clean() { | ||
client := misskey.NewClient("https://slippy.xyz", os.Getenv("MISSKEY_TOKEN")) | ||
|
||
err := client.Admin().Drive().Clean() | ||
if err != nil { | ||
log.Printf("[Admin/Drive/Clean] %s", err) | ||
|
||
return | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package drive | ||
|
||
import ( | ||
"github.com/yitsushi/go-misskey/core" | ||
"github.com/yitsushi/go-misskey/models" | ||
) | ||
|
||
// FilesRequest represents a Files request. | ||
type FilesRequest struct { | ||
Limit uint `json:"limit,omitempty"` | ||
SinceID string `json:"sinceId,omitempty"` | ||
UntilID string `json:"untilId,omitempty"` | ||
Type core.String `json:"type,omitempty"` | ||
Origin models.UserOrigin `json:"origin,omitempty"` | ||
Hostname core.String `json:"hostname,omitempty"` | ||
} | ||
|
||
// Validate the request. | ||
func (r FilesRequest) Validate() error { | ||
return nil | ||
} | ||
|
||
// Files lists all emojies. | ||
func (s *Service) Files(request FilesRequest) ([]models.File, error) { | ||
var response []models.File | ||
|
||
err := s.Call( | ||
&core.JSONRequest{Request: &request, Path: "/admin/drive/files"}, | ||
&response, | ||
) | ||
|
||
return response, err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package drive_test | ||
|
||
import ( | ||
"log" | ||
"net/http" | ||
"os" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/yitsushi/go-misskey" | ||
"github.com/yitsushi/go-misskey/core" | ||
"github.com/yitsushi/go-misskey/services/admin/drive" | ||
"github.com/yitsushi/go-misskey/test" | ||
) | ||
|
||
func TestService_Files(t *testing.T) { | ||
client := test.MakeMockClient(test.SimpleMockOptions{ | ||
Endpoint: "/api/admin/drive/files", | ||
RequestData: &drive.FilesRequest{}, | ||
ResponseFile: "files.json", | ||
StatusCode: http.StatusOK, | ||
}) | ||
|
||
response, err := client.Admin().Drive().Files(drive.FilesRequest{}) | ||
|
||
if !assert.NoError(t, err) { | ||
return | ||
} | ||
|
||
assert.Len(t, response, 10) | ||
} | ||
|
||
func TestFilesRequest_Validate(t *testing.T) { | ||
test.ValidateRequests( | ||
t, | ||
[]core.BaseRequest{}, | ||
[]core.BaseRequest{ | ||
drive.FilesRequest{}, | ||
}, | ||
) | ||
} | ||
|
||
func ExampleService_Files() { | ||
client := misskey.NewClient("https://slippy.xyz", os.Getenv("MISSKEY_TOKEN")) | ||
|
||
response, err := client.Admin().Drive().Files(drive.FilesRequest{}) | ||
if err != nil { | ||
log.Printf("[Admin/Drive/Files] %s", err) | ||
|
||
return | ||
} | ||
|
||
for _, item := range response { | ||
log.Printf("[Admin/Drive/Files] %s", item.URL) | ||
} | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"accessKey": "c68244ab-7edf-489f-a8b2-f476e6b9e165", | ||
"blurhash": "y9E.^YsC4Ti_00?vEL00-p_3xu~q4.o}^+MxIUM{xu%MIU-;ofNGtRIUV@xa4.tR?bWBn%njniE1E14.oJ%Mxuxb%gR+fkIUM{xu%M", | ||
"comment": null, | ||
"createdAt": "2022-03-19T18:54:24.968Z", | ||
"folderId": null, | ||
"id": "8y1rwxxkk9", | ||
"isLink": false, | ||
"isSensitive": false, | ||
"md5": "f1da991de57f451d7649a22026a5a15a", | ||
"name": "d4391807-0d94-4888-ac34-b23a040ac620", | ||
"properties": { | ||
"height": 112, | ||
"width": 112 | ||
}, | ||
"size": 9489, | ||
"src": "https://ente.fun/files/d4391807-0d94-4888-ac34-b23a040ac620", | ||
"storedInternal": true, | ||
"thumbnailAccessKey": "thumbnail-89d0d4ac-f755-4fe0-b82d-de69f3ab27ea", | ||
"thumbnailUrl": "https://slippy.xyz/files/thumbnail-89d0d4ac-f755-4fe0-b82d-de69f3ab27ea", | ||
"type": "image/png", | ||
"uri": null, | ||
"url": "https://slippy.xyz/files/c68244ab-7edf-489f-a8b2-f476e6b9e165", | ||
"userHost": null, | ||
"userId": null, | ||
"webpublicAccessKey": "webpublic-4eab0892-9dc0-4730-83e0-0e65642242ce", | ||
"webpublicType": "image/png", | ||
"webpublicUrl": "https://slippy.xyz/files/webpublic-4eab0892-9dc0-4730-83e0-0e65642242ce" | ||
} |
Oops, something went wrong.