本文整理匯總了Golang中github.com/cloudawan/cloudone_utility/restclient.RequestDelete函數的典型用法代碼示例。如果您正苦於以下問題:Golang RequestDelete函數的具體用法?Golang RequestDelete怎麽用?Golang RequestDelete使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了RequestDelete函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Delete
// @Title delete
// @Description delete the cluster application deployment
// @Param clusterApplicationName path string true "The name of cluster application deployment"
// @Success 200 {string} {}
// @Failure 404 error reason
// @router /:clusterApplicationName [delete]
func (c *DeleteController) Delete() {
clusterApplicationName := c.GetString(":clusterApplicationName")
cloudoneProtocol := beego.AppConfig.String("cloudoneProtocol")
cloudoneHost := beego.AppConfig.String("cloudoneHost")
cloudonePort := beego.AppConfig.String("cloudonePort")
namespace := c.GetSession("namespace").(string)
url := cloudoneProtocol + "://" + cloudoneHost + ":" + cloudonePort +
"/api/v1/deployclusterapplications/" + namespace + "/" + clusterApplicationName
tokenHeaderMap, _ := c.GetSession("tokenHeaderMap").(map[string]string)
_, err := restclient.RequestDelete(url, nil, tokenHeaderMap, true)
if identity.IsTokenInvalidAndRedirect(c, c.Ctx, err) {
return
}
if err != nil {
// Error
c.Data["json"] = make(map[string]interface{})
c.Data["json"].(map[string]interface{})["error"] = err.Error()
c.Ctx.Output.Status = 404
c.ServeJSON()
return
} else {
c.Data["json"] = make(map[string]interface{})
c.ServeJSON()
}
}
示例2: Get
func (c *PodDeleteController) Get() {
guimessage := guimessagedisplay.GetGUIMessage(c)
cloudoneProtocol := beego.AppConfig.String("cloudoneProtocol")
cloudoneHost := beego.AppConfig.String("cloudoneHost")
cloudonePort := beego.AppConfig.String("cloudonePort")
namespace := c.GetString("namespace")
pod := c.GetString("pod")
url := cloudoneProtocol + "://" + cloudoneHost + ":" + cloudonePort +
"/api/v1/pods/" + namespace + "/" + pod
tokenHeaderMap, _ := c.GetSession("tokenHeaderMap").(map[string]string)
_, err := restclient.RequestDelete(url, nil, tokenHeaderMap, true)
if identity.IsTokenInvalidAndRedirect(c, c.Ctx, err) {
return
}
if err != nil {
// Error
guimessage.AddDanger(guimessagedisplay.GetErrorMessage(err))
} else {
guimessage.AddSuccess("Pod " + pod + " is deleted")
}
// Redirect to list
c.Ctx.Redirect(302, "/gui/inventory/replicationcontroller/list")
guimessage.RedirectMessage(c)
}
示例3: Get
func (c *DeleteController) Get() {
guimessage := guimessagedisplay.GetGUIMessage(c)
cloudoneProtocol := beego.AppConfig.String("cloudoneProtocol")
cloudoneHost := beego.AppConfig.String("cloudoneHost")
cloudonePort := beego.AppConfig.String("cloudonePort")
imageInformation := c.GetString("imageInformation")
url := cloudoneProtocol + "://" + cloudoneHost + ":" + cloudonePort +
"/api/v1/deploybluegreens/" + imageInformation
tokenHeaderMap, _ := c.GetSession("tokenHeaderMap").(map[string]string)
_, err := restclient.RequestDelete(url, nil, tokenHeaderMap, true)
if identity.IsTokenInvalidAndRedirect(c, c.Ctx, err) {
return
}
if err != nil {
// Error
guimessage.AddDanger(guimessagedisplay.GetErrorMessage(err))
} else {
guimessage.AddSuccess("Deploy blue green deployment " + imageInformation + " is deleted")
}
// Redirect to list
c.Ctx.Redirect(302, "/gui/deploy/deploybluegreen/list")
guimessage.RedirectMessage(c)
}
示例4: Get
func (c *DeleteController) Get() {
guimessage := guimessagedisplay.GetGUIMessage(c)
cloudoneProtocol := beego.AppConfig.String("cloudoneProtocol")
cloudoneHost := beego.AppConfig.String("cloudoneHost")
cloudonePort := beego.AppConfig.String("cloudonePort")
serverName := c.GetString("serverName")
repositoryName := c.GetString("repositoryName")
tag := c.GetString("tag")
url := cloudoneProtocol + "://" + cloudoneHost + ":" + cloudonePort +
"/api/v1/privateregistries/servers/" + serverName + "/repositories/" + repositoryName + "/tags/" + tag
tokenHeaderMap, _ := c.GetSession("tokenHeaderMap").(map[string]string)
_, err := restclient.RequestDelete(url, nil, tokenHeaderMap, true)
if identity.IsTokenInvalidAndRedirect(c, c.Ctx, err) {
return
}
if err != nil {
// Error
guimessage.AddDanger(guimessagedisplay.GetErrorMessage(err))
} else {
guimessage.AddSuccess("Image labeled with the tag " + tag + " is deleted")
}
// Redirect to list
c.Ctx.Redirect(302, "/gui/system/privateregistry/image/list?serverName="+serverName+"&repositoryName="+repositoryName)
guimessage.RedirectMessage(c)
}
示例5: Get
func (c *DeleteController) Get() {
guimessage := guimessagedisplay.GetGUIMessage(c)
cloudoneProtocol := beego.AppConfig.String("cloudoneProtocol")
cloudoneHost := beego.AppConfig.String("cloudoneHost")
cloudonePort := beego.AppConfig.String("cloudonePort")
name := c.GetString("name")
url := cloudoneProtocol + "://" + cloudoneHost + ":" + cloudonePort +
"/api/v1/notifiers/emailserversmtp/" + name
tokenHeaderMap, _ := c.GetSession("tokenHeaderMap").(map[string]string)
_, err := restclient.RequestDelete(url, nil, tokenHeaderMap, true)
if identity.IsTokenInvalidAndRedirect(c, c.Ctx, err) {
return
}
if err != nil {
// Error
guimessage.AddDanger(guimessagedisplay.GetErrorMessage(err))
} else {
guimessage.AddSuccess("Email server configuration " + name + " is deleted")
}
// Redirect to list
c.Ctx.Redirect(302, "/gui/system/notification/emailserver/list")
guimessage.RedirectMessage(c)
}
示例6: Get
func (c *DeleteController) Get() {
guimessage := guimessagedisplay.GetGUIMessage(c)
cloudoneProtocol := beego.AppConfig.String("cloudoneProtocol")
cloudoneHost := beego.AppConfig.String("cloudoneHost")
cloudonePort := beego.AppConfig.String("cloudonePort")
imageInformationName := c.GetString("name")
imageRecordVersion := c.GetString("version")
url := cloudoneProtocol + "://" + cloudoneHost + ":" + cloudonePort +
"/api/v1/imagerecords/" + imageInformationName + "/" + imageRecordVersion
tokenHeaderMap, _ := c.GetSession("tokenHeaderMap").(map[string]string)
_, err := restclient.RequestDelete(url, nil, tokenHeaderMap, true)
if identity.IsTokenInvalidAndRedirect(c, c.Ctx, err) {
return
}
if err != nil {
// Error
guimessage.AddDanger(guimessagedisplay.GetErrorMessage(err))
} else {
guimessage.AddSuccess("Image record " + imageRecordVersion + " belonging to " + imageInformationName + " is deleted")
}
// Redirect to list
c.Ctx.Redirect(302, "/gui/repository/imagerecord/list?name="+imageInformationName)
guimessage.RedirectMessage(c)
}
示例7: Get
func (c *DeleteController) Get() {
guimessage := guimessagedisplay.GetGUIMessage(c)
clusterName := c.GetString("clusterName")
cloudoneProtocol := beego.AppConfig.String("cloudoneProtocol")
cloudoneHost := beego.AppConfig.String("cloudoneHost")
cloudonePort := beego.AppConfig.String("cloudonePort")
glusterfsVolume := c.GetString("glusterfsVolume")
url := cloudoneProtocol + "://" + cloudoneHost + ":" + cloudonePort +
"/api/v1/glusterfs/clusters/" + clusterName + "/volumes/" + glusterfsVolume
tokenHeaderMap, _ := c.GetSession("tokenHeaderMap").(map[string]string)
_, err := restclient.RequestDelete(url, nil, tokenHeaderMap, true)
if identity.IsTokenInvalidAndRedirect(c, c.Ctx, err) {
return
}
if err != nil {
// Error
guimessage.AddDanger(guimessagedisplay.GetErrorMessage(err))
} else {
guimessage.AddSuccess("Glusterfs volume " + glusterfsVolume + " is deleted")
}
// Redirect to list
c.Ctx.Redirect(302, "/gui/filesystem/glusterfs/volume/list?clusterName="+clusterName)
guimessage.RedirectMessage(c)
}
示例8: DeleteImageInRepository
func (privateRegistry *PrivateRegistry) DeleteImageInRepository(repositoryName string, tag string) error {
request, err := http.NewRequest("GET", privateRegistry.getPrivateRegistryEndpoint()+"/v2/"+repositoryName+"/manifests/"+tag, nil)
if err != nil {
log.Error(err)
return err
}
// For registry version 2.3 and later
request.Header.Add("Accept", "application/vnd.docker.distribution.manifest.v2+json")
response, err := restclient.GetInsecureHTTPSClient().Do(request)
if err != nil {
log.Error(err)
return err
}
digest := response.Header.Get("Docker-Content-Digest")
if len(digest) == 0 {
// The tag has no image
return nil
}
_, err = restclient.RequestDelete(privateRegistry.getPrivateRegistryEndpoint()+"/v2/"+repositoryName+"/manifests/"+digest, nil, nil, false)
requestError, _ := err.(restclient.RequestError)
if requestError.StatusCode == 404 {
// Not found so the target doesn't exist
return nil
}
if err != nil {
log.Error(err)
return err
}
return nil
}
示例9: Get
func (c *DeleteController) Get() {
guimessage := guimessagedisplay.GetGUIMessage(c)
cloudoneProtocol := beego.AppConfig.String("cloudoneProtocol")
cloudoneHost := beego.AppConfig.String("cloudoneHost")
cloudonePort := beego.AppConfig.String("cloudonePort")
ip := c.GetString("ip")
url := cloudoneProtocol + "://" + cloudoneHost + ":" + cloudonePort +
"/api/v1/hosts/credentials/" + ip
tokenHeaderMap, _ := c.GetSession("tokenHeaderMap").(map[string]string)
_, err := restclient.RequestDelete(url, nil, tokenHeaderMap, true)
if identity.IsTokenInvalidAndRedirect(c, c.Ctx, err) {
return
}
if err != nil {
// Error
guimessage.AddDanger(guimessagedisplay.GetErrorMessage(err))
} else {
guimessage.AddSuccess("Credential " + ip + " is deleted")
}
// Redirect to list
c.Ctx.Redirect(302, "/gui/system/host/credential/list")
guimessage.RedirectMessage(c)
}
示例10: DeleteReplicationController
func DeleteReplicationController(kubeApiServerEndPoint string, kubeApiServerToken string, namespace string, replicationControllerName string) (returnedError error) {
defer func() {
if err := recover(); err != nil {
log.Error("DeleteReplicationController Error: %s", err)
log.Error(logger.GetStackTrace(4096, false))
returnedError = err.(error)
}
}()
headerMap := make(map[string]string)
headerMap["Authorization"] = kubeApiServerToken
url := kubeApiServerEndPoint + "/api/v1/namespaces/" + namespace + "/replicationcontrollers/" + replicationControllerName
_, err := restclient.RequestDelete(url, nil, headerMap, true)
return err
}
示例11: DeleteNamespace
func DeleteNamespace(kubeApiServerEndPoint string, kubeApiServerToken string, name string) (returnedError error) {
defer func() {
if err := recover(); err != nil {
log.Error("DeleteNamespace Error: %s", err)
log.Error(logger.GetStackTrace(4096, false))
returnedError = err.(error)
}
}()
headerMap := make(map[string]string)
headerMap["Authorization"] = kubeApiServerToken
_, err := restclient.RequestDelete(kubeApiServerEndPoint+"/api/v1/namespaces/"+name, nil, headerMap, true)
if err != nil {
log.Error("Fail to delete namespace with endpoint: %s, token: %s, name: %s, error: %s", kubeApiServerEndPoint, kubeApiServerToken, name, err.Error())
return err
}
return nil
}
示例12: DeleteEvent
func DeleteEvent(kubeApiServerEndPoint string, kubeApiServerToken string, selfLink string) (returnedError error) {
defer func() {
if err := recover(); err != nil {
log.Error("DeleteEvent Error: %s", err)
log.Error(logger.GetStackTrace(4096, false))
returnedError = err.(error)
}
}()
headerMap := make(map[string]string)
headerMap["Authorization"] = kubeApiServerToken
_, err := restclient.RequestDelete(kubeApiServerEndPoint+selfLink, nil, headerMap, true)
if err != nil {
log.Error("Fail to delete event selfLink %s with endpoint: %s, token: %s, error: %s", selfLink, kubeApiServerEndPoint, kubeApiServerToken, err.Error())
return err
}
return nil
}
示例13: Delete
// @Title delete
// @Description delete the namespace
// @Param name path string true "The name of namespace"
// @Success 200 {string} {}
// @Failure 404 error reason
// @router /:name [delete]
func (c *DeleteController) Delete() {
name := c.GetString(":name")
cloudoneProtocol := beego.AppConfig.String("cloudoneProtocol")
cloudoneHost := beego.AppConfig.String("cloudoneHost")
cloudonePort := beego.AppConfig.String("cloudonePort")
url := cloudoneProtocol + "://" + cloudoneHost + ":" + cloudonePort +
"/api/v1/namespaces/" + name
tokenHeaderMap, _ := c.GetSession("tokenHeaderMap").(map[string]string)
_, err := restclient.RequestDelete(url, nil, tokenHeaderMap, true)
if identity.IsTokenInvalidAndRedirect(c, c.Ctx, err) {
return
}
if err != nil {
// Error
c.Data["json"] = make(map[string]interface{})
c.Data["json"].(map[string]interface{})["error"] = err.Error()
c.Ctx.Output.Status = 404
c.ServeJSON()
return
} else {
selectedNamespace := c.GetSession("namespace")
if selectedNamespace.(string) == name {
c.SetSession("namespace", "default")
}
time.Sleep(1000 * time.Millisecond)
c.Data["json"] = make(map[string]interface{})
c.ServeJSON()
}
}
示例14: RequestDeleteBuildLog
func RequestDeleteBuildLog(imageInformationName string, imageRecordVersion string) error {
cloudoneAnalysisHost, ok := configuration.LocalConfiguration.GetString("cloudoneAnalysisHost")
if ok == false {
log.Error("Fail to get configuration cloudoneAnalysisHost")
return errors.New("Fail to get configuration cloudoneAnalysisHost")
}
cloudoneAnalysisPort, ok := configuration.LocalConfiguration.GetInt("cloudoneAnalysisPort")
if ok == false {
log.Error("Fail to get configuration cloudoneAnalysisPort")
return errors.New("Fail to get configuration cloudoneAnalysisPort")
}
url := "https://" + cloudoneAnalysisHost + ":" + strconv.Itoa(cloudoneAnalysisPort) + "/api/v1/buildlogs/" + imageInformationName + "/" + imageRecordVersion
headerMap := make(map[string]string)
headerMap["token"] = authorization.SystemAdminToken
_, err := restclient.RequestDelete(url, nil, headerMap, false)
if err != nil {
log.Error("Fail to request delete build image information %s version %s log with error %s", imageInformationName, imageRecordVersion, err)
}
return err
}
示例15: Get
func (c *DeleteController) Get() {
guimessage := guimessagedisplay.GetGUIMessage(c)
name := c.GetString("name")
cloudoneProtocol := beego.AppConfig.String("cloudoneProtocol")
cloudoneHost := beego.AppConfig.String("cloudoneHost")
cloudonePort := beego.AppConfig.String("cloudonePort")
// Delete deploy
url := cloudoneProtocol + "://" + cloudoneHost + ":" + cloudonePort +
"/api/v1/deploys/" + name
deployInformationSlice := make([]deploy.DeployInformation, 0)
tokenHeaderMap, _ := c.GetSession("tokenHeaderMap").(map[string]string)
_, err := restclient.RequestGetWithStructure(url, &deployInformationSlice, tokenHeaderMap)
if identity.IsTokenInvalidAndRedirect(c, c.Ctx, err) {
return
}
if err != nil {
// Error
guimessage.AddDanger(guimessagedisplay.GetErrorMessage(err))
} else {
for _, deployInformation := range deployInformationSlice {
url := cloudoneProtocol + "://" + cloudoneHost + ":" + cloudonePort +
"/api/v1/deploys/" + name + "/" + deployInformation.ImageInformationName
_, err := restclient.RequestDelete(url, nil, tokenHeaderMap, true)
if identity.IsTokenInvalidAndRedirect(c, c.Ctx, err) {
return
}
if err != nil {
guimessage.AddDanger(guimessagedisplay.GetErrorMessage(err))
}
}
}
// Delete third party service
url = cloudoneProtocol + "://" + cloudoneHost + ":" + cloudonePort +
"/api/v1/deployclusterapplications/" + name
deployClusterApplicationSlice := make([]deployclusterapplication.DeployClusterApplication, 0)
_, err = restclient.RequestGetWithStructure(url, &deployClusterApplicationSlice, tokenHeaderMap)
if identity.IsTokenInvalidAndRedirect(c, c.Ctx, err) {
return
}
if err != nil {
// Error
guimessage.AddDanger(guimessagedisplay.GetErrorMessage(err))
} else {
for _, deployClusterApplication := range deployClusterApplicationSlice {
url := cloudoneProtocol + "://" + cloudoneHost + ":" + cloudonePort +
"/api/v1/deployclusterapplications/" + name + "/" + deployClusterApplication.Name
_, err := restclient.RequestDelete(url, nil, tokenHeaderMap, true)
if identity.IsTokenInvalidAndRedirect(c, c.Ctx, err) {
return
}
if err != nil {
guimessage.AddDanger(guimessagedisplay.GetErrorMessage(err))
}
}
}
// Delete namespace
url = cloudoneProtocol + "://" + cloudoneHost + ":" + cloudonePort +
"/api/v1/namespaces/" + name
_, err = restclient.RequestDelete(url, nil, tokenHeaderMap, true)
if identity.IsTokenInvalidAndRedirect(c, c.Ctx, err) {
return
}
if err != nil {
// Error
guimessage.AddDanger(guimessagedisplay.GetErrorMessage(err))
} else {
guimessage.AddSuccess("Namespace " + name + " is deleted")
selectedNamespace := c.GetSession("namespace")
if selectedNamespace.(string) == name {
c.SetSession("namespace", "default")
}
}
// Delete autoscaler
url = cloudoneProtocol + "://" + cloudoneHost + ":" + cloudonePort +
"/api/v1/autoscalers/"
//.........這裏部分代碼省略.........