diff --git a/compress/api_restreamer.go b/compress/api_restreamer.go index de6913d..03d421d 100644 --- a/compress/api_restreamer.go +++ b/compress/api_restreamer.go @@ -65,3 +65,34 @@ func (o *compress) GetSingleRestreamer(instanceName string) (*Restreamer, error) o.debugPrint(obj) return &obj, nil } + +/* + +*/ +func (o *compress) ScaleRestreamer(instanceName string, scale int) (*ResponseServer, error){ + // + requestBody := &scaleRestreamerRequest{ + BaseModel: BaseModel{ClientId: o.GetCliendId(), ApiKey: o.apiKey}, + InstanceName: instanceName, + Scale: scale + + } + if errs := validator.Validate(requestBody); errs != nil { + // values not valid, deal with errors here + return nil, errs + } + resp, err := o.restyPost(GET_RUNNING_SINGLE_INSTANCE(), requestBody) + if err != nil { + return nil, err + } + var obj ResponseServer + if err := json.Unmarshal(resp.Body(), &obj); err != nil { + return nil, err + } + if obj.Data == "KO" { + return nil, fmt.Errorf("Error %s", obj.Message) + } + o.debugPrint(obj) + return &obj, nil + // +} \ No newline at end of file diff --git a/compress/compress.go b/compress/compress.go index 7b98d07..b9c0687 100644 --- a/compress/compress.go +++ b/compress/compress.go @@ -20,6 +20,7 @@ type ICompress interface { CreateCategory(name string) (*Category, error) GetRestreamers() ([]Restreamer, error) // startFrom int, amount int GetSingleRestreamer(instanceName string) (*Restreamer, error) + ScaleRestreamer(instanceName string, scale int) (*ResponseServer, error) // } diff --git a/compress/constants.go b/compress/constants.go index c155930..eaf8fb6 100644 --- a/compress/constants.go +++ b/compress/constants.go @@ -28,6 +28,9 @@ var ( GET_RUNNING_SINGLE_INSTANCE = func() string { return TNGRM_BASE_URL + RESTREAMERS + "/single_instance" } + SCALE_INSTANCE = func() string { + return TNGRM_BASE_URL + RESTREAMERS + "/scale_instance" + } GET_UPLOADS = func() string { return TNGRM_BASE_URL + UPLOADS } diff --git a/compress/model_restreamer.go b/compress/model_restreamer.go index 99740c7..202aa43 100644 --- a/compress/model_restreamer.go +++ b/compress/model_restreamer.go @@ -83,4 +83,10 @@ type findRestreamersRequest struct { type restreamerRequest struct { BaseModel InstanceName string `json:"instance_name" validate:"nonzero,min=1" required:"true"` +} + +type scaleRestreamerRequest struct { + BaseModel + InstanceName string `json:"instance_name" validate:"nonzero,min=1" required:"true"` + Scale int `json:"instance_name validate:"nonnil,min=0" required:"true"" } \ No newline at end of file