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

feat: added credentials method #5

Merged
merged 1 commit into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions compress/api_customer.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,13 @@
/*

*/
func (o *compress) GetCredentials() (*ResponseServer, error) {
func (o *compress) GetCredentials() (*Credential, error) {
//
resp, err := o.restyPost(CREDENTIALS, BaseModel{ClientId: o.GetCliendId(), ApiKey: o.apiKey})
if err != nil {
return nil, err
}
o.debugPrint(resp)
if resp.IsError() {
return nil, fmt.Errorf("")
}
var obj ResponseServer
if err := json.Unmarshal(resp.Body(), &obj); err != nil {
return nil, err
Expand All @@ -26,5 +23,10 @@
return nil, fmt.Errorf("Error %s", obj.Message)
}
o.debugPrint(obj)
return &obj, nil
//
var cred Credential
if err := json.Unmarshal(obj.Data, &cred); err != nil {

Check failure on line 28 in compress/api_customer.go

View workflow job for this annotation

GitHub Actions / build (1.19.x)

cannot use obj.Data (variable of type interface{}) as type []byte in argument to json.Unmarshal:

Check failure on line 28 in compress/api_customer.go

View workflow job for this annotation

GitHub Actions / build (1.20.x)

cannot use obj.Data (variable of type interface{}) as []byte value in argument to json.Unmarshal: need type assertion

Check failure on line 28 in compress/api_customer.go

View workflow job for this annotation

GitHub Actions / build (1.21.x)

cannot use obj.Data (variable of type interface{}) as []byte value in argument to json.Unmarshal: need type assertion

Check failure on line 28 in compress/api_customer.go

View workflow job for this annotation

GitHub Actions / build (1.19.x)

cannot use obj.Data (variable of type interface{}) as type []byte in argument to json.Unmarshal:

Check failure on line 28 in compress/api_customer.go

View workflow job for this annotation

GitHub Actions / build (1.20.x)

cannot use obj.Data (variable of type interface{}) as []byte value in argument to json.Unmarshal: need type assertion

Check failure on line 28 in compress/api_customer.go

View workflow job for this annotation

GitHub Actions / build (1.21.x)

cannot use obj.Data (variable of type interface{}) as []byte value in argument to json.Unmarshal: need type assertion
return nil, err
}
return &cred, nil
}
18 changes: 10 additions & 8 deletions compress/compress.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type ICompress interface {
//
HealthCheck() error
IsDebug() bool
GetCredentials() (*ResponseServer, error)
GetCredentials() (*Credential, error)
GetUploads(uploadsPaginated UploadsPaginated) ([]VideoUploadInfo, error) // need to change it with args
GetSingleUpload(jobid int) (*VideoUploadInfo, error)
GetJobidProgress(jobid int) (*VideoUploadInfo, error)
Expand All @@ -20,13 +20,15 @@ type ICompress interface {
CreateCategory(name string) (*Category, error)
GetRestreamers() ([]Restreamer, error) // startFrom int, amount int
GetSingleRestreamer(instanceName string) (*Restreamer, error)
//
}

type compress struct {
restClient *resty.Client
debug bool
customerName string
apiKey string
restClient *resty.Client
debug bool
customerName string
apiKey string
customerId int
}

func NewCompress(customerName, apiKey string, isDebug bool) (ICompress, error) {
Expand All @@ -45,12 +47,12 @@ func NewCompress(customerName, apiKey string, isDebug bool) (ICompress, error) {
c.restClient.SetBaseURL(TNGRM_BASE_URL)
c.restClient.SetDebug(isDebug)
//
_, err := c.GetCredentials()
cred, err := c.GetCredentials()
if err != nil {
return nil, err
}
c.customerId = cred.CustomerID
//
return c, nil
}

//
//
34 changes: 34 additions & 0 deletions compress/model_customer.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package compress

/*
*/
type Credential struct {
ID int `json:"id"`
CustomerID int `json:"customer_id" `
S3Host string `json:"s3_host" `
S3Bucket string `json:"s3_bucket" `
S3AccessKey string `json:"s3_access_key" `
S3SecretKey string `json:"s3_secret_key" `
SftpUsername string `json:"sftp_username" `
SftpPassword string `json:"sftp_password" `
SftpRemoteHost string `json:"sftp_remote_host" `
SftpRemotePort int `json:"sftp_remote_port" `
SftpBasePath string `json:"sftp_base_path" `
Protocol string `json:"protocol" `
EndpointVisualization string `json:"endpoint_visualization" `
NfsMount string `json:"nfs_mount" `
VodesBaseURL string `json:"vodes_base_url" `
LiveBaseURL string `json:"live_base_url" `
LiveBaseURLDedicated string `json:"live_base_url_dedicated" `
ExternalClusters string `json:"external_clusters" `
RestreamerHlsBasePath string `json:"restreamer_hls_base_path" `
RestreamerHlstmpBasePath string `json:"restreamer_hlstmp_base_path" `
ClientID string `json:"client_id" `
SSDMount string `json:"ssd_mount" `
S3mount string `json:"s3_mount" `
SlaveMount int `json:"slave_mount"`
LumenS3Host string `json:"lumen_s3_host" `
LumenS3Bucket string `json:"lumen_s3_bucket" `
LumenS3AccessKey string `json:"lumen_s3_access_key" `
LumenS3SecretKey string `json:"lumen_s3_secret_key" `
}
Loading