Skip to content

Commit

Permalink
added cusomer s3
Browse files Browse the repository at this point in the history
  • Loading branch information
Allan-Nava authored Jun 4, 2024
1 parent 0831c67 commit b431a00
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 0 deletions.
24 changes: 24 additions & 0 deletions compress/api_customer.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,27 @@ func (o *compress) GetCredentials() (*Credential, error) {
//
return &obj.Data, nil
}


/**
* Need to call before upload s3
*
* @returns customer_s3
*/
func (o *compress) GetCustomerS3Zone() (*CustomerS3, error) {
resp, err := o.restyPost(GET_ZONE, BaseModel{ClientId: o.GetCliendId(), ApiKey: o.apiKey})

Check failure on line 37 in compress/api_customer.go

View workflow job for this annotation

GitHub Actions / build (1.21.x)

cannot use GET_ZONE (variable of type func() string) as string value in argument to o.restyPost

Check failure on line 37 in compress/api_customer.go

View workflow job for this annotation

GitHub Actions / build (1.21.x)

cannot use GET_ZONE (variable of type func() string) as string value in argument to o.restyPost

Check failure on line 37 in compress/api_customer.go

View workflow job for this annotation

GitHub Actions / build (1.20.x)

cannot use GET_ZONE (variable of type func() string) as string value in argument to o.restyPost

Check failure on line 37 in compress/api_customer.go

View workflow job for this annotation

GitHub Actions / build (1.20.x)

cannot use GET_ZONE (variable of type func() string) as string value in argument to o.restyPost

Check failure on line 37 in compress/api_customer.go

View workflow job for this annotation

GitHub Actions / build (1.18.x)

cannot use GET_ZONE (variable of type func() string) as type string in argument to o.restyPost
if err != nil {
return nil, err
}
o.debugPrint(resp)
var obj CustomerS3
if err := json.Unmarshal(resp.Body(), &obj); err != nil {
return nil, err
}
if obj.Response == "KO" {

Check failure on line 46 in compress/api_customer.go

View workflow job for this annotation

GitHub Actions / build (1.21.x)

obj.Response undefined (type CustomerS3 has no field or method Response)

Check failure on line 46 in compress/api_customer.go

View workflow job for this annotation

GitHub Actions / build (1.21.x)

obj.Response undefined (type CustomerS3 has no field or method Response)

Check failure on line 46 in compress/api_customer.go

View workflow job for this annotation

GitHub Actions / build (1.20.x)

obj.Response undefined (type CustomerS3 has no field or method Response)

Check failure on line 46 in compress/api_customer.go

View workflow job for this annotation

GitHub Actions / build (1.20.x)

obj.Response undefined (type CustomerS3 has no field or method Response)

Check failure on line 46 in compress/api_customer.go

View workflow job for this annotation

GitHub Actions / build (1.18.x)

obj.Response undefined (type CustomerS3 has no field or method Response)
return nil, fmt.Errorf("Error %s", obj.Message)

Check failure on line 47 in compress/api_customer.go

View workflow job for this annotation

GitHub Actions / build (1.21.x)

obj.Message undefined (type CustomerS3 has no field or method Message)

Check failure on line 47 in compress/api_customer.go

View workflow job for this annotation

GitHub Actions / build (1.21.x)

obj.Message undefined (type CustomerS3 has no field or method Message)

Check failure on line 47 in compress/api_customer.go

View workflow job for this annotation

GitHub Actions / build (1.20.x)

obj.Message undefined (type CustomerS3 has no field or method Message)

Check failure on line 47 in compress/api_customer.go

View workflow job for this annotation

GitHub Actions / build (1.20.x)

obj.Message undefined (type CustomerS3 has no field or method Message)

Check failure on line 47 in compress/api_customer.go

View workflow job for this annotation

GitHub Actions / build (1.18.x)

obj.Message undefined (type CustomerS3 has no field or method Message)
}
o.debugPrint(obj)
//
return &obj.Data, nil

Check failure on line 51 in compress/api_customer.go

View workflow job for this annotation

GitHub Actions / build (1.21.x)

obj.Data undefined (type CustomerS3 has no field or method Data)

Check failure on line 51 in compress/api_customer.go

View workflow job for this annotation

GitHub Actions / build (1.21.x)

obj.Data undefined (type CustomerS3 has no field or method Data)

Check failure on line 51 in compress/api_customer.go

View workflow job for this annotation

GitHub Actions / build (1.20.x)

obj.Data undefined (type CustomerS3 has no field or method Data)

Check failure on line 51 in compress/api_customer.go

View workflow job for this annotation

GitHub Actions / build (1.20.x)

obj.Data undefined (type CustomerS3 has no field or method Data)

Check failure on line 51 in compress/api_customer.go

View workflow job for this annotation

GitHub Actions / build (1.18.x)

obj.Data undefined (type CustomerS3 has no field or method Data)
}
1 change: 1 addition & 0 deletions compress/compress.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type ICompress interface {
CreateEventsBulk(request []InstancesEventCreate) (*ResponseServer, error)
RestreamerHlsStart(request hlsBodyRequest) (*HlsResponse, error)
RestreamerHlsStop(request hlsBodyRequest) (*HlsResponse, error)
GetCustomerS3Zone() (*CustomerS3, error)
//
}

Expand Down
4 changes: 4 additions & 0 deletions compress/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const (
UPLOADS = "/external/upload"
CREDENTIALS = "/external/credentials/"
EVENTS = "/external/events"
CUSTOMERS = "/external/customers"
)

var (
Expand Down Expand Up @@ -68,5 +69,8 @@ var (
PRESIGNED_URL_S3 = func() string {
return TNGRM_BASE_URL + UPLOADS + "/presignedUrl"
}
GET_ZONE = func() string {
return TNGRM_BASE_URL + CUSTOMERS + "/s3"
}
//
)
24 changes: 24 additions & 0 deletions compress/model_customer.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,27 @@ type ResponseServerCredential struct {
Response string `json:"response"`
Data Credential `json:"data"`
}


type CustomerS3 struct {
ID int `json:"id" `
CustomerID int `json:"customer_id" gorm:"column:customer_id"`
S3Name string `json:"s3_name" `
Host string `json:"host" `
Bucket string `json:"bucket" `
AccessKey string `json:"access_key" `
SecretKey string `json:"secret_key" `
IsActive int `json:"is_active" `
UpdateEnabled int `json:"update_enabled" `
CreatedAt *time.Time `json:"created_at" gorm:"type:timestamp;"`

Check failure on line 54 in compress/model_customer.go

View workflow job for this annotation

GitHub Actions / build (1.21.x)

undefined: time

Check failure on line 54 in compress/model_customer.go

View workflow job for this annotation

GitHub Actions / build (1.21.x)

undefined: time

Check failure on line 54 in compress/model_customer.go

View workflow job for this annotation

GitHub Actions / build (1.20.x)

undefined: time

Check failure on line 54 in compress/model_customer.go

View workflow job for this annotation

GitHub Actions / build (1.20.x)

undefined: time

Check failure on line 54 in compress/model_customer.go

View workflow job for this annotation

GitHub Actions / build (1.18.x)

undefined: time
UpdatedAt *time.Time `json:"updated_at" gorm:"type:timestamp;"`

Check failure on line 55 in compress/model_customer.go

View workflow job for this annotation

GitHub Actions / build (1.21.x)

undefined: time

Check failure on line 55 in compress/model_customer.go

View workflow job for this annotation

GitHub Actions / build (1.21.x)

undefined: time

Check failure on line 55 in compress/model_customer.go

View workflow job for this annotation

GitHub Actions / build (1.20.x)

undefined: time

Check failure on line 55 in compress/model_customer.go

View workflow job for this annotation

GitHub Actions / build (1.20.x)

undefined: time

Check failure on line 55 in compress/model_customer.go

View workflow job for this annotation

GitHub Actions / build (1.18.x)

undefined: time
DeletedAt *time.Time `json:"deleted_at" gorm:"type:timestamp;"`

Check failure on line 56 in compress/model_customer.go

View workflow job for this annotation

GitHub Actions / build (1.21.x)

undefined: time

Check failure on line 56 in compress/model_customer.go

View workflow job for this annotation

GitHub Actions / build (1.21.x)

undefined: time

Check failure on line 56 in compress/model_customer.go

View workflow job for this annotation

GitHub Actions / build (1.20.x)

undefined: time

Check failure on line 56 in compress/model_customer.go

View workflow job for this annotation

GitHub Actions / build (1.20.x)

undefined: time

Check failure on line 56 in compress/model_customer.go

View workflow job for this annotation

GitHub Actions / build (1.18.x)

undefined: time
LiveNFSMount string `json:"live_nfs_mount"`
VodNFSMount string `json:"vod_nfs_mount"`
VodCDNBaseURL string `json:"vod_cdn_base_url"`
LiveCDNBaseURL string `json:"live_cdn_base_url"`
LiveUnprotectedBaseURL string `json:"live_unprotected_base_url"`
VodUnprotectedBaseURL string `json:"vod_unprotected_base_url"`
Zone string `json:"zone"`
BucketUpload string `json:"bucket_upload"`
}

0 comments on commit b431a00

Please sign in to comment.