2025-02-13 20:32:19 +00:00
|
|
|
package android
|
|
|
|
|
|
2025-02-24 20:31:21 +00:00
|
|
|
import (
|
|
|
|
|
"context"
|
2025-09-04 12:17:37 +00:00
|
|
|
"net/http"
|
2025-02-24 20:31:21 +00:00
|
|
|
)
|
2025-02-13 20:32:19 +00:00
|
|
|
|
|
|
|
|
type Service interface {
|
|
|
|
|
EnterpriseSignup(ctx context.Context) (*SignupDetails, error)
|
2025-02-28 21:08:04 +00:00
|
|
|
EnterpriseSignupCallback(ctx context.Context, signupToken string, enterpriseToken string) error
|
2025-02-26 16:47:05 +00:00
|
|
|
GetEnterprise(ctx context.Context) (*Enterprise, error)
|
2025-02-18 15:43:11 +00:00
|
|
|
DeleteEnterprise(ctx context.Context) error
|
2025-02-26 22:20:02 +00:00
|
|
|
EnterpriseSignupSSE(ctx context.Context) (chan string, error)
|
2025-02-13 20:32:19 +00:00
|
|
|
|
2025-02-24 20:31:21 +00:00
|
|
|
// CreateEnrollmentToken creates an enrollment token for a new Android device.
|
2025-08-18 16:31:53 +00:00
|
|
|
CreateEnrollmentToken(ctx context.Context, enrollSecret, idpUUID string) (*EnrollmentToken, error)
|
2025-02-24 20:31:21 +00:00
|
|
|
ProcessPubSubPush(ctx context.Context, token string, message *PubSubMessage) error
|
2025-02-13 20:32:19 +00:00
|
|
|
}
|
2025-02-26 16:47:05 +00:00
|
|
|
|
|
|
|
|
// /////////////////////////////////////////////
|
|
|
|
|
// Android API request and response structs
|
|
|
|
|
|
|
|
|
|
type DefaultResponse struct {
|
|
|
|
|
Err error `json:"error,omitempty"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r DefaultResponse) Error() error { return r.Err }
|
|
|
|
|
|
2025-09-04 12:17:37 +00:00
|
|
|
// StatusCode implements the go-kit http StatusCoder interface to preserve HTTP status codes from errors
|
|
|
|
|
func (r DefaultResponse) StatusCode() int {
|
|
|
|
|
if r.Err != nil {
|
|
|
|
|
// Check if the error has a custom status code (like errors created with .WithStatus())
|
|
|
|
|
if sc, ok := r.Err.(interface{ StatusCode() int }); ok {
|
|
|
|
|
return sc.StatusCode()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Default to 200 OK if no error or no custom status code
|
|
|
|
|
return http.StatusOK
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-26 16:47:05 +00:00
|
|
|
type GetEnterpriseResponse struct {
|
|
|
|
|
EnterpriseID string `json:"android_enterprise_id"`
|
|
|
|
|
DefaultResponse
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type EnterpriseSignupResponse struct {
|
|
|
|
|
Url string `json:"android_enterprise_signup_url"`
|
|
|
|
|
DefaultResponse
|
|
|
|
|
}
|
2025-08-18 16:31:53 +00:00
|
|
|
|
|
|
|
|
type EnrollmentTokenResponse struct {
|
|
|
|
|
*EnrollmentToken
|
|
|
|
|
DefaultResponse
|
|
|
|
|
}
|