func (cs *StarterClient) ListWorkspaces(ctx context.Context, repository string) ([]WorkspaceResponse, error) {
	req, err := http.NewRequest("GET", fmt.Sprintf(cs.targetURL("workspace")+"&repository=%v", repository), nil)
	if err != nil {
		log.Error(ctx, map[string]interface{}{
			"repository": repository,
			"err":        err,
		}, "failed to create request object")
		return nil, err
	}
	cs.setHeaders(ctx, req)

	if log.IsDebug() {
		b, _ := httputil.DumpRequest(req, true)
		log.Debug(ctx, map[string]interface{}{
			"request": string(b),
		}, "request object")
	}

	resp, err := cs.client.Do(req)
	if err != nil {
		log.Error(ctx, map[string]interface{}{
			"repository": repository,
			"err":        err,
		}, "failed to list workspace for repository")
		return nil, err
	}

	defer resp.Body.Close()

	if resp.StatusCode != http.StatusCreated && resp.StatusCode != http.StatusOK {
		workspaceErr := WorkspaceError{}
		err = json.NewDecoder(resp.Body).Decode(&workspaceErr)
		if err != nil {
			log.Error(ctx, map[string]interface{}{
				"repository": repository,
				"err":        err,
			}, "failed to decode error response from list workspace for repository")
			return nil, err
		}
		log.Error(ctx, map[string]interface{}{
			"repository": repository,
			"err":        workspaceErr.String(),
		}, "failed to execute list workspace for repository")
		return nil, &workspaceErr
	}

	workspaceResp := []WorkspaceResponse{}
	err = json.NewDecoder(resp.Body).Decode(&workspaceResp)
	if err != nil {
		log.Error(ctx, map[string]interface{}{
			"repository": repository,
			"err":        err,
		}, "failed to decode response from list workspace for repository")
		return nil, err
	}
	return workspaceResp, nil
}
// ListWorkspaces lists the available workspaces for a given user
ListWorkspaces lists the available workspaces for a given user
// ListWorkspaces lists the available workspaces for a given user
func (cs *StarterClient) ListWorkspaces(ctx context.Context, repository string) ([]WorkspaceResponse, error) {
	req, err := http.NewRequest("GET", fmt.Sprintf(cs.targetURL("workspace")+"&repository=%v", repository), nil)
	if err != nil {
		log.Error(ctx, map[string]interface{}{
			"repository": repository,
			"err":        err,
		}, "failed to create request object")
		return nil, err
	}
	cs.setHeaders(ctx, req)
	if log.IsDebug() {
		b, _ := httputil.DumpRequest(req, true)
		log.Debug(ctx, map[string]interface{}{
			"request": string(b),
		}, "request object")
	}
	resp, err := cs.client.Do(req)
	if err != nil {
		log.Error(ctx, map[string]interface{}{
			"repository": repository,
			"err":        err,
		}, "failed to list workspace for repository")
		return nil, err
	}
	defer resp.Body.Close()
	if resp.StatusCode != http.StatusCreated && resp.StatusCode != http.StatusOK {
		workspaceErr := WorkspaceError{}
		err = json.NewDecoder(resp.Body).Decode(&workspaceErr)
		if err != nil {
			log.Error(ctx, map[string]interface{}{
				"repository": repository,
				"err":        err,
			}, "failed to decode error response from list workspace for repository")
			return nil, err
		}
		log.Error(ctx, map[string]interface{}{
			"repository": repository,
			"err":        workspaceErr.String(),
		}, "failed to execute list workspace for repository")
		return nil, &workspaceErr
	}
	workspaceResp := []WorkspaceResponse{}
	err = json.NewDecoder(resp.Body).Decode(&workspaceResp)
	if err != nil {
		log.Error(ctx, map[string]interface{}{
			"repository": repository,
			"err":        err,
		}, "failed to decode response from list workspace for repository")
		return nil, err
	}
	return workspaceResp, nil
}
func ( cs * StarterClient ) ListWorkspaces ( ctx context . Context , repository string ) ( [ ] WorkspaceResponse , error ) { req , err := http . NewRequest ( " " , fmt . Sprintf ( cs . targetURL ( " " ) + " " , repository ) , nil ) if err != nil { log . Error ( ctx , map [ string ] interface { } { " " : repository , " " : err , } , " " ) return nil , err } cs . setHeaders ( ctx , req ) if log . IsDebug ( ) { b , _ := httputil . DumpRequest ( req , true ) log . Debug ( ctx , map [ string ] interface { } { " " : string ( b ) , } , " " ) } resp , err := cs . client . Do ( req ) if err != nil { log . Error ( ctx , map [ string ] interface { } { " " : repository , " " : err , } , " " ) return nil , err } defer resp . Body . Close ( ) if resp . StatusCode != http . StatusCreated && resp . StatusCode != http . StatusOK { workspaceErr := WorkspaceError { } err = json . NewDecoder ( resp . Body ) . Decode ( & workspaceErr ) if err != nil { log . Error ( ctx , map [ string ] interface { } { " " : repository , " " : err , } , " " ) return nil , err } log . Error ( ctx , map [ string ] interface { } { " " : repository , " " : workspaceErr . String ( ) , } , " " ) return nil , & workspaceErr } workspaceResp := [ ] WorkspaceResponse { } err = json . NewDecoder ( resp . Body ) . Decode ( & workspaceResp ) if err != nil { log . Error ( ctx , map [ string ] interface { } { " " : repository , " " : err , } , " " ) return nil , err } return workspaceResp , nil }
ListWorkspaces lists the available workspaces for a given user
ListWorkspaces lists the available workspaces for a given user