// Get returns the requested Runner
Get returns the requested Runner
// Get returns the requested Runner
func (s *RunnerService) Get(ctx context.Context, r RunnerGetRequest) (*RunnerGetResponse, error) {
	requestBodyBytes, err := json.Marshal(r)
	if err != nil {
		return nil, errors.Wrap(err, "RunnerService.Get: marshal RunnerGetRequest")
	}
	signature, err := generateSignature(requestBodyBytes, s.client.secret)
	if err != nil {
		return nil, errors.Wrap(err, "RunnerService.Get: generate signature RunnerGetRequest")
	}
	url := s.client.RemoteHost + "RunnerService.Get"
	s.client.Debug(fmt.Sprintf("POST %s", url))
	s.client.Debug(fmt.Sprintf(">> %s", string(requestBodyBytes)))
	req, err := http.NewRequest(http.MethodPost, url, bytes.NewReader(requestBodyBytes))
	if err != nil {
		return nil, errors.Wrap(err, "RunnerService.Get: NewRequest")
	}
	req.Header.Set("X-API-SIGNATURE", signature)
	req.Header.Set("Content-Type", "application/json")
	req.Header.Set("Accept-Encoding", "gzip")
	req = req.WithContext(ctx)
	resp, err := s.client.HTTPClient.Do(req)
	if err != nil {
		return nil, errors.Wrap(err, "RunnerService.Get")
	}
	defer resp.Body.Close()
	var response struct {
		RunnerGetResponse
		Error string
	}
	var bodyReader io.Reader = resp.Body
	if strings.Contains(resp.Header.Get("Content-Encoding"), "gzip") {
		decodedBody, err := gzip.NewReader(resp.Body)
		if err != nil {
			return nil, errors.Wrap(err, "RunnerService.Get: new gzip reader")
		}
		defer decodedBody.Close()
		bodyReader = decodedBody
	}
	respBodyBytes, err := ioutil.ReadAll(bodyReader)
	if err != nil {
		return nil, errors.Wrap(err, "RunnerService.Get: read response body")
	}
	if err := json.Unmarshal(respBodyBytes, &response); err != nil {
		if resp.StatusCode != http.StatusOK {
			return nil, errors.Errorf("RunnerService.Get: (%d) %v", resp.StatusCode, string(respBodyBytes))
		}
		return nil, err
	}
	if response.Error != "" {
		return nil, errors.New(response.Error)
	}
	return &response.RunnerGetResponse, nil
}
func ( s * RunnerService ) Get ( ctx context . Context , r RunnerGetRequest ) ( * RunnerGetResponse , error ) { requestBodyBytes , err := json . Marshal ( r ) if err != nil { return nil , errors . Wrap ( err , " " ) } signature , err := generateSignature ( requestBodyBytes , s . client . secret ) if err != nil { return nil , errors . Wrap ( err , " " ) } url := s . client . RemoteHost + " " s . client . Debug ( fmt . Sprintf ( " " , url ) ) s . client . Debug ( fmt . Sprintf ( " " , string ( requestBodyBytes ) ) ) req , err := http . NewRequest ( http . MethodPost , url , bytes . NewReader ( requestBodyBytes ) ) if err != nil { return nil , errors . Wrap ( err , " " ) } req . Header . Set ( " " , signature ) req . Header . Set ( " " , " " ) req . Header . Set ( " " , " " ) req = req . WithContext ( ctx ) resp , err := s . client . HTTPClient . Do ( req ) if err != nil { return nil , errors . Wrap ( err , " " ) } defer resp . Body . Close ( ) var response struct { RunnerGetResponse Error string } var bodyReader io . Reader = resp . Body if strings . Contains ( resp . Header . Get ( " " ) , " " ) { decodedBody , err := gzip . NewReader ( resp . Body ) if err != nil { return nil , errors . Wrap ( err , " " ) } defer decodedBody . Close ( ) bodyReader = decodedBody } respBodyBytes , err := ioutil . ReadAll ( bodyReader ) if err != nil { return nil , errors . Wrap ( err , " " ) } if err := json . Unmarshal ( respBodyBytes , & response ) ; err != nil { if resp . StatusCode != http . StatusOK { return nil , errors . Errorf ( " " , resp . StatusCode , string ( respBodyBytes ) ) } return nil , err } if response . Error != " " { return nil , errors . New ( response . Error ) } return & response . RunnerGetResponse , nil }
Get returns the requested Runner
Get returns the requested Runner