auto_delete.go 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // Copyright 2019 Yunion
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. // Licensed under the Apache License, Version 2.0 (the "License");
  15. // you may not use this file except in compliance with the License.
  16. // You may obtain a copy of the License at
  17. //
  18. // http://www.apache.org/licenses/LICENSE-2.0
  19. //
  20. // Unless required by applicable law or agreed to in writing, software
  21. // distributed under the License is distributed on an "AS IS" BASIS,
  22. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  23. // See the License for the specific language governing permissions and
  24. // limitations under the License.
  25. // Code generated by model-api-gen. DO NOT EDIT.
  26. package db
  27. import (
  28. "context"
  29. "yunion.io/x/sqlchemy"
  30. "yunion.io/x/onecloud/pkg/apis"
  31. "yunion.io/x/onecloud/pkg/mcclient"
  32. )
  33. // +onecloud:model-api-gen
  34. type SAutoDeleteResourceBase struct {
  35. // 是否跟随资源自动删除
  36. // example: false
  37. AutoDelete bool `nullable:"false" default:"false" get:"user" update:"user" json:"auto_delete"`
  38. }
  39. type SAutoDeleteResourceBaseManager struct{}
  40. func (manager *SAutoDeleteResourceBaseManager) ListItemFilter(
  41. ctx context.Context,
  42. q *sqlchemy.SQuery,
  43. userCred mcclient.TokenCredential,
  44. query apis.AutoDeleteResourceBaseListInput,
  45. ) (*sqlchemy.SQuery, error) {
  46. if query.AutoDelete != nil {
  47. q = q.Equals("auto_delete", *query.AutoDelete)
  48. }
  49. return q, nil
  50. }
  51. func (self *SAutoDeleteResourceBase) SetAutoDelete(model IModel, userCred mcclient.TokenCredential, autoDelete bool) error {
  52. _, err := Update(model, func() error {
  53. self.AutoDelete = autoDelete
  54. return nil
  55. })
  56. return err
  57. }