Skip to content

Commit

Permalink
Merge pull request #18 from vngcloud/iam-vserver
Browse files Browse the repository at this point in the history
Iam vserver
  • Loading branch information
manhtu1997 authored May 30, 2023
2 parents 18a6006 + 4c2f243 commit 7e31292
Show file tree
Hide file tree
Showing 115 changed files with 10,904 additions and 963 deletions.
8 changes: 7 additions & 1 deletion client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@ package client
import (
"github.com/vngcloud/terraform-provider-vngcloud/client/authen"
"github.com/vngcloud/terraform-provider-vngcloud/client/vdb"
"github.com/vngcloud/terraform-provider-vngcloud/client/vloadbalancing"
"github.com/vngcloud/terraform-provider-vngcloud/client/vserver"
)

type Client struct {
AuthenClient *authen.AuthenClient
VserverClient *vserver.APIClient
VdbClient *vdb.APIClient
VlbClient *vloadbalancing.APIClient
ProjectId string
}

func NewClient(vdbBaseURL string, vserverBaseURL string, projectId string, userId string, ClientID string, ClientSecret string, TokenURL string) (*Client, error) {
func NewClient(vdbBaseURL string, vserverBaseURL string, vlbBaseURL string, projectId string, userId string, ClientID string, ClientSecret string, TokenURL string) (*Client, error) {
authenConfig := authen.NewConfiguration(ClientID, ClientSecret, TokenURL)
authenClient, err := authen.NewAuthenClient(authenConfig)
if err != nil {
Expand All @@ -23,6 +25,9 @@ func NewClient(vdbBaseURL string, vserverBaseURL string, projectId string, userI
vserverConfig := vserver.NewConfiguration(vserverBaseURL, authenClient.Client)
vserverClient := vserver.NewAPIClient(vserverConfig)

vlbConfig := vloadbalancing.NewConfiguration(vlbBaseURL, authenClient.Client)
vlbClient := vloadbalancing.NewAPIClient(vlbConfig)

vdbConfig := vdb.NewConfiguration(vdbBaseURL, authenClient.Client)
vdbClient := vdb.NewAPIClient(vdbConfig)

Expand All @@ -32,6 +37,7 @@ func NewClient(vdbBaseURL string, vserverBaseURL string, projectId string, userI
AuthenClient: authenClient,
VserverClient: vserverClient,
VdbClient: vdbClient,
VlbClient: vlbClient,
ProjectId: projectId,
}
return client, nil
Expand Down
27 changes: 27 additions & 0 deletions client/utils/json_parsing_date.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package utils

import (
"encoding/json"
"strings"
"time"
)

type JsonParsingDate time.Time

func (j *JsonParsingDate) UnmarshalJSON(b []byte) error {
s := strings.Trim(string(b), "\"")
if s == "" || s == "null" {
return nil
}
t, err := time.Parse("2006-01-02T15:04:05", s)
if err != nil {
return err
}
*j = JsonParsingDate(t)
return nil

}

func (j JsonParsingDate) MarshalJSON() ([]byte, error) {
return json.Marshal(time.Time(j))
}
7 changes: 5 additions & 2 deletions client/utils/model_error_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/vngcloud/terraform-provider-vngcloud/client/vserver"
)

// this class unpack message from returned error from swagger library
// ErrorResponse this class unpack message from returned error from swagger library
type ErrorResponse struct {
Message string `json:"message,omitempty"`
}
Expand All @@ -18,6 +18,9 @@ func GetErrorMessage(e error) error {
if !ok {
return e
}
json.Unmarshal(e.(vserver.GenericSwaggerError).Body(), &resp)
err := json.Unmarshal(e.(vserver.GenericSwaggerError).Body(), &resp)
if err != nil {
return err
}
return fmt.Errorf("%v%v", e, resp.Message)
}
96 changes: 96 additions & 0 deletions client/vloadbalancing/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# Go API client for swagger

Api Documentation

## Overview
This API client was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. By using the [swagger-spec](https://github.com/swagger-api/swagger-spec) from a remote server, you can easily generate an API client.

- API version: 1.0
- Package version: 1.0.0
- Build package: io.swagger.codegen.languages.GoClientCodegen

## Installation
Put the package under your project folder and add the following in import:
```golang
import "./swagger"
```

## Documentation for API Endpoints

All URIs are relative to *https://localhost:8089*

Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*LoadBalancerListenerRestControllerV2Api* | [**CreateListenerUsingPOST**](docs/LoadBalancerListenerRestControllerV2Api.md#createlistenerusingpost) | **Post** /v2/{projectId}/loadBalancers/{loadBalancerId}/listeners | Create a listener
*LoadBalancerListenerRestControllerV2Api* | [**CreatePolicyUsingPOST**](docs/LoadBalancerListenerRestControllerV2Api.md#createpolicyusingpost) | **Post** /v2/{projectId}/loadBalancers/{loadBalancerId}/listeners/{listenerId}/l7policies | Create a l7 policy
*LoadBalancerListenerRestControllerV2Api* | [**DeleteListenerUsingDELETE**](docs/LoadBalancerListenerRestControllerV2Api.md#deletelistenerusingdelete) | **Delete** /v2/{projectId}/loadBalancers/{loadBalancerId}/listeners/{listenerId} | Delete a listener
*LoadBalancerListenerRestControllerV2Api* | [**DeletePolicyUsingDELETE**](docs/LoadBalancerListenerRestControllerV2Api.md#deletepolicyusingdelete) | **Delete** /v2/{projectId}/loadBalancers/{loadBalancerId}/listeners/{listenerId}/l7policies/{l7PolicyId} | Delete a policy
*LoadBalancerListenerRestControllerV2Api* | [**GetListL7PoliciesUsingGET**](docs/LoadBalancerListenerRestControllerV2Api.md#getlistl7policiesusingget) | **Get** /v2/{projectId}/loadBalancers/{loadBalancerId}/listeners/{listenerId}/l7policies | Get list policies of a listener
*LoadBalancerListenerRestControllerV2Api* | [**GetListListenersByLoadBalancerUsingGET**](docs/LoadBalancerListenerRestControllerV2Api.md#getlistlistenersbyloadbalancerusingget) | **Get** /v2/{projectId}/loadBalancers/{loadBalancerId}/listeners | Get list of listeners of a Load Balancer
*LoadBalancerListenerRestControllerV2Api* | [**GetListenersUsingGET**](docs/LoadBalancerListenerRestControllerV2Api.md#getlistenersusingget) | **Get** /v2/{projectId}/loadBalancers/{loadBalancerId}/listeners/{listenerId} | Get a specific listener
*LoadBalancerListenerRestControllerV2Api* | [**ReorderPoliciesUsingPUT**](docs/LoadBalancerListenerRestControllerV2Api.md#reorderpoliciesusingput) | **Put** /v2/{projectId}/loadBalancers/{loadBalancerId}/listeners/{listenerId}/reorderL7Policies | Reorder the L7 policies
*LoadBalancerListenerRestControllerV2Api* | [**UpdateL7PolicyUsingPUT**](docs/LoadBalancerListenerRestControllerV2Api.md#updatel7policyusingput) | **Put** /v2/{projectId}/loadBalancers/{loadBalancerId}/listeners/{listenerId}/l7policies/{policyId} | Update a policy
*LoadBalancerListenerRestControllerV2Api* | [**UpdateListenerUsingPUT**](docs/LoadBalancerListenerRestControllerV2Api.md#updatelistenerusingput) | **Put** /v2/{projectId}/loadBalancers/{loadBalancerId}/listeners/{listenerId} | Update a listener
*LoadBalancerPoolRestControllerV2Api* | [**CreatePoolUsingPOST**](docs/LoadBalancerPoolRestControllerV2Api.md#createpoolusingpost) | **Post** /v2/{projectId}/loadBalancers/{loadBalancerId}/pools | Create a new pool
*LoadBalancerPoolRestControllerV2Api* | [**DeletePoolUsingDELETE**](docs/LoadBalancerPoolRestControllerV2Api.md#deletepoolusingdelete) | **Delete** /v2/{projectId}/loadBalancers/{loadBalancerId}/pools/{poolId} | Delete a pool
*LoadBalancerPoolRestControllerV2Api* | [**GetHealthMonitorFromPoolUsingGET**](docs/LoadBalancerPoolRestControllerV2Api.md#gethealthmonitorfrompoolusingget) | **Get** /v2/{projectId}/loadBalancers/{loadBalancerId}/pools/{poolId}/healthMonitor | Get the health monitor associated with a specific pool
*LoadBalancerPoolRestControllerV2Api* | [**GetListPoolsUsingGET**](docs/LoadBalancerPoolRestControllerV2Api.md#getlistpoolsusingget) | **Get** /v2/{projectId}/loadBalancers/{loadBalancerId}/pools | Get list of pools of a load balancer
*LoadBalancerPoolRestControllerV2Api* | [**GetMembersFromPoolUsingGET**](docs/LoadBalancerPoolRestControllerV2Api.md#getmembersfrompoolusingget) | **Get** /v2/{projectId}/loadBalancers/{loadBalancerId}/pools/{poolId}/members | Get members from a pool
*LoadBalancerPoolRestControllerV2Api* | [**GetPoolUsingGET**](docs/LoadBalancerPoolRestControllerV2Api.md#getpoolusingget) | **Get** /v2/{projectId}/loadBalancers/{loadBalancerId}/pools/{poolId} | Get a specific pool
*LoadBalancerPoolRestControllerV2Api* | [**UpdateMembersUsingPUT**](docs/LoadBalancerPoolRestControllerV2Api.md#updatemembersusingput) | **Put** /v2/{projectId}/loadBalancers/{loadBalancerId}/pools/{poolId}/members | Update list members
*LoadBalancerPoolRestControllerV2Api* | [**UpdatePoolUsingPUT**](docs/LoadBalancerPoolRestControllerV2Api.md#updatepoolusingput) | **Put** /v2/{projectId}/loadBalancers/{loadBalancerId}/pools/{poolId} | Update a pool
*LoadBalancerRestControllerV2Api* | [**CreateLoadBalancerUsingPOST**](docs/LoadBalancerRestControllerV2Api.md#createloadbalancerusingpost) | **Post** /v2/{projectId}/loadBalancers | Create a new load balancer
*LoadBalancerRestControllerV2Api* | [**DeleteLoadBalancerUsingDELETE**](docs/LoadBalancerRestControllerV2Api.md#deleteloadbalancerusingdelete) | **Delete** /v2/{projectId}/loadBalancers/{loadBalancerId} | Delete a load balancer
*LoadBalancerRestControllerV2Api* | [**GetHeadersUsingGET**](docs/LoadBalancerRestControllerV2Api.md#getheadersusingget) | **Get** /v2/{projectId}/loadBalancers/headers | Get list headers
*LoadBalancerRestControllerV2Api* | [**GetListLoadBalancerWithPagingUsingGET**](docs/LoadBalancerRestControllerV2Api.md#getlistloadbalancerwithpagingusingget) | **Get** /v2/{projectId}/loadBalancers | List LoadBalancers Paging
*LoadBalancerRestControllerV2Api* | [**GetLoadBalancerUsingGET**](docs/LoadBalancerRestControllerV2Api.md#getloadbalancerusingget) | **Get** /v2/{projectId}/loadBalancers/{loadBalancerId} | Load Balancer By Load Balancer Id
*LoadBalancerRestControllerV2Api* | [**GetPackagesUsingGET**](docs/LoadBalancerRestControllerV2Api.md#getpackagesusingget) | **Get** /v2/{projectId}/loadBalancers/packages | Get list packages


## Documentation For Models

- [CreateHealthMonitorRequest](docs/CreateHealthMonitorRequest.md)
- [CreateL7PolicyRequestV2](docs/CreateL7PolicyRequestV2.md)
- [CreateListenerRequestV2](docs/CreateListenerRequestV2.md)
- [CreateLoadBalancerRequest](docs/CreateLoadBalancerRequest.md)
- [CreateMemberRequest](docs/CreateMemberRequest.md)
- [CreatePoolRequestV2](docs/CreatePoolRequestV2.md)
- [DataResponseHealthMonitor](docs/DataResponseHealthMonitor.md)
- [DataResponseL7Policy](docs/DataResponseL7Policy.md)
- [DataResponseListL7Policy](docs/DataResponseListL7Policy.md)
- [DataResponseListListener](docs/DataResponseListListener.md)
- [DataResponseListMember](docs/DataResponseListMember.md)
- [DataResponseListPool](docs/DataResponseListPool.md)
- [DataResponseListener](docs/DataResponseListener.md)
- [DataResponseListstring](docs/DataResponseListstring.md)
- [DataResponseLoadBalancer](docs/DataResponseLoadBalancer.md)
- [DataResponseLoadBalancerDto](docs/DataResponseLoadBalancerDto.md)
- [DataResponsePool](docs/DataResponsePool.md)
- [HealthMonitor](docs/HealthMonitor.md)
- [L7Policy](docs/L7Policy.md)
- [L7Rule](docs/L7Rule.md)
- [Listener](docs/Listener.md)
- [LoadBalancer](docs/LoadBalancer.md)
- [LoadBalancerDto](docs/LoadBalancerDto.md)
- [LoadBalancerPackage](docs/LoadBalancerPackage.md)
- [Member](docs/Member.md)
- [PagingLoadBalancerDto](docs/PagingLoadBalancerDto.md)
- [PagingLoadBalancerPackage](docs/PagingLoadBalancerPackage.md)
- [Pool](docs/Pool.md)
- [ReorderPoliciesRequestV2](docs/ReorderPoliciesRequestV2.md)
- [ReorderPolicyRequest](docs/ReorderPolicyRequest.md)
- [UpdateHealthMonitorRequest](docs/UpdateHealthMonitorRequest.md)
- [UpdateL7PolicyRequestV2](docs/UpdateL7PolicyRequestV2.md)
- [UpdateListenerRequestV2](docs/UpdateListenerRequestV2.md)
- [UpdateMembersRequestV2](docs/UpdateMembersRequestV2.md)
- [UpdatePoolRequestV2](docs/UpdatePoolRequestV2.md)


## Documentation For Authorization
Endpoints do not require authorization.


## Author



Loading

0 comments on commit 7e31292

Please sign in to comment.