github.com/rakutentech/cli@v6.12.5-0.20151006231303-24468b65536e+incompatible/cf/api/security_groups/defaults/running/running.go (about)

     1  package running
     2  
     3  import (
     4  	"github.com/cloudfoundry/cli/cf/configuration/core_config"
     5  	"github.com/cloudfoundry/cli/cf/models"
     6  	"github.com/cloudfoundry/cli/cf/net"
     7  
     8  	. "github.com/cloudfoundry/cli/cf/api/security_groups/defaults"
     9  )
    10  
    11  const urlPath = "/v2/config/running_security_groups"
    12  
    13  type RunningSecurityGroupsRepo interface {
    14  	BindToRunningSet(string) error
    15  	List() ([]models.SecurityGroupFields, error)
    16  	UnbindFromRunningSet(string) error
    17  }
    18  
    19  type cloudControllerRunningSecurityGroupRepo struct {
    20  	repoBase DefaultSecurityGroupsRepoBase
    21  }
    22  
    23  func NewRunningSecurityGroupsRepo(configRepo core_config.Reader, gateway net.Gateway) RunningSecurityGroupsRepo {
    24  	return &cloudControllerRunningSecurityGroupRepo{
    25  		repoBase: DefaultSecurityGroupsRepoBase{
    26  			ConfigRepo: configRepo,
    27  			Gateway:    gateway,
    28  		},
    29  	}
    30  }
    31  
    32  func (repo *cloudControllerRunningSecurityGroupRepo) BindToRunningSet(groupGuid string) error {
    33  	return repo.repoBase.Bind(groupGuid, urlPath)
    34  }
    35  
    36  func (repo *cloudControllerRunningSecurityGroupRepo) List() ([]models.SecurityGroupFields, error) {
    37  	return repo.repoBase.List(urlPath)
    38  }
    39  
    40  func (repo *cloudControllerRunningSecurityGroupRepo) UnbindFromRunningSet(groupGuid string) error {
    41  	return repo.repoBase.Delete(groupGuid, urlPath)
    42  }