v1.0.0
This commit is contained in:
commit
e7f605ec8c
292 files changed
+43992
No files matched your search
@@ -0,0 +1,4 @@
|
||||
Makefile
|
||||
.gitlab
|
||||
.idea
|
||||
/examples/05_file/downloaded_image.img
|
||||
@@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright 2022 Basis LTD
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@@ -0,0 +1,179 @@
|
||||
# Базис.Digital Energy GO SDK
|
||||
|
||||
Go SDK для работы с Базис.Digital Energy.
|
||||
|
||||
Примеры работы можно увидеть в [examples](examples):
|
||||
|
||||
1. [examples/01_credentials_auth](examples/01_credentials_auth/main.go) - аутентификация по логину и паролю и получение
|
||||
версий SDK, DE и DX.
|
||||
2. [examples/02_token_auth](examples/02_token_auth/main.go) - проверка готового токена через `AuthenticateWithToken` и
|
||||
получение списка кластеров.
|
||||
3. [examples/03_explicit_config](examples/03_explicit_config/main.go) - создание клиента при помощи расширенной
|
||||
конфигурации с собственным HTTP-клиентом, User-Agent и заголовком.
|
||||
4. [examples/04_cluster_create](examples/04_cluster_create/main.go) - создание кластера и ожидание фоновой задачи.
|
||||
5. [examples/05_file](examples/05_file/main.go) - потоковая загрузка OCI-образа в istore и его скачивание.
|
||||
|
||||
## Аутентификация
|
||||
|
||||
- Используйте `client.Authenticate()` для логина и пароля или `client.AuthenticateWithToken()` для токена. По умолчанию
|
||||
оба метода проверяют доступ к DE и совместимость версий.
|
||||
- `client.SetToken()` только устанавливает токен без проверки совместимости с DE. Желательно использовать
|
||||
`client.AuthenticateWithToken()`.
|
||||
- `cfg.SkipCompatibilityCheck = true` отключает автоматическую проверку в методах аутентификации. Явный
|
||||
`client.CheckCompatibility()` выполняется вне зависимости от этой настройки.
|
||||
|
||||
## Совместимость версий
|
||||
|
||||
| Версия SDK | Поддерживаемая версия DE |
|
||||
|------------|--------------------------|
|
||||
| `1.x.x` | `1.8.x` |
|
||||
|
||||
С выходом DE 1.9.0 будет выпущена новая major-версия SDK `v2`. Путь Go-модуля и импорт будут содержать суффикс `/v2`:
|
||||
|
||||
```go
|
||||
import desdk "repository.basistech.ru/BASIS/de-golang-sdk/v2"
|
||||
```
|
||||
|
||||
## Детали
|
||||
|
||||
1. Почти для всех функций применима логика "Эндпоинт E из группы эндпоинтов G имеет структуру запроса G.ERequest".
|
||||
1. Например, `client.DeCluster.List(ctx, req)` имеет структуру запроса `de_cluster.ListRequest{}`.
|
||||
2. В качестве документации в структурах запросов в комментариях помимо пояснений может быть указано, является ли поле
|
||||
обязательным и (если применимо) набор возможных значений.
|
||||
1. Например, в запросе на установку GitLab:
|
||||
```go
|
||||
type InstallRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// hostname for gitlab
|
||||
//
|
||||
// Required.
|
||||
Hostname string `json:"hostname" form:"hostname"`
|
||||
// Hostname for integagent
|
||||
IntegagentHostname string `json:"integagentHostname,omitempty" form:"integagentHostname,omitempty"`
|
||||
// storage type
|
||||
//
|
||||
// Allowed values:
|
||||
// - "longhorn"
|
||||
// - "glusterfs"
|
||||
// - ""
|
||||
StorageClass string `json:"storageClass,omitempty" form:"storageClass,omitempty"`
|
||||
// ...
|
||||
}
|
||||
```
|
||||
3. **В запросах задавайте все важные опциональные параметры, иначе будет задано zero value.**
|
||||
1. Например, в DE 1.8.0 в `/digitalenergy/cluster/updateWorkerGroup` есть опциональный параметр
|
||||
`MinWorkerCount int64`. Если его не задавать, будет отправлен `0` (zero value для `int64`).
|
||||
2. Исключением являются запросы с указателями - например, в DE 1.8.0 в `/digitalenergy/istore/charts/update` есть
|
||||
опциональный параметр `Description *string`. Если не задавать его, то значением по умолчанию будет `nil`, в таком
|
||||
случае DE не будет обновлять описание. Если явно задать `""` или `"some description"`, то поле обновится.
|
||||
4. Ответы DE приходят в унифицированном формате, который парсится внутри SDK.
|
||||
1. Например, если мы запрашиваем список пользователей, то **из API** возвращается не просто `[]User{...}`, а
|
||||
`{error: true/false, errorCode: 0, message: "string", result: []User{...}}`.
|
||||
2. Поля `error`, `errorCode`, `message` автоматически проверяются внутри SDK.
|
||||
3. Методы SDK возвращают полезную нагрузку (то есть `[]User{...}`) и, при необходимости, код и текст ошибки.
|
||||
4. Например, `List() ([]User, error)` может вернуть
|
||||
`nil, "code: 101, message: Authorization error: exp not satisfied"`.
|
||||
5. SDK генерируется из swagger DE.
|
||||
|
||||
## Список API
|
||||
|
||||
### Базис.Digital Energy
|
||||
|
||||
| Клиент | Назначение |
|
||||
|---------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| [`DeAPISIX`](tags/de_apisix) | Установка APISIX (API-шлюз, предназначенный для управления, обеспечения безопасности и маршрутизации трафика в кластере Kubernetes) |
|
||||
| [`DeAudits`](tags/de_audits) | Подготовка ссылок на скачивание журналов аудита Kubernetes |
|
||||
| [`DeAutoscaler`](tags/de_autoscaler) | Управление автомасштабированием Deployment в Kubernetes (HPA) |
|
||||
| [`DeCertificates`](tags/de_certificates) | Проверка и обновление сертификатов kubeadm |
|
||||
| [`DeCertmanager`](tags/de_certmanager) | Установка Certmanager (утилита для удалённого управления сертификатами) |
|
||||
| [`DeCluster`](tags/de_cluster) | Управление Kubernetes-кластерами |
|
||||
| [`DeClusterTemplate`](tags/de_cluster_template) | Управление шаблонами Kubernetes-кластеров |
|
||||
| [`DeCodeScoring`](tags/de_codescoring) | Установка CodeScoring (композиционный анализ программных проектов) |
|
||||
| [`DeCriobox`](tags/de_criobox) | Установка Criobox (утилита для взаимодействия с CRI-O) |
|
||||
| [`DeCustomApp`](tags/de_customapp) | Установка пользовательских приложений |
|
||||
| [`DeDatabase`](tags/de_database) | Создание и удаление баз данных и пользователей PostgreSQL (требуется установленный PostgreSQL HA) |
|
||||
| [`DeDependencyTrack`](tags/de_dependency_track) | Установка Dependency-Track (мониторинг уязвимостей зависимостей) |
|
||||
| [`DeDeployment`](tags/de_deployment) | Получение информации о сборке demanager |
|
||||
| [`DeFiles`](tags/de_files) | Загрузка временных файлов на сервер DE |
|
||||
| [`DeGitLab`](tags/de_gitlab) | Установка GitLab (Git-репозиторий и DevOps-платформа) |
|
||||
| [`DeGrafana`](tags/de_grafana) | Установка Grafana (визуализация метрик и мониторинг) |
|
||||
| [`DeGroup`](tags/de_group) | Управление группами пользователей DE |
|
||||
| [`DeHarbor`](tags/de_harbor) | Установка Harbor (реестр контейнерных образов) |
|
||||
| [`DeIngressNginx`](tags/de_ingress_nginx) | Установка NGINX Ingress Controller (маршрутизация входящего трафика в Kubernetes) |
|
||||
| [`DeIntegagent`](tags/de_integagent) | Установка Integagent (управление пользователями в PostgreSQL для приложений из маркетплейса) |
|
||||
| [`DeIstio`](tags/de_istio) | Установка Istio (service mesh для Kubernetes) |
|
||||
| [`DeIstore`](tags/de_istore) | Работа с istore (чарты, образы и журнал операций) |
|
||||
| [`DeJenkins`](tags/de_jenkins) | Установка Jenkins (сервер CI/CD) |
|
||||
| [`DeKubernetesUser`](tags/de_kubernetes_user) | Управление пользователями Kubernetes и их правами доступа (настройка RBAC) |
|
||||
| [`DeKyverno`](tags/de_kyverno) | Установка Kyverno (проверка ресурсов Kubernetes по правилам) |
|
||||
| [`DeKyvernoPolicy`](tags/de_kyverno_policy) | Управление политиками Kyverno |
|
||||
| [`DeLogWatcher`](tags/de_logwatcher) | Обновление LogWatcher (сервис записи аудитов на управляющих узлах кластера) |
|
||||
| [`DeLonghorn`](tags/de_longhorn) | Установка Longhorn (распределённое хранилище для Kubernetes) |
|
||||
| [`DeLrecords`](tags/de_lrecords) | Загрузка логов из кластера |
|
||||
| [`DeMetrics`](tags/de_metrics) | Получение и удаление метрик кластера, управление сборщиками метрик (Observer) |
|
||||
| [`DeMinIO`](tags/de_minio) | Установка MinIO (S3-совместимое объектное хранилище) |
|
||||
| [`DeNexus`](tags/de_nexus) | Установка Nexus Repository (репозиторий артефактов) |
|
||||
| [`DeNotification`](tags/de_notification) | Управление уведомлениями |
|
||||
| [`DeOpenELB`](tags/de_openelb) | Установка OpenELB (балансировщик нагрузки для Kubernetes) |
|
||||
| [`DeOperation`](tags/de_operation) | Управление журналом операций (действий) пользователей |
|
||||
| [`DePodLogger`](tags/de_podlogger) | Установка и настройка PodLogger (сборка логов подов в кластере) |
|
||||
| [`DePostgreSQLHA`](tags/de_postgresql_ha) | Установка PostgreSQL HA (отказоустойчивый кластер PostgreSQL) |
|
||||
| [`DeProducts`](tags/de_products) | Получение информации о продуктах и их состоянии в кластере |
|
||||
| [`DePrometheus`](tags/de_prometheus) | Установка Prometheus (сбор и хранение метрик) |
|
||||
| [`DeProperty`](tags/de_property) | Получение информации о конфигурации demanager |
|
||||
| [`DeRBACManager`](tags/de_rbacmanager) | Установка RBAC Manager (управление ролями Kubernetes) |
|
||||
| [`DeRedisCluster`](tags/de_redis_cluster) | Установка Redis Cluster (кластер in-memory СУБД Redis) |
|
||||
| [`DeRedmine`](tags/de_redmine) | Установка Redmine (система управления проектами) |
|
||||
| [`DeReportCluster`](tags/de_report_cluster) | Управление отчётами проверок кластера (Kyverno, конфигурация и уязвимости) |
|
||||
| [`DeRepositoryApps`](tags/de_repository_apps) | Управление репозиториями приложений |
|
||||
| [`DeRepositoryCharts`](tags/de_repository_charts) | Управление репозиториями Helm-чартов |
|
||||
| [`DeRepositoryFiles`](tags/de_repository_files) | Управление репозиториями файлов |
|
||||
| [`DeRepositoryKube`](tags/de_repository_kube) | Управление репозиториями пакетов Kubernetes |
|
||||
| [`DeServchecker`](tags/de_servchecker) | Установка Servchecker (мониторинг процесса установки приложений в кластере) |
|
||||
| [`DeSonarQube`](tags/de_sonarqube) | Установка SonarQube (анализ качества кода) |
|
||||
| [`DeSvacer`](tags/de_svacer) | Установка Svacer (хранение и обработка результатов статического анализа) |
|
||||
| [`DeTask`](tags/de_task) | Отслеживание фоновых задач DE (например, задачи создания кластера) |
|
||||
| [`DeTrivy`](tags/de_trivy) | Установка Trivy (сканер уязвимостей) |
|
||||
| [`DeUser`](tags/de_user) | Управление пользователями Базис.Digital Energy |
|
||||
| [`DeVault`](tags/de_vault) | Установка Vault (хранилище секретов) |
|
||||
| [`DeWorkerGroup`](tags/de_worker_group) | Управление группами рабочих узлов Kubernetes |
|
||||
| [`DeX509`](tags/de_x509) | Генерация CA-сертификатов |
|
||||
|
||||
### Базис.Dynamix
|
||||
|
||||
| Клиент | Назначение |
|
||||
|--------------------------------|---------------------------------------------------|
|
||||
| [`DxAccount`](tags/dx_account) | Чтение Аккаунтов Базис.Dynamix |
|
||||
| [`DxCompute`](tags/dx_compute) | Чтение и удаление Виртуальных машин Базис.Dynamix |
|
||||
| [`DxDisks`](tags/dx_disks) | Чтение типов Дисков Базис.Dynamix |
|
||||
| [`DxExtNet`](tags/dx_extnet) | Чтение Внешних сетей Базис.Dynamix |
|
||||
| [`DxImage`](tags/dx_image) | Чтение Образов Базис.Dynamix |
|
||||
| [`DxK8CI`](tags/dx_k8ci) | Чтение конфигураций K8CI Базис.Dynamix |
|
||||
| [`DxRG`](tags/dx_rg) | Чтение Ресурсных Групп Базис.Dynamix |
|
||||
| [`DxSP`](tags/dx_sp) | Чтение Политик хранения Базис.Dynamix |
|
||||
| [`DxTasks`](tags/dx_tasks) | Чтение Процессов Базис.Dynamix |
|
||||
| [`DxVersion`](tags/dx_version) | Чтение версии Базис.Dynamix |
|
||||
| [`DxVGPU`](tags/dx_vgpu) | Чтение Виртуальных GPU Базис.Dynamix |
|
||||
| [`DxViNS`](tags/dx_vins) | Чтение Внутренних сетей (ViNS) Базис.Dynamix |
|
||||
|
||||
### Авторизация
|
||||
|
||||
| Клиент | Назначение |
|
||||
|---------------------------|---------------------------------------|
|
||||
| [`Session`](tags/session) | Получение, обновление и отзыв токенов |
|
||||
| [`OpenID`](tags/openid) | Вход через OpenID Connect |
|
||||
|
||||
### Управление пользователями продуктов
|
||||
|
||||
| Клиент | Назначение |
|
||||
|-----------------------------------------------------|----------------------------------------------------------------------------------|
|
||||
| [`ProdDependencyTrack`](tags/prod_dependency_track) | Управление пользователями Dependency-Track (мониторинг уязвимостей зависимостей) |
|
||||
| [`ProdGitLab`](tags/prod_gitlab) | Управление пользователями GitLab (Git-репозиторий и DevOps-платформа) |
|
||||
| [`ProdHarbor`](tags/prod_harbor) | Управление пользователями Harbor (реестр контейнерных образов) |
|
||||
| [`ProdJenkins`](tags/prod_jenkins) | Управление пользователями Jenkins (сервер CI/CD) |
|
||||
| [`ProdNexus`](tags/prod_nexus) | Управление пользователями Nexus (репозиторий артефактов) |
|
||||
| [`ProdRedmine`](tags/prod_redmine) | Управление пользователями Redmine (система управления проектами) |
|
||||
| [`ProdSonarQube`](tags/prod_sonarqube) | Управление пользователями SonarQube (анализ качества кода) |
|
||||
@@ -0,0 +1,293 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package desdk
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/core"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/de_apisix"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/de_audits"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/de_autoscaler"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/de_certificates"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/de_certmanager"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/de_cluster"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/de_cluster_template"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/de_codescoring"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/de_criobox"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/de_customapp"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/de_database"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/de_dependency_track"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/de_deployment"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/de_files"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/de_gitlab"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/de_grafana"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/de_group"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/de_harbor"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/de_ingress_nginx"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/de_integagent"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/de_istio"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/de_istore"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/de_jenkins"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/de_kubernetes_user"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/de_kyverno"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/de_kyverno_policy"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/de_logwatcher"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/de_longhorn"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/de_lrecords"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/de_metrics"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/de_minio"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/de_nexus"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/de_notification"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/de_openelb"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/de_operation"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/de_podlogger"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/de_postgresql_ha"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/de_products"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/de_prometheus"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/de_property"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/de_rbacmanager"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/de_redis_cluster"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/de_redmine"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/de_report_cluster"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/de_repository_apps"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/de_repository_charts"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/de_repository_files"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/de_repository_kube"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/de_servchecker"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/de_sonarqube"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/de_svacer"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/de_task"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/de_trivy"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/de_user"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/de_vault"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/de_worker_group"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/de_x509"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/dx_account"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/dx_compute"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/dx_disks"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/dx_extnet"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/dx_image"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/dx_k8ci"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/dx_rg"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/dx_sp"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/dx_tasks"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/dx_version"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/dx_vgpu"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/dx_vins"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/openid"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/prod_dependency_track"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/prod_gitlab"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/prod_harbor"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/prod_jenkins"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/prod_nexus"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/prod_redmine"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/prod_sonarqube"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/session"
|
||||
)
|
||||
|
||||
func NewConfiguration() *core.Configuration {
|
||||
return core.NewConfiguration()
|
||||
}
|
||||
|
||||
type Client struct {
|
||||
cfg *core.Configuration
|
||||
|
||||
DeAPISIX *de_apisix.DeAPISIXService
|
||||
DeAudits *de_audits.DeAuditsService
|
||||
DeAutoscaler *de_autoscaler.DeAutoscalerService
|
||||
DeCertificates *de_certificates.DeCertificatesService
|
||||
DeCertmanager *de_certmanager.DeCertmanagerService
|
||||
DeCluster *de_cluster.DeClusterService
|
||||
DeClusterTemplate *de_cluster_template.DeClusterTemplateService
|
||||
DeCodeScoring *de_codescoring.DeCodeScoringService
|
||||
DeCriobox *de_criobox.DeCrioboxService
|
||||
DeCustomApp *de_customapp.DeCustomAppService
|
||||
DeDatabase *de_database.DeDatabaseService
|
||||
DeDependencyTrack *de_dependency_track.DeDependencyTrackService
|
||||
DeDeployment *de_deployment.DeDeploymentService
|
||||
DeFiles *de_files.DeFilesService
|
||||
DeGitLab *de_gitlab.DeGitLabService
|
||||
DeGrafana *de_grafana.DeGrafanaService
|
||||
DeGroup *de_group.DeGroupService
|
||||
DeHarbor *de_harbor.DeHarborService
|
||||
DeIngressNginx *de_ingress_nginx.DeIngressNginxService
|
||||
DeIntegagent *de_integagent.DeIntegagentService
|
||||
DeIstio *de_istio.DeIstioService
|
||||
DeIstore *de_istore.DeIstoreService
|
||||
DeJenkins *de_jenkins.DeJenkinsService
|
||||
DeKubernetesUser *de_kubernetes_user.DeKubernetesUserService
|
||||
DeKyverno *de_kyverno.DeKyvernoService
|
||||
DeKyvernoPolicy *de_kyverno_policy.DeKyvernoPolicyService
|
||||
DeLogWatcher *de_logwatcher.DeLogWatcherService
|
||||
DeLonghorn *de_longhorn.DeLonghornService
|
||||
DeLrecords *de_lrecords.DeLrecordsService
|
||||
DeMetrics *de_metrics.DeMetricsService
|
||||
DeMinIO *de_minio.DeMinIOService
|
||||
DeNexus *de_nexus.DeNexusService
|
||||
DeNotification *de_notification.DeNotificationService
|
||||
DeOpenELB *de_openelb.DeOpenELBService
|
||||
DeOperation *de_operation.DeOperationService
|
||||
DePodLogger *de_podlogger.DePodLoggerService
|
||||
DePostgreSQLHA *de_postgresql_ha.DePostgreSQLHAService
|
||||
DeProducts *de_products.DeProductsService
|
||||
DePrometheus *de_prometheus.DePrometheusService
|
||||
DeProperty *de_property.DePropertyService
|
||||
DeRBACManager *de_rbacmanager.DeRBACManagerService
|
||||
DeRedisCluster *de_redis_cluster.DeRedisClusterService
|
||||
DeRedmine *de_redmine.DeRedmineService
|
||||
DeReportCluster *de_report_cluster.DeReportClusterService
|
||||
DeRepositoryApps *de_repository_apps.DeRepositoryAppsService
|
||||
DeRepositoryCharts *de_repository_charts.DeRepositoryChartsService
|
||||
DeRepositoryFiles *de_repository_files.DeRepositoryFilesService
|
||||
DeRepositoryKube *de_repository_kube.DeRepositoryKubeService
|
||||
DeServchecker *de_servchecker.DeServcheckerService
|
||||
DeSonarQube *de_sonarqube.DeSonarQubeService
|
||||
DeSvacer *de_svacer.DeSvacerService
|
||||
DeTask *de_task.DeTaskService
|
||||
DeTrivy *de_trivy.DeTrivyService
|
||||
DeUser *de_user.DeUserService
|
||||
DeVault *de_vault.DeVaultService
|
||||
DeWorkerGroup *de_worker_group.DeWorkerGroupService
|
||||
DeX509 *de_x509.DeX509Service
|
||||
DxAccount *dx_account.DxAccountService
|
||||
DxCompute *dx_compute.DxComputeService
|
||||
DxDisks *dx_disks.DxDisksService
|
||||
DxExtNet *dx_extnet.DxExtNetService
|
||||
DxImage *dx_image.DxImageService
|
||||
DxK8CI *dx_k8ci.DxK8CIService
|
||||
DxRG *dx_rg.DxRGService
|
||||
DxSP *dx_sp.DxSPService
|
||||
DxTasks *dx_tasks.DxTasksService
|
||||
DxVersion *dx_version.DxVersionService
|
||||
DxVGPU *dx_vgpu.DxVGPUService
|
||||
DxViNS *dx_vins.DxViNSService
|
||||
OpenID *openid.OpenIDService
|
||||
ProdDependencyTrack *prod_dependency_track.ProdDependencyTrackService
|
||||
ProdGitLab *prod_gitlab.ProdGitLabService
|
||||
ProdHarbor *prod_harbor.ProdHarborService
|
||||
ProdJenkins *prod_jenkins.ProdJenkinsService
|
||||
ProdNexus *prod_nexus.ProdNexusService
|
||||
ProdRedmine *prod_redmine.ProdRedmineService
|
||||
ProdSonarQube *prod_sonarqube.ProdSonarQubeService
|
||||
Session *session.SessionService
|
||||
}
|
||||
|
||||
func NewClient(serverURL string, skipCertificateChecks bool) (*Client, error) {
|
||||
cfg := NewConfiguration()
|
||||
cfg.ServerURL = serverURL
|
||||
|
||||
if skipCertificateChecks {
|
||||
defaultTransport, ok := http.DefaultTransport.(*http.Transport)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("clone http.DefaultTransport: got %T, want *http.Transport", http.DefaultTransport)
|
||||
}
|
||||
transport := defaultTransport.Clone()
|
||||
tlsConfig := &tls.Config{}
|
||||
if transport.TLSClientConfig != nil {
|
||||
tlsConfig = transport.TLSClientConfig.Clone()
|
||||
}
|
||||
tlsConfig.InsecureSkipVerify = true
|
||||
transport.TLSClientConfig = tlsConfig
|
||||
cfg.HTTPClient = &http.Client{Transport: transport}
|
||||
}
|
||||
|
||||
return NewClientWithConfig(cfg), nil
|
||||
}
|
||||
|
||||
func NewClientWithConfig(cfg *core.Configuration) *Client {
|
||||
if cfg == nil {
|
||||
cfg = NewConfiguration()
|
||||
}
|
||||
cfg.ServerURL = strings.TrimSuffix(cfg.ServerURL, "/")
|
||||
if !strings.HasSuffix(cfg.ServerURL, "/api/v1") {
|
||||
cfg.ServerURL += "/api/v1"
|
||||
}
|
||||
if cfg.HTTPClient == nil {
|
||||
cfg.HTTPClient = http.DefaultClient
|
||||
}
|
||||
client := &Client{cfg: cfg}
|
||||
client.DeAPISIX = de_apisix.NewAPIClient(cfg).DeAPISIX
|
||||
client.DeAudits = de_audits.NewAPIClient(cfg).DeAudits
|
||||
client.DeAutoscaler = de_autoscaler.NewAPIClient(cfg).DeAutoscaler
|
||||
client.DeCertificates = de_certificates.NewAPIClient(cfg).DeCertificates
|
||||
client.DeCertmanager = de_certmanager.NewAPIClient(cfg).DeCertmanager
|
||||
client.DeCluster = de_cluster.NewAPIClient(cfg).DeCluster
|
||||
client.DeClusterTemplate = de_cluster_template.NewAPIClient(cfg).DeClusterTemplate
|
||||
client.DeCodeScoring = de_codescoring.NewAPIClient(cfg).DeCodeScoring
|
||||
client.DeCriobox = de_criobox.NewAPIClient(cfg).DeCriobox
|
||||
client.DeCustomApp = de_customapp.NewAPIClient(cfg).DeCustomApp
|
||||
client.DeDatabase = de_database.NewAPIClient(cfg).DeDatabase
|
||||
client.DeDependencyTrack = de_dependency_track.NewAPIClient(cfg).DeDependencyTrack
|
||||
client.DeDeployment = de_deployment.NewAPIClient(cfg).DeDeployment
|
||||
client.DeFiles = de_files.NewAPIClient(cfg).DeFiles
|
||||
client.DeGitLab = de_gitlab.NewAPIClient(cfg).DeGitLab
|
||||
client.DeGrafana = de_grafana.NewAPIClient(cfg).DeGrafana
|
||||
client.DeGroup = de_group.NewAPIClient(cfg).DeGroup
|
||||
client.DeHarbor = de_harbor.NewAPIClient(cfg).DeHarbor
|
||||
client.DeIngressNginx = de_ingress_nginx.NewAPIClient(cfg).DeIngressNginx
|
||||
client.DeIntegagent = de_integagent.NewAPIClient(cfg).DeIntegagent
|
||||
client.DeIstio = de_istio.NewAPIClient(cfg).DeIstio
|
||||
client.DeIstore = de_istore.NewAPIClient(cfg).DeIstore
|
||||
client.DeJenkins = de_jenkins.NewAPIClient(cfg).DeJenkins
|
||||
client.DeKubernetesUser = de_kubernetes_user.NewAPIClient(cfg).DeKubernetesUser
|
||||
client.DeKyverno = de_kyverno.NewAPIClient(cfg).DeKyverno
|
||||
client.DeKyvernoPolicy = de_kyverno_policy.NewAPIClient(cfg).DeKyvernoPolicy
|
||||
client.DeLogWatcher = de_logwatcher.NewAPIClient(cfg).DeLogWatcher
|
||||
client.DeLonghorn = de_longhorn.NewAPIClient(cfg).DeLonghorn
|
||||
client.DeLrecords = de_lrecords.NewAPIClient(cfg).DeLrecords
|
||||
client.DeMetrics = de_metrics.NewAPIClient(cfg).DeMetrics
|
||||
client.DeMinIO = de_minio.NewAPIClient(cfg).DeMinIO
|
||||
client.DeNexus = de_nexus.NewAPIClient(cfg).DeNexus
|
||||
client.DeNotification = de_notification.NewAPIClient(cfg).DeNotification
|
||||
client.DeOpenELB = de_openelb.NewAPIClient(cfg).DeOpenELB
|
||||
client.DeOperation = de_operation.NewAPIClient(cfg).DeOperation
|
||||
client.DePodLogger = de_podlogger.NewAPIClient(cfg).DePodLogger
|
||||
client.DePostgreSQLHA = de_postgresql_ha.NewAPIClient(cfg).DePostgreSQLHA
|
||||
client.DeProducts = de_products.NewAPIClient(cfg).DeProducts
|
||||
client.DePrometheus = de_prometheus.NewAPIClient(cfg).DePrometheus
|
||||
client.DeProperty = de_property.NewAPIClient(cfg).DeProperty
|
||||
client.DeRBACManager = de_rbacmanager.NewAPIClient(cfg).DeRBACManager
|
||||
client.DeRedisCluster = de_redis_cluster.NewAPIClient(cfg).DeRedisCluster
|
||||
client.DeRedmine = de_redmine.NewAPIClient(cfg).DeRedmine
|
||||
client.DeReportCluster = de_report_cluster.NewAPIClient(cfg).DeReportCluster
|
||||
client.DeRepositoryApps = de_repository_apps.NewAPIClient(cfg).DeRepositoryApps
|
||||
client.DeRepositoryCharts = de_repository_charts.NewAPIClient(cfg).DeRepositoryCharts
|
||||
client.DeRepositoryFiles = de_repository_files.NewAPIClient(cfg).DeRepositoryFiles
|
||||
client.DeRepositoryKube = de_repository_kube.NewAPIClient(cfg).DeRepositoryKube
|
||||
client.DeServchecker = de_servchecker.NewAPIClient(cfg).DeServchecker
|
||||
client.DeSonarQube = de_sonarqube.NewAPIClient(cfg).DeSonarQube
|
||||
client.DeSvacer = de_svacer.NewAPIClient(cfg).DeSvacer
|
||||
client.DeTask = de_task.NewAPIClient(cfg).DeTask
|
||||
client.DeTrivy = de_trivy.NewAPIClient(cfg).DeTrivy
|
||||
client.DeUser = de_user.NewAPIClient(cfg).DeUser
|
||||
client.DeVault = de_vault.NewAPIClient(cfg).DeVault
|
||||
client.DeWorkerGroup = de_worker_group.NewAPIClient(cfg).DeWorkerGroup
|
||||
client.DeX509 = de_x509.NewAPIClient(cfg).DeX509
|
||||
client.DxAccount = dx_account.NewAPIClient(cfg).DxAccount
|
||||
client.DxCompute = dx_compute.NewAPIClient(cfg).DxCompute
|
||||
client.DxDisks = dx_disks.NewAPIClient(cfg).DxDisks
|
||||
client.DxExtNet = dx_extnet.NewAPIClient(cfg).DxExtNet
|
||||
client.DxImage = dx_image.NewAPIClient(cfg).DxImage
|
||||
client.DxK8CI = dx_k8ci.NewAPIClient(cfg).DxK8CI
|
||||
client.DxRG = dx_rg.NewAPIClient(cfg).DxRG
|
||||
client.DxSP = dx_sp.NewAPIClient(cfg).DxSP
|
||||
client.DxTasks = dx_tasks.NewAPIClient(cfg).DxTasks
|
||||
client.DxVersion = dx_version.NewAPIClient(cfg).DxVersion
|
||||
client.DxVGPU = dx_vgpu.NewAPIClient(cfg).DxVGPU
|
||||
client.DxViNS = dx_vins.NewAPIClient(cfg).DxViNS
|
||||
client.OpenID = openid.NewAPIClient(cfg).OpenID
|
||||
client.ProdDependencyTrack = prod_dependency_track.NewAPIClient(cfg).ProdDependencyTrack
|
||||
client.ProdGitLab = prod_gitlab.NewAPIClient(cfg).ProdGitLab
|
||||
client.ProdHarbor = prod_harbor.NewAPIClient(cfg).ProdHarbor
|
||||
client.ProdJenkins = prod_jenkins.NewAPIClient(cfg).ProdJenkins
|
||||
client.ProdNexus = prod_nexus.NewAPIClient(cfg).ProdNexus
|
||||
client.ProdRedmine = prod_redmine.NewAPIClient(cfg).ProdRedmine
|
||||
client.ProdSonarQube = prod_sonarqube.NewAPIClient(cfg).ProdSonarQube
|
||||
client.Session = session.NewAPIClient(cfg).Session
|
||||
|
||||
return client
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package core
|
||||
|
||||
import (
|
||||
"maps"
|
||||
"net/http"
|
||||
"runtime/debug"
|
||||
"strings"
|
||||
"sync"
|
||||
)
|
||||
|
||||
const sdkModulePath = "repository.basistech.ru/BASIS/de-golang-sdk"
|
||||
|
||||
type Configuration struct {
|
||||
ServerURL string `json:"serverURL,omitempty"`
|
||||
UserAgent string `json:"userAgent,omitempty"`
|
||||
HTTPClient *http.Client
|
||||
// SkipCompatibilityCheck disables the automatic compatibility checks performed during authentication.
|
||||
//
|
||||
// It does not affect explicit CheckCompatibility calls.
|
||||
SkipCompatibilityCheck bool `json:"skipCompatibilityCheck,omitempty"`
|
||||
|
||||
defaultHeaderMu sync.RWMutex
|
||||
defaultHeader map[string]string
|
||||
}
|
||||
|
||||
func NewConfiguration() *Configuration {
|
||||
return &Configuration{
|
||||
defaultHeader: make(map[string]string),
|
||||
UserAgent: "de-golang-sdk/" + SDKVersion(),
|
||||
}
|
||||
}
|
||||
|
||||
// Clone returns an independent configuration copy. The HTTP client is shared,
|
||||
// while the default headers use independent storage and synchronization.
|
||||
func (c *Configuration) Clone() *Configuration {
|
||||
if c == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
c.defaultHeaderMu.RLock()
|
||||
defer c.defaultHeaderMu.RUnlock()
|
||||
|
||||
return &Configuration{
|
||||
ServerURL: c.ServerURL,
|
||||
UserAgent: c.UserAgent,
|
||||
HTTPClient: c.HTTPClient,
|
||||
SkipCompatibilityCheck: c.SkipCompatibilityCheck,
|
||||
defaultHeader: maps.Clone(c.defaultHeader),
|
||||
}
|
||||
}
|
||||
|
||||
// SDKVersion returns the module version embedded in the running program.
|
||||
func SDKVersion() string {
|
||||
buildInfo, ok := debug.ReadBuildInfo()
|
||||
if !ok {
|
||||
return "devel"
|
||||
}
|
||||
|
||||
return sdkVersionFromBuildInfo(buildInfo)
|
||||
}
|
||||
|
||||
func sdkVersionFromBuildInfo(buildInfo *debug.BuildInfo) string {
|
||||
if buildInfo == nil {
|
||||
return "devel"
|
||||
}
|
||||
|
||||
modules := append([]*debug.Module{&buildInfo.Main}, buildInfo.Deps...)
|
||||
for _, module := range modules {
|
||||
if module == nil || module.Path != sdkModulePath {
|
||||
continue
|
||||
}
|
||||
if module.Replace != nil {
|
||||
module = module.Replace
|
||||
}
|
||||
|
||||
version := strings.TrimPrefix(module.Version, "v")
|
||||
if version == "" || version == "(devel)" {
|
||||
return "devel"
|
||||
}
|
||||
|
||||
return version
|
||||
}
|
||||
|
||||
return "devel"
|
||||
}
|
||||
|
||||
func (c *Configuration) AddDefaultHeader(key, value string) {
|
||||
c.defaultHeaderMu.Lock()
|
||||
defer c.defaultHeaderMu.Unlock()
|
||||
|
||||
if c.defaultHeader == nil {
|
||||
c.defaultHeader = make(map[string]string)
|
||||
}
|
||||
c.defaultHeader[http.CanonicalHeaderKey(key)] = value
|
||||
}
|
||||
|
||||
func (c *Configuration) DefaultHeaders() map[string]string {
|
||||
c.defaultHeaderMu.RLock()
|
||||
defer c.defaultHeaderMu.RUnlock()
|
||||
|
||||
return maps.Clone(c.defaultHeader)
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package core
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// HTTPError is returned for a non-2xx HTTP response.
|
||||
type HTTPError struct {
|
||||
StatusCode int
|
||||
Header http.Header
|
||||
Body []byte
|
||||
}
|
||||
|
||||
func (e *HTTPError) Error() string {
|
||||
status := fmt.Sprintf("HTTP %d", e.StatusCode)
|
||||
if statusText := http.StatusText(e.StatusCode); statusText != "" {
|
||||
status += " " + statusText
|
||||
}
|
||||
if len(e.Body) == 0 {
|
||||
return status
|
||||
}
|
||||
return status + ": " + string(e.Body)
|
||||
}
|
||||
|
||||
// BackendError is returned when the backend reports an error in an otherwise
|
||||
// successful HTTP response.
|
||||
type BackendError struct {
|
||||
Code int64
|
||||
Message string
|
||||
}
|
||||
|
||||
func (e *BackendError) Error() string {
|
||||
return fmt.Sprintf("code: %v, message: %v", e.Code, e.Message)
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package core
|
||||
|
||||
import "io"
|
||||
|
||||
// UploadFile describes a file part in a multipart request. The SDK reads from
|
||||
// Reader but does not close it.
|
||||
type UploadFile struct {
|
||||
Filename string
|
||||
Reader io.Reader
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/core"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var (
|
||||
serverURL = os.Getenv("DESDK_SERVER_URL")
|
||||
|
||||
username = os.Getenv("DESDK_USERNAME")
|
||||
password = os.Getenv("DESDK_PASSWORD")
|
||||
)
|
||||
if serverURL == "" || username == "" || password == "" {
|
||||
log.Fatal("DESDK_SERVER_URL, DESDK_USERNAME and DESDK_PASSWORD must be set")
|
||||
}
|
||||
|
||||
client, err := desdk.NewClient(serverURL, false)
|
||||
if err != nil {
|
||||
log.Fatalf("create client: %v", err)
|
||||
}
|
||||
|
||||
authCtx, authCancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer authCancel()
|
||||
|
||||
if _, err := client.Authenticate(authCtx, username, password); err != nil {
|
||||
log.Fatalf("authenticate: %v", err)
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
|
||||
fmt.Printf("SDK version: %s\n", core.SDKVersion())
|
||||
|
||||
deVersion, err := client.DeDeployment.Get(ctx)
|
||||
if err != nil {
|
||||
log.Fatalf("get DE version: %v", err)
|
||||
}
|
||||
fmt.Printf("DE version: %s\n", deVersion.ReleaseVersion)
|
||||
|
||||
dxVersion, err := client.DxVersion.GetVersion(ctx)
|
||||
if err != nil {
|
||||
log.Fatalf("get DX version: %v", err)
|
||||
}
|
||||
fmt.Printf("DX version: %d.%d.%d\n", dxVersion.Record.Major, dxVersion.Record.Minor, dxVersion.Record.Patch)
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/de_cluster"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var (
|
||||
serverURL = os.Getenv("DESDK_SERVER_URL")
|
||||
|
||||
token = os.Getenv("DESDK_TOKEN")
|
||||
)
|
||||
if serverURL == "" || token == "" {
|
||||
log.Fatal("DESDK_SERVER_URL and DESDK_TOKEN must be set")
|
||||
}
|
||||
|
||||
client, err := desdk.NewClient(serverURL, false)
|
||||
if err != nil {
|
||||
log.Fatalf("create client: %v", err)
|
||||
}
|
||||
|
||||
authCtx, authCancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer authCancel()
|
||||
|
||||
if err := client.AuthenticateWithToken(authCtx, token); err != nil {
|
||||
log.Fatalf("authenticate with token: %v", err)
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
|
||||
list, err := client.DeCluster.List(ctx, de_cluster.ListRequest{})
|
||||
if err != nil {
|
||||
log.Fatalf("cluster list: %v", err)
|
||||
}
|
||||
|
||||
fmt.Printf("Got %d clusters\n", len(list.Clusters))
|
||||
for _, c := range list.Clusters {
|
||||
fmt.Printf(" - Cluster with id %v and name %q is in status %q\n", c.ID, c.Name, c.DenergyStatus)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/de_user"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var (
|
||||
serverURL = os.Getenv("DESDK_SERVER_URL")
|
||||
|
||||
token = os.Getenv("DESDK_TOKEN")
|
||||
)
|
||||
if serverURL == "" || token == "" {
|
||||
log.Fatal("DESDK_SERVER_URL and DESDK_TOKEN must be set")
|
||||
}
|
||||
|
||||
cfg := desdk.NewConfiguration()
|
||||
cfg.ServerURL = serverURL
|
||||
cfg.UserAgent = "de-golang-sdk-explicit-config-example/1.0"
|
||||
cfg.AddDefaultHeader("X-Client-Name", "explicit-config-example")
|
||||
cfg.HTTPClient = &http.Client{Timeout: 15 * time.Second}
|
||||
|
||||
client := desdk.NewClientWithConfig(cfg)
|
||||
|
||||
authCtx, authCancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer authCancel()
|
||||
|
||||
if err := client.AuthenticateWithToken(authCtx, token); err != nil {
|
||||
log.Fatalf("authenticate with token: %v", err)
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
|
||||
list, err := client.DeUser.List(ctx, de_user.ListRequest{
|
||||
SortBy: "username",
|
||||
Limit: 5,
|
||||
})
|
||||
if err != nil {
|
||||
log.Fatalf("list users: %v", err)
|
||||
}
|
||||
|
||||
fmt.Printf("Got %d users\n", len(list.Records))
|
||||
for _, u := range list.Records {
|
||||
fmt.Printf(" - User with ID %v, name %q and role %q\n", u.ID, u.Name, u.Role)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/de_cluster"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var (
|
||||
serverURL = os.Getenv("DESDK_SERVER_URL")
|
||||
|
||||
token = os.Getenv("DESDK_TOKEN")
|
||||
)
|
||||
if serverURL == "" || token == "" {
|
||||
log.Fatal("DESDK_SERVER_URL and DESDK_TOKEN must be set")
|
||||
}
|
||||
|
||||
client, err := desdk.NewClient(serverURL, false)
|
||||
if err != nil {
|
||||
log.Fatalf("create client: %v", err)
|
||||
}
|
||||
|
||||
authCtx, authCancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer authCancel()
|
||||
|
||||
if err := client.AuthenticateWithToken(authCtx, token); err != nil {
|
||||
log.Fatalf("authenticate with token: %v", err)
|
||||
}
|
||||
|
||||
ctxCreate, cancelCreate := context.WithTimeout(context.Background(), 30*time.Minute)
|
||||
defer cancelCreate()
|
||||
|
||||
clusterName := fmt.Sprintf("sdk-example-%d", time.Now().Unix())
|
||||
createRes, err := client.DeCluster.Create(ctxCreate, de_cluster.CreateRequest{
|
||||
ClusterType: "denergy",
|
||||
ClusterName: clusterName,
|
||||
// ...
|
||||
})
|
||||
if err != nil {
|
||||
log.Fatalf("cluster create: %v", err)
|
||||
}
|
||||
|
||||
task, err := client.WaitForTask(ctxCreate, createRes.TaskID, desdk.DefaultTaskPollInterval)
|
||||
if err != nil {
|
||||
log.Fatalf("task wait: %v", err)
|
||||
}
|
||||
clusterID := task.SubjectID
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
|
||||
cluster, err := client.DeCluster.Get(ctx, de_cluster.GetRequest{ID: clusterID})
|
||||
if err != nil {
|
||||
log.Fatalf("cluster get: %v", err)
|
||||
}
|
||||
|
||||
fmt.Printf("Created cluster with id: %v, name: %v, masters: %d, workers: %d\n",
|
||||
cluster.Cluster.ID, cluster.Cluster.Name, len(cluster.Masters), len(cluster.Workers))
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,111 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/core"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/tags/de_istore"
|
||||
)
|
||||
|
||||
func main() {
|
||||
if err := run(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func run() error {
|
||||
const imageReference = "0.1"
|
||||
|
||||
var (
|
||||
serverURL = os.Getenv("DESDK_SERVER_URL")
|
||||
token = os.Getenv("DESDK_TOKEN")
|
||||
|
||||
uploadFilePath = os.Getenv("DESDK_UPLOAD_FILE_PATH")
|
||||
downloadFilePath = os.Getenv("DESDK_DOWNLOAD_FILE_PATH")
|
||||
)
|
||||
if uploadFilePath == "" {
|
||||
uploadFilePath = "examples/05_file/hello_world.img"
|
||||
}
|
||||
if downloadFilePath == "" {
|
||||
downloadFilePath = "examples/05_file/downloaded_image.img"
|
||||
}
|
||||
if serverURL == "" || token == "" {
|
||||
return fmt.Errorf("DESDK_SERVER_URL and DESDK_TOKEN must be set")
|
||||
}
|
||||
|
||||
client, err := desdk.NewClient(serverURL, false)
|
||||
if err != nil {
|
||||
return fmt.Errorf("create client: %w", err)
|
||||
}
|
||||
|
||||
authCtx, authCancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer authCancel()
|
||||
|
||||
if err := client.AuthenticateWithToken(authCtx, token); err != nil {
|
||||
return fmt.Errorf("authenticate with token: %w", err)
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
|
||||
defer cancel()
|
||||
|
||||
uploadFile, err := os.Open(uploadFilePath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("open upload file: %w", err)
|
||||
}
|
||||
defer uploadFile.Close()
|
||||
|
||||
imageName := fmt.Sprintf("sdk-file-example-%d", time.Now().UnixNano())
|
||||
imageUploadResp, err := client.DeIstore.ImageUpload(ctx, de_istore.ImageUploadRequest{
|
||||
Name: imageName,
|
||||
Reference: imageReference,
|
||||
File: &core.UploadFile{
|
||||
Filename: filepath.Base(uploadFilePath),
|
||||
Reader: uploadFile,
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("upload image: %w", err)
|
||||
}
|
||||
fmt.Printf("Imported image %q with ID %q\n", imageName, imageUploadResp.Manifest.ID)
|
||||
defer func() {
|
||||
cleanupCtx, cleanupCancel := context.WithTimeout(context.Background(), time.Minute)
|
||||
defer cleanupCancel()
|
||||
|
||||
_, cleanupErr := client.DeIstore.ImageDelete(cleanupCtx, de_istore.ImageDeleteRequest{
|
||||
ID: imageUploadResp.Manifest.ID,
|
||||
})
|
||||
if cleanupErr != nil {
|
||||
log.Printf("delete image %q: %v", imageName, cleanupErr)
|
||||
}
|
||||
}()
|
||||
|
||||
imageReader, err := client.DeIstore.ImageDownload(ctx, de_istore.ImageDownloadRequest{
|
||||
Path: imageName,
|
||||
Reference: imageReference,
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("download image: %w", err)
|
||||
}
|
||||
defer imageReader.Close()
|
||||
|
||||
downloadFile, err := os.Create(downloadFilePath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("create download file: %w", err)
|
||||
}
|
||||
defer downloadFile.Close()
|
||||
|
||||
written, err := io.Copy(downloadFile, imageReader)
|
||||
if err != nil {
|
||||
return fmt.Errorf("save image: %w", err)
|
||||
}
|
||||
fmt.Printf("Downloaded %d bytes to %q\n", written, downloadFilePath)
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,268 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package utils
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"encoding/xml"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"mime/multipart"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/core"
|
||||
)
|
||||
|
||||
var (
|
||||
jsonCheck = regexp.MustCompile(`(?i:(?:application|text)/(?:[^;]+\+)?json)`)
|
||||
xmlCheck = regexp.MustCompile(`(?i:(?:application|text)/(?:[^;]+\+)?xml)`)
|
||||
queryParamSplit = regexp.MustCompile(`(^|&)([^&]+)`)
|
||||
queryParamUnescaper = strings.NewReplacer("%5B", "[", "%5D", "]")
|
||||
)
|
||||
|
||||
type Client struct {
|
||||
cfg *core.Configuration
|
||||
}
|
||||
|
||||
func NewClient(cfg *core.Configuration) *Client {
|
||||
if cfg == nil {
|
||||
cfg = core.NewConfiguration()
|
||||
}
|
||||
if cfg.HTTPClient == nil {
|
||||
cfg.HTTPClient = http.DefaultClient
|
||||
}
|
||||
|
||||
return &Client{cfg: cfg}
|
||||
}
|
||||
|
||||
func (c *Client) BaseURL() string {
|
||||
return strings.TrimRight(c.cfg.ServerURL, "/")
|
||||
}
|
||||
|
||||
func (c *Client) CallAPI(request *http.Request, _ bool) (*http.Response, error) {
|
||||
return c.callAPIWithHTTPClient(c.cfg.HTTPClient, request)
|
||||
}
|
||||
|
||||
func (c *Client) CallAPIWithoutRedirects(request *http.Request) (*http.Response, error) {
|
||||
httpClient := *c.cfg.HTTPClient
|
||||
httpClient.CheckRedirect = func(*http.Request, []*http.Request) error {
|
||||
return http.ErrUseLastResponse
|
||||
}
|
||||
|
||||
return c.callAPIWithHTTPClient(&httpClient, request)
|
||||
}
|
||||
|
||||
func (c *Client) callAPIWithHTTPClient(httpClient *http.Client, request *http.Request) (*http.Response, error) {
|
||||
resp, err := httpClient.Do(request)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
type FormFile struct {
|
||||
FieldName string
|
||||
Filename string
|
||||
Reader io.Reader
|
||||
}
|
||||
|
||||
func (c *Client) PrepareRequest(
|
||||
ctx context.Context,
|
||||
path string,
|
||||
method string,
|
||||
requestBody any,
|
||||
headerParams map[string]string,
|
||||
queryParams url.Values,
|
||||
formParams url.Values,
|
||||
formFiles []FormFile,
|
||||
) (*http.Request, error) {
|
||||
if ctx == nil {
|
||||
return nil, errors.New("nil context")
|
||||
}
|
||||
for _, formFile := range formFiles {
|
||||
if formFile.Filename == "" {
|
||||
return nil, fmt.Errorf("multipart file %q has an empty filename", formFile.FieldName)
|
||||
}
|
||||
if formFile.Reader == nil {
|
||||
return nil, fmt.Errorf("multipart file %q has a nil reader", formFile.FieldName)
|
||||
}
|
||||
}
|
||||
|
||||
var body io.Reader
|
||||
var closeMultipart func(error)
|
||||
|
||||
if requestBody != nil {
|
||||
contentType := headerParams["Content-Type"]
|
||||
if contentType == "" {
|
||||
contentType = detectContentType(requestBody)
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
var err error
|
||||
body, err = setBody(requestBody, contentType)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
if (strings.HasPrefix(headerParams["Content-Type"], "multipart/form-data") && len(formParams) > 0) || len(formFiles) > 0 {
|
||||
if body != nil {
|
||||
return nil, errors.New("cannot specify requestBody and multipart form at the same time.")
|
||||
}
|
||||
pipeReader, pipeWriter := io.Pipe()
|
||||
writer := multipart.NewWriter(pipeWriter)
|
||||
headerParams["Content-Type"] = writer.FormDataContentType()
|
||||
|
||||
body = pipeReader
|
||||
go func() {
|
||||
var err error
|
||||
defer func() {
|
||||
pipeWriter.CloseWithError(err)
|
||||
}()
|
||||
|
||||
for key, values := range formParams {
|
||||
for _, value := range values {
|
||||
err = writer.WriteField(key, value)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, formFile := range formFiles {
|
||||
var part io.Writer
|
||||
part, err = writer.CreateFormFile(formFile.FieldName, filepath.Base(formFile.Filename))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if _, err = io.Copy(part, formFile.Reader); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
err = writer.Close()
|
||||
}()
|
||||
closeMultipart = func(err error) {
|
||||
pipeReader.CloseWithError(err)
|
||||
pipeWriter.CloseWithError(err)
|
||||
}
|
||||
}
|
||||
|
||||
if strings.HasPrefix(headerParams["Content-Type"], "application/x-www-form-urlencoded") && len(formParams) > 0 {
|
||||
if body != nil {
|
||||
return nil, errors.New("cannot specify requestBody and x-www-form-urlencoded form at the same time.")
|
||||
}
|
||||
formBody := &bytes.Buffer{}
|
||||
if _, err := formBody.WriteString(formParams.Encode()); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
body = formBody
|
||||
headerParams["Content-Length"] = fmt.Sprintf("%d", formBody.Len())
|
||||
}
|
||||
|
||||
pathParsed, err := url.Parse(path)
|
||||
if err != nil {
|
||||
if closeMultipart != nil {
|
||||
closeMultipart(err)
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
query := pathParsed.Query()
|
||||
for key, values := range queryParams {
|
||||
for _, value := range values {
|
||||
query.Add(key, value)
|
||||
}
|
||||
}
|
||||
|
||||
pathParsed.RawQuery = queryParamSplit.ReplaceAllStringFunc(query.Encode(), func(value string) string {
|
||||
pieces := strings.Split(value, "=")
|
||||
pieces[0] = queryParamUnescaper.Replace(pieces[0])
|
||||
return strings.Join(pieces, "=")
|
||||
})
|
||||
|
||||
var request *http.Request
|
||||
if body != nil {
|
||||
request, err = http.NewRequestWithContext(ctx, method, pathParsed.String(), body)
|
||||
} else {
|
||||
request, err = http.NewRequestWithContext(ctx, method, pathParsed.String(), nil)
|
||||
}
|
||||
if err != nil {
|
||||
if closeMultipart != nil {
|
||||
closeMultipart(err)
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(headerParams) > 0 {
|
||||
headers := http.Header{}
|
||||
for header, value := range headerParams {
|
||||
headers[header] = []string{value}
|
||||
}
|
||||
request.Header = headers
|
||||
}
|
||||
|
||||
request.Header.Add("User-Agent", c.cfg.UserAgent)
|
||||
|
||||
for header, value := range c.cfg.DefaultHeaders() {
|
||||
request.Header.Add(header, value)
|
||||
}
|
||||
|
||||
return request, nil
|
||||
}
|
||||
|
||||
func setBody(body any, contentType string) (bodyBuffer *bytes.Buffer, err error) {
|
||||
if bodyBuffer == nil {
|
||||
bodyBuffer = &bytes.Buffer{}
|
||||
}
|
||||
|
||||
if reader, ok := body.(io.Reader); ok {
|
||||
_, err = bodyBuffer.ReadFrom(reader)
|
||||
} else if bytesValue, ok := body.([]byte); ok {
|
||||
_, err = bodyBuffer.Write(bytesValue)
|
||||
} else if stringValue, ok := body.(string); ok {
|
||||
_, err = bodyBuffer.WriteString(stringValue)
|
||||
} else if stringValue, ok := body.(*string); ok {
|
||||
_, err = bodyBuffer.WriteString(*stringValue)
|
||||
} else if jsonCheck.MatchString(contentType) {
|
||||
err = json.NewEncoder(bodyBuffer).Encode(body)
|
||||
} else if xmlCheck.MatchString(contentType) {
|
||||
var encoded []byte
|
||||
encoded, err = xml.Marshal(body)
|
||||
if err == nil {
|
||||
bodyBuffer.Write(encoded)
|
||||
}
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if bodyBuffer.Len() == 0 {
|
||||
return nil, fmt.Errorf("invalid body type %s\n", contentType)
|
||||
}
|
||||
return bodyBuffer, nil
|
||||
}
|
||||
|
||||
func detectContentType(body any) string {
|
||||
contentType := "text/plain; charset=utf-8"
|
||||
kind := reflect.TypeOf(body).Kind()
|
||||
|
||||
switch kind {
|
||||
case reflect.Struct, reflect.Map, reflect.Ptr:
|
||||
contentType = "application/json; charset=utf-8"
|
||||
case reflect.String:
|
||||
contentType = "text/plain; charset=utf-8"
|
||||
default:
|
||||
if bytesValue, ok := body.([]byte); ok {
|
||||
contentType = http.DetectContentType(bytesValue)
|
||||
} else if kind == reflect.Slice {
|
||||
contentType = "application/json; charset=utf-8"
|
||||
}
|
||||
}
|
||||
|
||||
return contentType
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package utils
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"reflect"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
func SelectHeaderContentType(contentTypes []string) string {
|
||||
if len(contentTypes) == 0 {
|
||||
return ""
|
||||
}
|
||||
if contains(contentTypes, "application/json") {
|
||||
return "application/json"
|
||||
}
|
||||
return contentTypes[0]
|
||||
}
|
||||
|
||||
func SelectHeaderAccept(accepts []string) string {
|
||||
if len(accepts) == 0 {
|
||||
return ""
|
||||
}
|
||||
|
||||
if contains(accepts, "application/json") {
|
||||
return "application/json"
|
||||
}
|
||||
|
||||
return strings.Join(accepts, ",")
|
||||
}
|
||||
|
||||
func contains(haystack []string, needle string) bool {
|
||||
for _, value := range haystack {
|
||||
if strings.EqualFold(value, needle) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func ParameterValueToString(obj any) string {
|
||||
if obj == nil {
|
||||
return ""
|
||||
}
|
||||
|
||||
if actualObj, ok := obj.(interface{ GetActualInstanceValue() any }); ok {
|
||||
return fmt.Sprintf("%v", actualObj.GetActualInstanceValue())
|
||||
}
|
||||
|
||||
value := reflect.ValueOf(obj)
|
||||
for value.Kind() == reflect.Interface || value.Kind() == reflect.Ptr {
|
||||
if value.IsNil() {
|
||||
return ""
|
||||
}
|
||||
value = value.Elem()
|
||||
current := value.Interface()
|
||||
|
||||
if actualObj, ok := current.(interface{ GetActualInstanceValue() any }); ok {
|
||||
return fmt.Sprintf("%v", actualObj.GetActualInstanceValue())
|
||||
}
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%v", value.Interface())
|
||||
}
|
||||
|
||||
func ReplacePathParameter(path, name, value string) string {
|
||||
return strings.ReplaceAll(path, "{"+name+"}", url.PathEscape(value))
|
||||
}
|
||||
|
||||
func ParameterAddToHeaderOrQuery(headerOrQueryParams any, keyPrefix string, obj any, style string, collectionType string) {
|
||||
if obj == nil {
|
||||
addParameterValue(headerOrQueryParams, keyPrefix, "null", collectionType)
|
||||
return
|
||||
}
|
||||
|
||||
value := reflect.ValueOf(obj)
|
||||
if !value.IsValid() {
|
||||
addParameterValue(headerOrQueryParams, keyPrefix, "invalid", collectionType)
|
||||
return
|
||||
}
|
||||
|
||||
for value.Kind() == reflect.Interface || value.Kind() == reflect.Ptr {
|
||||
if value.IsNil() {
|
||||
addParameterValue(headerOrQueryParams, keyPrefix, "null", collectionType)
|
||||
return
|
||||
}
|
||||
value = value.Elem()
|
||||
}
|
||||
|
||||
switch value.Kind() {
|
||||
case reflect.Struct:
|
||||
if t, ok := value.Interface().(time.Time); ok {
|
||||
ParameterAddToHeaderOrQuery(headerOrQueryParams, keyPrefix, t.Format(time.RFC3339Nano), style, collectionType)
|
||||
return
|
||||
}
|
||||
addParameterValue(headerOrQueryParams, keyPrefix, value.Type().String()+" value", collectionType)
|
||||
case reflect.Slice, reflect.Array:
|
||||
if value.Kind() == reflect.Slice && value.IsNil() {
|
||||
return
|
||||
}
|
||||
for i := 0; i < value.Len(); i++ {
|
||||
itemKeyPrefix := keyPrefix
|
||||
if style == "deepObject" {
|
||||
itemKeyPrefix = keyPrefix + "[" + strconv.Itoa(i) + "]"
|
||||
}
|
||||
ParameterAddToHeaderOrQuery(headerOrQueryParams, itemKeyPrefix, value.Index(i).Interface(), style, collectionType)
|
||||
}
|
||||
case reflect.Map:
|
||||
if value.IsNil() {
|
||||
return
|
||||
}
|
||||
iter := value.MapRange()
|
||||
for iter.Next() {
|
||||
mapKey := fmt.Sprintf("%v", iter.Key().Interface())
|
||||
ParameterAddToHeaderOrQuery(headerOrQueryParams, fmt.Sprintf("%s[%s]", keyPrefix, mapKey), iter.Value().Interface(), style, collectionType)
|
||||
}
|
||||
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
|
||||
addParameterValue(headerOrQueryParams, keyPrefix, strconv.FormatInt(value.Int(), 10), collectionType)
|
||||
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
|
||||
addParameterValue(headerOrQueryParams, keyPrefix, strconv.FormatUint(value.Uint(), 10), collectionType)
|
||||
case reflect.Float32:
|
||||
addParameterValue(headerOrQueryParams, keyPrefix, strconv.FormatFloat(value.Float(), 'g', -1, 32), collectionType)
|
||||
case reflect.Float64:
|
||||
addParameterValue(headerOrQueryParams, keyPrefix, strconv.FormatFloat(value.Float(), 'g', -1, 64), collectionType)
|
||||
case reflect.Bool:
|
||||
addParameterValue(headerOrQueryParams, keyPrefix, strconv.FormatBool(value.Bool()), collectionType)
|
||||
case reflect.String:
|
||||
addParameterValue(headerOrQueryParams, keyPrefix, value.String(), collectionType)
|
||||
default:
|
||||
addParameterValue(headerOrQueryParams, keyPrefix, value.Type().String()+" value", collectionType)
|
||||
}
|
||||
}
|
||||
|
||||
func addParameterValue(headerOrQueryParams any, keyPrefix, value, collectionType string) {
|
||||
switch values := headerOrQueryParams.(type) {
|
||||
case url.Values:
|
||||
if collectionType == "csv" && values.Get(keyPrefix) != "" {
|
||||
values.Set(keyPrefix, values.Get(keyPrefix)+","+value)
|
||||
} else {
|
||||
values.Add(keyPrefix, value)
|
||||
}
|
||||
case map[string]string:
|
||||
values[keyPrefix] = value
|
||||
}
|
||||
}
|
||||
|
||||
func ParameterToJSON(obj any) (string, error) {
|
||||
jsonBuf, err := json.Marshal(obj)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return string(jsonBuf), err
|
||||
}
|
||||
@@ -0,0 +1,240 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package utils
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"encoding/xml"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"reflect"
|
||||
"strings"
|
||||
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/core"
|
||||
)
|
||||
|
||||
func (c *Client) Decode(v any, body []byte, contentType string) (err error) {
|
||||
if len(body) == 0 {
|
||||
return nil
|
||||
}
|
||||
if stringValue, ok := v.(*string); ok {
|
||||
*stringValue = string(body)
|
||||
return nil
|
||||
}
|
||||
if xmlCheck.MatchString(contentType) {
|
||||
if err = xml.Unmarshal(body, v); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
if jsonCheck.MatchString(contentType) {
|
||||
if actualObj, ok := v.(interface{ GetActualInstance() any }); ok {
|
||||
if unmarshalObj, ok := actualObj.(interface{ UnmarshalJSON([]byte) error }); ok {
|
||||
if err = unmarshalObj.UnmarshalJSON(body); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
return errors.New("Unknown type with GetActualInstance but no unmarshalObj.UnmarshalJSON defined")
|
||||
}
|
||||
} else if err = json.Unmarshal(body, v); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = populateEmbeddedAnyMap(v, body); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("undefined response type: %v", contentType)
|
||||
}
|
||||
|
||||
func decodeFileResponseError(body []byte) error {
|
||||
var responseError struct {
|
||||
Message string `json:"message"`
|
||||
Error bool `json:"error"`
|
||||
ErrorCode int64 `json:"errorCode"`
|
||||
}
|
||||
if err := json.Unmarshal(body, &responseError); err != nil || !responseError.Error {
|
||||
return nil
|
||||
}
|
||||
return &core.BackendError{
|
||||
Code: responseError.ErrorCode,
|
||||
Message: responseError.Message,
|
||||
}
|
||||
}
|
||||
|
||||
func ReadResponseBody(resp *http.Response) ([]byte, error) {
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
resp.Body.Close()
|
||||
return body, err
|
||||
}
|
||||
|
||||
func (c *Client) FileResponse(resp *http.Response) (io.ReadCloser, error) {
|
||||
if resp.Body == nil {
|
||||
return nil, errors.New("file response body is nil")
|
||||
}
|
||||
if !jsonCheck.MatchString(resp.Header.Get("Content-Type")) {
|
||||
return resp.Body, nil
|
||||
}
|
||||
|
||||
body, err := ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := decodeFileResponseError(body); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return io.NopCloser(bytes.NewReader(body)), nil
|
||||
}
|
||||
|
||||
func populateEmbeddedAnyMap(v any, data []byte) error {
|
||||
return populateEmbeddedAnyMapValue(reflect.ValueOf(v), data)
|
||||
}
|
||||
|
||||
func populateEmbeddedAnyMapValue(value reflect.Value, data []byte) error {
|
||||
if !value.IsValid() {
|
||||
return nil
|
||||
}
|
||||
for value.Kind() == reflect.Ptr || value.Kind() == reflect.Interface {
|
||||
if value.IsNil() {
|
||||
return nil
|
||||
}
|
||||
value = value.Elem()
|
||||
}
|
||||
|
||||
trimmed := bytes.TrimSpace(data)
|
||||
if len(trimmed) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
switch value.Kind() {
|
||||
case reflect.Struct:
|
||||
if trimmed[0] != '{' {
|
||||
return nil
|
||||
}
|
||||
return populateEmbeddedAnyMapStruct(value, trimmed)
|
||||
case reflect.Slice, reflect.Array:
|
||||
if trimmed[0] != '[' {
|
||||
return nil
|
||||
}
|
||||
var rawItems []json.RawMessage
|
||||
if err := json.Unmarshal(trimmed, &rawItems); err != nil {
|
||||
return err
|
||||
}
|
||||
for i := 0; i < value.Len() && i < len(rawItems); i++ {
|
||||
if err := populateEmbeddedAnyMapValue(value.Index(i), rawItems[i]); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func populateEmbeddedAnyMapStruct(value reflect.Value, data []byte) error {
|
||||
var rawObject map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &rawObject); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if anyField, ok := embeddedAnyMapField(value); ok {
|
||||
if hasJSONKeyFold(rawObject, "any") {
|
||||
return nil
|
||||
}
|
||||
|
||||
var anyValue map[string]any
|
||||
if err := json.Unmarshal(data, &anyValue); err != nil {
|
||||
return err
|
||||
}
|
||||
anyField.Set(reflect.ValueOf(anyValue))
|
||||
return nil
|
||||
}
|
||||
|
||||
valueType := value.Type()
|
||||
for i := 0; i < value.NumField(); i++ {
|
||||
fieldType := valueType.Field(i)
|
||||
if fieldType.PkgPath != "" {
|
||||
continue
|
||||
}
|
||||
rawField, ok := rawJSONField(rawObject, fieldType)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
if err := populateEmbeddedAnyMapValue(value.Field(i), rawField); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func embeddedAnyMapField(value reflect.Value) (reflect.Value, bool) {
|
||||
valueType := value.Type()
|
||||
var exportedCount int
|
||||
var anyField reflect.Value
|
||||
|
||||
for i := 0; i < value.NumField(); i++ {
|
||||
fieldType := valueType.Field(i)
|
||||
if fieldType.PkgPath != "" {
|
||||
continue
|
||||
}
|
||||
|
||||
exportedCount++
|
||||
if fieldType.Name == "Any" {
|
||||
anyField = value.Field(i)
|
||||
}
|
||||
}
|
||||
|
||||
if exportedCount != 1 || !anyField.IsValid() || !anyField.CanSet() {
|
||||
return reflect.Value{}, false
|
||||
}
|
||||
|
||||
anyFieldType := anyField.Type()
|
||||
switch anyFieldType.Kind() {
|
||||
case reflect.Interface:
|
||||
case reflect.Map:
|
||||
if anyFieldType.Key().Kind() != reflect.String || anyFieldType.Elem().Kind() != reflect.Interface {
|
||||
return reflect.Value{}, false
|
||||
}
|
||||
default:
|
||||
return reflect.Value{}, false
|
||||
}
|
||||
|
||||
return anyField, true
|
||||
}
|
||||
|
||||
func rawJSONField(rawObject map[string]json.RawMessage, field reflect.StructField) (json.RawMessage, bool) {
|
||||
name := field.Name
|
||||
if tag := field.Tag.Get("json"); tag != "" {
|
||||
tagName := strings.Split(tag, ",")[0]
|
||||
if tagName == "-" {
|
||||
return nil, false
|
||||
}
|
||||
if tagName != "" {
|
||||
name = tagName
|
||||
}
|
||||
}
|
||||
|
||||
if rawField, ok := rawObject[name]; ok {
|
||||
return rawField, true
|
||||
}
|
||||
|
||||
for key, rawField := range rawObject {
|
||||
if strings.EqualFold(key, name) {
|
||||
return rawField, true
|
||||
}
|
||||
}
|
||||
|
||||
return nil, false
|
||||
}
|
||||
|
||||
func hasJSONKeyFold(rawObject map[string]json.RawMessage, name string) bool {
|
||||
for key := range rawObject {
|
||||
if strings.EqualFold(key, name) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package utils
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"strings"
|
||||
"unicode/utf8"
|
||||
)
|
||||
|
||||
func IsZeroValue(v any) bool {
|
||||
if v == nil {
|
||||
return true
|
||||
}
|
||||
|
||||
rv := reflect.ValueOf(v)
|
||||
switch rv.Kind() {
|
||||
case reflect.Array, reflect.Map, reflect.Slice, reflect.String:
|
||||
return rv.Len() == 0
|
||||
case reflect.Bool:
|
||||
return !rv.Bool()
|
||||
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
|
||||
return rv.Int() == 0
|
||||
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
|
||||
return rv.Uint() == 0
|
||||
case reflect.Float32, reflect.Float64:
|
||||
return rv.Float() == 0
|
||||
case reflect.Interface, reflect.Pointer:
|
||||
return rv.IsNil()
|
||||
default:
|
||||
return rv.IsZero()
|
||||
}
|
||||
}
|
||||
|
||||
func IsRequiredParamMissing(v any) bool {
|
||||
if v == nil {
|
||||
return true
|
||||
}
|
||||
|
||||
rv := reflect.ValueOf(v)
|
||||
switch rv.Kind() {
|
||||
case reflect.Bool:
|
||||
return false
|
||||
case reflect.Slice:
|
||||
return rv.IsNil()
|
||||
case reflect.Interface, reflect.Pointer:
|
||||
return rv.IsNil()
|
||||
default:
|
||||
return IsZeroValue(v)
|
||||
}
|
||||
}
|
||||
|
||||
func MissingRequiredParamsError(params []string) error {
|
||||
return fmt.Errorf("required params are missing: %s", strings.Join(params, ", "))
|
||||
}
|
||||
|
||||
func Strlen(s string) int {
|
||||
return utf8.RuneCountInString(s)
|
||||
}
|
||||
Executable
+59
@@ -0,0 +1,59 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package shared
|
||||
|
||||
type CreateTaskResult struct {
|
||||
TaskID int64 `json:"taskId,omitempty"`
|
||||
}
|
||||
|
||||
type CreateTaskResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result CreateTaskResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type DependencyAny struct {
|
||||
Depends []string `json:"depends,omitempty"`
|
||||
Key string `json:"key,omitempty"`
|
||||
}
|
||||
|
||||
type ImageDescr struct {
|
||||
Image string `json:"image,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
}
|
||||
|
||||
type ProductDescr struct {
|
||||
Depends []string `json:"depends,omitempty"`
|
||||
DependsAny []DependencyAny `json:"dependsAny,omitempty"`
|
||||
Images []ImageDescr `json:"images,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
ProductName string `json:"productName,omitempty"`
|
||||
ProductVersion string `json:"productVersion,omitempty"`
|
||||
}
|
||||
|
||||
type Rule struct {
|
||||
Message string `json:"message,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
Type string `json:"type,omitempty"`
|
||||
}
|
||||
|
||||
type TaskBrief struct {
|
||||
Deleted bool `json:"deleted,omitempty"`
|
||||
Done bool `json:"done,omitempty"`
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorMessage string `json:"errormessage,omitempty"`
|
||||
ID int64 `json:"id,omitempty"`
|
||||
Operation string `json:"operation,omitempty"`
|
||||
OwnerID int64 `json:"ownerId,omitempty"`
|
||||
StartTimestamp string `json:"startTimestamp,omitempty"`
|
||||
StopTimestamp string `json:"stopTimestamp,omitempty"`
|
||||
SubjectID int64 `json:"subjectId,omitempty"`
|
||||
SubjectType string `json:"subjectType,omitempty"`
|
||||
}
|
||||
|
||||
type Version struct {
|
||||
Major int64 `json:"major,omitempty"`
|
||||
Minor int64 `json:"minor,omitempty"`
|
||||
Patch int64 `json:"patch,omitempty"`
|
||||
}
|
||||
@@ -0,0 +1,307 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_apisix
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/core"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type DeAPISIXService service
|
||||
|
||||
type DescribeRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// true for checking whether the apisix is installed in the cluster
|
||||
CheckInstallation bool `json:"checkInstallation" form:"checkInstallation"`
|
||||
// true for checking k8s apisix pods liveness and the availability of the API
|
||||
CheckLiveness bool `json:"checkLiveness" form:"checkLiveness"`
|
||||
}
|
||||
|
||||
// Get apisix by id
|
||||
func (a *DeAPISIXService) Describe(ctx context.Context, req DescribeRequest) (DescribeAPISIXResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result DescribeAPISIXResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ClusterID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "clusterId")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/apisix/describe"
|
||||
|
||||
contentTypes := []string{"application/x-www-form-urlencoded"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "clusterId", req.ClusterID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "checkInstallation", req.CheckInstallation, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "checkLiveness", req.CheckLiveness, "", "")
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp DescribeAPISIXResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
type InstallRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// hostname for apisix
|
||||
//
|
||||
// Required.
|
||||
Hostname string `json:"hostname" form:"hostname"`
|
||||
// http port
|
||||
//
|
||||
// Required.
|
||||
HTTPPort int64 `json:"httpPort" form:"httpPort"`
|
||||
// Hostname for integagent
|
||||
IntegagentHostname string `json:"integagentHostname" form:"integagentHostname"`
|
||||
// https port
|
||||
HTTPSPort int64 `json:"httpsPort" form:"httpsPort"`
|
||||
// images apps repository ID. If the ID is zero or the value is empty, the default images apps repository will be used.
|
||||
AppsRepositoryID int64 `json:"appsRepositoryId" form:"appsRepositoryId"`
|
||||
// charts repository ID. If the ID is zero or the value is empty, the default charts repository will be used.
|
||||
ChartsRepositoryID int64 `json:"chartsRepositoryId" form:"chartsRepositoryId"`
|
||||
// worker group name
|
||||
WorkerGroupName string `json:"workerGroupName" form:"workerGroupName"`
|
||||
// download chart anyway
|
||||
DownloadChartAnyway bool `json:"downloadChartAnyway" form:"downloadChartAnyway"`
|
||||
}
|
||||
|
||||
// Install apisix in cluster
|
||||
func (a *DeAPISIXService) Install(ctx context.Context, req InstallRequest) (CreateTaskResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result CreateTaskResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ClusterID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "clusterId")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.Hostname) {
|
||||
missingRequiredParams = append(missingRequiredParams, "hostname")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.HTTPPort) {
|
||||
missingRequiredParams = append(missingRequiredParams, "httpPort")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/apisix/install"
|
||||
|
||||
contentTypes := []string{"application/x-www-form-urlencoded"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "clusterId", req.ClusterID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "hostname", req.Hostname, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "integagentHostname", req.IntegagentHostname, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "httpPort", req.HTTPPort, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "httpsPort", req.HTTPSPort, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "appsRepositoryId", req.AppsRepositoryID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "chartsRepositoryId", req.ChartsRepositoryID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "workerGroupName", req.WorkerGroupName, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "downloadChartAnyway", req.DownloadChartAnyway, "", "")
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp CreateTaskResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
type UninstallRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// true for deleting the apisix even if it is not registered
|
||||
CleanAlways bool `json:"cleanAlways" form:"cleanAlways"`
|
||||
// true for ignoring dns server errors
|
||||
IgnoreDNSError bool `json:"ignoreDnsError" form:"ignoreDnsError"`
|
||||
}
|
||||
|
||||
// Uninstall apisix from cluster
|
||||
func (a *DeAPISIXService) Uninstall(ctx context.Context, req UninstallRequest) (CreateTaskResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result CreateTaskResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ClusterID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "clusterId")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/apisix/uninstall"
|
||||
|
||||
contentTypes := []string{"application/x-www-form-urlencoded"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "clusterId", req.ClusterID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "cleanAlways", req.CleanAlways, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "ignoreDnsError", req.IgnoreDNSError, "", "")
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp CreateTaskResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_apisix
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/core"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type APIClient struct {
|
||||
common service
|
||||
|
||||
DeAPISIX *DeAPISIXService
|
||||
}
|
||||
|
||||
type service struct {
|
||||
client *utils.Client
|
||||
}
|
||||
|
||||
func NewAPIClient(cfg *core.Configuration) *APIClient {
|
||||
c := &APIClient{}
|
||||
c.common.client = utils.NewClient(cfg)
|
||||
|
||||
c.DeAPISIX = (*DeAPISIXService)(&c.common)
|
||||
|
||||
return c
|
||||
}
|
||||
Executable
+33
@@ -0,0 +1,33 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_apisix
|
||||
|
||||
type APISIXRecord struct {
|
||||
Addresses map[string]string `json:"addresses,omitempty"`
|
||||
ClusterID int64 `json:"clusterId,omitempty"`
|
||||
Hostnames map[string]string `json:"hostnames,omitempty"`
|
||||
HTTPPort int64 `json:"httpPort,omitempty"`
|
||||
HTTPSPort int64 `json:"httpsPort,omitempty"`
|
||||
ID int64 `json:"id,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
OwnerID int64 `json:"ownerId,omitempty"`
|
||||
ProductName string `json:"productName,omitempty"`
|
||||
ProductVersion string `json:"productVersion,omitempty"`
|
||||
TaskIDs []int64 `json:"taskIds,omitempty"`
|
||||
WorkerGroupName string `json:"workerGroupName,omitempty"`
|
||||
}
|
||||
|
||||
type DescribeAPISIXResult struct {
|
||||
CheckListOk bool `json:"checkListOk,omitempty"`
|
||||
Description ProductDescr `json:"description,omitempty"`
|
||||
Installed bool `json:"installed,omitempty"`
|
||||
Registered bool `json:"registered,omitempty"`
|
||||
Registry APISIXRecord `json:"registry,omitempty"`
|
||||
}
|
||||
|
||||
type DescribeAPISIXResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result DescribeAPISIXResult `json:"result,omitempty"`
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_apisix
|
||||
|
||||
import (
|
||||
shared "repository.basistech.ru/BASIS/de-golang-sdk/shared"
|
||||
)
|
||||
|
||||
type CreateTaskResult = shared.CreateTaskResult
|
||||
type CreateTaskResultWithError = shared.CreateTaskResultWithError
|
||||
type ProductDescr = shared.ProductDescr
|
||||
@@ -0,0 +1,273 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_audits
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/core"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type DeAuditsService service
|
||||
|
||||
type LinkRequest struct {
|
||||
// filter audits by clusterId
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// filter audits by nodeId
|
||||
//
|
||||
// Required.
|
||||
NodeID int64 `json:"nodeId" form:"nodeId"`
|
||||
// filter audits by time after (starttime) as unix timestamp in seconds
|
||||
TimeAfter int64 `json:"timeAfter" form:"timeAfter"`
|
||||
// filter audits by time before (endtime) as unix timestamp in seconds
|
||||
TimeBefore int64 `json:"timeBefore" form:"timeBefore"`
|
||||
// filter audits by request uri
|
||||
RequestURI string `json:"requestUri" form:"requestUri"`
|
||||
// filter audits by verb
|
||||
//
|
||||
// Allowed values:
|
||||
// - "get"
|
||||
// - "list"
|
||||
// - "create"
|
||||
// - "update"
|
||||
// - "patch"
|
||||
// - "delete"
|
||||
// - "watch"
|
||||
// - "deletecollection"
|
||||
// - ""
|
||||
Verb string `json:"verb" form:"verb"`
|
||||
// filter audits by authorization decision
|
||||
//
|
||||
// Allowed values:
|
||||
// - "forbid"
|
||||
// - "allow"
|
||||
// - ""
|
||||
Decision string `json:"decision" form:"decision"`
|
||||
// filter audits by object source ip
|
||||
SourceIP string `json:"sourceIp" form:"sourceIp"`
|
||||
}
|
||||
|
||||
// Get link to download audits
|
||||
func (a *DeAuditsService) Link(ctx context.Context, req LinkRequest) (CreateTaskResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result CreateTaskResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ClusterID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "clusterId")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.NodeID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "nodeId")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
if !utils.IsZeroValue(req.Verb) {
|
||||
verbValue := req.Verb
|
||||
verbAllowedValues := []string{
|
||||
"get",
|
||||
"list",
|
||||
"create",
|
||||
"update",
|
||||
"patch",
|
||||
"delete",
|
||||
"watch",
|
||||
"deletecollection",
|
||||
"",
|
||||
}
|
||||
verbValid := false
|
||||
for _, allowed := range verbAllowedValues {
|
||||
if verbValue == allowed {
|
||||
verbValid = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !verbValid {
|
||||
return result, fmt.Errorf("verb must be one of %v", verbAllowedValues)
|
||||
}
|
||||
}
|
||||
if !utils.IsZeroValue(req.Decision) {
|
||||
decisionValue := req.Decision
|
||||
decisionAllowedValues := []string{
|
||||
"forbid",
|
||||
"allow",
|
||||
"",
|
||||
}
|
||||
decisionValid := false
|
||||
for _, allowed := range decisionAllowedValues {
|
||||
if decisionValue == allowed {
|
||||
decisionValid = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !decisionValid {
|
||||
return result, fmt.Errorf("decision must be one of %v", decisionAllowedValues)
|
||||
}
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/audit/link"
|
||||
|
||||
contentTypes := []string{"application/x-www-form-urlencoded"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "clusterId", req.ClusterID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "nodeId", req.NodeID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "timeAfter", req.TimeAfter, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "timeBefore", req.TimeBefore, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "requestUri", req.RequestURI, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "verb", req.Verb, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "decision", req.Decision, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "sourceIp", req.SourceIP, "", "")
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp CreateTaskResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
type ListRequest struct {
|
||||
// clusterId for which to show links with downloadable audits
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// if true, only active links are shown. By default, all links (including expired) are shown
|
||||
ShowActive bool `json:"showActive" form:"showActive"`
|
||||
// Limit number of audit links results to be shown in the result. If not set, all results will be shown.
|
||||
Limit int64 `json:"limit" form:"limit"`
|
||||
// Select page of the result. If not set, the first page will be shown.
|
||||
Page int64 `json:"page" form:"page"`
|
||||
}
|
||||
|
||||
// List links to download audits
|
||||
func (a *DeAuditsService) List(ctx context.Context, req ListRequest) (ListLinksAuditsResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result ListLinksAuditsResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ClusterID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "clusterId")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/audit/list"
|
||||
|
||||
contentTypes := []string{"application/x-www-form-urlencoded"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "clusterId", req.ClusterID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "showActive", req.ShowActive, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "limit", req.Limit, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "page", req.Page, "", "")
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp ListLinksAuditsResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_audits
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/core"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type APIClient struct {
|
||||
common service
|
||||
|
||||
DeAudits *DeAuditsService
|
||||
}
|
||||
|
||||
type service struct {
|
||||
client *utils.Client
|
||||
}
|
||||
|
||||
func NewAPIClient(cfg *core.Configuration) *APIClient {
|
||||
c := &APIClient{}
|
||||
c.common.client = utils.NewClient(cfg)
|
||||
|
||||
c.DeAudits = (*DeAuditsService)(&c.common)
|
||||
|
||||
return c
|
||||
}
|
||||
Executable
+49
@@ -0,0 +1,49 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_audits
|
||||
|
||||
type Audit struct {
|
||||
RequestURIFilter string `json:"RequestUriFilter,omitempty"`
|
||||
AuditsCount int64 `json:"auditsCount,omitempty"`
|
||||
ClusterID int64 `json:"clusterId,omitempty"`
|
||||
CreationDate string `json:"creationDate,omitempty"`
|
||||
DecisionFilter string `json:"decisionFilter,omitempty"`
|
||||
// download info
|
||||
Downloads []Download `json:"downloads,omitempty"`
|
||||
Error string `json:"error,omitempty"`
|
||||
FileName string `json:"fileName,omitempty"`
|
||||
FilePath string `json:"filePath,omitempty"`
|
||||
FileSize int64 `json:"fileSize,omitempty"`
|
||||
// audit link info
|
||||
ID int64 `json:"id,omitempty"`
|
||||
IsActive bool `json:"isActive,omitempty"`
|
||||
NodeID int64 `json:"nodeId,omitempty"`
|
||||
OwnerID int64 `json:"ownerId,omitempty"`
|
||||
SourceIPFilter string `json:"sourceIpFilter,omitempty"`
|
||||
Status string `json:"status,omitempty"`
|
||||
// optional audit filters
|
||||
TimeAfterFilter int64 `json:"timeAfterFilter,omitempty"`
|
||||
TimeBeforeFilter int64 `json:"timeBeforeFilter,omitempty"`
|
||||
URL string `json:"url,omitempty"`
|
||||
VerbFilter string `json:"verbFilter,omitempty"`
|
||||
ZipSize int64 `json:"zipSize,omitempty"`
|
||||
}
|
||||
|
||||
type Download struct {
|
||||
DownloadDate string `json:"downloadDate,omitempty"`
|
||||
Successfull bool `json:"successfull,omitempty"`
|
||||
UserID int64 `json:"userId,omitempty"`
|
||||
UserName string `json:"userName,omitempty"`
|
||||
}
|
||||
|
||||
type ListLinksAuditsResult struct {
|
||||
Audit []Audit `json:"audit,omitempty"`
|
||||
Total int64 `json:"total,omitempty"`
|
||||
}
|
||||
|
||||
type ListLinksAuditsResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result ListLinksAuditsResult `json:"result,omitempty"`
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_audits
|
||||
|
||||
import (
|
||||
shared "repository.basistech.ru/BASIS/de-golang-sdk/shared"
|
||||
)
|
||||
|
||||
type CreateTaskResult = shared.CreateTaskResult
|
||||
type CreateTaskResultWithError = shared.CreateTaskResultWithError
|
||||
@@ -0,0 +1,432 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_autoscaler
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/core"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type DeAutoscalerService service
|
||||
|
||||
type ListAutoscalerDeploymentsRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// The namespace scope
|
||||
//
|
||||
// Required.
|
||||
Namespace string `json:"namespace" form:"namespace"`
|
||||
}
|
||||
|
||||
// Get list of autoscaler deployments
|
||||
func (a *DeAutoscalerService) ListAutoscalerDeployments(ctx context.Context, req ListAutoscalerDeploymentsRequest) (ListAutoscalerDeploymentsResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result ListAutoscalerDeploymentsResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ClusterID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "clusterId")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.Namespace) {
|
||||
missingRequiredParams = append(missingRequiredParams, "namespace")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/autoscaler/listAutoscalerDeployments"
|
||||
|
||||
contentTypes := []string{"application/x-www-form-urlencoded"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "clusterId", req.ClusterID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "namespace", req.Namespace, "", "")
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp ListAutoscalerDeploymentsResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
type TurnOffAutoscalerDeploymentRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// Name of the deployment to which auto scaling will be applied
|
||||
//
|
||||
// Required.
|
||||
NameDeployment string `json:"nameDeployment" form:"nameDeployment"`
|
||||
// The namespace scope
|
||||
//
|
||||
// Required.
|
||||
Namespace string `json:"namespace" form:"namespace"`
|
||||
}
|
||||
|
||||
// Turn off autoscaler deployment
|
||||
func (a *DeAutoscalerService) TurnOffAutoscalerDeployment(ctx context.Context, req TurnOffAutoscalerDeploymentRequest) (any, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result any
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ClusterID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "clusterId")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.NameDeployment) {
|
||||
missingRequiredParams = append(missingRequiredParams, "nameDeployment")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.Namespace) {
|
||||
missingRequiredParams = append(missingRequiredParams, "namespace")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/autoscaler/turnOffAutoscalerDeployment"
|
||||
|
||||
contentTypes := []string{"application/x-www-form-urlencoded"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "clusterId", req.ClusterID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "nameDeployment", req.NameDeployment, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "namespace", req.Namespace, "", "")
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp TurnOffAutoscalerDeploymentResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
type TurnOnAutoscalerDeploymentRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// Name of the deployment to which auto scaling will be applied
|
||||
//
|
||||
// Required.
|
||||
NameDeployment string `json:"nameDeployment" form:"nameDeployment"`
|
||||
// The namespace scope
|
||||
//
|
||||
// Required.
|
||||
Namespace string `json:"namespace" form:"namespace"`
|
||||
// The lower limit for the number of pods that can be set by the autoscaler
|
||||
//
|
||||
// Required.
|
||||
MinPods int64 `json:"minPods" form:"minPods"`
|
||||
// The upper limit for the number of pods that can be set by the autoscaler
|
||||
//
|
||||
// Required.
|
||||
MaxPods int64 `json:"maxPods" form:"maxPods"`
|
||||
// The target average CPU utilization (represented as a percent of requested CPU) over all the pods
|
||||
//
|
||||
// Required.
|
||||
CPUPercent int64 `json:"cpuPercent" form:"cpuPercent"`
|
||||
}
|
||||
|
||||
// Turn on autoscaler deployment
|
||||
func (a *DeAutoscalerService) TurnOnAutoscalerDeployment(ctx context.Context, req TurnOnAutoscalerDeploymentRequest) (any, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result any
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ClusterID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "clusterId")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.NameDeployment) {
|
||||
missingRequiredParams = append(missingRequiredParams, "nameDeployment")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.Namespace) {
|
||||
missingRequiredParams = append(missingRequiredParams, "namespace")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.MinPods) {
|
||||
missingRequiredParams = append(missingRequiredParams, "minPods")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.MaxPods) {
|
||||
missingRequiredParams = append(missingRequiredParams, "maxPods")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.CPUPercent) {
|
||||
missingRequiredParams = append(missingRequiredParams, "cpuPercent")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/autoscaler/turnOnAutoscalerDeployment"
|
||||
|
||||
contentTypes := []string{"application/x-www-form-urlencoded"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "clusterId", req.ClusterID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "nameDeployment", req.NameDeployment, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "namespace", req.Namespace, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "minPods", req.MinPods, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "maxPods", req.MaxPods, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "cpuPercent", req.CPUPercent, "", "")
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp TurnOnAutoscalerDeploymentResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
type UpdateAutoscalerDeploymentRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// Name of the deployment to which auto scaling will be applied
|
||||
//
|
||||
// Required.
|
||||
NameDeployment string `json:"nameDeployment" form:"nameDeployment"`
|
||||
// The namespace scope
|
||||
//
|
||||
// Required.
|
||||
Namespace string `json:"namespace" form:"namespace"`
|
||||
// The lower limit for the number of pods that can be set by the autoscaler
|
||||
MinPods int64 `json:"minPods" form:"minPods"`
|
||||
// The upper limit for the number of pods that can be set by the autoscaler
|
||||
MaxPods int64 `json:"maxPods" form:"maxPods"`
|
||||
// The target average CPU utilization (represented as a percent of requested CPU) over all the pods
|
||||
CPUPercent int64 `json:"cpuPercent" form:"cpuPercent"`
|
||||
}
|
||||
|
||||
// Update params autoscaler deployment
|
||||
func (a *DeAutoscalerService) UpdateAutoscalerDeployment(ctx context.Context, req UpdateAutoscalerDeploymentRequest) (any, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result any
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ClusterID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "clusterId")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.NameDeployment) {
|
||||
missingRequiredParams = append(missingRequiredParams, "nameDeployment")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.Namespace) {
|
||||
missingRequiredParams = append(missingRequiredParams, "namespace")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/autoscaler/updateAutoscalerDeployment"
|
||||
|
||||
contentTypes := []string{"application/x-www-form-urlencoded"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "clusterId", req.ClusterID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "nameDeployment", req.NameDeployment, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "namespace", req.Namespace, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "minPods", req.MinPods, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "maxPods", req.MaxPods, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "cpuPercent", req.CPUPercent, "", "")
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp UpdateAutoscalerDeploymentResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_autoscaler
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/core"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type APIClient struct {
|
||||
common service
|
||||
|
||||
DeAutoscaler *DeAutoscalerService
|
||||
}
|
||||
|
||||
type service struct {
|
||||
client *utils.Client
|
||||
}
|
||||
|
||||
func NewAPIClient(cfg *core.Configuration) *APIClient {
|
||||
c := &APIClient{}
|
||||
c.common.client = utils.NewClient(cfg)
|
||||
|
||||
c.DeAutoscaler = (*DeAutoscalerService)(&c.common)
|
||||
|
||||
return c
|
||||
}
|
||||
Executable
+83
@@ -0,0 +1,83 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_autoscaler
|
||||
|
||||
type Autoscaler struct {
|
||||
Metadata AutoscalerMetadata `json:"metadata,omitempty"`
|
||||
Spec AutoscalerSpec `json:"spec,omitempty"`
|
||||
Status AutoscalerStatus `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
type AutoscalerMetadata struct {
|
||||
Annotations map[string]string `json:"annotations,omitempty"`
|
||||
CreationTimestamp string `json:"creationTimestamp,omitempty"`
|
||||
ManagedFields []ManagedField `json:"managedFields,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
Namespace string `json:"namespace,omitempty"`
|
||||
ResourceVersion string `json:"resourceVersion,omitempty"`
|
||||
UID string `json:"uid,omitempty"`
|
||||
}
|
||||
|
||||
type AutoscalerSpec struct {
|
||||
MaxReplicas int64 `json:"maxReplicas,omitempty"`
|
||||
MinReplicas int64 `json:"minReplicas,omitempty"`
|
||||
ScaleTargetRef ScaleTargetRef `json:"scaleTargetRef,omitempty"`
|
||||
TargetCPUUtilizationPercentage int64 `json:"targetCPUUtilizationPercentage,omitempty"`
|
||||
}
|
||||
|
||||
type AutoscalerStatus struct {
|
||||
CurrentReplicas int64 `json:"currentReplicas,omitempty"`
|
||||
DesiredReplicas int64 `json:"desiredReplicas,omitempty"`
|
||||
}
|
||||
|
||||
type ListAutoscalerDeploymentsResult struct {
|
||||
Items []Autoscaler `json:"items,omitempty"`
|
||||
Metadata ListAutoscalerMetadata `json:"metadata,omitempty"`
|
||||
}
|
||||
|
||||
type ListAutoscalerDeploymentsResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result ListAutoscalerDeploymentsResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type ListAutoscalerMetadata struct {
|
||||
ResourceVersion string `json:"resourceVersion,omitempty"`
|
||||
}
|
||||
|
||||
type ManagedField struct {
|
||||
APIVersion string `json:"apiVersion,omitempty"`
|
||||
FieldsType string `json:"fieldsType,omitempty"`
|
||||
Manager string `json:"manager,omitempty"`
|
||||
Operation string `json:"operation,omitempty"`
|
||||
Subresource string `json:"subresource,omitempty"`
|
||||
Time string `json:"time,omitempty"`
|
||||
}
|
||||
|
||||
type ScaleTargetRef struct {
|
||||
APIVersion string `json:"apiVersion,omitempty"`
|
||||
Kind string `json:"kind,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
}
|
||||
|
||||
type TurnOffAutoscalerDeploymentResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result any `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type TurnOnAutoscalerDeploymentResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result any `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type UpdateAutoscalerDeploymentResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result any `json:"result,omitempty"`
|
||||
}
|
||||
@@ -0,0 +1,179 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_certificates
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/core"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type DeCertificatesService service
|
||||
|
||||
type KubeadmCheckExpirationRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
}
|
||||
|
||||
// Check certificates expiration for a Kubernetes cluster
|
||||
func (a *DeCertificatesService) KubeadmCheckExpiration(ctx context.Context, req KubeadmCheckExpirationRequest) (KubeadmCertsCheckExpirationResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result KubeadmCertsCheckExpirationResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ClusterID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "clusterId")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/certificates/kubeadm/checkExpiration"
|
||||
|
||||
contentTypes := []string{"application/x-www-form-urlencoded"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "clusterId", req.ClusterID, "", "")
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp KubeadmCertsCheckExpirationResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
type KubeadmRenewRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
}
|
||||
|
||||
// Renew certificates for a Kubernetes cluster
|
||||
func (a *DeCertificatesService) KubeadmRenew(ctx context.Context, req KubeadmRenewRequest) (KubeadmCertsRenewResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result KubeadmCertsRenewResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ClusterID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "clusterId")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/certificates/kubeadm/renew"
|
||||
|
||||
contentTypes := []string{"application/x-www-form-urlencoded"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "clusterId", req.ClusterID, "", "")
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp KubeadmCertsRenewResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_certificates
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/core"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type APIClient struct {
|
||||
common service
|
||||
|
||||
DeCertificates *DeCertificatesService
|
||||
}
|
||||
|
||||
type service struct {
|
||||
client *utils.Client
|
||||
}
|
||||
|
||||
func NewAPIClient(cfg *core.Configuration) *APIClient {
|
||||
c := &APIClient{}
|
||||
c.common.client = utils.NewClient(cfg)
|
||||
|
||||
c.DeCertificates = (*DeCertificatesService)(&c.common)
|
||||
|
||||
return c
|
||||
}
|
||||
Executable
+25
@@ -0,0 +1,25 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_certificates
|
||||
|
||||
type KubeadmCertsCheckExpirationResult struct {
|
||||
TaskID int64 `json:"taskID,omitempty"`
|
||||
}
|
||||
|
||||
type KubeadmCertsCheckExpirationResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result KubeadmCertsCheckExpirationResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type KubeadmCertsRenewResult struct {
|
||||
TaskID int64 `json:"taskID,omitempty"`
|
||||
}
|
||||
|
||||
type KubeadmCertsRenewResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result KubeadmCertsRenewResult `json:"result,omitempty"`
|
||||
}
|
||||
@@ -0,0 +1,296 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_certmanager
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/core"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type DeCertmanagerService service
|
||||
|
||||
type DescribeRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// true for checking whether the certmanager is installed in the cluster
|
||||
CheckInstallation bool `json:"checkInstallation" form:"checkInstallation"`
|
||||
// true for checking k8s certmanager pods liveness and the availability of the API
|
||||
CheckLiveness bool `json:"CheckLiveness" form:"CheckLiveness"`
|
||||
}
|
||||
|
||||
// Get certmanager by id
|
||||
func (a *DeCertmanagerService) Describe(ctx context.Context, req DescribeRequest) (DescribeCertmanagerResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result DescribeCertmanagerResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ClusterID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "clusterId")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/certmanager/describe"
|
||||
|
||||
contentTypes := []string{"application/x-www-form-urlencoded"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "clusterId", req.ClusterID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "checkInstallation", req.CheckInstallation, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "CheckLiveness", req.CheckLiveness, "", "")
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp DescribeCertmanagerResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
type InstallRequest struct {
|
||||
// Cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// Hostname for certmanager
|
||||
//
|
||||
// Required.
|
||||
Hostname string `json:"hostname" form:"hostname"`
|
||||
// Hostname for integagent
|
||||
IntegagentHostname string `json:"integagentHostname" form:"integagentHostname"`
|
||||
// images apps repository ID. If the ID is zero or the value is empty, the default images apps repository will be used.
|
||||
AppsRepositoryID int64 `json:"appsRepositoryId" form:"appsRepositoryId"`
|
||||
// charts repository ID. If the ID is zero or the value is empty, the default charts repository will be used.
|
||||
ChartsRepositoryID int64 `json:"chartsRepositoryId" form:"chartsRepositoryId"`
|
||||
// worker group name for certmanager
|
||||
WorkerGroupName string `json:"workerGroupName" form:"workerGroupName"`
|
||||
// download chart anyway
|
||||
DownloadChartAnyway bool `json:"downloadChartAnyway" form:"downloadChartAnyway"`
|
||||
}
|
||||
|
||||
// Install certmanager in cluster
|
||||
func (a *DeCertmanagerService) Install(ctx context.Context, req InstallRequest) (CreateTaskResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result CreateTaskResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ClusterID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "clusterId")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.Hostname) {
|
||||
missingRequiredParams = append(missingRequiredParams, "hostname")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/certmanager/install"
|
||||
|
||||
contentTypes := []string{"application/x-www-form-urlencoded"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "clusterId", req.ClusterID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "hostname", req.Hostname, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "integagentHostname", req.IntegagentHostname, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "appsRepositoryId", req.AppsRepositoryID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "chartsRepositoryId", req.ChartsRepositoryID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "workerGroupName", req.WorkerGroupName, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "downloadChartAnyway", req.DownloadChartAnyway, "", "")
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp CreateTaskResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
type UninstallRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// true for deleting the certmanager even if it is not registered
|
||||
CleanAlways bool `json:"cleanAlways" form:"cleanAlways"`
|
||||
// true for ignoring dns server errors
|
||||
IgnoreDNSError bool `json:"ignoreDnsError" form:"ignoreDnsError"`
|
||||
}
|
||||
|
||||
// Uninstall certmanager from cluster
|
||||
func (a *DeCertmanagerService) Uninstall(ctx context.Context, req UninstallRequest) (CreateTaskResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result CreateTaskResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ClusterID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "clusterId")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/certmanager/uninstall"
|
||||
|
||||
contentTypes := []string{"application/x-www-form-urlencoded"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "clusterId", req.ClusterID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "cleanAlways", req.CleanAlways, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "ignoreDnsError", req.IgnoreDNSError, "", "")
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp CreateTaskResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_certmanager
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/core"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type APIClient struct {
|
||||
common service
|
||||
|
||||
DeCertmanager *DeCertmanagerService
|
||||
}
|
||||
|
||||
type service struct {
|
||||
client *utils.Client
|
||||
}
|
||||
|
||||
func NewAPIClient(cfg *core.Configuration) *APIClient {
|
||||
c := &APIClient{}
|
||||
c.common.client = utils.NewClient(cfg)
|
||||
|
||||
c.DeCertmanager = (*DeCertmanagerService)(&c.common)
|
||||
|
||||
return c
|
||||
}
|
||||
Executable
+33
@@ -0,0 +1,33 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_certmanager
|
||||
|
||||
type CertmanagerRecord struct {
|
||||
Addresses map[string]string `json:"addresses,omitempty"`
|
||||
CACert string `json:"caCert,omitempty"`
|
||||
CAKey string `json:"caKey,omitempty"`
|
||||
ClusterID int64 `json:"clusterId,omitempty"`
|
||||
Hostnames map[string]string `json:"hostnames,omitempty"`
|
||||
ID int64 `json:"id,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
OwnerID int64 `json:"ownerId,omitempty"`
|
||||
ProductName string `json:"productName,omitempty"`
|
||||
ProductVersion string `json:"productVersion,omitempty"`
|
||||
TaskIDs []int64 `json:"taskIds,omitempty"`
|
||||
WorkerGroupName string `json:"workerGroupName,omitempty"`
|
||||
}
|
||||
|
||||
type DescribeCertmanagerResult struct {
|
||||
CheckListOk bool `json:"checkListOk,omitempty"`
|
||||
Description ProductDescr `json:"description,omitempty"`
|
||||
Installed bool `json:"installed,omitempty"`
|
||||
Registered bool `json:"registered,omitempty"`
|
||||
Registry CertmanagerRecord `json:"registry,omitempty"`
|
||||
}
|
||||
|
||||
type DescribeCertmanagerResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result DescribeCertmanagerResult `json:"result,omitempty"`
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_certmanager
|
||||
|
||||
import (
|
||||
shared "repository.basistech.ru/BASIS/de-golang-sdk/shared"
|
||||
)
|
||||
|
||||
type CreateTaskResult = shared.CreateTaskResult
|
||||
type CreateTaskResultWithError = shared.CreateTaskResultWithError
|
||||
type ProductDescr = shared.ProductDescr
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,27 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_cluster
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/core"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type APIClient struct {
|
||||
common service
|
||||
|
||||
DeCluster *DeClusterService
|
||||
}
|
||||
|
||||
type service struct {
|
||||
client *utils.Client
|
||||
}
|
||||
|
||||
func NewAPIClient(cfg *core.Configuration) *APIClient {
|
||||
c := &APIClient{}
|
||||
c.common.client = utils.NewClient(cfg)
|
||||
|
||||
c.DeCluster = (*DeClusterService)(&c.common)
|
||||
|
||||
return c
|
||||
}
|
||||
Executable
+703
@@ -0,0 +1,703 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_cluster
|
||||
|
||||
type Cluster struct {
|
||||
AppContainerRepository string `json:"appContainerRepository,omitempty"`
|
||||
AuditEnabled bool `json:"auditEnabled,omitempty"`
|
||||
CertificateKey string `json:"certificateKey,omitempty"`
|
||||
CertificateValidityBefore string `json:"certificateValidityBefore,omitempty"`
|
||||
// Cni
|
||||
ContainerNetworkType string `json:"containerNetworkType,omitempty"`
|
||||
// Lifecycle data
|
||||
CreationDate string `json:"creationDate,omitempty"`
|
||||
CreationError string `json:"creationError,omitempty"`
|
||||
CustomMTU int64 `json:"customMTU,omitempty"`
|
||||
// Denergy data
|
||||
DenergyID int64 `json:"denergyId,omitempty"`
|
||||
DenergyName string `json:"denergyName,omitempty"`
|
||||
DenergyStatus string `json:"denergyStatus,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
DescriptionStatus map[string]string `json:"descriptionStatus,omitempty"`
|
||||
DestroyingDate string `json:"destroyingDate,omitempty"`
|
||||
DestroyingError string `json:"destroyingError,omitempty"`
|
||||
DNSDomain string `json:"dnsDomain,omitempty"`
|
||||
DomainResolvers []string `json:"domainResolvers,omitempty"`
|
||||
DynamixCIID int64 `json:"dynamixCIId,omitempty"`
|
||||
DynamixCreateTaskID string `json:"dynamixCreateTaskId,omitempty"`
|
||||
// Dynamyx data
|
||||
DynamixID int64 `json:"dynamixId,omitempty"`
|
||||
DynamixK8CIID int64 `json:"dynamixK8CIId,omitempty"`
|
||||
DynamixOwnerID int64 `json:"dynamixOwnerId,omitempty"`
|
||||
DynamixRGID int64 `json:"dynamixRGId,omitempty"`
|
||||
DynamixSEPID int64 `json:"dynamixSEPId,omitempty"`
|
||||
DynamixSEPPool string `json:"dynamixSEPPool,omitempty"`
|
||||
DynamixStatus string `json:"dynamixStatus,omitempty"`
|
||||
DynamixTechStatus string `json:"dynamixTechStatus,omitempty"`
|
||||
DynamixVersion DynamixVersion `json:"dynamixVersion,omitempty"`
|
||||
// Data encryption information
|
||||
Encrypted bool `json:"encrypted,omitempty"`
|
||||
ExtVirtualAddress string `json:"extVirtualAddress,omitempty"`
|
||||
// Virtual addresses
|
||||
ExtVirtualAddressID int64 `json:"extVirtualAddressId,omitempty"`
|
||||
GlobalNetworkID int64 `json:"globalNetworkId,omitempty"`
|
||||
// Components data
|
||||
ILoadBalancerIDs []int64 `json:"iLoadBalancerIds,omitempty"`
|
||||
ID int64 `json:"id,omitempty"`
|
||||
InitialDynamixSEPID int64 `json:"initialDynamixSEPId,omitempty"`
|
||||
InitialDynamixSEPPool string `json:"initialDynamixSEPPool,omitempty"`
|
||||
InitialMachineOSBuild string `json:"initialMachineOSBuild,omitempty"`
|
||||
InitialMachineOSImageID int64 `json:"initialMachineOSImageId,omitempty"`
|
||||
InitialMachineOSType string `json:"initialMachineOSType,omitempty"`
|
||||
// Reference for next machines
|
||||
InitialMachineProvider string `json:"initialMachineProvider,omitempty"`
|
||||
InitialRuntimeType string `json:"initialRuntimeType,omitempty"`
|
||||
// secure shell
|
||||
InitialSecureShellPort int64 `json:"initialSecureShellPort,omitempty"`
|
||||
// Instaled Components
|
||||
InstalledAutoscaler bool `json:"installedAutoscaler,omitempty"`
|
||||
InstalledCriobox bool `json:"installedCriobox,omitempty"`
|
||||
InstalledIntegagent bool `json:"installedIntegagent,omitempty"`
|
||||
InstalledKyverno bool `json:"installedKyverno,omitempty"`
|
||||
InstalledMetricServer bool `json:"installedMetricServer,omitempty"`
|
||||
InstalledMonitoring bool `json:"installedMonitoring,omitempty"`
|
||||
InstalledPodLogger bool `json:"installedPodLogger,omitempty"`
|
||||
InstalledRBACManager bool `json:"installedRbacManager,omitempty"`
|
||||
InstalledServchecker bool `json:"installedServchecker,omitempty"`
|
||||
InstalledTrivy bool `json:"installedTrivy,omitempty"`
|
||||
IntVirtualAddress string `json:"intVirtualAddress,omitempty"`
|
||||
IntVirtualAddressID int64 `json:"intVirtualAddressId,omitempty"`
|
||||
KubeAddresses []string `json:"kubeAddresses,omitempty"`
|
||||
KubeConfig string `json:"kubeConfig,omitempty"`
|
||||
// Repositories used for cluster nodes preparing and post install operatios
|
||||
KubeContainerRepository string `json:"kubeContainerRepository,omitempty"`
|
||||
KubeHostname string `json:"kubeHostname,omitempty"`
|
||||
// Kube data
|
||||
KubeVersion string `json:"kubeVersion,omitempty"`
|
||||
LoadBalancerCloudInitTemplate string `json:"loadBalancerCloudInitTemplate,omitempty"`
|
||||
LocalNetwork string `json:"localNetwork,omitempty"`
|
||||
LocalNetworkID int64 `json:"localNetworkId,omitempty"`
|
||||
// Templates
|
||||
MasterCloudInitTemplate string `json:"masterCloudInitTemplate,omitempty"`
|
||||
MasterIDs []int64 `json:"masterIds,omitempty"`
|
||||
// Generic data
|
||||
Name string `json:"name,omitempty"`
|
||||
OwnerID int64 `json:"ownerId,omitempty"`
|
||||
PolicyIDs []int64 `json:"policyIds,omitempty"`
|
||||
PoolVMIDs []int64 `json:"poolVmIds,omitempty"`
|
||||
// DNS data
|
||||
ProvideDNS bool `json:"provideDNS,omitempty"`
|
||||
Quorum int64 `json:"quorum,omitempty"`
|
||||
ReleaseVersion string `json:"releaseVersion,omitempty"`
|
||||
RootCAID int64 `json:"rootCaId,omitempty"`
|
||||
StoragePolicyID int64 `json:"storagePolicyId,omitempty"`
|
||||
TechStatus string `json:"techStatus,omitempty"`
|
||||
Type string `json:"type,omitempty"`
|
||||
UpgradeDate string `json:"upgradeDate,omitempty"`
|
||||
UpgradeError string `json:"upgradeError,omitempty"`
|
||||
// UseDynamixExtnet
|
||||
UseDynamixExtNet bool `json:"useDynamixExtnet,omitempty"`
|
||||
UserID int64 `json:"userId,omitempty"`
|
||||
VersionCrypt string `json:"versionCrypt,omitempty"`
|
||||
ViNSGlobalNetworkID int64 `json:"vinsGlobalNetworkId,omitempty"`
|
||||
WorkerGroupIDs []int64 `json:"workerGroupIds,omitempty"`
|
||||
WorkerIDs []int64 `json:"workerIds,omitempty"`
|
||||
}
|
||||
|
||||
type ClusterBrief struct {
|
||||
// Lifecycle data
|
||||
CreationDate string `json:"creationDate,omitempty"`
|
||||
// Denergy data
|
||||
DenergyStatus string `json:"denergyStatus,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
DescriptionStatus map[string]string `json:"descriptionStatus,omitempty"`
|
||||
// Dynamyx data
|
||||
DynamixCreateTaskID string `json:"dynamixCreateTaskId,omitempty"`
|
||||
DynamixStatus string `json:"dynamixStatus,omitempty"`
|
||||
ID int64 `json:"id,omitempty"`
|
||||
// Instaled Components
|
||||
InstalledAutoscaler bool `json:"installedAutoscaler,omitempty"`
|
||||
InstalledCriobox bool `json:"installedCriobox,omitempty"`
|
||||
InstalledKyverno bool `json:"installedKyverno,omitempty"`
|
||||
InstalledMetricServer bool `json:"installedMetricServer,omitempty"`
|
||||
InstalledMonitoring bool `json:"installedMonitoring,omitempty"`
|
||||
InstalledPodLogger bool `json:"installedPodLogger,omitempty"`
|
||||
InstalledRBACManager bool `json:"installedRbacManager,omitempty"`
|
||||
InstalledServchecker bool `json:"installedServchecker,omitempty"`
|
||||
InstalledTrivy bool `json:"installedTrivy,omitempty"`
|
||||
// Generic data
|
||||
Name string `json:"name,omitempty"`
|
||||
OwnerID int64 `json:"ownerId,omitempty"`
|
||||
// Reference for next machines
|
||||
TaskIDs []int64 `json:"taskIds,omitempty"`
|
||||
TechStatus string `json:"techStatus,omitempty"`
|
||||
Type string `json:"type,omitempty"`
|
||||
Username string `json:"username,omitempty"`
|
||||
}
|
||||
|
||||
type ClusterTaskCreationResult struct {
|
||||
AuditID string `json:"auditId,omitempty"`
|
||||
ClusterID int64 `json:"clusterId,omitempty"`
|
||||
ClusterType string `json:"clusterType,omitempty"`
|
||||
TaskID int64 `json:"taskId,omitempty"`
|
||||
TaskIsAsync bool `json:"taskIsAsync,omitempty"`
|
||||
}
|
||||
|
||||
type ClusterTaskCreationResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result ClusterTaskCreationResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type DescribeClusterResult struct {
|
||||
IncompleteVerificationTaskBriefs []TaskBrief `json:"incompleteVerificationTaskBriefs,omitempty"`
|
||||
TaskBriefs []TaskBrief `json:"taskBriefs,omitempty"`
|
||||
VerificationBriefs []VerificationBriefItem `json:"verificationBriefs,omitempty"`
|
||||
}
|
||||
|
||||
type DescribeClusterResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result DescribeClusterResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type DynamixVersion struct {
|
||||
Major int64 `json:"major,omitempty"`
|
||||
Minor int64 `json:"minor,omitempty"`
|
||||
Patch int64 `json:"patch,omitempty"`
|
||||
}
|
||||
|
||||
type GetClusterConfigResult struct {
|
||||
Config string `json:"config,omitempty"`
|
||||
}
|
||||
|
||||
type GetClusterConfigResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result GetClusterConfigResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type GetClusterResult struct {
|
||||
Cluster Cluster `json:"cluster,omitempty"`
|
||||
ILoadBalancers []LoadBalancerBrief `json:"iLoadBalancers,omitempty"`
|
||||
Masters []MasterBrief `json:"masters,omitempty"`
|
||||
Policies []PolicyBrief `json:"policies,omitempty"`
|
||||
Products []ProductShortDescr `json:"products,omitempty"`
|
||||
Quorum int64 `json:"quorum,omitempty"`
|
||||
TaskBriefs []TaskBrief `json:"taskBriefs,omitempty"`
|
||||
Username string `json:"username,omitempty"`
|
||||
Workers []WorkerBrief `json:"workers,omitempty"`
|
||||
}
|
||||
|
||||
type GetClusterResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result GetClusterResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type GetKubeResourcesResult struct {
|
||||
Any any `json:"any,omitempty"`
|
||||
}
|
||||
|
||||
type GetKubeResourcesResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result GetKubeResourcesResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type GetLoadBalancerResult struct {
|
||||
LoadBalancer LoadBalancer `json:"loadBalancer,omitempty"`
|
||||
}
|
||||
|
||||
type GetLoadBalancerResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result GetLoadBalancerResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type GetMasterResult struct {
|
||||
Master Master `json:"master,omitempty"`
|
||||
}
|
||||
|
||||
type GetMasterResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result GetMasterResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type GetWorkerResult struct {
|
||||
Worker Worker `json:"worker,omitempty"`
|
||||
}
|
||||
|
||||
type GetWorkerResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result GetWorkerResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type GPU struct {
|
||||
// TODO
|
||||
CoreCount int64 `json:"coreCount,omitempty"`
|
||||
// TODO change for vendor/ model?
|
||||
GPUName string `json:"gpuName,omitempty"`
|
||||
// TODO
|
||||
VideoMemorySize int64 `json:"videoMemorySize,omitempty"`
|
||||
}
|
||||
|
||||
type ListClustersResult struct {
|
||||
Clusters []ClusterBrief `json:"clusters,omitempty"`
|
||||
}
|
||||
|
||||
type ListClustersResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result ListClustersResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type ListKubeResourcesResult struct {
|
||||
Any any `json:"any,omitempty"`
|
||||
}
|
||||
|
||||
type ListKubeResourcesResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result ListKubeResourcesResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type ListLoadBalancersResult struct {
|
||||
LoadBalancers []LoadBalancer `json:"loadBalancers,omitempty"`
|
||||
}
|
||||
|
||||
type ListLoadBalancersResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result ListLoadBalancersResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type ListMastersResult struct {
|
||||
Masters []Master `json:"masters,omitempty"`
|
||||
Total int64 `json:"total,omitempty"`
|
||||
}
|
||||
|
||||
type ListMastersResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result ListMastersResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type ListWorkersResult struct {
|
||||
Workers []Worker `json:"workers,omitempty"`
|
||||
}
|
||||
|
||||
type ListWorkersResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result ListWorkersResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type LoadBalancer struct {
|
||||
BalancerStatus string `json:"balancerStatus,omitempty"`
|
||||
CloudInit string `json:"cloudInit,omitempty"`
|
||||
ClusterID int64 `json:"clusterId,omitempty"`
|
||||
CPUCount int64 `json:"cpuCount,omitempty"`
|
||||
// Lifecycle data
|
||||
CreationDate string `json:"creationDate,omitempty"`
|
||||
CreationError string `json:"creationError,omitempty"`
|
||||
// UpgradeDate string `json:\"upgradeDate,omitempty\" bson:\"upgradeDate\"` UpgradeError string `json:\"upgradeError,omitempty\" bson:\"upgradeError\"`
|
||||
DestroyingDate string `json:"destroyingDate,omitempty"`
|
||||
DestroyingError string `json:"destroyingError,omitempty"`
|
||||
DiskSize int64 `json:"diskSize,omitempty"`
|
||||
// Volume information
|
||||
DynamixSEPID int64 `json:"dynamixSEPId,omitempty"`
|
||||
DynamixSEPPool string `json:"dynamixSEPPool,omitempty"`
|
||||
// data encryption information
|
||||
Encrypted bool `json:"encrypted,omitempty"`
|
||||
// Access parameters
|
||||
ExtIPAddress string `json:"extIPAddress,omitempty"`
|
||||
GPUID int64 `json:"gpuId,omitempty"`
|
||||
GPUs []GPU `json:"gpus,omitempty"`
|
||||
HasGPU bool `json:"hasGPU,omitempty"`
|
||||
ID int64 `json:"id,omitempty"`
|
||||
IntIPAddress string `json:"intIPAddress,omitempty"`
|
||||
LBManagerPassword string `json:"lbmanagerPassword,omitempty"`
|
||||
LBManagerPort int64 `json:"lbmanagerPort,omitempty"`
|
||||
// Lbmanager
|
||||
LBManagerUsername string `json:"lbmanagerUsername,omitempty"`
|
||||
MachineOSImageID int64 `json:"machineOSImageId,omitempty"`
|
||||
MachineOSBuild string `json:"machineOsBuild,omitempty"`
|
||||
// Reference parametres
|
||||
MachineProvider string `json:"machineProvider,omitempty"`
|
||||
// Operational parameters
|
||||
MachineStatus string `json:"machineStatus,omitempty"`
|
||||
MachineType string `json:"machineType,omitempty"`
|
||||
// Information parameters
|
||||
MemorySize int64 `json:"memorySize,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
OwnerID int64 `json:"ownerId,omitempty"`
|
||||
ProviderMachineID int64 `json:"providerMachineId,omitempty"`
|
||||
ProviderMachineName string `json:"providerMachineName,omitempty"`
|
||||
ReferenceID int64 `json:"referenceId,omitempty"`
|
||||
SecureShellPort int64 `json:"secureShellPort,omitempty"`
|
||||
SysRootPassword string `json:"sysRootPassword,omitempty"`
|
||||
SysRootUsername string `json:"sysRootUsername,omitempty"`
|
||||
SysUserPassword string `json:"sysUserPassword,omitempty"`
|
||||
// Access parameters of service System & secure shell
|
||||
SysUserUsername string `json:"sysUserUsername,omitempty"`
|
||||
SysagentPassword string `json:"sysagentPassword,omitempty"`
|
||||
SysagentPort int64 `json:"sysagentPort,omitempty"`
|
||||
// Sysagent
|
||||
SysagentUsername string `json:"sysagentUsername,omitempty"`
|
||||
Type string `json:"type,omitempty"`
|
||||
VersionCrypt string `json:"versionCrypt,omitempty"`
|
||||
}
|
||||
|
||||
type LoadBalancerBrief struct {
|
||||
// Operational parameters
|
||||
BalancerStatus string `json:"balancerStatus,omitempty"`
|
||||
CPUCount int64 `json:"cpuCount,omitempty"`
|
||||
// Lifecycle data
|
||||
CreationDate string `json:"creationDate,omitempty"`
|
||||
DiskSize int64 `json:"diskSize,omitempty"`
|
||||
// Access parameters
|
||||
ExtIPAddress string `json:"extIPAddress,omitempty"`
|
||||
GPUID int64 `json:"gpuId,omitempty"`
|
||||
GPUName string `json:"gpuName,omitempty"`
|
||||
HasGPU bool `json:"hasGPU,omitempty"`
|
||||
ID int64 `json:"id,omitempty"`
|
||||
IntIPAddress string `json:"intIPAddress,omitempty"`
|
||||
// Information parameters
|
||||
MemorySize int64 `json:"memorySize,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
}
|
||||
|
||||
type Master struct {
|
||||
// Audit parameters for master
|
||||
AuditEnable bool `json:"auditEnable,omitempty"`
|
||||
AuditLogFilepath string `json:"auditLogFilepath,omitempty"`
|
||||
AuditLogMaxAge int64 `json:"auditLogMaxAge,omitempty"`
|
||||
AuditLogMaxBackup int64 `json:"auditLogMaxBackup,omitempty"`
|
||||
AuditLogMaxSize int64 `json:"auditLogMaxSize,omitempty"`
|
||||
AuditPolicy string `json:"auditPolicy,omitempty"`
|
||||
// Input data for cloud-init facility
|
||||
CloudInit string `json:"cloudInit,omitempty"`
|
||||
ClusterID int64 `json:"clusterId,omitempty"`
|
||||
CPUCount int64 `json:"cpuCount,omitempty"`
|
||||
// Lifecycle data
|
||||
CreationDate string `json:"creationDate,omitempty"`
|
||||
CreationError string `json:"creationError,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
// UpgradeDate string `json:\"upgradeDate,omitempty\" bson:\"upgradeDate\"` UpgradeError string `json:\"upgradeError,omitempty\" bson:\"upgradeError\"`
|
||||
DestroyingDate string `json:"destroyingDate,omitempty"`
|
||||
DestroyingError string `json:"destroyingError,omitempty"`
|
||||
DiskSize int64 `json:"diskSize,omitempty"`
|
||||
// Volume information
|
||||
DynamixSEPID int64 `json:"dynamixSEPId,omitempty"`
|
||||
DynamixSEPPool string `json:"dynamixSEPPool,omitempty"`
|
||||
// data encryption information
|
||||
Encrypted bool `json:"encrypted,omitempty"`
|
||||
// Access parameters
|
||||
ExtIPAddress string `json:"extIPAddress,omitempty"`
|
||||
GPUID int64 `json:"gpuId,omitempty"`
|
||||
GPUs []GPU `json:"gpus,omitempty"`
|
||||
HasGPU bool `json:"hasGPU,omitempty"`
|
||||
ID int64 `json:"id,omitempty"`
|
||||
IntIPAddress string `json:"intIPAddress,omitempty"`
|
||||
IsSpare bool `json:"isSpare,omitempty"`
|
||||
// Encryption key for /etc/kubernetes/encryption-config.yaml:
|
||||
KeyForEncryptionConfig string `json:"keyForEncryptionConfig,omitempty"`
|
||||
LogWatcherPassword string `json:"logwatcherPassword,omitempty"`
|
||||
LogWatcherPort int64 `json:"logwatcherPort,omitempty"`
|
||||
LogWatcherUsername string `json:"logwatcherUsername,omitempty"`
|
||||
MachineOSBuild string `json:"machineOSBuild,omitempty"`
|
||||
MachineOSImageID int64 `json:"machineOSImageId,omitempty"`
|
||||
MachineOSType string `json:"machineOSType,omitempty"`
|
||||
// Reference parameters
|
||||
MachineProvider string `json:"machineProvider,omitempty"`
|
||||
// Operational parameters
|
||||
MachineStatus string `json:"machineStatus,omitempty"`
|
||||
// Information parameters
|
||||
MemorySize int64 `json:"memorySize,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
NodeStatus string `json:"nodeStatus,omitempty"`
|
||||
OwnerID int64 `json:"ownerId,omitempty"`
|
||||
ProviderMachineID int64 `json:"providerMachineId,omitempty"`
|
||||
ProviderMachineName string `json:"providerMachineName,omitempty"`
|
||||
ReferenceID int64 `json:"referenceId,omitempty"`
|
||||
// Container runtime info
|
||||
RuntimeEndPoint string `json:"runtimeEndPoint,omitempty"`
|
||||
RuntimeType string `json:"runtimeType,omitempty"`
|
||||
SecureShellPort int64 `json:"secureShellPort,omitempty"`
|
||||
SysRootPassword string `json:"sysRootPassword,omitempty"`
|
||||
SysRootUsername string `json:"sysRootUsername,omitempty"`
|
||||
SysUserPassword string `json:"sysUserPassword,omitempty"`
|
||||
// Access parameters of services System & secure shell
|
||||
SysUserUsername string `json:"sysUserUsername,omitempty"`
|
||||
SysagentPassword string `json:"sysagentPassword,omitempty"`
|
||||
SysagentPort int64 `json:"sysagentPort,omitempty"`
|
||||
// Sysagent
|
||||
SysagentUsername string `json:"sysagentUsername,omitempty"`
|
||||
Type string `json:"type,omitempty"`
|
||||
VersionCrypt string `json:"versionCrypt,omitempty"`
|
||||
// WorkerGroup label for worker
|
||||
WorkerGroupID int64 `json:"workerGroupId,omitempty"`
|
||||
}
|
||||
|
||||
type MasterBrief struct {
|
||||
CPUCount int64 `json:"cpuCount,omitempty"`
|
||||
// Lifecycle data
|
||||
CreationDate string `json:"creationDate,omitempty"`
|
||||
DiskSize int64 `json:"diskSize,omitempty"`
|
||||
// Access parameters
|
||||
ExtIPAddress string `json:"extIPAddress,omitempty"`
|
||||
GPUID int64 `json:"gpuId,omitempty"`
|
||||
GPUName string `json:"gpuName,omitempty"`
|
||||
HasGPU bool `json:"hasGPU,omitempty"`
|
||||
ID int64 `json:"id,omitempty"`
|
||||
// Information parameters
|
||||
MemorySize int64 `json:"memorySize,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
// Operational parameters
|
||||
NodeStatus string `json:"nodeStatus,omitempty"`
|
||||
// Container runtime info
|
||||
RuntimeType string `json:"runtimeType,omitempty"`
|
||||
}
|
||||
|
||||
type NetworkDescribeResult struct {
|
||||
ClusterDNS string `json:"clusterDns,omitempty"`
|
||||
Cni string `json:"cni,omitempty"`
|
||||
Encap string `json:"encap,omitempty"`
|
||||
KubeProxy string `json:"kubeProxy,omitempty"`
|
||||
MTU int64 `json:"mtu,omitempty"`
|
||||
NetworkPolicy string `json:"networkPolicy,omitempty"`
|
||||
Overlay bool `json:"overlay,omitempty"`
|
||||
PodCIDR string `json:"podCidr,omitempty"`
|
||||
ServiceCIDR string `json:"serviceCidr,omitempty"`
|
||||
TrafficRouting string `json:"trafficRouting,omitempty"`
|
||||
}
|
||||
|
||||
type NetworkDescribeResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result NetworkDescribeResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type PolicyBrief struct {
|
||||
Background bool `json:"background,omitempty"`
|
||||
Category string `json:"category,omitempty"`
|
||||
Default bool `json:"default,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
ID int64 `json:"id,omitempty"`
|
||||
// main brief info showed by kubectl get cluterpolicy command
|
||||
Name string `json:"name,omitempty"`
|
||||
Rules []Rule `json:"rules,omitempty"`
|
||||
Severity string `json:"severity,omitempty"`
|
||||
ValidateAction string `json:"validateAction,omitempty"`
|
||||
}
|
||||
|
||||
type ProductShortDescr struct {
|
||||
ID int64 `json:"id,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
ProductName string `json:"productName,omitempty"`
|
||||
ProductVersion string `json:"productVersion,omitempty"`
|
||||
}
|
||||
|
||||
type SetClusterKubeVersionResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result any `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type SetClusterStatusResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result any `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type SetLoadBalancerStatusResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result any `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type SetMasterStatusResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result any `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type SetPoolVMStatusResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result any `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type SetWorkerStatusResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result any `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type UpdateClusterConfigResult struct {
|
||||
KubeConfig string `json:"kubeConfig,omitempty"`
|
||||
}
|
||||
|
||||
type UpdateClusterConfigResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result UpdateClusterConfigResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type UpdateClusterOwnerIDResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result any `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type UpdateCNIConfigResult struct {
|
||||
TaskID int64 `json:"taskId,omitempty"`
|
||||
}
|
||||
|
||||
type UpdateCNIConfigResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result UpdateCNIConfigResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type VerificationBrief struct {
|
||||
Done bool `json:"done,omitempty"`
|
||||
Error bool `json:"error,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
NodeID int64 `json:"nodeId,omitempty"`
|
||||
Operation string `json:"operation,omitempty"`
|
||||
ReportID int64 `json:"reportId,omitempty"`
|
||||
StartTimestamp string `json:"startTimestamp,omitempty"`
|
||||
StopTimestamp string `json:"stopTimestamp,omitempty"`
|
||||
SubjectID int64 `json:"subjectId,omitempty"`
|
||||
TotalFail int64 `json:"totalFail,omitempty"`
|
||||
TotalInfo int64 `json:"totalInfo,omitempty"`
|
||||
TotalPass int64 `json:"totalPass,omitempty"`
|
||||
TotalWarn int64 `json:"totalWarn,omitempty"`
|
||||
VerificationType string `json:"verificationType,omitempty"`
|
||||
}
|
||||
|
||||
type VerificationBriefItem struct {
|
||||
// Verification briefs for the task
|
||||
BriefsList []VerificationBrief `json:"briefsList,omitempty"`
|
||||
// Task info
|
||||
TaskBrief TaskBrief `json:"taskBrief,omitempty"`
|
||||
}
|
||||
|
||||
type Worker struct {
|
||||
// Audit parameters for master
|
||||
AuditEnable bool `json:"auditEnable,omitempty"`
|
||||
AuditLogFilepath string `json:"auditLogFilepath,omitempty"`
|
||||
AuditLogMaxAge int64 `json:"auditLogMaxAge,omitempty"`
|
||||
AuditLogMaxBackup int64 `json:"auditLogMaxBackup,omitempty"`
|
||||
AuditLogMaxSize int64 `json:"auditLogMaxSize,omitempty"`
|
||||
AuditPolicy string `json:"auditPolicy,omitempty"`
|
||||
// Input data for cloud-init facility
|
||||
CloudInit string `json:"cloudInit,omitempty"`
|
||||
ClusterID int64 `json:"clusterId,omitempty"`
|
||||
CPUCount int64 `json:"cpuCount,omitempty"`
|
||||
// Lifecycle data
|
||||
CreationDate string `json:"creationDate,omitempty"`
|
||||
CreationError string `json:"creationError,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
// UpgradeDate string `json:\"upgradeDate,omitempty\" bson:\"upgradeDate\"` UpgradeError string `json:\"upgradeError,omitempty\" bson:\"upgradeError\"`
|
||||
DestroyingDate string `json:"destroyingDate,omitempty"`
|
||||
DestroyingError string `json:"destroyingError,omitempty"`
|
||||
DiskSize int64 `json:"diskSize,omitempty"`
|
||||
// Volume information
|
||||
DynamixSEPID int64 `json:"dynamixSEPId,omitempty"`
|
||||
DynamixSEPPool string `json:"dynamixSEPPool,omitempty"`
|
||||
// data encryption information
|
||||
Encrypted bool `json:"encrypted,omitempty"`
|
||||
// Access parameters
|
||||
ExtIPAddress string `json:"extIPAddress,omitempty"`
|
||||
GPUID int64 `json:"gpuId,omitempty"`
|
||||
GPUs []GPU `json:"gpus,omitempty"`
|
||||
HasGPU bool `json:"hasGPU,omitempty"`
|
||||
ID int64 `json:"id,omitempty"`
|
||||
IntIPAddress string `json:"intIPAddress,omitempty"`
|
||||
IsSpare bool `json:"isSpare,omitempty"`
|
||||
// Encryption key for /etc/kubernetes/encryption-config.yaml:
|
||||
KeyForEncryptionConfig string `json:"keyForEncryptionConfig,omitempty"`
|
||||
LogWatcherPassword string `json:"logwatcherPassword,omitempty"`
|
||||
LogWatcherPort int64 `json:"logwatcherPort,omitempty"`
|
||||
LogWatcherUsername string `json:"logwatcherUsername,omitempty"`
|
||||
MachineOSBuild string `json:"machineOSBuild,omitempty"`
|
||||
MachineOSImageID int64 `json:"machineOSImageId,omitempty"`
|
||||
MachineOSType string `json:"machineOSType,omitempty"`
|
||||
// Reference parameters
|
||||
MachineProvider string `json:"machineProvider,omitempty"`
|
||||
// Operational parameters
|
||||
MachineStatus string `json:"machineStatus,omitempty"`
|
||||
// Information parameters
|
||||
MemorySize int64 `json:"memorySize,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
NodeStatus string `json:"nodeStatus,omitempty"`
|
||||
OwnerID int64 `json:"ownerId,omitempty"`
|
||||
ProviderMachineID int64 `json:"providerMachineId,omitempty"`
|
||||
ProviderMachineName string `json:"providerMachineName,omitempty"`
|
||||
ReferenceID int64 `json:"referenceId,omitempty"`
|
||||
// Container runtime info
|
||||
RuntimeEndPoint string `json:"runtimeEndPoint,omitempty"`
|
||||
RuntimeType string `json:"runtimeType,omitempty"`
|
||||
SecureShellPort int64 `json:"secureShellPort,omitempty"`
|
||||
SysRootPassword string `json:"sysRootPassword,omitempty"`
|
||||
SysRootUsername string `json:"sysRootUsername,omitempty"`
|
||||
SysUserPassword string `json:"sysUserPassword,omitempty"`
|
||||
// Access parameters of services System & secure shell
|
||||
SysUserUsername string `json:"sysUserUsername,omitempty"`
|
||||
SysagentPassword string `json:"sysagentPassword,omitempty"`
|
||||
SysagentPort int64 `json:"sysagentPort,omitempty"`
|
||||
// Sysagent
|
||||
SysagentUsername string `json:"sysagentUsername,omitempty"`
|
||||
Type string `json:"type,omitempty"`
|
||||
VersionCrypt string `json:"versionCrypt,omitempty"`
|
||||
// WorkerGroup label for worker
|
||||
WorkerGroupID int64 `json:"workerGroupId,omitempty"`
|
||||
}
|
||||
|
||||
type WorkerBrief struct {
|
||||
CPUCount int64 `json:"cpuCount,omitempty"`
|
||||
// Lifecycle data
|
||||
CreationDate string `json:"creationDate,omitempty"`
|
||||
DiskSize int64 `json:"diskSize,omitempty"`
|
||||
GPUID int64 `json:"gpuId,omitempty"`
|
||||
GPUName string `json:"gpuName,omitempty"`
|
||||
HasGPU bool `json:"hasGPU,omitempty"`
|
||||
ID int64 `json:"id,omitempty"`
|
||||
// Information parameters
|
||||
MemorySize int64 `json:"memorySize,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
// Operational parameters
|
||||
NodeStatus string `json:"nodeStatus,omitempty"`
|
||||
// Container runtime info
|
||||
RuntimeType string `json:"runtimeType,omitempty"`
|
||||
// WorkerGroup label for worker
|
||||
WorkerGroupID int64 `json:"workerGroupId,omitempty"`
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_cluster
|
||||
|
||||
import (
|
||||
shared "repository.basistech.ru/BASIS/de-golang-sdk/shared"
|
||||
)
|
||||
|
||||
type CreateTaskResult = shared.CreateTaskResult
|
||||
type CreateTaskResultWithError = shared.CreateTaskResultWithError
|
||||
type Rule = shared.Rule
|
||||
type TaskBrief = shared.TaskBrief
|
||||
@@ -0,0 +1,460 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_cluster_template
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/core"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type DeClusterTemplateService service
|
||||
|
||||
type DeleteRequest struct {
|
||||
// cluster template id
|
||||
//
|
||||
// Required.
|
||||
ID int64 `json:"id" form:"id"`
|
||||
}
|
||||
|
||||
// Delete cluster template
|
||||
func (a *DeClusterTemplateService) Delete(ctx context.Context, req DeleteRequest) (DeleteClusterTemplateResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result DeleteClusterTemplateResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "id")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/clusterTemplate/delete"
|
||||
|
||||
contentTypes := []string{"application/x-www-form-urlencoded"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "id", req.ID, "", "")
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp DeleteClusterTemplateResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
type DuplicateRequest struct {
|
||||
// cluster template id
|
||||
//
|
||||
// Required.
|
||||
ID int64 `json:"id" form:"id"`
|
||||
// cluster template name (default: from original)
|
||||
ClusterTemplateName string `json:"clusterTemplateName" form:"clusterTemplateName"`
|
||||
// cluster template description (default: from original)
|
||||
ClusterTemplateDescription string `json:"clusterTemplateDescription" form:"clusterTemplateDescription"`
|
||||
// share cluster template with others
|
||||
ShareClusterTemplate bool `json:"shareClusterTemplate" form:"shareClusterTemplate"`
|
||||
}
|
||||
|
||||
// Duplicate cluster template
|
||||
func (a *DeClusterTemplateService) Duplicate(ctx context.Context, req DuplicateRequest) (DuplicateClusterTemplateResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result DuplicateClusterTemplateResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "id")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/clusterTemplate/duplicate"
|
||||
|
||||
contentTypes := []string{"application/x-www-form-urlencoded"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "id", req.ID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "clusterTemplateName", req.ClusterTemplateName, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "clusterTemplateDescription", req.ClusterTemplateDescription, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "shareClusterTemplate", req.ShareClusterTemplate, "", "")
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp DuplicateClusterTemplateResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
type GetRequest struct {
|
||||
// cluster template id
|
||||
//
|
||||
// Required.
|
||||
ID int64 `json:"id" form:"id"`
|
||||
}
|
||||
|
||||
// Get cluster template
|
||||
func (a *DeClusterTemplateService) Get(ctx context.Context, req GetRequest) (GetClusterTemplateResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result GetClusterTemplateResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "id")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/clusterTemplate/get"
|
||||
|
||||
contentTypes := []string{"application/x-www-form-urlencoded"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "id", req.ID, "", "")
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp GetClusterTemplateResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
type ListRequest struct {
|
||||
// filter by installed cluster type
|
||||
//
|
||||
// Allowed values:
|
||||
// - "dynamix"
|
||||
// - "generic"
|
||||
// - "denergy"
|
||||
// - "baremetal"
|
||||
ClusterType string `json:"clusterType" form:"clusterType"`
|
||||
// Sort by one of supported fields, format +|-(field>)
|
||||
SortBy string `json:"sortBy" form:"sortBy"`
|
||||
// Limit number of tasks results to be shown in the result. If not set, all task results will be shown.
|
||||
Limit int64 `json:"limit" form:"limit"`
|
||||
// Select page of the result. If not set, the first page will be shown.
|
||||
Page int64 `json:"page" form:"page"`
|
||||
}
|
||||
|
||||
// List cluster templates
|
||||
func (a *DeClusterTemplateService) List(ctx context.Context, req ListRequest) (ListClusterTemplatesResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result ListClusterTemplatesResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
|
||||
if !utils.IsZeroValue(req.ClusterType) {
|
||||
clusterTypeValue := req.ClusterType
|
||||
clusterTypeAllowedValues := []string{
|
||||
"dynamix",
|
||||
"generic",
|
||||
"denergy",
|
||||
"baremetal",
|
||||
}
|
||||
clusterTypeValid := false
|
||||
for _, allowed := range clusterTypeAllowedValues {
|
||||
if clusterTypeValue == allowed {
|
||||
clusterTypeValid = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !clusterTypeValid {
|
||||
return result, fmt.Errorf("clusterType must be one of %v", clusterTypeAllowedValues)
|
||||
}
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/clusterTemplate/list"
|
||||
|
||||
contentTypes := []string{"application/x-www-form-urlencoded"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "clusterType", req.ClusterType, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "sortBy", req.SortBy, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "limit", req.Limit, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "page", req.Page, "", "")
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp ListClusterTemplatesResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
type UpdateRequest struct {
|
||||
// update cluster templates request
|
||||
//
|
||||
// Required.
|
||||
ExtraCluster UpdateClusterTemplateRequest `json:"extraCluster" form:"extraCluster"`
|
||||
}
|
||||
|
||||
// Update cluster template
|
||||
func (a *DeClusterTemplateService) Update(ctx context.Context, req UpdateRequest) (UpdateClusterTemplateResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result UpdateClusterTemplateResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ExtraCluster) {
|
||||
missingRequiredParams = append(missingRequiredParams, "extraCluster")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/clusterTemplate/update"
|
||||
|
||||
contentTypes := []string{"application/json"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
requestBody = req.ExtraCluster
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp UpdateClusterTemplateResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_cluster_template
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/core"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type APIClient struct {
|
||||
common service
|
||||
|
||||
DeClusterTemplate *DeClusterTemplateService
|
||||
}
|
||||
|
||||
type service struct {
|
||||
client *utils.Client
|
||||
}
|
||||
|
||||
func NewAPIClient(cfg *core.Configuration) *APIClient {
|
||||
c := &APIClient{}
|
||||
c.common.client = utils.NewClient(cfg)
|
||||
|
||||
c.DeClusterTemplate = (*DeClusterTemplateService)(&c.common)
|
||||
|
||||
return c
|
||||
}
|
||||
Executable
+354
@@ -0,0 +1,354 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_cluster_template
|
||||
|
||||
type ClusterTemplate struct {
|
||||
AppContainerRepository int64 `json:"appContainerRepository,omitempty"`
|
||||
AuditEnable bool `json:"auditEnable,omitempty"`
|
||||
AuditLogMaxAge int64 `json:"auditLogMaxAge,omitempty"`
|
||||
AuditLogMaxBackup int64 `json:"auditLogMaxBackup,omitempty"`
|
||||
AuditLogMaxSize int64 `json:"auditLogMaxSize,omitempty"`
|
||||
AuditPolicy string `json:"auditPolicy,omitempty"`
|
||||
BalancersDynamixSEPID int64 `json:"balancersDynamixSEPId,omitempty"`
|
||||
BalancersDynamixSEPPool string `json:"balancersDynamixSEPPool,omitempty"`
|
||||
CertificateIssuerID int64 `json:"certificateIssuerId,omitempty"`
|
||||
CertificateKey string `json:"certificateKey,omitempty"`
|
||||
CertificateValidityBefore string `json:"certificateValidityBefore,omitempty"`
|
||||
ChartRepository int64 `json:"chartRepository,omitempty"`
|
||||
ClusterHostname string `json:"clusterHostname,omitempty"`
|
||||
ClusterMachineOSBuild string `json:"clusterMachineOSBuild,omitempty"`
|
||||
ClusterMachineOSType string `json:"clusterMachineOSType,omitempty"`
|
||||
ClusterName string `json:"clusterName,omitempty"`
|
||||
ClusterTemplateDescription string `json:"clusterTemplateDescription,omitempty"`
|
||||
ClusterTemplateName string `json:"clusterTemplateName,omitempty"`
|
||||
ClusterType string `json:"clusterType,omitempty"`
|
||||
ContainerNetworkType string `json:"containerNetworkType,omitempty"`
|
||||
CreationDate string `json:"creationDate,omitempty"`
|
||||
CustomMTU int64 `json:"customMTU,omitempty"`
|
||||
DenergyRuntimeType string `json:"denergyRuntimeType,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
DomainResolvers []string `json:"domainResolvers,omitempty"`
|
||||
DynamixAppID string `json:"dynamixAppId,omitempty"`
|
||||
DynamixAppSecret string `json:"dynamixAppSecret,omitempty"`
|
||||
DynamixAuthDomain string `json:"dynamixAuthDomain,omitempty"`
|
||||
DynamixAuthType string `json:"dynamixAuthType,omitempty"`
|
||||
DynamixK8CIID int64 `json:"dynamixK8CIId,omitempty"`
|
||||
DynamixPassword string `json:"dynamixPassword,omitempty"`
|
||||
DynamixRGID int64 `json:"dynamixRGId,omitempty"`
|
||||
DynamixSEPID int64 `json:"dynamixSEPId,omitempty"`
|
||||
DynamixSEPPool string `json:"dynamixSEPPool,omitempty"`
|
||||
DynamixSSOURL string `json:"dynamixSSOURL,omitempty"`
|
||||
DynamixURL string `json:"dynamixURL,omitempty"`
|
||||
DynamixUsername string `json:"dynamixUsername,omitempty"`
|
||||
EnableCustomLoadBalancerHostnames bool `json:"enableCustomLoadBalancerHostnames,omitempty"`
|
||||
EnableCustomMasterHostnames bool `json:"enableCustomMasterHostnames,omitempty"`
|
||||
EnableCustomWorkerHostnames bool `json:"enableCustomWorkerHostnames,omitempty"`
|
||||
// Data encryption information
|
||||
Encrypted bool `json:"encrypted,omitempty"`
|
||||
// VirtualAddresses Section
|
||||
ExtVirtualAddress string `json:"extVirtualAddress,omitempty"`
|
||||
ExternalLBAddresses []string `json:"externalLBAddresses,omitempty"`
|
||||
GlobalNetworkID int64 `json:"globalNetworkId,omitempty"`
|
||||
ILoadBalancerCPUCount int64 `json:"iLoadBalancerCPUCount,omitempty"`
|
||||
ILoadBalancerCloudInit string `json:"iLoadBalancerCloudInit,omitempty"`
|
||||
ILoadBalancerCount int64 `json:"iLoadBalancerCount,omitempty"`
|
||||
ILoadBalancerDiskSize int64 `json:"iLoadBalancerDiskSize,omitempty"`
|
||||
ILoadBalancerGPUIDs []int64 `json:"iLoadBalancerGpuIds,omitempty"`
|
||||
ILoadBalancerMemorySize int64 `json:"iLoadBalancerMemorySize,omitempty"`
|
||||
ID int64 `json:"id,omitempty"`
|
||||
InitialSecureShellPort int64 `json:"initialSecureShellPort,omitempty"`
|
||||
InstallAutoscaler bool `json:"installAutoscaler,omitempty"`
|
||||
InstallCriobox bool `json:"installCriobox,omitempty"`
|
||||
InstallKyverno bool `json:"installKyverno,omitempty"`
|
||||
InstallMetrics bool `json:"installMetrics,omitempty"`
|
||||
InstallMonitoring bool `json:"installMonitoring,omitempty"`
|
||||
InstallPodLogger bool `json:"installPodLogger,omitempty"`
|
||||
InstallRBACManager bool `json:"installRbacManager,omitempty"`
|
||||
InstallTrivy bool `json:"installTrivy,omitempty"`
|
||||
IntVirtualAddress string `json:"intVirtualAddress,omitempty"`
|
||||
InternalLBAddresses []string `json:"internalLBAddresses,omitempty"`
|
||||
KubeConfig string `json:"kubeConfig,omitempty"`
|
||||
KubeContainerRepository int64 `json:"kubeContainerRepository,omitempty"`
|
||||
KubeVersion string `json:"kubeVersion,omitempty"`
|
||||
LastEditor int64 `json:"lastEditor,omitempty"`
|
||||
LoadBalancerExternalIPAddresses []string `json:"loadBalancerExternalIPAddresses,omitempty"`
|
||||
LoadBalancerHostnames []string `json:"loadBalancerHostnames,omitempty"`
|
||||
LoadBalancerInternalIPAddresses []string `json:"loadBalancerInternalIPAddresses,omitempty"`
|
||||
LoadBalancerMachineOSBuild []string `json:"loadBalancerMachineOSBuild,omitempty"`
|
||||
LoadBalancerMachineOSType []string `json:"loadBalancerMachineOSType,omitempty"`
|
||||
LoadBalancerRootPasswords []string `json:"loadBalancerRootPasswords,omitempty"`
|
||||
LoadBalancerRootUsernames []string `json:"loadBalancerRootUsernames,omitempty"`
|
||||
LoadBalancerSecureShellPorts []int64 `json:"loadBalancerSecureShellPorts,omitempty"`
|
||||
LoadBalancerUserPasswords []string `json:"loadBalancerUserPasswords,omitempty"`
|
||||
LoadBalancerUserUsernames []string `json:"loadBalancerUserUsernames,omitempty"`
|
||||
LocalNetworkID int64 `json:"localNetworkId,omitempty"`
|
||||
MachineOSBuild string `json:"machineOSBuild,omitempty"`
|
||||
MachineOSImageID int64 `json:"machineOSImageId,omitempty"`
|
||||
MachineOSType string `json:"machineOSType,omitempty"`
|
||||
MachineProvider string `json:"machineProvider,omitempty"`
|
||||
MasterAddresses []string `json:"masterAddresses,omitempty"`
|
||||
MasterCPUCount int64 `json:"masterCPUCount,omitempty"`
|
||||
MasterCloudInit string `json:"masterCloudInit,omitempty"`
|
||||
MasterCount int64 `json:"masterCount,omitempty"`
|
||||
MasterDiskSize int64 `json:"masterDiskSize,omitempty"`
|
||||
MasterGPUIDs []int64 `json:"masterGpuIds,omitempty"`
|
||||
MasterHostnames []string `json:"masterHostnames,omitempty"`
|
||||
MasterMemorySize int64 `json:"masterMemorySize,omitempty"`
|
||||
MasterNodesExternalIPAdresses []string `json:"masterNodesExternalIPAdresses,omitempty"`
|
||||
MasterNodesMachineOSBuilds []string `json:"masterNodesMachineOSBuilds,omitempty"`
|
||||
MasterNodesMachineOSTypes []string `json:"masterNodesMachineOSTypes,omitempty"`
|
||||
MasterNodesRootPasswords []string `json:"masterNodesRootPasswords,omitempty"`
|
||||
MasterNodesRootUsernames []string `json:"masterNodesRootUsernames,omitempty"`
|
||||
MasterNodesSecureShellPorts []int64 `json:"masterNodesSecureShellPorts,omitempty"`
|
||||
MasterNodesUserPasswords []string `json:"masterNodesUserPasswords,omitempty"`
|
||||
MasterNodesUserUsernames []string `json:"masterNodesUserUsernames,omitempty"`
|
||||
MastersDynamixSEPID int64 `json:"mastersDynamixSEPId,omitempty"`
|
||||
MastersDynamixSEPPool string `json:"mastersDynamixSEPPool,omitempty"`
|
||||
OwnerID int64 `json:"ownerId,omitempty"`
|
||||
PackageRepository int64 `json:"packageRepository,omitempty"`
|
||||
ProvideDNS bool `json:"provideDNS,omitempty"`
|
||||
SaveComputesOnFailedK8SCreation bool `json:"saveComputesOnFailedK8SCreation,omitempty"`
|
||||
Shared bool `json:"shared,omitempty"`
|
||||
StoragePolicyID int64 `json:"storagePolicyID,omitempty"`
|
||||
UseCustomExternalLBAddreses bool `json:"useCustomExternalLBAddreses,omitempty"`
|
||||
UseCustomInternalLBAddreses bool `json:"useCustomInternalLBAddreses,omitempty"`
|
||||
UseCustomMasterIPAddresses bool `json:"useCustomMasterIPAddresses,omitempty"`
|
||||
UseCustomWorkerIPAddresses bool `json:"useCustomWorkerIPAddresses,omitempty"`
|
||||
UseDynamixExtNet bool `json:"useDynamixExtnet,omitempty"`
|
||||
UserID int64 `json:"userId,omitempty"`
|
||||
VersionCrypt string `json:"versionCrypt,omitempty"`
|
||||
ViNSGlobalNetworkID int64 `json:"vinsGlobalNetworkId,omitempty"`
|
||||
WorkerAddresses []string `json:"workerAddresses,omitempty"`
|
||||
WorkerAnnotations []string `json:"workerAnnotations,omitempty"`
|
||||
WorkerCPUCount int64 `json:"workerCPUCount,omitempty"`
|
||||
WorkerCloudInit string `json:"workerCloudInit,omitempty"`
|
||||
WorkerCount int64 `json:"workerCount,omitempty"`
|
||||
WorkerDiskSize int64 `json:"workerDiskSize,omitempty"`
|
||||
WorkerGPUIDs []int64 `json:"workerGpuIds,omitempty"`
|
||||
WorkerGroupName string `json:"workerGroupName,omitempty"`
|
||||
WorkerHostnames []string `json:"workerHostnames,omitempty"`
|
||||
// WorkerGroup string `json:\"workerGroup\" bson:\"workerGroup\"`
|
||||
WorkerLabels []string `json:"workerLabels,omitempty"`
|
||||
WorkerMemorySize int64 `json:"workerMemorySize,omitempty"`
|
||||
WorkerNodesExternalIPAdresses []string `json:"workerNodesExternalIPAdresses,omitempty"`
|
||||
WorkerNodesMachineOSBuilds []string `json:"workerNodesMachineOSBuilds,omitempty"`
|
||||
WorkerNodesMachineOSTypes []string `json:"workerNodesMachineOSTypes,omitempty"`
|
||||
WorkerNodesRootPasswords []string `json:"workerNodesRootPasswords,omitempty"`
|
||||
WorkerNodesRootUsernames []string `json:"workerNodesRootUsernames,omitempty"`
|
||||
WorkerNodesSecureShellPorts []int64 `json:"workerNodesSecureShellPorts,omitempty"`
|
||||
WorkerNodesUserPasswords []string `json:"workerNodesUserPasswords,omitempty"`
|
||||
WorkerNodesUserUsernames []string `json:"workerNodesUserUsernames,omitempty"`
|
||||
WorkerTaints []string `json:"workerTaints,omitempty"`
|
||||
WorkersDynamixSEPID int64 `json:"workersDynamixSEPId,omitempty"`
|
||||
WorkersDynamixSEPPool string `json:"workersDynamixSEPPool,omitempty"`
|
||||
}
|
||||
|
||||
type ClusterTemplateBrief struct {
|
||||
ClusterTemplateName string `json:"clusterTemplateName,omitempty"`
|
||||
ClusterType string `json:"clusterType,omitempty"`
|
||||
ContainerNetworkType string `json:"containerNetworkType,omitempty"`
|
||||
CreationDate string `json:"creationDate,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
ID int64 `json:"id,omitempty"`
|
||||
KubeVersion string `json:"kubeVersion,omitempty"`
|
||||
MachineOSType string `json:"machineOSType,omitempty"`
|
||||
OwnerID int64 `json:"ownerId,omitempty"`
|
||||
Shared bool `json:"shared,omitempty"`
|
||||
UserID int64 `json:"userId,omitempty"`
|
||||
Username string `json:"username,omitempty"`
|
||||
}
|
||||
|
||||
type CreateClusterRequest struct {
|
||||
AppContainerRepository int64 `json:"appContainerRepository"`
|
||||
AuditEnable bool `json:"auditEnable"`
|
||||
AuditLogMaxAge int64 `json:"auditLogMaxAge"`
|
||||
AuditLogMaxBackup int64 `json:"auditLogMaxBackup"`
|
||||
AuditLogMaxSize int64 `json:"auditLogMaxSize"`
|
||||
AuditPolicy string `json:"auditPolicy"`
|
||||
BalancersDynamixSEPID int64 `json:"balancersDynamixSEPId"`
|
||||
BalancersDynamixSEPPool string `json:"balancersDynamixSEPPool"`
|
||||
CertificateIssuerID int64 `json:"certificateIssuerId"`
|
||||
CertificateKey string `json:"certificateKey"`
|
||||
CertificateValidityBefore string `json:"certificateValidityBefore"`
|
||||
ChartRepository int64 `json:"chartRepository"`
|
||||
ClusterHostname string `json:"clusterHostname"`
|
||||
ClusterMachineOSBuild string `json:"clusterMachineOSBuild"`
|
||||
ClusterMachineOSType string `json:"clusterMachineOSType"`
|
||||
ClusterName string `json:"clusterName"`
|
||||
ClusterTemplateDescription string `json:"clusterTemplateDescription"`
|
||||
ClusterTemplateName string `json:"clusterTemplateName"`
|
||||
ClusterType string `json:"clusterType"`
|
||||
ContainerNetworkType string `json:"containerNetworkType"`
|
||||
CreateClusterTemplate bool `json:"createClusterTemplate"`
|
||||
CustomMTU int64 `json:"customMTU"`
|
||||
DenergyRuntimeType string `json:"denergyRuntimeType"`
|
||||
Description string `json:"description"`
|
||||
DomainResolvers []string `json:"domainResolvers,omitempty"`
|
||||
DynamixAppID string `json:"dynamixAppId"`
|
||||
DynamixAppSecret string `json:"dynamixAppSecret"`
|
||||
DynamixAuthDomain string `json:"dynamixAuthDomain"`
|
||||
DynamixAuthType string `json:"dynamixAuthType"`
|
||||
DynamixK8CIID int64 `json:"dynamixK8CIId"`
|
||||
DynamixPassword string `json:"dynamixPassword"`
|
||||
DynamixRGID int64 `json:"dynamixRGId"`
|
||||
DynamixSEPID int64 `json:"dynamixSEPId"`
|
||||
DynamixSEPPool string `json:"dynamixSEPPool"`
|
||||
DynamixSSOURL string `json:"dynamixSSOURL"`
|
||||
DynamixURL string `json:"dynamixURL"`
|
||||
DynamixUsername string `json:"dynamixUsername"`
|
||||
EnableCustomLoadBalancerHostnames bool `json:"enableCustomLoadBalancerHostnames"`
|
||||
EnableCustomMasterHostnames bool `json:"enableCustomMasterHostnames"`
|
||||
EnableCustomWorkerHostnames bool `json:"enableCustomWorkerHostnames"`
|
||||
// VirtualAddresses Section
|
||||
ExtVirtualAddress string `json:"extVirtualAddress"`
|
||||
ExternalLBAddresses []string `json:"externalLBAddresses,omitempty"`
|
||||
GlobalNetworkID int64 `json:"globalNetworkId"`
|
||||
ILoadBalancerCPUCount int64 `json:"iLoadBalancerCPUCount"`
|
||||
ILoadBalancerCloudInit string `json:"iLoadBalancerCloudInit"`
|
||||
ILoadBalancerCount int64 `json:"iLoadBalancerCount"`
|
||||
ILoadBalancerDiskSize int64 `json:"iLoadBalancerDiskSize"`
|
||||
ILoadBalancerGPUIDs []int64 `json:"iLoadBalancerGpuIds,omitempty"`
|
||||
ILoadBalancerMemorySize int64 `json:"iLoadBalancerMemorySize"`
|
||||
InitialSecureShellPort int64 `json:"initialSecureShellPort"`
|
||||
InstallAutoscaler bool `json:"installAutoscaler"`
|
||||
InstallCriobox bool `json:"installCriobox"`
|
||||
InstallKyverno bool `json:"installKyverno"`
|
||||
InstallMetrics bool `json:"installMetrics"`
|
||||
InstallMonitoring bool `json:"installMonitoring"`
|
||||
InstallPodLogger bool `json:"installPodLogger"`
|
||||
InstallRBACManager bool `json:"installRbacManager"`
|
||||
InstallTrivy bool `json:"installTrivy"`
|
||||
IntVirtualAddress string `json:"intVirtualAddress"`
|
||||
InternalLBAddresses []string `json:"internalLBAddresses,omitempty"`
|
||||
KubeConfig string `json:"kubeConfig"`
|
||||
KubeContainerRepository int64 `json:"kubeContainerRepository"`
|
||||
KubeVersion string `json:"kubeVersion"`
|
||||
LoadBalancerExternalIPAddresses []string `json:"loadBalancerExternalIPAddresses,omitempty"`
|
||||
LoadBalancerHostnames []string `json:"loadBalancerHostnames,omitempty"`
|
||||
LoadBalancerInternalIPAddresses []string `json:"loadBalancerInternalIPAddresses,omitempty"`
|
||||
LoadBalancerMachineOSBuild []string `json:"loadBalancerMachineOSBuild,omitempty"`
|
||||
LoadBalancerMachineOSType []string `json:"loadBalancerMachineOSType,omitempty"`
|
||||
LoadBalancerRootPasswords []string `json:"loadBalancerRootPasswords,omitempty"`
|
||||
LoadBalancerRootUsernames []string `json:"loadBalancerRootUsernames,omitempty"`
|
||||
LoadBalancerSecureShellPorts []int64 `json:"loadBalancerSecureShellPorts,omitempty"`
|
||||
LoadBalancerUserPasswords []string `json:"loadBalancerUserPasswords,omitempty"`
|
||||
LoadBalancerUserUsernames []string `json:"loadBalancerUserUsernames,omitempty"`
|
||||
LocalNetworkID int64 `json:"localNetworkId"`
|
||||
MachineOSBuild string `json:"machineOSBuild"`
|
||||
MachineOSImageID int64 `json:"machineOSImageId"`
|
||||
MachineOSType string `json:"machineOSType"`
|
||||
MachineProvider string `json:"machineProvider"`
|
||||
MasterAddresses []string `json:"masterAddresses,omitempty"`
|
||||
MasterCPUCount int64 `json:"masterCPUCount"`
|
||||
MasterCloudInit string `json:"masterCloudInit"`
|
||||
MasterCount int64 `json:"masterCount"`
|
||||
MasterDiskSize int64 `json:"masterDiskSize"`
|
||||
MasterGPUIDs []int64 `json:"masterGpuIds,omitempty"`
|
||||
MasterHostnames []string `json:"masterHostnames,omitempty"`
|
||||
MasterMemorySize int64 `json:"masterMemorySize"`
|
||||
MasterNodesExternalIPAdresses []string `json:"masterNodesExternalIPAdresses,omitempty"`
|
||||
MasterNodesMachineOSBuilds []string `json:"masterNodesMachineOSBuilds,omitempty"`
|
||||
MasterNodesMachineOSTypes []string `json:"masterNodesMachineOSTypes,omitempty"`
|
||||
MasterNodesRootPasswords []string `json:"masterNodesRootPasswords,omitempty"`
|
||||
MasterNodesRootUsernames []string `json:"masterNodesRootUsernames,omitempty"`
|
||||
MasterNodesSecureShellPorts []int64 `json:"masterNodesSecureShellPorts,omitempty"`
|
||||
MasterNodesUserPasswords []string `json:"masterNodesUserPasswords,omitempty"`
|
||||
MasterNodesUserUsernames []string `json:"masterNodesUserUsernames,omitempty"`
|
||||
MastersDynamixSEPID int64 `json:"mastersDynamixSEPId"`
|
||||
MastersDynamixSEPPool string `json:"mastersDynamixSEPPool"`
|
||||
PackageRepository int64 `json:"packageRepository"`
|
||||
ProvideDNS bool `json:"provideDNS"`
|
||||
SaveComputesOnFailedK8SCreation bool `json:"saveComputesOnFailedK8SCreation"`
|
||||
SharedClusterTemplate bool `json:"sharedClusterTemplate"`
|
||||
StoragePolicyID int64 `json:"storagePolicyId"`
|
||||
UseCustomExternalLBAddreses bool `json:"useCustomExternalLBAddreses"`
|
||||
UseCustomInternalLBAddreses bool `json:"useCustomInternalLBAddreses"`
|
||||
UseCustomMasterIPAddresses bool `json:"useCustomMasterIPAddresses"`
|
||||
UseCustomWorkerIPAddresses bool `json:"useCustomWorkerIPAddresses"`
|
||||
UseDynamixExtNet bool `json:"useDynamixExtnet"`
|
||||
ViNSGlobalNetworkID int64 `json:"vinsGlobalNetworkId"`
|
||||
WorkerAddresses []string `json:"workerAddresses,omitempty"`
|
||||
WorkerAnnotations []string `json:"workerAnnotations,omitempty"`
|
||||
WorkerCPUCount int64 `json:"workerCPUCount"`
|
||||
WorkerCloudInit string `json:"workerCloudInit"`
|
||||
WorkerCount int64 `json:"workerCount"`
|
||||
WorkerDiskSize int64 `json:"workerDiskSize"`
|
||||
WorkerGPUIDs []int64 `json:"workerGpuIds,omitempty"`
|
||||
WorkerGroupName string `json:"workerGroupName"`
|
||||
WorkerHostnames []string `json:"workerHostnames,omitempty"`
|
||||
// WorkerGroup string `json:\"workerGroup\" form:\"workerGroup\"`
|
||||
WorkerLabels []string `json:"workerLabels,omitempty"`
|
||||
WorkerMemorySize int64 `json:"workerMemorySize"`
|
||||
WorkerNodesExternalIPAdresses []string `json:"workerNodesExternalIPAdresses,omitempty"`
|
||||
WorkerNodesMachineOSBuilds []string `json:"workerNodesMachineOSBuilds,omitempty"`
|
||||
WorkerNodesMachineOSTypes []string `json:"workerNodesMachineOSTypes,omitempty"`
|
||||
WorkerNodesRootPasswords []string `json:"workerNodesRootPasswords,omitempty"`
|
||||
WorkerNodesRootUsernames []string `json:"workerNodesRootUsernames,omitempty"`
|
||||
WorkerNodesSecureShellPorts []int64 `json:"workerNodesSecureShellPorts,omitempty"`
|
||||
WorkerNodesUserPasswords []string `json:"workerNodesUserPasswords,omitempty"`
|
||||
WorkerNodesUserUsernames []string `json:"workerNodesUserUsernames,omitempty"`
|
||||
WorkerTaints []string `json:"workerTaints,omitempty"`
|
||||
WorkersDynamixSEPID int64 `json:"workersDynamixSEPId"`
|
||||
WorkersDynamixSEPPool string `json:"workersDynamixSEPPool"`
|
||||
}
|
||||
|
||||
type DeleteClusterTemplateResult struct {
|
||||
ID int64 `json:"id,omitempty"`
|
||||
}
|
||||
|
||||
type DeleteClusterTemplateResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result DeleteClusterTemplateResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type DuplicateClusterTemplateResult struct {
|
||||
ID int64 `json:"id,omitempty"`
|
||||
}
|
||||
|
||||
type DuplicateClusterTemplateResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result DuplicateClusterTemplateResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type GetClusterTemplateResult struct {
|
||||
Template ClusterTemplate `json:"template,omitempty"`
|
||||
}
|
||||
|
||||
type GetClusterTemplateResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result GetClusterTemplateResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type ListClusterTemplatesResult struct {
|
||||
Templates []ClusterTemplateBrief `json:"templates,omitempty"`
|
||||
Total int64 `json:"total,omitempty"`
|
||||
}
|
||||
|
||||
type ListClusterTemplatesResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result ListClusterTemplatesResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type UpdateClusterTemplateRequest struct {
|
||||
ExtraCluster CreateClusterRequest `json:"extraCluster"`
|
||||
ID int64 `json:"id"`
|
||||
}
|
||||
|
||||
type UpdateClusterTemplateResult struct {
|
||||
ID int64 `json:"id,omitempty"`
|
||||
}
|
||||
|
||||
type UpdateClusterTemplateResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result UpdateClusterTemplateResult `json:"result,omitempty"`
|
||||
}
|
||||
@@ -0,0 +1,347 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_codescoring
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/core"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type DeCodeScoringService service
|
||||
|
||||
type DescribeRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// true for checking whether the codescoring is installed in the cluster
|
||||
CheckInstallation bool `json:"checkInstallation" form:"checkInstallation"`
|
||||
// true for checking k8s codescoring pods liveness and the availability of the API
|
||||
CheckLiveness bool `json:"checkLiveness" form:"checkLiveness"`
|
||||
}
|
||||
|
||||
// Get codescoring by id
|
||||
func (a *DeCodeScoringService) Describe(ctx context.Context, req DescribeRequest) (DescribeCodeScoringResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result DescribeCodeScoringResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ClusterID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "clusterId")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/codescoring/describe"
|
||||
|
||||
contentTypes := []string{"application/x-www-form-urlencoded"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "clusterId", req.ClusterID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "checkInstallation", req.CheckInstallation, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "checkLiveness", req.CheckLiveness, "", "")
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp DescribeCodeScoringResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
type InstallRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// username codescoring
|
||||
//
|
||||
// Required.
|
||||
Username string `json:"username" form:"username"`
|
||||
// password for codescoring
|
||||
//
|
||||
// Required.
|
||||
Password string `json:"password" form:"password"`
|
||||
// secret key for codescoring
|
||||
//
|
||||
// Required.
|
||||
SecretKey string `json:"secretKey" form:"secretKey"`
|
||||
// hostname for codescoring
|
||||
//
|
||||
// Required.
|
||||
Hostname string `json:"hostname" form:"hostname"`
|
||||
// Hostname for integagent
|
||||
IntegagentHostname string `json:"integagentHostname" form:"integagentHostname"`
|
||||
// storage type
|
||||
//
|
||||
// Allowed values:
|
||||
// - "longhorn"
|
||||
// - "glusterfs"
|
||||
// - ""
|
||||
StorageClass string `json:"storageClass" form:"storageClass"`
|
||||
// images apps repository ID. If the ID is zero or the value is empty, the default images apps repository will be used.
|
||||
AppsRepositoryID int64 `json:"appsRepositoryId" form:"appsRepositoryId"`
|
||||
// charts repository ID. If the ID is zero or the value is empty, the default charts repository will be used.
|
||||
ChartsRepositoryID int64 `json:"chartsRepositoryId" form:"chartsRepositoryId"`
|
||||
// worker group name
|
||||
WorkerGroupName string `json:"workerGroupName" form:"workerGroupName"`
|
||||
// download chart anyway
|
||||
DownloadChartAnyway bool `json:"downloadChartAnyway" form:"downloadChartAnyway"`
|
||||
}
|
||||
|
||||
// Install codescoring in cluster
|
||||
func (a *DeCodeScoringService) Install(ctx context.Context, req InstallRequest) (CreateTaskResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result CreateTaskResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ClusterID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "clusterId")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.Username) {
|
||||
missingRequiredParams = append(missingRequiredParams, "username")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.Password) {
|
||||
missingRequiredParams = append(missingRequiredParams, "password")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.SecretKey) {
|
||||
missingRequiredParams = append(missingRequiredParams, "secretKey")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.Hostname) {
|
||||
missingRequiredParams = append(missingRequiredParams, "hostname")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
if !utils.IsZeroValue(req.StorageClass) {
|
||||
storageClassValue := req.StorageClass
|
||||
storageClassAllowedValues := []string{
|
||||
"longhorn",
|
||||
"glusterfs",
|
||||
"",
|
||||
}
|
||||
storageClassValid := false
|
||||
for _, allowed := range storageClassAllowedValues {
|
||||
if storageClassValue == allowed {
|
||||
storageClassValid = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !storageClassValid {
|
||||
return result, fmt.Errorf("storageClass must be one of %v", storageClassAllowedValues)
|
||||
}
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/codescoring/install"
|
||||
|
||||
contentTypes := []string{"application/x-www-form-urlencoded"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "clusterId", req.ClusterID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "username", req.Username, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "password", req.Password, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "secretKey", req.SecretKey, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "hostname", req.Hostname, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "integagentHostname", req.IntegagentHostname, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "storageClass", req.StorageClass, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "appsRepositoryId", req.AppsRepositoryID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "chartsRepositoryId", req.ChartsRepositoryID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "workerGroupName", req.WorkerGroupName, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "downloadChartAnyway", req.DownloadChartAnyway, "", "")
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp CreateTaskResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
type UninstallRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// true for deleting the codescoring even if it is not registered
|
||||
CleanAlways bool `json:"cleanAlways" form:"cleanAlways"`
|
||||
// true for ignoring dns server errors
|
||||
IgnoreDNSError bool `json:"ignoreDnsError" form:"ignoreDnsError"`
|
||||
}
|
||||
|
||||
// Uninstall codescoring from cluster
|
||||
func (a *DeCodeScoringService) Uninstall(ctx context.Context, req UninstallRequest) (CreateTaskResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result CreateTaskResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ClusterID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "clusterId")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/codescoring/uninstall"
|
||||
|
||||
contentTypes := []string{"application/x-www-form-urlencoded"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "clusterId", req.ClusterID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "cleanAlways", req.CleanAlways, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "ignoreDnsError", req.IgnoreDNSError, "", "")
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp CreateTaskResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_codescoring
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/core"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type APIClient struct {
|
||||
common service
|
||||
|
||||
DeCodeScoring *DeCodeScoringService
|
||||
}
|
||||
|
||||
type service struct {
|
||||
client *utils.Client
|
||||
}
|
||||
|
||||
func NewAPIClient(cfg *core.Configuration) *APIClient {
|
||||
c := &APIClient{}
|
||||
c.common.client = utils.NewClient(cfg)
|
||||
|
||||
c.DeCodeScoring = (*DeCodeScoringService)(&c.common)
|
||||
|
||||
return c
|
||||
}
|
||||
Executable
+35
@@ -0,0 +1,35 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_codescoring
|
||||
|
||||
type CodeScoringRecord struct {
|
||||
Addresses map[string]string `json:"addresses,omitempty"`
|
||||
ClusterID int64 `json:"clusterId,omitempty"`
|
||||
Hostnames map[string]string `json:"hostnames,omitempty"`
|
||||
ID int64 `json:"id,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
OwnerID int64 `json:"ownerId,omitempty"`
|
||||
Password string `json:"password,omitempty"`
|
||||
ProductName string `json:"productName,omitempty"`
|
||||
ProductVersion string `json:"productVersion,omitempty"`
|
||||
SecretKey string `json:"secretKey,omitempty"`
|
||||
StorageType string `json:"storageType,omitempty"`
|
||||
TaskIDs []int64 `json:"taskIds,omitempty"`
|
||||
Username string `json:"username,omitempty"`
|
||||
WorkerGroupName string `json:"workerGroupName,omitempty"`
|
||||
}
|
||||
|
||||
type DescribeCodeScoringResult struct {
|
||||
CheckListOk bool `json:"checkListOk,omitempty"`
|
||||
Description ProductDescr `json:"description,omitempty"`
|
||||
Installed bool `json:"installed,omitempty"`
|
||||
Registered bool `json:"registered,omitempty"`
|
||||
Registry CodeScoringRecord `json:"registry,omitempty"`
|
||||
}
|
||||
|
||||
type DescribeCodeScoringResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result DescribeCodeScoringResult `json:"result,omitempty"`
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_codescoring
|
||||
|
||||
import (
|
||||
shared "repository.basistech.ru/BASIS/de-golang-sdk/shared"
|
||||
)
|
||||
|
||||
type CreateTaskResult = shared.CreateTaskResult
|
||||
type CreateTaskResultWithError = shared.CreateTaskResultWithError
|
||||
type ProductDescr = shared.ProductDescr
|
||||
@@ -0,0 +1,312 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_criobox
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/core"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type DeCrioboxService service
|
||||
|
||||
type DescribeRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// true for checking whether the criobox is installed in the cluster
|
||||
CheckInstallation bool `json:"checkInstallation" form:"checkInstallation"`
|
||||
}
|
||||
|
||||
// Get criobox by id
|
||||
func (a *DeCrioboxService) Describe(ctx context.Context, req DescribeRequest) (DescribeCrioboxResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result DescribeCrioboxResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ClusterID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "clusterId")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/criobox/describe"
|
||||
|
||||
contentTypes := []string{"application/x-www-form-urlencoded"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "clusterId", req.ClusterID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "checkInstallation", req.CheckInstallation, "", "")
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp DescribeCrioboxResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
type InstallRequest struct {
|
||||
// Cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// images apps repository ID. If the ID is zero or the value is empty, the default images apps repository will be used.
|
||||
AppsRepositoryID int64 `json:"appsRepositoryId" form:"appsRepositoryId"`
|
||||
// charts repository ID. If the ID is zero or the value is empty, the default charts repository will be used.
|
||||
ChartsRepositoryID int64 `json:"chartsRepositoryId" form:"chartsRepositoryId"`
|
||||
// download chart anyway
|
||||
DownloadChartAnyway bool `json:"downloadChartAnyway" form:"downloadChartAnyway"`
|
||||
// log level for criobox running in cluster. By default is warning
|
||||
//
|
||||
// Allowed values:
|
||||
// - "system"
|
||||
// - "debug"
|
||||
// - "info"
|
||||
// - "warning"
|
||||
// - "error"
|
||||
// - ""
|
||||
LogLevel string `json:"logLevel" form:"logLevel"`
|
||||
}
|
||||
|
||||
// Install Criobox
|
||||
func (a *DeCrioboxService) Install(ctx context.Context, req InstallRequest) (InstallCrioboxResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result InstallCrioboxResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ClusterID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "clusterId")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
if !utils.IsZeroValue(req.LogLevel) {
|
||||
logLevelValue := req.LogLevel
|
||||
logLevelAllowedValues := []string{
|
||||
"system",
|
||||
"debug",
|
||||
"info",
|
||||
"warning",
|
||||
"error",
|
||||
"",
|
||||
}
|
||||
logLevelValid := false
|
||||
for _, allowed := range logLevelAllowedValues {
|
||||
if logLevelValue == allowed {
|
||||
logLevelValid = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !logLevelValid {
|
||||
return result, fmt.Errorf("logLevel must be one of %v", logLevelAllowedValues)
|
||||
}
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/criobox/install"
|
||||
|
||||
contentTypes := []string{"application/x-www-form-urlencoded"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "clusterId", req.ClusterID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "appsRepositoryId", req.AppsRepositoryID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "chartsRepositoryId", req.ChartsRepositoryID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "downloadChartAnyway", req.DownloadChartAnyway, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "logLevel", req.LogLevel, "", "")
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp InstallCrioboxResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
type UninstallRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// true for deleting the certmanager even if it is not registered
|
||||
CleanAlways bool `json:"cleanAlways" form:"cleanAlways"`
|
||||
// true for ignoring dns server errors
|
||||
IgnoreDNSError bool `json:"ignoreDnsError" form:"ignoreDnsError"`
|
||||
}
|
||||
|
||||
// Uninstall Criobox
|
||||
func (a *DeCrioboxService) Uninstall(ctx context.Context, req UninstallRequest) (UninstallCrioboxResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result UninstallCrioboxResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ClusterID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "clusterId")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/criobox/uninstall"
|
||||
|
||||
contentTypes := []string{"application/x-www-form-urlencoded"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "clusterId", req.ClusterID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "cleanAlways", req.CleanAlways, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "ignoreDnsError", req.IgnoreDNSError, "", "")
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp UninstallCrioboxResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_criobox
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/core"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type APIClient struct {
|
||||
common service
|
||||
|
||||
DeCriobox *DeCrioboxService
|
||||
}
|
||||
|
||||
type service struct {
|
||||
client *utils.Client
|
||||
}
|
||||
|
||||
func NewAPIClient(cfg *core.Configuration) *APIClient {
|
||||
c := &APIClient{}
|
||||
c.common.client = utils.NewClient(cfg)
|
||||
|
||||
c.DeCriobox = (*DeCrioboxService)(&c.common)
|
||||
|
||||
return c
|
||||
}
|
||||
Executable
+53
@@ -0,0 +1,53 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_criobox
|
||||
|
||||
type CrioboxRecord struct {
|
||||
ClusterID int64 `json:"clusterId,omitempty"`
|
||||
Hostname string `json:"hostname,omitempty"`
|
||||
ID int64 `json:"id,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
OwnerID int64 `json:"ownerId,omitempty"`
|
||||
Password string `json:"password,omitempty"`
|
||||
Port int64 `json:"port,omitempty"`
|
||||
ProductName string `json:"productName,omitempty"`
|
||||
ProductVersion string `json:"productVersion,omitempty"`
|
||||
TaskIDs []int64 `json:"taskIds,omitempty"`
|
||||
Username string `json:"username,omitempty"`
|
||||
}
|
||||
|
||||
type DescribeCrioboxResult struct {
|
||||
Description ProductDescr `json:"description,omitempty"`
|
||||
Installed bool `json:"installed,omitempty"`
|
||||
Registered bool `json:"registered,omitempty"`
|
||||
Registry CrioboxRecord `json:"registry,omitempty"`
|
||||
}
|
||||
|
||||
type DescribeCrioboxResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result DescribeCrioboxResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type InstallCrioboxResult struct {
|
||||
TaskID int64 `json:"taskId,omitempty"`
|
||||
}
|
||||
|
||||
type InstallCrioboxResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result InstallCrioboxResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type UninstallCrioboxResult struct {
|
||||
TaskID int64 `json:"taskId,omitempty"`
|
||||
}
|
||||
|
||||
type UninstallCrioboxResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result UninstallCrioboxResult `json:"result,omitempty"`
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_criobox
|
||||
|
||||
import (
|
||||
shared "repository.basistech.ru/BASIS/de-golang-sdk/shared"
|
||||
)
|
||||
|
||||
type ProductDescr = shared.ProductDescr
|
||||
@@ -0,0 +1,405 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_customapp
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/core"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type DeCustomAppService service
|
||||
|
||||
type DescribeRequest struct {
|
||||
// custom app ID
|
||||
//
|
||||
// Required.
|
||||
CustomAppID int64 `json:"customAppId" form:"customAppId"`
|
||||
// true for checking whether the custom app is installed in the cluster
|
||||
CheckInstallation bool `json:"checkInstallation" form:"checkInstallation"`
|
||||
// true for checking k8s custom app pods liveness and the availability of the API
|
||||
CheckLiveness bool `json:"CheckLiveness" form:"CheckLiveness"`
|
||||
}
|
||||
|
||||
// Get custom app by id
|
||||
func (a *DeCustomAppService) Describe(ctx context.Context, req DescribeRequest) (DescribeCustomAppResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result DescribeCustomAppResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.CustomAppID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "customAppId")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/customapp/describe"
|
||||
|
||||
contentTypes := []string{"application/x-www-form-urlencoded"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "customAppId", req.CustomAppID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "checkInstallation", req.CheckInstallation, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "CheckLiveness", req.CheckLiveness, "", "")
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp DescribeCustomAppResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
type InstallRequest struct {
|
||||
// Cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// custom chart ID
|
||||
//
|
||||
// Required.
|
||||
ChartID string `json:"chartId" form:"chartId"`
|
||||
// custom release name
|
||||
//
|
||||
// Required.
|
||||
ReleaseName string `json:"releaseName" form:"releaseName"`
|
||||
// custom release namespace
|
||||
//
|
||||
// Required.
|
||||
ReleaseNamespace string `json:"releaseNamespace" form:"releaseNamespace"`
|
||||
// Hostname for custom app
|
||||
//
|
||||
// Required.
|
||||
Hostname string `json:"hostname" form:"hostname"`
|
||||
// Install timeout in minutes. Max is 60 minutes, min is 5 minutes. If not specified, default timeout of 10 minutes will be used
|
||||
InstallTimeout int64 `json:"installTimeout" form:"installTimeout"`
|
||||
// download chart anyway
|
||||
DownloadChartAnyway bool `json:"downloadChartAnyway" form:"downloadChartAnyway"`
|
||||
}
|
||||
|
||||
// Install custom app in cluster
|
||||
func (a *DeCustomAppService) Install(ctx context.Context, req InstallRequest) (CreateTaskResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result CreateTaskResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ClusterID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "clusterId")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.ChartID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "chartId")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.ReleaseName) {
|
||||
missingRequiredParams = append(missingRequiredParams, "releaseName")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.ReleaseNamespace) {
|
||||
missingRequiredParams = append(missingRequiredParams, "releaseNamespace")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.Hostname) {
|
||||
missingRequiredParams = append(missingRequiredParams, "hostname")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/customapp/install"
|
||||
|
||||
contentTypes := []string{"application/x-www-form-urlencoded"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "clusterId", req.ClusterID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "chartId", req.ChartID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "releaseName", req.ReleaseName, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "releaseNamespace", req.ReleaseNamespace, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "hostname", req.Hostname, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "installTimeout", req.InstallTimeout, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "downloadChartAnyway", req.DownloadChartAnyway, "", "")
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp CreateTaskResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
type ListRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// true for checking whether custom apps are installed in the cluster
|
||||
CheckInstallation bool `json:"checkInstallation" form:"checkInstallation"`
|
||||
// true for checking custom apps pods liveness and the availability of the API
|
||||
CheckLiveness bool `json:"CheckLiveness" form:"CheckLiveness"`
|
||||
}
|
||||
|
||||
// List custom app by cluster id
|
||||
func (a *DeCustomAppService) List(ctx context.Context, req ListRequest) (ListCustomAppsResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result ListCustomAppsResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ClusterID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "clusterId")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/customapp/list"
|
||||
|
||||
contentTypes := []string{"application/x-www-form-urlencoded"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "clusterId", req.ClusterID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "checkInstallation", req.CheckInstallation, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "CheckLiveness", req.CheckLiveness, "", "")
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp ListCustomAppsResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
type UninstallRequest struct {
|
||||
// custom app ID
|
||||
//
|
||||
// Required.
|
||||
CustomAppID int64 `json:"customAppId" form:"customAppId"`
|
||||
// true for deleting the custom app even if it is not registered
|
||||
CleanAlways bool `json:"cleanAlways" form:"cleanAlways"`
|
||||
// true for deleting namespace
|
||||
DeleteNamespace bool `json:"deleteNamespace" form:"deleteNamespace"`
|
||||
// true for ignoring dns server errors
|
||||
IgnoreDNSError bool `json:"ignoreDnsError" form:"ignoreDnsError"`
|
||||
// Uninstall timeout in minutes. Max is 30 minutes, min is 5 minutes. If not specified, default timeout of 10 minutes will be used
|
||||
UninstallTimeout int64 `json:"uninstallTimeout" form:"uninstallTimeout"`
|
||||
}
|
||||
|
||||
// Uninstall custom app from cluster
|
||||
func (a *DeCustomAppService) Uninstall(ctx context.Context, req UninstallRequest) (CreateTaskResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result CreateTaskResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.CustomAppID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "customAppId")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/customapp/uninstall"
|
||||
|
||||
contentTypes := []string{"application/x-www-form-urlencoded"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "customAppId", req.CustomAppID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "cleanAlways", req.CleanAlways, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "deleteNamespace", req.DeleteNamespace, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "ignoreDnsError", req.IgnoreDNSError, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "uninstallTimeout", req.UninstallTimeout, "", "")
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp CreateTaskResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_customapp
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/core"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type APIClient struct {
|
||||
common service
|
||||
|
||||
DeCustomApp *DeCustomAppService
|
||||
}
|
||||
|
||||
type service struct {
|
||||
client *utils.Client
|
||||
}
|
||||
|
||||
func NewAPIClient(cfg *core.Configuration) *APIClient {
|
||||
c := &APIClient{}
|
||||
c.common.client = utils.NewClient(cfg)
|
||||
|
||||
c.DeCustomApp = (*DeCustomAppService)(&c.common)
|
||||
|
||||
return c
|
||||
}
|
||||
Executable
+42
@@ -0,0 +1,42 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_customapp
|
||||
|
||||
type CustomAppRecord struct {
|
||||
ChartID string `json:"chartId,omitempty"`
|
||||
ClusterID int64 `json:"clusterId,omitempty"`
|
||||
ID int64 `json:"id,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
Namespace string `json:"namespace,omitempty"`
|
||||
OwnerID int64 `json:"ownerId,omitempty"`
|
||||
ProductName string `json:"productName,omitempty"`
|
||||
ProductVersion string `json:"productVersion,omitempty"`
|
||||
TaskIDs []int64 `json:"taskIds,omitempty"`
|
||||
}
|
||||
|
||||
type DescribeCustomAppResult struct {
|
||||
CheckListOk bool `json:"checkListOk,omitempty"`
|
||||
Description ProductDescr `json:"description,omitempty"`
|
||||
IconPath string `json:"iconPath,omitempty"`
|
||||
Installed bool `json:"installed,omitempty"`
|
||||
Registered bool `json:"registered,omitempty"`
|
||||
Registry CustomAppRecord `json:"registry,omitempty"`
|
||||
}
|
||||
|
||||
type DescribeCustomAppResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result DescribeCustomAppResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type ListCustomAppsResult struct {
|
||||
CustomApps []DescribeCustomAppResult `json:"customApps,omitempty"`
|
||||
}
|
||||
|
||||
type ListCustomAppsResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result ListCustomAppsResult `json:"result,omitempty"`
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_customapp
|
||||
|
||||
import (
|
||||
shared "repository.basistech.ru/BASIS/de-golang-sdk/shared"
|
||||
)
|
||||
|
||||
type CreateTaskResult = shared.CreateTaskResult
|
||||
type CreateTaskResultWithError = shared.CreateTaskResultWithError
|
||||
type ProductDescr = shared.ProductDescr
|
||||
@@ -0,0 +1,398 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_database
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/core"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type DeDatabaseService service
|
||||
|
||||
type CreateDatabasesRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// drop existing
|
||||
//
|
||||
// Required.
|
||||
DropExisting bool `json:"dropExisting" form:"dropExisting"`
|
||||
// comma separated list of databases
|
||||
Databases string `json:"databases" form:"databases"`
|
||||
// owner of databases
|
||||
Owner string `json:"owner" form:"owner"`
|
||||
}
|
||||
|
||||
// Create databases
|
||||
func (a *DeDatabaseService) CreateDatabases(ctx context.Context, req CreateDatabasesRequest) (any, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result any
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ClusterID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "clusterId")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.DropExisting) {
|
||||
missingRequiredParams = append(missingRequiredParams, "dropExisting")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/database/createDatabases"
|
||||
|
||||
contentTypes := []string{"application/x-www-form-urlencoded"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "clusterId", req.ClusterID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "databases", req.Databases, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "owner", req.Owner, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "dropExisting", req.DropExisting, "", "")
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp CreateDatabasesResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
type CreateDBUserRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// database name for postgresql
|
||||
//
|
||||
// Required.
|
||||
Username string `json:"username" form:"username"`
|
||||
// password for postgresql user
|
||||
//
|
||||
// Required.
|
||||
Password string `json:"password" form:"password"`
|
||||
// drop existings databases
|
||||
DropExisting bool `json:"dropExisting" form:"dropExisting"`
|
||||
// comma separated list of databases
|
||||
Databases string `json:"databases" form:"databases"`
|
||||
}
|
||||
|
||||
// Create database user & databases
|
||||
func (a *DeDatabaseService) CreateDBUser(ctx context.Context, req CreateDBUserRequest) (any, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result any
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ClusterID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "clusterId")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.Username) {
|
||||
missingRequiredParams = append(missingRequiredParams, "username")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.Password) {
|
||||
missingRequiredParams = append(missingRequiredParams, "password")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/database/createDbUser"
|
||||
|
||||
contentTypes := []string{"application/x-www-form-urlencoded"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "clusterId", req.ClusterID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "username", req.Username, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "password", req.Password, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "dropExisting", req.DropExisting, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "databases", req.Databases, "", "")
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp CreateDBUserResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
type DeleteDatabaseRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// comma separated list of databases
|
||||
Databases string `json:"databases" form:"databases"`
|
||||
}
|
||||
|
||||
// Delete databases
|
||||
func (a *DeDatabaseService) DeleteDatabase(ctx context.Context, req DeleteDatabaseRequest) (any, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result any
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ClusterID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "clusterId")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/database/deleteDatabase"
|
||||
|
||||
contentTypes := []string{"application/x-www-form-urlencoded"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "clusterId", req.ClusterID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "databases", req.Databases, "", "")
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp DeleteDatabasesResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
type DeleteDBUserRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// database name for postgresql
|
||||
//
|
||||
// Required.
|
||||
Username string `json:"username" form:"username"`
|
||||
// drop databases
|
||||
//
|
||||
// Required.
|
||||
DropDatabases bool `json:"dropDatabases" form:"dropDatabases"`
|
||||
}
|
||||
|
||||
// Delete database user & databases
|
||||
func (a *DeDatabaseService) DeleteDBUser(ctx context.Context, req DeleteDBUserRequest) (any, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result any
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ClusterID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "clusterId")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.Username) {
|
||||
missingRequiredParams = append(missingRequiredParams, "username")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.DropDatabases) {
|
||||
missingRequiredParams = append(missingRequiredParams, "dropDatabases")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/database/deleteDbUser"
|
||||
|
||||
contentTypes := []string{"application/x-www-form-urlencoded"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "clusterId", req.ClusterID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "username", req.Username, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "dropDatabases", req.DropDatabases, "", "")
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp DeleteDBUserResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_database
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/core"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type APIClient struct {
|
||||
common service
|
||||
|
||||
DeDatabase *DeDatabaseService
|
||||
}
|
||||
|
||||
type service struct {
|
||||
client *utils.Client
|
||||
}
|
||||
|
||||
func NewAPIClient(cfg *core.Configuration) *APIClient {
|
||||
c := &APIClient{}
|
||||
c.common.client = utils.NewClient(cfg)
|
||||
|
||||
c.DeDatabase = (*DeDatabaseService)(&c.common)
|
||||
|
||||
return c
|
||||
}
|
||||
Executable
+31
@@ -0,0 +1,31 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_database
|
||||
|
||||
type CreateDatabasesResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result any `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type CreateDBUserResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result any `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type DeleteDatabasesResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result any `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type DeleteDBUserResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result any `json:"result,omitempty"`
|
||||
}
|
||||
@@ -0,0 +1,326 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_dependency_track
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/core"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type DeDependencyTrackService service
|
||||
|
||||
type DescribeRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// true for checking whether the dtrack is installed in the cluster
|
||||
CheckInstallation bool `json:"checkInstallation" form:"checkInstallation"`
|
||||
// true for checking k8s dtrack pods liveness and the availability of the API
|
||||
CheckLiveness bool `json:"checkLiveness" form:"checkLiveness"`
|
||||
}
|
||||
|
||||
// Get dependency-track by id
|
||||
func (a *DeDependencyTrackService) Describe(ctx context.Context, req DescribeRequest) (DescribeDeptrackResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result DescribeDeptrackResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ClusterID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "clusterId")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/dependency-track/describe"
|
||||
|
||||
contentTypes := []string{"application/x-www-form-urlencoded"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "clusterId", req.ClusterID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "checkInstallation", req.CheckInstallation, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "checkLiveness", req.CheckLiveness, "", "")
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp DescribeDeptrackResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
type InstallRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// hostname for dependency track
|
||||
//
|
||||
// Required.
|
||||
Hostname string `json:"hostname" form:"hostname"`
|
||||
// Hostname for integagent
|
||||
IntegagentHostname string `json:"integagentHostname" form:"integagentHostname"`
|
||||
// password for the admin user. Do not use the password 'admin' because it will not work
|
||||
Password string `json:"password" form:"password"`
|
||||
// storage type
|
||||
//
|
||||
// Allowed values:
|
||||
// - "longhorn"
|
||||
// - "glusterfs"
|
||||
// - ""
|
||||
StorageClass string `json:"storageClass" form:"storageClass"`
|
||||
// images apps repository ID. If the ID is zero or the value is empty, the default images apps repository will be used.
|
||||
AppsRepositoryID int64 `json:"appsRepositoryId" form:"appsRepositoryId"`
|
||||
// charts repository ID. If the ID is zero or the value is empty, the default charts repository will be used.
|
||||
ChartsRepositoryID int64 `json:"chartsRepositoryId" form:"chartsRepositoryId"`
|
||||
// worker group name
|
||||
WorkerGroupName string `json:"workerGroupName" form:"workerGroupName"`
|
||||
// download chart anyway
|
||||
DownloadChartAnyway bool `json:"downloadChartAnyway" form:"downloadChartAnyway"`
|
||||
}
|
||||
|
||||
// Install dependency-track in cluster
|
||||
func (a *DeDependencyTrackService) Install(ctx context.Context, req InstallRequest) (CreateTaskResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result CreateTaskResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ClusterID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "clusterId")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.Hostname) {
|
||||
missingRequiredParams = append(missingRequiredParams, "hostname")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
if !utils.IsZeroValue(req.StorageClass) {
|
||||
storageClassValue := req.StorageClass
|
||||
storageClassAllowedValues := []string{
|
||||
"longhorn",
|
||||
"glusterfs",
|
||||
"",
|
||||
}
|
||||
storageClassValid := false
|
||||
for _, allowed := range storageClassAllowedValues {
|
||||
if storageClassValue == allowed {
|
||||
storageClassValid = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !storageClassValid {
|
||||
return result, fmt.Errorf("storageClass must be one of %v", storageClassAllowedValues)
|
||||
}
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/dependency-track/install"
|
||||
|
||||
contentTypes := []string{"application/x-www-form-urlencoded"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "clusterId", req.ClusterID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "hostname", req.Hostname, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "integagentHostname", req.IntegagentHostname, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "password", req.Password, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "storageClass", req.StorageClass, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "appsRepositoryId", req.AppsRepositoryID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "chartsRepositoryId", req.ChartsRepositoryID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "workerGroupName", req.WorkerGroupName, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "downloadChartAnyway", req.DownloadChartAnyway, "", "")
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp CreateTaskResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
type UninstallRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// true for deleting the dtrack even if it is not registered
|
||||
CleanAlways bool `json:"cleanAlways" form:"cleanAlways"`
|
||||
// true for ignoring dns server errors
|
||||
IgnoreDNSError bool `json:"ignoreDnsError" form:"ignoreDnsError"`
|
||||
}
|
||||
|
||||
// Uninstall dependency-track from cluster
|
||||
func (a *DeDependencyTrackService) Uninstall(ctx context.Context, req UninstallRequest) (CreateTaskResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result CreateTaskResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ClusterID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "clusterId")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/dependency-track/uninstall"
|
||||
|
||||
contentTypes := []string{"application/x-www-form-urlencoded"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "clusterId", req.ClusterID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "cleanAlways", req.CleanAlways, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "ignoreDnsError", req.IgnoreDNSError, "", "")
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp CreateTaskResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_dependency_track
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/core"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type APIClient struct {
|
||||
common service
|
||||
|
||||
DeDependencyTrack *DeDependencyTrackService
|
||||
}
|
||||
|
||||
type service struct {
|
||||
client *utils.Client
|
||||
}
|
||||
|
||||
func NewAPIClient(cfg *core.Configuration) *APIClient {
|
||||
c := &APIClient{}
|
||||
c.common.client = utils.NewClient(cfg)
|
||||
|
||||
c.DeDependencyTrack = (*DeDependencyTrackService)(&c.common)
|
||||
|
||||
return c
|
||||
}
|
||||
Executable
+36
@@ -0,0 +1,36 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_dependency_track
|
||||
|
||||
type DeptrackRecord struct {
|
||||
Addresses map[string]string `json:"addresses,omitempty"`
|
||||
ClusterID int64 `json:"clusterId,omitempty"`
|
||||
Hostnames map[string]string `json:"hostnames,omitempty"`
|
||||
ID int64 `json:"id,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
OwnerID int64 `json:"ownerId,omitempty"`
|
||||
Password string `json:"password,omitempty"`
|
||||
ProductName string `json:"productName,omitempty"`
|
||||
ProductVersion string `json:"productVersion,omitempty"`
|
||||
PsqlPassword string `json:"psqlPassword,omitempty"`
|
||||
PsqlUsername string `json:"psqlUsername,omitempty"`
|
||||
StorageType string `json:"storageType,omitempty"`
|
||||
TaskIDs []int64 `json:"taskIds,omitempty"`
|
||||
Username string `json:"username,omitempty"`
|
||||
WorkerGroupName string `json:"workerGroupName,omitempty"`
|
||||
}
|
||||
|
||||
type DescribeDeptrackResult struct {
|
||||
CheckListOk bool `json:"checkListOk,omitempty"`
|
||||
Description ProductDescr `json:"description,omitempty"`
|
||||
Installed bool `json:"installed,omitempty"`
|
||||
Registered bool `json:"registered,omitempty"`
|
||||
Registry DeptrackRecord `json:"registry,omitempty"`
|
||||
}
|
||||
|
||||
type DescribeDeptrackResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result DescribeDeptrackResult `json:"result,omitempty"`
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_dependency_track
|
||||
|
||||
import (
|
||||
shared "repository.basistech.ru/BASIS/de-golang-sdk/shared"
|
||||
)
|
||||
|
||||
type CreateTaskResult = shared.CreateTaskResult
|
||||
type CreateTaskResultWithError = shared.CreateTaskResultWithError
|
||||
type ProductDescr = shared.ProductDescr
|
||||
@@ -0,0 +1,82 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_deployment
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/core"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type DeDeploymentService service
|
||||
|
||||
// Get deployment
|
||||
func (a *DeDeploymentService) Get(ctx context.Context) (GetDeploymentResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result GetDeploymentResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/deployment/get"
|
||||
|
||||
contentTypes := []string{}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp GetDeploymentResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_deployment
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/core"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type APIClient struct {
|
||||
common service
|
||||
|
||||
DeDeployment *DeDeploymentService
|
||||
}
|
||||
|
||||
type service struct {
|
||||
client *utils.Client
|
||||
}
|
||||
|
||||
func NewAPIClient(cfg *core.Configuration) *APIClient {
|
||||
c := &APIClient{}
|
||||
c.common.client = utils.NewClient(cfg)
|
||||
|
||||
c.DeDeployment = (*DeDeploymentService)(&c.common)
|
||||
|
||||
return c
|
||||
}
|
||||
Executable
+18
@@ -0,0 +1,18 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_deployment
|
||||
|
||||
type GetDeploymentResult struct {
|
||||
BuildBranchName string `json:"buildBranchName,omitempty"`
|
||||
BuildTime string `json:"buildTime,omitempty"`
|
||||
BuildVersionShort string `json:"buildVersionShort,omitempty"`
|
||||
CheckIstoreEntityResult string `json:"checkIstoreEntityResult,omitempty"`
|
||||
ReleaseVersion string `json:"releaseVersion,omitempty"`
|
||||
}
|
||||
|
||||
type GetDeploymentResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result GetDeploymentResult `json:"result,omitempty"`
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_files
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/core"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type DeFilesService service
|
||||
|
||||
type FileUploadRequest struct {
|
||||
// file to upload
|
||||
//
|
||||
// Required.
|
||||
File *core.UploadFile `json:"file" form:"file"`
|
||||
// the time after which the file will be deleted
|
||||
TimeToDelete int64 `json:"timeToDelete" form:"timeToDelete"`
|
||||
}
|
||||
|
||||
// Upload file to server
|
||||
func (a *DeFilesService) FileUpload(ctx context.Context, req FileUploadRequest) (FileUploadResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result FileUploadResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if req.File == nil {
|
||||
missingRequiredParams = append(missingRequiredParams, "file")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/files/fileUpload"
|
||||
|
||||
contentTypes := []string{"multipart/form-data"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
if file := req.File; file != nil {
|
||||
formFiles = append(formFiles, utils.FormFile{
|
||||
FieldName: "file",
|
||||
Filename: file.Filename,
|
||||
Reader: file.Reader,
|
||||
})
|
||||
}
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "timeToDelete", req.TimeToDelete, "", "")
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp FileUploadResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_files
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/core"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type APIClient struct {
|
||||
common service
|
||||
|
||||
DeFiles *DeFilesService
|
||||
}
|
||||
|
||||
type service struct {
|
||||
client *utils.Client
|
||||
}
|
||||
|
||||
func NewAPIClient(cfg *core.Configuration) *APIClient {
|
||||
c := &APIClient{}
|
||||
c.common.client = utils.NewClient(cfg)
|
||||
|
||||
c.DeFiles = (*DeFilesService)(&c.common)
|
||||
|
||||
return c
|
||||
}
|
||||
Executable
+14
@@ -0,0 +1,14 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_files
|
||||
|
||||
type FileUploadResult struct {
|
||||
FilePath string `json:"filePath,omitempty"`
|
||||
}
|
||||
|
||||
type FileUploadResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result FileUploadResult `json:"result,omitempty"`
|
||||
}
|
||||
@@ -0,0 +1,323 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_gitlab
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/core"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type DeGitLabService service
|
||||
|
||||
type DescribeRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// true for checking whether the gitlab is installed in the cluster
|
||||
CheckInstallation bool `json:"checkInstallation" form:"checkInstallation"`
|
||||
// true for checking k8s gitlab pods liveness and the availability of the API
|
||||
CheckLiveness bool `json:"checkLiveness" form:"checkLiveness"`
|
||||
}
|
||||
|
||||
// Get gitlab by id
|
||||
func (a *DeGitLabService) Describe(ctx context.Context, req DescribeRequest) (DescribeGitLabResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result DescribeGitLabResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ClusterID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "clusterId")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/gitlab/describe"
|
||||
|
||||
contentTypes := []string{"application/x-www-form-urlencoded"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "clusterId", req.ClusterID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "checkInstallation", req.CheckInstallation, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "checkLiveness", req.CheckLiveness, "", "")
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp DescribeGitLabResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
type InstallRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// hostname for gitlab
|
||||
//
|
||||
// Required.
|
||||
Hostname string `json:"hostname" form:"hostname"`
|
||||
// Hostname for integagent
|
||||
IntegagentHostname string `json:"integagentHostname" form:"integagentHostname"`
|
||||
// storage type
|
||||
//
|
||||
// Allowed values:
|
||||
// - "longhorn"
|
||||
// - "glusterfs"
|
||||
// - ""
|
||||
StorageClass string `json:"storageClass" form:"storageClass"`
|
||||
// images apps repository ID. If the ID is zero or the value is empty, the default images apps repository will be used.
|
||||
AppsRepositoryID int64 `json:"appsRepositoryId" form:"appsRepositoryId"`
|
||||
// charts repository ID. If the ID is zero or the value is empty, the default charts repository will be used.
|
||||
ChartsRepositoryID int64 `json:"chartsRepositoryId" form:"chartsRepositoryId"`
|
||||
// worker group name
|
||||
WorkerGroupName string `json:"workerGroupName" form:"workerGroupName"`
|
||||
// download chart anyway
|
||||
DownloadChartAnyway bool `json:"downloadChartAnyway" form:"downloadChartAnyway"`
|
||||
}
|
||||
|
||||
// Install gitlab in cluster
|
||||
func (a *DeGitLabService) Install(ctx context.Context, req InstallRequest) (CreateTaskResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result CreateTaskResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ClusterID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "clusterId")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.Hostname) {
|
||||
missingRequiredParams = append(missingRequiredParams, "hostname")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
if !utils.IsZeroValue(req.StorageClass) {
|
||||
storageClassValue := req.StorageClass
|
||||
storageClassAllowedValues := []string{
|
||||
"longhorn",
|
||||
"glusterfs",
|
||||
"",
|
||||
}
|
||||
storageClassValid := false
|
||||
for _, allowed := range storageClassAllowedValues {
|
||||
if storageClassValue == allowed {
|
||||
storageClassValid = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !storageClassValid {
|
||||
return result, fmt.Errorf("storageClass must be one of %v", storageClassAllowedValues)
|
||||
}
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/gitlab/install"
|
||||
|
||||
contentTypes := []string{"application/x-www-form-urlencoded"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "clusterId", req.ClusterID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "hostname", req.Hostname, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "integagentHostname", req.IntegagentHostname, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "storageClass", req.StorageClass, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "appsRepositoryId", req.AppsRepositoryID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "chartsRepositoryId", req.ChartsRepositoryID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "workerGroupName", req.WorkerGroupName, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "downloadChartAnyway", req.DownloadChartAnyway, "", "")
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp CreateTaskResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
type UninstallRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// true for deleting the gitlab even if it is not registered
|
||||
CleanAlways bool `json:"cleanAlways" form:"cleanAlways"`
|
||||
// true for ignoring dns server errors
|
||||
IgnoreDNSError bool `json:"ignoreDnsError" form:"ignoreDnsError"`
|
||||
}
|
||||
|
||||
// Uninstall gitlab from cluster
|
||||
func (a *DeGitLabService) Uninstall(ctx context.Context, req UninstallRequest) (CreateTaskResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result CreateTaskResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ClusterID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "clusterId")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/gitlab/uninstall"
|
||||
|
||||
contentTypes := []string{"application/x-www-form-urlencoded"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "clusterId", req.ClusterID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "cleanAlways", req.CleanAlways, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "ignoreDnsError", req.IgnoreDNSError, "", "")
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp CreateTaskResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_gitlab
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/core"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type APIClient struct {
|
||||
common service
|
||||
|
||||
DeGitLab *DeGitLabService
|
||||
}
|
||||
|
||||
type service struct {
|
||||
client *utils.Client
|
||||
}
|
||||
|
||||
func NewAPIClient(cfg *core.Configuration) *APIClient {
|
||||
c := &APIClient{}
|
||||
c.common.client = utils.NewClient(cfg)
|
||||
|
||||
c.DeGitLab = (*DeGitLabService)(&c.common)
|
||||
|
||||
return c
|
||||
}
|
||||
Executable
+35
@@ -0,0 +1,35 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_gitlab
|
||||
|
||||
type DescribeGitLabResult struct {
|
||||
CheckListOk bool `json:"checkListOk,omitempty"`
|
||||
Description ProductDescr `json:"description,omitempty"`
|
||||
Installed bool `json:"installed,omitempty"`
|
||||
Registered bool `json:"registered,omitempty"`
|
||||
Registry GitLabRecord `json:"registry,omitempty"`
|
||||
}
|
||||
|
||||
type DescribeGitLabResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result DescribeGitLabResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type GitLabRecord struct {
|
||||
Addresses map[string]string `json:"addresses,omitempty"`
|
||||
ClusterID int64 `json:"clusterId,omitempty"`
|
||||
Hostnames map[string]string `json:"hostnames,omitempty"`
|
||||
ID int64 `json:"id,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
OwnerID int64 `json:"ownerId,omitempty"`
|
||||
Password string `json:"password,omitempty"`
|
||||
ProductName string `json:"productName,omitempty"`
|
||||
ProductVersion string `json:"productVersion,omitempty"`
|
||||
PsqlPassword string `json:"psqlPassword,omitempty"`
|
||||
PsqlUsername string `json:"psqlUsername,omitempty"`
|
||||
TaskIDs []int64 `json:"taskIds,omitempty"`
|
||||
Username string `json:"username,omitempty"`
|
||||
WorkerGroupName string `json:"workerGroupName,omitempty"`
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_gitlab
|
||||
|
||||
import (
|
||||
shared "repository.basistech.ru/BASIS/de-golang-sdk/shared"
|
||||
)
|
||||
|
||||
type CreateTaskResult = shared.CreateTaskResult
|
||||
type CreateTaskResultWithError = shared.CreateTaskResultWithError
|
||||
type ProductDescr = shared.ProductDescr
|
||||
@@ -0,0 +1,339 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_grafana
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/core"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type DeGrafanaService service
|
||||
|
||||
type DescribeRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// true for checking whether the grafana is installed in the cluster
|
||||
CheckInstallation bool `json:"checkInstallation" form:"checkInstallation"`
|
||||
// true for checking k8s grafana pods liveness and the availability of the API
|
||||
CheckLiveness bool `json:"checkLiveness" form:"checkLiveness"`
|
||||
}
|
||||
|
||||
// Get grafana by id
|
||||
func (a *DeGrafanaService) Describe(ctx context.Context, req DescribeRequest) (DescribeGrafanaResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result DescribeGrafanaResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ClusterID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "clusterId")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/grafana/describe"
|
||||
|
||||
contentTypes := []string{"application/x-www-form-urlencoded"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "clusterId", req.ClusterID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "checkInstallation", req.CheckInstallation, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "checkLiveness", req.CheckLiveness, "", "")
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp DescribeGrafanaResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
type InstallRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// grafana hostname
|
||||
//
|
||||
// Required.
|
||||
Hostname string `json:"hostname" form:"hostname"`
|
||||
// username
|
||||
//
|
||||
// Required.
|
||||
Username string `json:"username" form:"username"`
|
||||
// password
|
||||
//
|
||||
// Required.
|
||||
Password string `json:"password" form:"password"`
|
||||
// Hostname for integagent
|
||||
IntegagentHostname string `json:"integagentHostname" form:"integagentHostname"`
|
||||
// storage type
|
||||
//
|
||||
// Allowed values:
|
||||
// - "longhorn"
|
||||
// - "glusterfs"
|
||||
// - ""
|
||||
StorageClass string `json:"storageClass" form:"storageClass"`
|
||||
// images apps repository ID. If the ID is zero or the value is empty, the default images apps repository will be used.
|
||||
AppsRepositoryID int64 `json:"appsRepositoryId" form:"appsRepositoryId"`
|
||||
// charts repository ID. If the ID is zero or the value is empty, the default charts repository will be used.
|
||||
ChartsRepositoryID int64 `json:"chartsRepositoryId" form:"chartsRepositoryId"`
|
||||
// worker group name
|
||||
WorkerGroupName string `json:"workerGroupName" form:"workerGroupName"`
|
||||
// download chart anyway
|
||||
DownloadChartAnyway bool `json:"downloadChartAnyway" form:"downloadChartAnyway"`
|
||||
}
|
||||
|
||||
// Install grafana in cluster
|
||||
func (a *DeGrafanaService) Install(ctx context.Context, req InstallRequest) (CreateTaskResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result CreateTaskResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ClusterID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "clusterId")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.Hostname) {
|
||||
missingRequiredParams = append(missingRequiredParams, "hostname")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.Username) {
|
||||
missingRequiredParams = append(missingRequiredParams, "username")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.Password) {
|
||||
missingRequiredParams = append(missingRequiredParams, "password")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
if !utils.IsZeroValue(req.StorageClass) {
|
||||
storageClassValue := req.StorageClass
|
||||
storageClassAllowedValues := []string{
|
||||
"longhorn",
|
||||
"glusterfs",
|
||||
"",
|
||||
}
|
||||
storageClassValid := false
|
||||
for _, allowed := range storageClassAllowedValues {
|
||||
if storageClassValue == allowed {
|
||||
storageClassValid = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !storageClassValid {
|
||||
return result, fmt.Errorf("storageClass must be one of %v", storageClassAllowedValues)
|
||||
}
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/grafana/install"
|
||||
|
||||
contentTypes := []string{"application/x-www-form-urlencoded"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "clusterId", req.ClusterID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "hostname", req.Hostname, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "integagentHostname", req.IntegagentHostname, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "username", req.Username, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "password", req.Password, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "storageClass", req.StorageClass, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "appsRepositoryId", req.AppsRepositoryID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "chartsRepositoryId", req.ChartsRepositoryID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "workerGroupName", req.WorkerGroupName, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "downloadChartAnyway", req.DownloadChartAnyway, "", "")
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp CreateTaskResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
type UninstallRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// true for deleting the grafana even if it is not registered
|
||||
CleanAlways bool `json:"cleanAlways" form:"cleanAlways"`
|
||||
// true for ignoring dns server errors
|
||||
IgnoreDNSError bool `json:"ignoreDnsError" form:"ignoreDnsError"`
|
||||
}
|
||||
|
||||
// Uninstall grafana from cluster
|
||||
func (a *DeGrafanaService) Uninstall(ctx context.Context, req UninstallRequest) (CreateTaskResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result CreateTaskResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ClusterID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "clusterId")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/grafana/uninstall"
|
||||
|
||||
contentTypes := []string{"application/x-www-form-urlencoded"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "clusterId", req.ClusterID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "cleanAlways", req.CleanAlways, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "ignoreDnsError", req.IgnoreDNSError, "", "")
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp CreateTaskResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_grafana
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/core"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type APIClient struct {
|
||||
common service
|
||||
|
||||
DeGrafana *DeGrafanaService
|
||||
}
|
||||
|
||||
type service struct {
|
||||
client *utils.Client
|
||||
}
|
||||
|
||||
func NewAPIClient(cfg *core.Configuration) *APIClient {
|
||||
c := &APIClient{}
|
||||
c.common.client = utils.NewClient(cfg)
|
||||
|
||||
c.DeGrafana = (*DeGrafanaService)(&c.common)
|
||||
|
||||
return c
|
||||
}
|
||||
Executable
+36
@@ -0,0 +1,36 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_grafana
|
||||
|
||||
type DescribeGrafanaResult struct {
|
||||
CheckListOk bool `json:"checkListOk,omitempty"`
|
||||
Description ProductDescr `json:"description,omitempty"`
|
||||
Installed bool `json:"installed,omitempty"`
|
||||
Registered bool `json:"registered,omitempty"`
|
||||
Registry GrafanaRecord `json:"registry,omitempty"`
|
||||
}
|
||||
|
||||
type DescribeGrafanaResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result DescribeGrafanaResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type GrafanaRecord struct {
|
||||
Addresses map[string]string `json:"addresses,omitempty"`
|
||||
ClusterID int64 `json:"clusterId,omitempty"`
|
||||
Hostnames map[string]string `json:"hostnames,omitempty"`
|
||||
ID int64 `json:"id,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
OwnerID int64 `json:"ownerId,omitempty"`
|
||||
Password string `json:"password,omitempty"`
|
||||
ProductName string `json:"productName,omitempty"`
|
||||
ProductVersion string `json:"productVersion,omitempty"`
|
||||
RootToken string `json:"rootToken,omitempty"`
|
||||
StorageType string `json:"storageType,omitempty"`
|
||||
TaskIDs []int64 `json:"taskIds,omitempty"`
|
||||
UnsealKeys []string `json:"unsealKeys,omitempty"`
|
||||
Username string `json:"username,omitempty"`
|
||||
WorkerGroupName string `json:"workerGroupName,omitempty"`
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_grafana
|
||||
|
||||
import (
|
||||
shared "repository.basistech.ru/BASIS/de-golang-sdk/shared"
|
||||
)
|
||||
|
||||
type CreateTaskResult = shared.CreateTaskResult
|
||||
type CreateTaskResultWithError = shared.CreateTaskResultWithError
|
||||
type ProductDescr = shared.ProductDescr
|
||||
@@ -0,0 +1,439 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_group
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/core"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type DeGroupService service
|
||||
|
||||
type CreateRequest struct {
|
||||
// Group description
|
||||
//
|
||||
// Required.
|
||||
Name string `json:"name" form:"name"`
|
||||
}
|
||||
|
||||
// Create group for service
|
||||
func (a *DeGroupService) Create(ctx context.Context, req CreateRequest) (CreateGroupResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result CreateGroupResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.Name) {
|
||||
missingRequiredParams = append(missingRequiredParams, "name")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/group/create"
|
||||
|
||||
contentTypes := []string{"application/x-www-form-urlencoded"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "name", req.Name, "", "")
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp CreateGroupResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
type DeleteRequest struct {
|
||||
// Group ID
|
||||
//
|
||||
// Required.
|
||||
ID int64 `json:"id" form:"id"`
|
||||
}
|
||||
|
||||
// Delete group
|
||||
func (a *DeGroupService) Delete(ctx context.Context, req DeleteRequest) (any, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result any
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "id")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/group/delete"
|
||||
|
||||
contentTypes := []string{"application/x-www-form-urlencoded"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "id", req.ID, "", "")
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp DeleteGroupResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
type GetRequest struct {
|
||||
// Group ID
|
||||
//
|
||||
// Required.
|
||||
ID int64 `json:"id" form:"id"`
|
||||
}
|
||||
|
||||
// Get group by id
|
||||
func (a *DeGroupService) Get(ctx context.Context, req GetRequest) (GetGroupResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result GetGroupResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "id")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/group/get"
|
||||
|
||||
contentTypes := []string{"application/x-www-form-urlencoded"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "id", req.ID, "", "")
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp GetGroupResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
type ListRequest struct {
|
||||
// include archive groups
|
||||
IncludeArchiveGroups bool `json:"includeArchiveGroups" form:"includeArchiveGroups"`
|
||||
// filter by Group ID
|
||||
ID int64 `json:"id" form:"id"`
|
||||
// filter by Group name
|
||||
Name string `json:"name" form:"name"`
|
||||
// Sort by one of supported fields, format +|-(field>)
|
||||
SortBy string `json:"sortBy" form:"sortBy"`
|
||||
// Limit number of groups outputs to be shown in the result. If not set, all groups will be shown.
|
||||
Limit int64 `json:"limit" form:"limit"`
|
||||
// Select page of the result. If not set, the first page will be shown.
|
||||
Page int64 `json:"page" form:"page"`
|
||||
}
|
||||
|
||||
// Get group list
|
||||
func (a *DeGroupService) List(ctx context.Context, req ListRequest) (ListGroupsResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result ListGroupsResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/group/list"
|
||||
|
||||
contentTypes := []string{"application/x-www-form-urlencoded"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "includeArchiveGroups", req.IncludeArchiveGroups, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "id", req.ID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "name", req.Name, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "sortBy", req.SortBy, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "limit", req.Limit, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "page", req.Page, "", "")
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp ListGroupsResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
type UpdateRequest struct {
|
||||
// Group ID
|
||||
//
|
||||
// Required.
|
||||
ID int64 `json:"id" form:"id"`
|
||||
// Group description
|
||||
//
|
||||
// Required.
|
||||
Name string `json:"name" form:"name"`
|
||||
}
|
||||
|
||||
// Upgrade group server for cluster
|
||||
func (a *DeGroupService) Update(ctx context.Context, req UpdateRequest) (UpdateGroupResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result UpdateGroupResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "id")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.Name) {
|
||||
missingRequiredParams = append(missingRequiredParams, "name")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/group/update"
|
||||
|
||||
contentTypes := []string{"application/x-www-form-urlencoded"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "id", req.ID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "name", req.Name, "", "")
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp UpdateGroupResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_group
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/core"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type APIClient struct {
|
||||
common service
|
||||
|
||||
DeGroup *DeGroupService
|
||||
}
|
||||
|
||||
type service struct {
|
||||
client *utils.Client
|
||||
}
|
||||
|
||||
func NewAPIClient(cfg *core.Configuration) *APIClient {
|
||||
c := &APIClient{}
|
||||
c.common.client = utils.NewClient(cfg)
|
||||
|
||||
c.DeGroup = (*DeGroupService)(&c.common)
|
||||
|
||||
return c
|
||||
}
|
||||
Executable
+60
@@ -0,0 +1,60 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_group
|
||||
|
||||
type CreateGroupResult struct {
|
||||
ID int64 `json:"id,omitempty"`
|
||||
}
|
||||
|
||||
type CreateGroupResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result CreateGroupResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type DeleteGroupResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result any `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type GetGroupResult struct {
|
||||
Record Group `json:"record,omitempty"`
|
||||
}
|
||||
|
||||
type GetGroupResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result GetGroupResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type Group struct {
|
||||
ID int64 `json:"id,omitempty"`
|
||||
Locked bool `json:"locked,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
}
|
||||
|
||||
type ListGroupsResult struct {
|
||||
Records []Group `json:"records,omitempty"`
|
||||
}
|
||||
|
||||
type ListGroupsResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result ListGroupsResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type UpdateGroupResult struct {
|
||||
Record Group `json:"record,omitempty"`
|
||||
}
|
||||
|
||||
type UpdateGroupResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result UpdateGroupResult `json:"result,omitempty"`
|
||||
}
|
||||
@@ -0,0 +1,339 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_harbor
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/core"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type DeHarborService service
|
||||
|
||||
type DescribeRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// true for checking whether the harbor is installed in the cluster
|
||||
CheckInstallation bool `json:"checkInstallation" form:"checkInstallation"`
|
||||
// true for checking k8s harbor pods liveness and the availability of the API
|
||||
CheckLiveness bool `json:"checkLiveness" form:"checkLiveness"`
|
||||
}
|
||||
|
||||
// Get harbor by id
|
||||
func (a *DeHarborService) Describe(ctx context.Context, req DescribeRequest) (DescribeHarborResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result DescribeHarborResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ClusterID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "clusterId")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/harbor/describe"
|
||||
|
||||
contentTypes := []string{"application/x-www-form-urlencoded"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "clusterId", req.ClusterID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "checkInstallation", req.CheckInstallation, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "checkLiveness", req.CheckLiveness, "", "")
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp DescribeHarborResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
type InstallRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// username for harbor
|
||||
//
|
||||
// Required.
|
||||
Username string `json:"username" form:"username"`
|
||||
// password for the admin user
|
||||
//
|
||||
// Required.
|
||||
Password string `json:"password" form:"password"`
|
||||
// hostname for harbor
|
||||
//
|
||||
// Required.
|
||||
Hostname string `json:"hostname" form:"hostname"`
|
||||
// Hostname for integagent
|
||||
IntegagentHostname string `json:"integagentHostname" form:"integagentHostname"`
|
||||
// storage type
|
||||
//
|
||||
// Allowed values:
|
||||
// - "longhorn"
|
||||
// - "glusterfs"
|
||||
// - ""
|
||||
StorageClass string `json:"storageClass" form:"storageClass"`
|
||||
// images apps repository ID. If the ID is zero or the value is empty, the default images apps repository will be used.
|
||||
AppsRepositoryID int64 `json:"appsRepositoryId" form:"appsRepositoryId"`
|
||||
// charts repository ID. If the ID is zero or the value is empty, the default charts repository will be used.
|
||||
ChartsRepositoryID int64 `json:"chartsRepositoryId" form:"chartsRepositoryId"`
|
||||
// worker group name
|
||||
WorkerGroupName string `json:"workerGroupName" form:"workerGroupName"`
|
||||
// download chart anyway
|
||||
DownloadChartAnyway bool `json:"downloadChartAnyway" form:"downloadChartAnyway"`
|
||||
}
|
||||
|
||||
// Install harbor in cluster
|
||||
func (a *DeHarborService) Install(ctx context.Context, req InstallRequest) (CreateTaskResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result CreateTaskResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ClusterID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "clusterId")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.Username) {
|
||||
missingRequiredParams = append(missingRequiredParams, "username")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.Password) {
|
||||
missingRequiredParams = append(missingRequiredParams, "password")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.Hostname) {
|
||||
missingRequiredParams = append(missingRequiredParams, "hostname")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
if !utils.IsZeroValue(req.StorageClass) {
|
||||
storageClassValue := req.StorageClass
|
||||
storageClassAllowedValues := []string{
|
||||
"longhorn",
|
||||
"glusterfs",
|
||||
"",
|
||||
}
|
||||
storageClassValid := false
|
||||
for _, allowed := range storageClassAllowedValues {
|
||||
if storageClassValue == allowed {
|
||||
storageClassValid = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !storageClassValid {
|
||||
return result, fmt.Errorf("storageClass must be one of %v", storageClassAllowedValues)
|
||||
}
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/harbor/install"
|
||||
|
||||
contentTypes := []string{"application/x-www-form-urlencoded"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "clusterId", req.ClusterID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "username", req.Username, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "password", req.Password, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "hostname", req.Hostname, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "integagentHostname", req.IntegagentHostname, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "storageClass", req.StorageClass, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "appsRepositoryId", req.AppsRepositoryID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "chartsRepositoryId", req.ChartsRepositoryID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "workerGroupName", req.WorkerGroupName, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "downloadChartAnyway", req.DownloadChartAnyway, "", "")
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp CreateTaskResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
type UninstallRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// true for deleting the harbor even if it is not registered
|
||||
CleanAlways bool `json:"cleanAlways" form:"cleanAlways"`
|
||||
// true for ignoring dns server errors
|
||||
IgnoreDNSError bool `json:"ignoreDnsError" form:"ignoreDnsError"`
|
||||
}
|
||||
|
||||
// Uninstall harbor from cluster
|
||||
func (a *DeHarborService) Uninstall(ctx context.Context, req UninstallRequest) (CreateTaskResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result CreateTaskResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ClusterID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "clusterId")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/harbor/uninstall"
|
||||
|
||||
contentTypes := []string{"application/x-www-form-urlencoded"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "clusterId", req.ClusterID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "cleanAlways", req.CleanAlways, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "ignoreDnsError", req.IgnoreDNSError, "", "")
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp CreateTaskResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_harbor
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/core"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type APIClient struct {
|
||||
common service
|
||||
|
||||
DeHarbor *DeHarborService
|
||||
}
|
||||
|
||||
type service struct {
|
||||
client *utils.Client
|
||||
}
|
||||
|
||||
func NewAPIClient(cfg *core.Configuration) *APIClient {
|
||||
c := &APIClient{}
|
||||
c.common.client = utils.NewClient(cfg)
|
||||
|
||||
c.DeHarbor = (*DeHarborService)(&c.common)
|
||||
|
||||
return c
|
||||
}
|
||||
Executable
+36
@@ -0,0 +1,36 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_harbor
|
||||
|
||||
type DescribeHarborResult struct {
|
||||
CheckListOk bool `json:"checkListOk,omitempty"`
|
||||
Description ProductDescr `json:"description,omitempty"`
|
||||
Installed bool `json:"installed,omitempty"`
|
||||
Registered bool `json:"registered,omitempty"`
|
||||
Registry HarborRecord `json:"registry,omitempty"`
|
||||
}
|
||||
|
||||
type DescribeHarborResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result DescribeHarborResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type HarborRecord struct {
|
||||
Addresses map[string]string `json:"addresses,omitempty"`
|
||||
ClusterID int64 `json:"clusterId,omitempty"`
|
||||
Hostnames map[string]string `json:"hostnames,omitempty"`
|
||||
ID int64 `json:"id,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
OwnerID int64 `json:"ownerId,omitempty"`
|
||||
Password string `json:"password,omitempty"`
|
||||
ProductName string `json:"productName,omitempty"`
|
||||
ProductVersion string `json:"productVersion,omitempty"`
|
||||
PsqlPassword string `json:"psqlPassword,omitempty"`
|
||||
PsqlUsername string `json:"psqlUsername,omitempty"`
|
||||
StorageType string `json:"storageType,omitempty"`
|
||||
TaskIDs []int64 `json:"taskIds,omitempty"`
|
||||
Username string `json:"username,omitempty"`
|
||||
WorkerGroupName string `json:"workerGroupName,omitempty"`
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_harbor
|
||||
|
||||
import (
|
||||
shared "repository.basistech.ru/BASIS/de-golang-sdk/shared"
|
||||
)
|
||||
|
||||
type CreateTaskResult = shared.CreateTaskResult
|
||||
type CreateTaskResultWithError = shared.CreateTaskResultWithError
|
||||
type ProductDescr = shared.ProductDescr
|
||||
@@ -0,0 +1,307 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_ingress_nginx
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/core"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type DeIngressNginxService service
|
||||
|
||||
type DescribeRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// true for checking whether the nginx is installed in the cluster
|
||||
CheckInstallation bool `json:"checkInstallation" form:"checkInstallation"`
|
||||
// true for checking k8s nginx pods liveness and the availability of the API
|
||||
CheckLiveness bool `json:"checkLiveness" form:"checkLiveness"`
|
||||
}
|
||||
|
||||
// Get nginx by id
|
||||
func (a *DeIngressNginxService) Describe(ctx context.Context, req DescribeRequest) (DescribeNginxResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result DescribeNginxResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ClusterID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "clusterId")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/ingress-nginx/describe"
|
||||
|
||||
contentTypes := []string{"application/x-www-form-urlencoded"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "clusterId", req.ClusterID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "checkInstallation", req.CheckInstallation, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "checkLiveness", req.CheckLiveness, "", "")
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp DescribeNginxResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
type InstallRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// hostname for nginx
|
||||
//
|
||||
// Required.
|
||||
Hostname string `json:"hostname" form:"hostname"`
|
||||
// http port
|
||||
//
|
||||
// Required.
|
||||
HTTPPort int64 `json:"httpPort" form:"httpPort"`
|
||||
// Hostname for integagent
|
||||
IntegagentHostname string `json:"integagentHostname" form:"integagentHostname"`
|
||||
// https port
|
||||
HTTPSPort int64 `json:"httpsPort" form:"httpsPort"`
|
||||
// images apps repository ID. If the ID is zero or the value is empty, the default images apps repository will be used.
|
||||
AppsRepositoryID int64 `json:"appsRepositoryId" form:"appsRepositoryId"`
|
||||
// charts repository ID. If the ID is zero or the value is empty, the default charts repository will be used.
|
||||
ChartsRepositoryID int64 `json:"chartsRepositoryId" form:"chartsRepositoryId"`
|
||||
// worker group name
|
||||
WorkerGroupName string `json:"workerGroupName" form:"workerGroupName"`
|
||||
// download chart anyway
|
||||
DownloadChartAnyway bool `json:"downloadChartAnyway" form:"downloadChartAnyway"`
|
||||
}
|
||||
|
||||
// Install nginx in cluster
|
||||
func (a *DeIngressNginxService) Install(ctx context.Context, req InstallRequest) (CreateTaskResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result CreateTaskResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ClusterID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "clusterId")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.Hostname) {
|
||||
missingRequiredParams = append(missingRequiredParams, "hostname")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.HTTPPort) {
|
||||
missingRequiredParams = append(missingRequiredParams, "httpPort")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/ingress-nginx/install"
|
||||
|
||||
contentTypes := []string{"application/x-www-form-urlencoded"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "clusterId", req.ClusterID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "hostname", req.Hostname, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "integagentHostname", req.IntegagentHostname, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "httpPort", req.HTTPPort, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "httpsPort", req.HTTPSPort, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "appsRepositoryId", req.AppsRepositoryID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "chartsRepositoryId", req.ChartsRepositoryID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "workerGroupName", req.WorkerGroupName, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "downloadChartAnyway", req.DownloadChartAnyway, "", "")
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp CreateTaskResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
type UninstallRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// true for deleting the nginx even if it is not registered
|
||||
CleanAlways bool `json:"cleanAlways" form:"cleanAlways"`
|
||||
// true for ignoring dns server errors
|
||||
IgnoreDNSError bool `json:"ignoreDnsError" form:"ignoreDnsError"`
|
||||
}
|
||||
|
||||
// Uninstall nginx from cluster
|
||||
func (a *DeIngressNginxService) Uninstall(ctx context.Context, req UninstallRequest) (CreateTaskResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result CreateTaskResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ClusterID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "clusterId")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/ingress-nginx/uninstall"
|
||||
|
||||
contentTypes := []string{"application/x-www-form-urlencoded"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "clusterId", req.ClusterID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "cleanAlways", req.CleanAlways, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "ignoreDnsError", req.IgnoreDNSError, "", "")
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp CreateTaskResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_ingress_nginx
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/core"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type APIClient struct {
|
||||
common service
|
||||
|
||||
DeIngressNginx *DeIngressNginxService
|
||||
}
|
||||
|
||||
type service struct {
|
||||
client *utils.Client
|
||||
}
|
||||
|
||||
func NewAPIClient(cfg *core.Configuration) *APIClient {
|
||||
c := &APIClient{}
|
||||
c.common.client = utils.NewClient(cfg)
|
||||
|
||||
c.DeIngressNginx = (*DeIngressNginxService)(&c.common)
|
||||
|
||||
return c
|
||||
}
|
||||
Executable
+33
@@ -0,0 +1,33 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_ingress_nginx
|
||||
|
||||
type DescribeNginxResult struct {
|
||||
CheckListOk bool `json:"checkListOk,omitempty"`
|
||||
Description ProductDescr `json:"description,omitempty"`
|
||||
Installed bool `json:"installed,omitempty"`
|
||||
Registered bool `json:"registered,omitempty"`
|
||||
Registry NginxRecord `json:"registry,omitempty"`
|
||||
}
|
||||
|
||||
type DescribeNginxResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result DescribeNginxResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type NginxRecord struct {
|
||||
Addresses map[string]string `json:"addresses,omitempty"`
|
||||
ClusterID int64 `json:"clusterId,omitempty"`
|
||||
Hostnames map[string]string `json:"hostnames,omitempty"`
|
||||
HTTPPort int64 `json:"httpPort,omitempty"`
|
||||
HTTPSPort int64 `json:"httpsPort,omitempty"`
|
||||
ID int64 `json:"id,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
OwnerID int64 `json:"ownerId,omitempty"`
|
||||
ProductName string `json:"productName,omitempty"`
|
||||
ProductVersion string `json:"productVersion,omitempty"`
|
||||
TaskIDs []int64 `json:"taskIds,omitempty"`
|
||||
WorkerGroupName string `json:"workerGroupName,omitempty"`
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_ingress_nginx
|
||||
|
||||
import (
|
||||
shared "repository.basistech.ru/BASIS/de-golang-sdk/shared"
|
||||
)
|
||||
|
||||
type CreateTaskResult = shared.CreateTaskResult
|
||||
type CreateTaskResultWithError = shared.CreateTaskResultWithError
|
||||
type ProductDescr = shared.ProductDescr
|
||||
@@ -0,0 +1,284 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_integagent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/core"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type DeIntegagentService service
|
||||
|
||||
type DescribeRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// true for checking whether the podlogger is installed in the cluster
|
||||
CheckInstallation bool `json:"checkInstallation" form:"checkInstallation"`
|
||||
}
|
||||
|
||||
// Get Integagent by id
|
||||
func (a *DeIntegagentService) Describe(ctx context.Context, req DescribeRequest) (DescribeIntegagentResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result DescribeIntegagentResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ClusterID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "clusterId")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/integagent/describe"
|
||||
|
||||
contentTypes := []string{"application/x-www-form-urlencoded"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "clusterId", req.ClusterID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "checkInstallation", req.CheckInstallation, "", "")
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp DescribeIntegagentResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
type InstallRequest struct {
|
||||
// Cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// integagent hostname
|
||||
//
|
||||
// Required.
|
||||
Hostname string `json:"hostname" form:"hostname"`
|
||||
// images apps repository ID. If the ID is zero or the value is empty, the default images apps repository will be used.
|
||||
AppsRepositoryID int64 `json:"appsRepositoryId" form:"appsRepositoryId"`
|
||||
// charts repository ID. If the ID is zero or the value is empty, the default charts repository will be used.
|
||||
ChartsRepositoryID int64 `json:"chartsRepositoryId" form:"chartsRepositoryId"`
|
||||
// worker group name
|
||||
WorkerGroupName string `json:"workerGroupName" form:"workerGroupName"`
|
||||
// download chart anyway
|
||||
DownloadChartAnyway bool `json:"downloadChartAnyway" form:"downloadChartAnyway"`
|
||||
}
|
||||
|
||||
// Install Integagent
|
||||
func (a *DeIntegagentService) Install(ctx context.Context, req InstallRequest) (InstallIntegagentResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result InstallIntegagentResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ClusterID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "clusterId")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.Hostname) {
|
||||
missingRequiredParams = append(missingRequiredParams, "hostname")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/integagent/install"
|
||||
|
||||
contentTypes := []string{"application/x-www-form-urlencoded"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "clusterId", req.ClusterID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "hostname", req.Hostname, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "appsRepositoryId", req.AppsRepositoryID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "chartsRepositoryId", req.ChartsRepositoryID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "workerGroupName", req.WorkerGroupName, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "downloadChartAnyway", req.DownloadChartAnyway, "", "")
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp InstallIntegagentResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
type UninstallRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
}
|
||||
|
||||
// Uninstall Integagent
|
||||
func (a *DeIntegagentService) Uninstall(ctx context.Context, req UninstallRequest) (UninstallIntegagentResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result UninstallIntegagentResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ClusterID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "clusterId")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/integagent/uninstall"
|
||||
|
||||
contentTypes := []string{"application/x-www-form-urlencoded"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "clusterId", req.ClusterID, "", "")
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp UninstallIntegagentResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_integagent
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/core"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type APIClient struct {
|
||||
common service
|
||||
|
||||
DeIntegagent *DeIntegagentService
|
||||
}
|
||||
|
||||
type service struct {
|
||||
client *utils.Client
|
||||
}
|
||||
|
||||
func NewAPIClient(cfg *core.Configuration) *APIClient {
|
||||
c := &APIClient{}
|
||||
c.common.client = utils.NewClient(cfg)
|
||||
|
||||
c.DeIntegagent = (*DeIntegagentService)(&c.common)
|
||||
|
||||
return c
|
||||
}
|
||||
Executable
+54
@@ -0,0 +1,54 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_integagent
|
||||
|
||||
type DescribeIntegagentResult struct {
|
||||
Description ProductDescr `json:"description,omitempty"`
|
||||
Installed bool `json:"installed,omitempty"`
|
||||
Registered bool `json:"registered,omitempty"`
|
||||
Registry IntegagentRecord `json:"registry,omitempty"`
|
||||
}
|
||||
|
||||
type DescribeIntegagentResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result DescribeIntegagentResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type InstallIntegagentResult struct {
|
||||
TaskID int64 `json:"taskId,omitempty"`
|
||||
}
|
||||
|
||||
type InstallIntegagentResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result InstallIntegagentResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type IntegagentRecord struct {
|
||||
Addresses map[string]string `json:"addresses,omitempty"`
|
||||
ClusterID int64 `json:"clusterId,omitempty"`
|
||||
Hostnames map[string]string `json:"hostnames,omitempty"`
|
||||
ID int64 `json:"id,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
OwnerID int64 `json:"ownerId,omitempty"`
|
||||
Password string `json:"password,omitempty"`
|
||||
ProductName string `json:"productName,omitempty"`
|
||||
ProductVersion string `json:"productVersion,omitempty"`
|
||||
TaskIDs []int64 `json:"taskIds,omitempty"`
|
||||
Username string `json:"username,omitempty"`
|
||||
WorkerGroupName string `json:"workerGroupName,omitempty"`
|
||||
}
|
||||
|
||||
type UninstallIntegagentResult struct {
|
||||
TaskID int64 `json:"taskId,omitempty"`
|
||||
}
|
||||
|
||||
type UninstallIntegagentResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result UninstallIntegagentResult `json:"result,omitempty"`
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_integagent
|
||||
|
||||
import (
|
||||
shared "repository.basistech.ru/BASIS/de-golang-sdk/shared"
|
||||
)
|
||||
|
||||
type ProductDescr = shared.ProductDescr
|
||||
@@ -0,0 +1,296 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_istio
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/core"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type DeIstioService service
|
||||
|
||||
type DescribeRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// true for checking whether the istio is installed in the cluster
|
||||
CheckInstallation bool `json:"checkInstallation" form:"checkInstallation"`
|
||||
// true for checking k8s istio pods liveness and the availability of the API
|
||||
CheckLiveness bool `json:"checkLiveness" form:"checkLiveness"`
|
||||
}
|
||||
|
||||
// Get istio by id
|
||||
func (a *DeIstioService) Describe(ctx context.Context, req DescribeRequest) (DescribeIstioResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result DescribeIstioResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ClusterID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "clusterId")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/istio/describe"
|
||||
|
||||
contentTypes := []string{"application/x-www-form-urlencoded"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "clusterId", req.ClusterID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "checkInstallation", req.CheckInstallation, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "checkLiveness", req.CheckLiveness, "", "")
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp DescribeIstioResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
type InstallRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// hostname
|
||||
//
|
||||
// Required.
|
||||
Hostname string `json:"hostname" form:"hostname"`
|
||||
// Hostname for integagent
|
||||
IntegagentHostname string `json:"integagentHostname" form:"integagentHostname"`
|
||||
// images apps repository ID. If the ID is zero or the value is empty, the default images apps repository will be used.
|
||||
AppsRepositoryID int64 `json:"appsRepositoryId" form:"appsRepositoryId"`
|
||||
// charts repository ID. If the ID is zero or the value is empty, the default charts repository will be used.
|
||||
ChartsRepositoryID int64 `json:"chartsRepositoryId" form:"chartsRepositoryId"`
|
||||
// worker group name
|
||||
WorkerGroupName string `json:"workerGroupName" form:"workerGroupName"`
|
||||
// download chart anyway
|
||||
DownloadChartAnyway bool `json:"downloadChartAnyway" form:"downloadChartAnyway"`
|
||||
}
|
||||
|
||||
// Install istio in cluster
|
||||
func (a *DeIstioService) Install(ctx context.Context, req InstallRequest) (CreateTaskResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result CreateTaskResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ClusterID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "clusterId")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.Hostname) {
|
||||
missingRequiredParams = append(missingRequiredParams, "hostname")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/istio/install"
|
||||
|
||||
contentTypes := []string{"application/x-www-form-urlencoded"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "clusterId", req.ClusterID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "hostname", req.Hostname, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "integagentHostname", req.IntegagentHostname, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "appsRepositoryId", req.AppsRepositoryID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "chartsRepositoryId", req.ChartsRepositoryID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "workerGroupName", req.WorkerGroupName, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "downloadChartAnyway", req.DownloadChartAnyway, "", "")
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp CreateTaskResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
type UninstallRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// true for deleting the istio even if it is not registered
|
||||
CleanAlways bool `json:"cleanAlways" form:"cleanAlways"`
|
||||
// true for ignoring dns server errors
|
||||
IgnoreDNSError bool `json:"ignoreDnsError" form:"ignoreDnsError"`
|
||||
}
|
||||
|
||||
// Uninstall istio from cluster
|
||||
func (a *DeIstioService) Uninstall(ctx context.Context, req UninstallRequest) (CreateTaskResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result CreateTaskResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ClusterID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "clusterId")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/istio/uninstall"
|
||||
|
||||
contentTypes := []string{"application/x-www-form-urlencoded"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "clusterId", req.ClusterID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "cleanAlways", req.CleanAlways, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "ignoreDnsError", req.IgnoreDNSError, "", "")
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp CreateTaskResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_istio
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/core"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type APIClient struct {
|
||||
common service
|
||||
|
||||
DeIstio *DeIstioService
|
||||
}
|
||||
|
||||
type service struct {
|
||||
client *utils.Client
|
||||
}
|
||||
|
||||
func NewAPIClient(cfg *core.Configuration) *APIClient {
|
||||
c := &APIClient{}
|
||||
c.common.client = utils.NewClient(cfg)
|
||||
|
||||
c.DeIstio = (*DeIstioService)(&c.common)
|
||||
|
||||
return c
|
||||
}
|
||||
Executable
+31
@@ -0,0 +1,31 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_istio
|
||||
|
||||
type DescribeIstioResult struct {
|
||||
CheckListOk bool `json:"checkListOk,omitempty"`
|
||||
Description ProductDescr `json:"description,omitempty"`
|
||||
Installed bool `json:"installed,omitempty"`
|
||||
Registered bool `json:"registered,omitempty"`
|
||||
Registry IstioRecord `json:"registry,omitempty"`
|
||||
}
|
||||
|
||||
type DescribeIstioResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result DescribeIstioResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type IstioRecord struct {
|
||||
Addresses map[string]string `json:"addresses,omitempty"`
|
||||
ClusterID int64 `json:"clusterId,omitempty"`
|
||||
Hostnames map[string]string `json:"hostnames,omitempty"`
|
||||
ID int64 `json:"id,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
OwnerID int64 `json:"ownerId,omitempty"`
|
||||
ProductName string `json:"productName,omitempty"`
|
||||
ProductVersion string `json:"productVersion,omitempty"`
|
||||
TaskIDs []int64 `json:"taskIds,omitempty"`
|
||||
WorkerGroupName string `json:"workerGroupName,omitempty"`
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_istio
|
||||
|
||||
import (
|
||||
shared "repository.basistech.ru/BASIS/de-golang-sdk/shared"
|
||||
)
|
||||
|
||||
type CreateTaskResult = shared.CreateTaskResult
|
||||
type CreateTaskResultWithError = shared.CreateTaskResultWithError
|
||||
type ProductDescr = shared.ProductDescr
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,27 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_istore
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/core"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type APIClient struct {
|
||||
common service
|
||||
|
||||
DeIstore *DeIstoreService
|
||||
}
|
||||
|
||||
type service struct {
|
||||
client *utils.Client
|
||||
}
|
||||
|
||||
func NewAPIClient(cfg *core.Configuration) *APIClient {
|
||||
c := &APIClient{}
|
||||
c.common.client = utils.NewClient(cfg)
|
||||
|
||||
c.DeIstore = (*DeIstoreService)(&c.common)
|
||||
|
||||
return c
|
||||
}
|
||||
Executable
+196
@@ -0,0 +1,196 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package de_istore
|
||||
|
||||
type Blob struct {
|
||||
CreatedAt string `json:"createdAt,omitempty"`
|
||||
Digest string `json:"digest,omitempty"`
|
||||
ID string `json:"id,omitempty"`
|
||||
MediaType string `json:"mediaType,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
Reference string `json:"reference,omitempty"`
|
||||
Size int64 `json:"size,omitempty"`
|
||||
UpdatedAt string `json:"updatedAt,omitempty"`
|
||||
}
|
||||
|
||||
type Chart struct {
|
||||
Checksum string `json:"checksum,omitempty"`
|
||||
Collection string `json:"collection,omitempty"`
|
||||
CreatedAt string `json:"createdAt,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
IconPath string `json:"iconPath,omitempty"`
|
||||
ID string `json:"id,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
OwnerID int64 `json:"ownerId,omitempty"`
|
||||
Path string `json:"path,omitempty"`
|
||||
Public bool `json:"public,omitempty"`
|
||||
ReadOnly bool `json:"readOnly,omitempty"`
|
||||
Shared bool `json:"shared,omitempty"`
|
||||
Size int64 `json:"size,omitempty"`
|
||||
UpdatedAt string `json:"updatedAt,omitempty"`
|
||||
UpdatedBy int64 `json:"updatedBy,omitempty"`
|
||||
UserID int64 `json:"userId,omitempty"`
|
||||
Version string `json:"version,omitempty"`
|
||||
}
|
||||
|
||||
type DeleteChartResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result any `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type DeleteImageResult struct {
|
||||
Result string `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type DeleteImageResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result DeleteImageResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type GetChartResult struct {
|
||||
Chart Chart `json:"chart,omitempty"`
|
||||
}
|
||||
|
||||
type GetChartResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result GetChartResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type GetImageResult struct {
|
||||
Manifest Manifest `json:"manifest,omitempty"`
|
||||
}
|
||||
|
||||
type GetImageResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result GetImageResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type ListChartsResult struct {
|
||||
Charts []Chart `json:"charts,omitempty"`
|
||||
Page int64 `json:"page,omitempty"`
|
||||
PageSize int64 `json:"pageSize,omitempty"`
|
||||
Total int64 `json:"total,omitempty"`
|
||||
TotalPages int64 `json:"totalPages,omitempty"`
|
||||
}
|
||||
|
||||
type ListChartsResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result ListChartsResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type ListImagesResult struct {
|
||||
Manifests []Manifest `json:"manifests,omitempty"`
|
||||
Total int64 `json:"total,omitempty"`
|
||||
}
|
||||
|
||||
type ListImagesResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result ListImagesResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type ListOprecordsResult struct {
|
||||
Oprecords []Oprecord `json:"oprecords,omitempty"`
|
||||
Page int64 `json:"page,omitempty"`
|
||||
PageSize int64 `json:"pageSize,omitempty"`
|
||||
Total int64 `json:"total,omitempty"`
|
||||
TotalPages int64 `json:"totalPages,omitempty"`
|
||||
}
|
||||
|
||||
type ListOprecordsResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result ListOprecordsResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type Manifest struct {
|
||||
Collection string `json:"collection,omitempty"`
|
||||
ContentType string `json:"contentType,omitempty"`
|
||||
CreatedAt string `json:"createdAt,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Digest string `json:"digest,omitempty"`
|
||||
GroupID int64 `json:"groupId,omitempty"`
|
||||
ID string `json:"id,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
Public bool `json:"public,omitempty"`
|
||||
ReadOnly bool `json:"readOnly,omitempty"`
|
||||
Reference string `json:"reference,omitempty"`
|
||||
Shared bool `json:"shared,omitempty"`
|
||||
UpdatedAt string `json:"updatedAt,omitempty"`
|
||||
UpdatedBy int64 `json:"updatedBy,omitempty"`
|
||||
UserID int64 `json:"userId,omitempty"`
|
||||
}
|
||||
|
||||
type Oprecord struct {
|
||||
IP string `json:"IP,omitempty"`
|
||||
APIEndpoint string `json:"apiEndpoint,omitempty"`
|
||||
CreatedAt string `json:"createdAt,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
ErrorMessage string `json:"errorMessage,omitempty"`
|
||||
FinishedWithError bool `json:"finishedWithError,omitempty"`
|
||||
GroupID int64 `json:"groupId,omitempty"`
|
||||
GroupName string `json:"groupName,omitempty"`
|
||||
ID int64 `json:"id,omitempty"`
|
||||
Operation string `json:"operation,omitempty"`
|
||||
UserID int64 `json:"userId,omitempty"`
|
||||
Username string `json:"username,omitempty"`
|
||||
}
|
||||
|
||||
type UpdateChartResult struct {
|
||||
Chart Chart `json:"chart,omitempty"`
|
||||
}
|
||||
|
||||
type UpdateChartResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result UpdateChartResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type UpdateImageResult struct {
|
||||
Manifest Manifest `json:"manifest,omitempty"`
|
||||
}
|
||||
|
||||
type UpdateImageResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result UpdateImageResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type UploadChartResult struct {
|
||||
Chart Chart `json:"chart,omitempty"`
|
||||
Replace bool `json:"replace,omitempty"`
|
||||
UploadInGroup bool `json:"uploadInGroup,omitempty"`
|
||||
}
|
||||
|
||||
type UploadChartResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result UploadChartResult `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
type UploadImageResult struct {
|
||||
Blobs []Blob `json:"blobs,omitempty"`
|
||||
Manifest Manifest `json:"manifest,omitempty"`
|
||||
}
|
||||
|
||||
type UploadImageResultWithError struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
ErrorCode int64 `json:"errorCode,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Result UploadImageResult `json:"result,omitempty"`
|
||||
}
|
||||
@@ -0,0 +1,339 @@
|
||||
// Code generated by OpenAPI Generator; DO NOT EDIT.
|
||||
|
||||
package de_jenkins
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/core"
|
||||
"repository.basistech.ru/BASIS/de-golang-sdk/internal/utils"
|
||||
)
|
||||
|
||||
type DeJenkinsService service
|
||||
|
||||
type DescribeRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// true for checking whether the jenkins is installed in the cluster
|
||||
CheckInstallation bool `json:"checkInstallation" form:"checkInstallation"`
|
||||
// true for checking k8s jenkins pods liveness and the availability of the API
|
||||
CheckLiveness bool `json:"checkLiveness" form:"checkLiveness"`
|
||||
}
|
||||
|
||||
// Get jenkins by id
|
||||
func (a *DeJenkinsService) Describe(ctx context.Context, req DescribeRequest) (DescribeJenkinsResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result DescribeJenkinsResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ClusterID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "clusterId")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/jenkins/describe"
|
||||
|
||||
contentTypes := []string{"application/x-www-form-urlencoded"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "clusterId", req.ClusterID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "checkInstallation", req.CheckInstallation, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "checkLiveness", req.CheckLiveness, "", "")
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp DescribeJenkinsResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
type InstallRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// username for the admin user
|
||||
//
|
||||
// Required.
|
||||
Username string `json:"username" form:"username"`
|
||||
// password for the admin user
|
||||
//
|
||||
// Required.
|
||||
Password string `json:"password" form:"password"`
|
||||
// hostname for jenkins
|
||||
//
|
||||
// Required.
|
||||
Hostname string `json:"hostname" form:"hostname"`
|
||||
// Hostname for integagent
|
||||
IntegagentHostname string `json:"integagentHostname" form:"integagentHostname"`
|
||||
// storage class
|
||||
//
|
||||
// Allowed values:
|
||||
// - "longhorn"
|
||||
// - "glusterfs"
|
||||
// - ""
|
||||
StorageClass string `json:"storageClass" form:"storageClass"`
|
||||
// images apps repository ID. If the ID is zero or the value is empty, the default images apps repository will be used.
|
||||
AppsRepositoryID int64 `json:"appsRepositoryId" form:"appsRepositoryId"`
|
||||
// charts repository ID. If the ID is zero or the value is empty, the default charts repository will be used.
|
||||
ChartsRepositoryID int64 `json:"chartsRepositoryId" form:"chartsRepositoryId"`
|
||||
// worker group name
|
||||
WorkerGroupName string `json:"workerGroupName" form:"workerGroupName"`
|
||||
// download chart anyway
|
||||
DownloadChartAnyway bool `json:"downloadChartAnyway" form:"downloadChartAnyway"`
|
||||
}
|
||||
|
||||
// Install jenkins in cluster
|
||||
func (a *DeJenkinsService) Install(ctx context.Context, req InstallRequest) (CreateTaskResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result CreateTaskResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ClusterID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "clusterId")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.Username) {
|
||||
missingRequiredParams = append(missingRequiredParams, "username")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.Password) {
|
||||
missingRequiredParams = append(missingRequiredParams, "password")
|
||||
}
|
||||
if utils.IsRequiredParamMissing(req.Hostname) {
|
||||
missingRequiredParams = append(missingRequiredParams, "hostname")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
if !utils.IsZeroValue(req.StorageClass) {
|
||||
storageClassValue := req.StorageClass
|
||||
storageClassAllowedValues := []string{
|
||||
"longhorn",
|
||||
"glusterfs",
|
||||
"",
|
||||
}
|
||||
storageClassValid := false
|
||||
for _, allowed := range storageClassAllowedValues {
|
||||
if storageClassValue == allowed {
|
||||
storageClassValid = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !storageClassValid {
|
||||
return result, fmt.Errorf("storageClass must be one of %v", storageClassAllowedValues)
|
||||
}
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/jenkins/install"
|
||||
|
||||
contentTypes := []string{"application/x-www-form-urlencoded"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "clusterId", req.ClusterID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "username", req.Username, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "password", req.Password, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "hostname", req.Hostname, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "integagentHostname", req.IntegagentHostname, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "storageClass", req.StorageClass, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "appsRepositoryId", req.AppsRepositoryID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "chartsRepositoryId", req.ChartsRepositoryID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "workerGroupName", req.WorkerGroupName, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "downloadChartAnyway", req.DownloadChartAnyway, "", "")
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp CreateTaskResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
type UninstallRequest struct {
|
||||
// cluster ID
|
||||
//
|
||||
// Required.
|
||||
ClusterID int64 `json:"clusterId" form:"clusterId"`
|
||||
// true for deleting the jenkins even if it is not registered
|
||||
CleanAlways bool `json:"cleanAlways" form:"cleanAlways"`
|
||||
// true for ignoring dns server errors
|
||||
IgnoreDNSError bool `json:"ignoreDnsError" form:"ignoreDnsError"`
|
||||
}
|
||||
|
||||
// Uninstall jenkins from cluster
|
||||
func (a *DeJenkinsService) Uninstall(ctx context.Context, req UninstallRequest) (CreateTaskResult, error) {
|
||||
var (
|
||||
method = http.MethodPost
|
||||
requestBody any
|
||||
formFiles []utils.FormFile
|
||||
result CreateTaskResult
|
||||
)
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := url.Values{}
|
||||
missingRequiredParams := make([]string, 0)
|
||||
if utils.IsRequiredParamMissing(req.ClusterID) {
|
||||
missingRequiredParams = append(missingRequiredParams, "clusterId")
|
||||
}
|
||||
if len(missingRequiredParams) > 0 {
|
||||
return result, utils.MissingRequiredParamsError(missingRequiredParams)
|
||||
}
|
||||
|
||||
basePath := a.client.BaseURL()
|
||||
requestPath := basePath + "/digitalenergy/jenkins/uninstall"
|
||||
|
||||
contentTypes := []string{"application/x-www-form-urlencoded"}
|
||||
|
||||
contentType := utils.SelectHeaderContentType(contentTypes)
|
||||
if contentType != "" {
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
accepts := []string{"application/json"}
|
||||
|
||||
accept := utils.SelectHeaderAccept(accepts)
|
||||
if accept != "" {
|
||||
headerParams["Accept"] = accept
|
||||
}
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "clusterId", req.ClusterID, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "cleanAlways", req.CleanAlways, "", "")
|
||||
utils.ParameterAddToHeaderOrQuery(formParams, "ignoreDnsError", req.IgnoreDNSError, "", "")
|
||||
httpReq, err := a.client.PrepareRequest(ctx, requestPath, method, requestBody, headerParams, queryParams, formParams, formFiles)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("prepare request: %w", err)
|
||||
}
|
||||
resp, err := a.client.CallAPI(httpReq, false)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
respBody, err := utils.ReadResponseBody(resp)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
httpErr := &core.HTTPError{
|
||||
StatusCode: resp.StatusCode,
|
||||
Header: resp.Header.Clone(),
|
||||
Body: respBody,
|
||||
}
|
||||
return result, httpErr
|
||||
}
|
||||
var wrappedResp CreateTaskResultWithError
|
||||
err = a.client.Decode(&wrappedResp, respBody, resp.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
if wrappedResp.Error {
|
||||
return result, &core.BackendError{
|
||||
Code: wrappedResp.ErrorCode,
|
||||
Message: wrappedResp.Message,
|
||||
}
|
||||
}
|
||||
result = wrappedResp.Result
|
||||
|
||||
return result, nil
|
||||
}
|
||||
Loaded 100 of 292 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user